admin.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter web page
  5. name:admin.py 管理员相关页面
  6. author:rabin
  7. """
  8. from __load__ import *
  9. class admin_path(Load):
  10. @Web.auth
  11. @Web.setting
  12. def get(self):
  13. self.common(
  14. name = u'管理员' #中文名
  15. ,path = '/admin/admin' #路径
  16. ,width = '600' # 新增页面的宽度
  17. ,height = '400' # 新增页面的高度
  18. ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike','mobile-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'管理员姓名',u'手机号')) #搜索
  19. ,thead = (u'管理员ID',u'管理员姓名', u'所属角色', u'手机号', u'更新时间') #表头
  20. ,tbody = ('id','username', 'role', 'mobile', 'cdate') #表内容
  21. ,state = False #启用回收站
  22. )
  23. self.commonList('manage_admin')
  24. self.commonView('list')
  25. class admin_update_path(Load):
  26. @Web.auth
  27. @Web.setting
  28. def get(self):
  29. self.common(
  30. path = '/admin/admin'
  31. ,label = (u'管理员姓名',u'所属角色',u'手机号',u'密码')
  32. ,update = ('username-input-required','role_id-select-required','mobile-input-phone','password-password-')
  33. ,update_role_id = self.service('common').list('manage_role')
  34. )
  35. self.commonOne('manage_admin')
  36. self.commonView('update')
  37. @Web.auth
  38. @Web.setting
  39. def post(self):
  40. self.commonUpdate('manage_admin', '手机号已经被注册', mobile=self.data['update']['mobile'])
  41. class role_path(Load):
  42. @Web.auth
  43. @Web.setting
  44. def get(self):
  45. self.common(
  46. name = u'角色'
  47. ,path = '/admin/role'
  48. ,width = '800'
  49. ,height = '600'
  50. ,full = 1
  51. #,add = False
  52. #,edit = False
  53. ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'角色名称'))
  54. ,thead = (u'角色ID',u'角色名称', u'更新时间')
  55. ,tbody = ('id','name', 'cdate')
  56. ,state = False
  57. )
  58. self.commonList('manage_role')
  59. self.commonView('list')
  60. class role_update_path(Load):
  61. @Web.auth
  62. @Web.setting
  63. def get(self):
  64. auth = self.data['setting']['menuList']
  65. self.common(
  66. path = '/admin/role'
  67. #,label = (u'角色名称',u'操作权限',u'左侧菜单',u'头部菜单')
  68. #,update = ('name-input-required','oper-checkbox-required','auth-checkmenu-required','top-checkbox-required')
  69. ,label = (u'角色名称',u'左侧菜单',u'头部菜单')
  70. ,update = ('name-input-required','auth-checkmenu-required','top-checkbox-required')
  71. ,update_oper = ({'id':'select', 'name':'查询'}, {'id':'insert', 'name':'新增'}, {'id':'update', 'name':'修改'}, {'id':'delete', 'name':'删除'}, {'id':'search', 'name':'搜索'})
  72. ,update_top = self.service('common').list('farm')
  73. ,update_auth = auth
  74. )
  75. self.commonOne('manage_role')
  76. self.commonView('update')
  77. @Web.auth
  78. @Web.setting
  79. def post(self):
  80. self.commonUpdate('manage_role')
  81. @Web.auth
  82. @Web.setting
  83. def delete(self):
  84. self.commonDelete('manage_role')
  85. class log_path(Load):
  86. @Web.auth
  87. @Web.setting
  88. def get(self):
  89. self.common(
  90. name = u'日志' #中文名
  91. ,path = '/admin/log' #路径
  92. ,width = '600' # 新增页面的宽度
  93. ,height = '400' # 新增页面的高度
  94. ,add = False
  95. ,edit = False
  96. ,search = (('label-1','cdate-time-start','cdate-time-end', 'admin_id-input-'), (u'日期范围',u'开始时间',u'截止时间',u'管理员ID')) #搜索
  97. ,thead = (u'管理员ID', u'操作表', u'方法', u'数据', u'更新时间') #表头
  98. ,tbody = ('admin_id', 'model', 'method', 'data', 'cdate') #表内容
  99. ,state = False #启用回收站
  100. )
  101. self.commonList('manage_log')
  102. self.commonView('list')
  103. class setCookie_path(Load):
  104. @Web.auth
  105. @Web.setting
  106. def post(self):
  107. value = self.input('farm', Demeter.config['setting']['farm'])
  108. self.set_secure_cookie('farm', value)
  109. #self.set_cookie('farm', value)
  110. Demeter.config['base']['farm'] = value