blob: e28e5baa410a562a7d3e04e4114dbbcacedfe677 [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05302# License: GNU General Public License v3. See license.txt"
Rushabh Mehta74506e92013-03-25 17:52:14 +05303
4
5from __future__ import unicode_literals
6import webnotes
Rushabh Mehta74506e92013-03-25 17:52:14 +05307
8def boot_session(bootinfo):
9 """boot session - send website info if guest"""
10 import webnotes
11 import webnotes.model.doc
12
13 bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or ''
14 bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings')
15
Rushabh Mehtadd790a52013-06-17 12:55:54 +053016 if webnotes.session['user']!='Guest':
Rushabh Mehta74506e92013-03-25 17:52:14 +053017 bootinfo['letter_heads'] = get_letter_heads()
Rushabh Mehta9dd25b32013-09-03 17:36:41 +053018
19 load_country_and_currency(bootinfo)
20
Rushabh Mehta74506e92013-03-25 17:52:14 +053021 import webnotes.model.doctype
22 bootinfo['notification_settings'] = webnotes.doc("Notification Control",
23 "Notification Control").get_values()
Rushabh Mehta27c40792013-04-03 15:21:44 +053024
Rushabh Mehta74506e92013-03-25 17:52:14 +053025 # if no company, show a dialog box to create a new company
Rushabh Mehta2f7e1ab2013-06-26 17:20:12 +053026 bootinfo["customer_count"] = webnotes.conn.sql("""select count(*) from tabCustomer""")[0][0]
27
28 if not bootinfo["customer_count"]:
29 bootinfo['setup_complete'] = webnotes.conn.sql("""select name from
30 tabCompany limit 1""") and 'Yes' or 'No'
31
Rushabh Mehta74506e92013-03-25 17:52:14 +053032
33 # load subscription info
Pratik Vyascfed8c42013-09-21 15:16:47 +053034 from webnotes import conf
Rushabh Mehta881a47f2013-09-06 12:42:54 +053035 for key in ['max_users', 'expires_on', 'max_space', 'status', 'commercial_support']:
Anand Doshide8b6aa2013-09-24 17:17:39 +053036 if key in conf: bootinfo[key] = conf.get(key)
Rushabh Mehta74506e92013-03-25 17:52:14 +053037
Anand Doshiaeef7bd2013-04-19 16:21:55 +053038 bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center
39 from `tabCompany`""", as_dict=1, update={"doctype":":Company"})
Rushabh Mehta9dd25b32013-09-03 17:36:41 +053040
41def load_country_and_currency(bootinfo):
42 if bootinfo.control_panel.country and \
43 webnotes.conn.exists("Country", bootinfo.control_panel.country):
44 bootinfo["docs"] += [webnotes.doc("Country", bootinfo.control_panel.country)]
45
46 bootinfo["docs"] += webnotes.conn.sql("""select * from tabCurrency
47 where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":":Currency"})
48
Rushabh Mehta74506e92013-03-25 17:52:14 +053049def get_letter_heads():
Rushabh Mehta74506e92013-03-25 17:52:14 +053050 import webnotes
51 ret = webnotes.conn.sql("""select name, content from `tabLetter Head`
52 where ifnull(disabled,0)=0""")
53 return dict(ret)
Pratik Vyascfed8c42013-09-21 15:16:47 +053054