You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
1.8 KiB

  1. """
  2. bootstrap client session
  3. """
  4. def get_bootinfo():
  5. """build and return boot info"""
  6. import webnotes
  7. bootinfo = {}
  8. doclist = []
  9. webnotes.conn.begin()
  10. # profile
  11. get_profile(bootinfo)
  12. # control panel
  13. import webnotes.model.doc
  14. cp = webnotes.model.doc.getsingle('Control Panel')
  15. # remove email settings from control panel dict
  16. for field in ['mail_login', 'mail_password', 'mail_port', 'outgoing_mail_server', 'use_ssl']:
  17. del cp[field]
  18. # system info
  19. bootinfo['control_panel'] = cp.copy()
  20. bootinfo['account_name'] = cp.get('account_id')
  21. bootinfo['sysdefaults'] = webnotes.utils.get_defaults()
  22. if webnotes.session['user'] != 'Guest':
  23. import webnotes.widgets.menus
  24. bootinfo['start_items'] = webnotes.widgets.menus.get_menu_items()
  25. bootinfo['dt_labels'] = get_dt_labels()
  26. # home page
  27. get_home_page(bootinfo, doclist)
  28. # ipinfo
  29. if webnotes.session['data'].get('ipinfo'):
  30. bootinfo['ipinfo'] = webnotes.session['data']['ipinfo']
  31. # add docs
  32. bootinfo['docs'] = doclist
  33. # plugins
  34. import startup.event_handlers
  35. if getattr(startup.event_handlers, 'boot_session'):
  36. startup.event_handlers.boot_session(bootinfo)
  37. webnotes.conn.commit()
  38. return bootinfo
  39. def get_profile(bootinfo):
  40. """get profile info"""
  41. import webnotes
  42. bootinfo['profile'] = webnotes.user.load_profile()
  43. webnotes.session['data']['profile'] = bootinfo['profile']
  44. def get_home_page(bootinfo, doclist):
  45. """load home page"""
  46. import webnotes
  47. home_page = webnotes.user.get_home_page()
  48. if home_page:
  49. import webnotes.widgets.page
  50. page_doclist = webnotes.widgets.page.get(home_page)
  51. doclist += webnotes.widgets.page.get(home_page)
  52. bootinfo['home_page_html'] = page_doclist[0].content
  53. bootinfo['home_page'] = home_page or ''
  54. def get_dt_labels():
  55. import webnotes
  56. res = webnotes.conn.sql("select name, dt_label from `tabDocType Label`")
  57. return dict(res)