Rushabh Mehta | e67d1fb | 2013-08-05 14:59:54 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. |
| 2 | # License: GNU General Public License v3. See license.txt" |
Rushabh Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 3 | |
| 4 | |
| 5 | from __future__ import unicode_literals |
| 6 | import webnotes |
| 7 | import home |
| 8 | |
| 9 | def 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 Mehta | dd790a5 | 2013-06-17 12:55:54 +0530 | [diff] [blame] | 17 | if webnotes.session['user']!='Guest': |
Rushabh Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 18 | 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 Mehta | 27c4079 | 2013-04-03 15:21:44 +0530 | [diff] [blame] | 23 | |
Rushabh Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 24 | # if no company, show a dialog box to create a new company |
Rushabh Mehta | 2f7e1ab | 2013-06-26 17:20:12 +0530 | [diff] [blame] | 25 | 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 Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 31 | |
| 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 Doshi | aeef7bd | 2013-04-19 16:21:55 +0530 | [diff] [blame] | 37 | bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center |
| 38 | from `tabCompany`""", as_dict=1, update={"doctype":":Company"}) |
Rushabh Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 39 | |
| 40 | def 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 | |