blob: 79f0a7bd04a93c53572177493285a3ae3bea1cb1 [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()
19
20 import webnotes.model.doctype
21 bootinfo['notification_settings'] = webnotes.doc("Notification Control",
22 "Notification Control").get_values()
Rushabh Mehta27c40792013-04-03 15:21:44 +053023
Rushabh Mehta74506e92013-03-25 17:52:14 +053024 # if no company, show a dialog box to create a new company
Rushabh Mehta2f7e1ab2013-06-26 17:20:12 +053025 bootinfo["customer_count"] = webnotes.conn.sql("""select count(*) from tabCustomer""")[0][0]
26
27 if not bootinfo["customer_count"]:
28 bootinfo['setup_complete'] = webnotes.conn.sql("""select name from
29 tabCompany limit 1""") and 'Yes' or 'No'
30
Rushabh Mehta74506e92013-03-25 17:52:14 +053031
32 # load subscription info
33 import conf
34 for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']:
35 if hasattr(conf, key): bootinfo[key] = getattr(conf, key)
36
Anand Doshiaeef7bd2013-04-19 16:21:55 +053037 bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center
38 from `tabCompany`""", as_dict=1, update={"doctype":":Company"})
Rushabh Mehta74506e92013-03-25 17:52:14 +053039
40def get_letter_heads():
41 """load letter heads with startup"""
42 import webnotes
43 ret = webnotes.conn.sql("""select name, content from `tabLetter Head`
44 where ifnull(disabled,0)=0""")
45 return dict(ret)
46