admin.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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_auth = auth
  73. )
  74. self.commonOne('manage_role')
  75. self.commonView('update')
  76. @Web.auth
  77. @Web.setting
  78. def post(self):
  79. self.commonUpdate('manage_role')
  80. @Web.auth
  81. @Web.setting
  82. def delete(self):
  83. self.commonDelete('manage_role')
  84. class log_path(Load):
  85. @Web.auth
  86. @Web.setting
  87. def get(self):
  88. self.common(
  89. name = u'日志' #中文名
  90. ,path = '/admin/log' #路径
  91. ,width = '600' # 新增页面的宽度
  92. ,height = '400' # 新增页面的高度
  93. ,add = False
  94. ,edit = False
  95. ,search = (('label-1','cdate-time-start','cdate-time-end', 'admin_id-input-'), (u'日期范围',u'开始时间',u'截止时间',u'管理员ID')) #搜索
  96. ,thead = (u'管理员ID', u'操作表', u'方法', u'数据', u'更新时间') #表头
  97. ,tbody = ('admin_id', 'model', 'method', 'data', 'cdate') #表内容
  98. ,state = False #启用回收站
  99. )
  100. self.commonList('manage_log')
  101. self.commonView('list')
  102. class setCookie_path(Load):
  103. @Web.auth
  104. @Web.setting
  105. def post(self):
  106. value = self.input('farm', Demeter.config['setting']['farm'])
  107. self.set_secure_cookie('farm', value)
  108. #self.set_cookie('farm', value)
  109. Demeter.config['base']['farm'] = value