admin.py 3.8 KB

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