blob: 886b805db43adb3a1b9c16cd1855d19a326f4c0c [file] [log] [blame]
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
2# 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
7import home
8
9def boot_session(bootinfo):
10 """boot session - send website info if guest"""
11 import webnotes
12 import webnotes.model.doc
13
14 bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or ''
15 bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings')
16
Rushabh Mehtadd790a52013-06-17 12:55:54 +053017 if webnotes.session['user']!='Guest':
Rushabh Mehta74506e92013-03-25 17:52:14 +053018 bootinfo['letter_heads'] = get_letter_heads()
Rushabh Mehta9dd25b32013-09-03 17:36:41 +053019
20 load_country_and_currency(bootinfo)
21
Rushabh Mehta74506e92013-03-25 17:52:14 +053022 import webnotes.model.doctype
23 bootinfo['notification_settings'] = webnotes.doc("Notification Control",
24 "Notification Control").get_values()
Rushabh Mehta27c40792013-04-03 15:21:44 +053025
Rushabh Mehta74506e92013-03-25 17:52:14 +053026 # if no company, show a dialog box to create a new company
Rushabh Mehta2f7e1ab2013-06-26 17:20:12 +053027 bootinfo["customer_count"] = webnotes.conn.sql("""select count(*) from tabCustomer""")[0][0]
28
29 if not bootinfo["customer_count"]:
30 bootinfo['setup_complete'] = webnotes.conn.sql("""select name from
31 tabCompany limit 1""") and 'Yes' or 'No'
32
Rushabh Mehta74506e92013-03-25 17:52:14 +053033
34 # load subscription info
35 import conf
Rushabh Mehta881a47f2013-09-06 12:42:54 +053036 for key in ['max_users', 'expires_on', 'max_space', 'status', 'commercial_support']:
37 if hasattr(conf, key): bootinfo[key] = getattr(conf, key)
Rushabh Mehta74506e92013-03-25 17:52:14 +053038
Anand Doshiaeef7bd2013-04-19 16:21:55 +053039 bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center
40 from `tabCompany`""", as_dict=1, update={"doctype":":Company"})
Rushabh Mehta9dd25b32013-09-03 17:36:41 +053041
42def load_country_and_currency(bootinfo):
43 if bootinfo.control_panel.country and \
44 webnotes.conn.exists("Country", bootinfo.control_panel.country):
45 bootinfo["docs"] += [webnotes.doc("Country", bootinfo.control_panel.country)]
46
47 bootinfo["docs"] += webnotes.conn.sql("""select * from tabCurrency
48 where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":":Currency"})
49
Rushabh Mehta74506e92013-03-25 17:52:14 +053050def get_letter_heads():
51 """load letter heads with startup"""
52 import webnotes
53 ret = webnotes.conn.sql("""select name, content from `tabLetter Head`
54 where ifnull(disabled,0)=0""")
55 return dict(ret)
56