record.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # -*- coding: utf-8 -*-
  2. """
  3. demeter web page
  4. name:record.py 统计记录相关
  5. author:rabin
  6. """
  7. from .__load__ import *
  8. class record_path(Load):
  9. @Web.auth
  10. @Web.setting
  11. def get(self):
  12. self.set(
  13. name = u'记录点类型管理'
  14. ,path = '/record/record'
  15. ,width = '600'
  16. ,height = '600'
  17. ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'类型名称'))
  18. ,thead = (u'类型ID', u'类型名称', u'操作类型', u'更新时间')
  19. ,tbody = ('id','name','type', 'cdate')
  20. ,state = True
  21. )
  22. self.list('record_type')
  23. if self.data['list']:
  24. for key, value in enumerate(self.data['list']):
  25. id = str(value['id'])
  26. param = '?search_site_id-select-=' + id
  27. if value['type'] == 1:
  28. self.data['list'][key]['type'] = '浏览'
  29. else:
  30. self.data['list'][key]['type'] = '操作'
  31. self.show('list')
  32. class record_update_path(Load):
  33. @Web.auth
  34. @Web.setting
  35. def get(self):
  36. typeValue = [{'id':1, 'name':'浏览'}, {'id':2, 'name':'操作'}]
  37. self.set(
  38. path = '/record/record'
  39. ,label = (u'类型名称',u'操作类型')
  40. ,update = ('name-input-required','type-select-required')
  41. ,update_type = typeValue
  42. )
  43. self.one('record_type')
  44. self.show('update')
  45. @Web.auth
  46. @Web.setting
  47. def post(self):
  48. self.update('record_type')
  49. @Web.auth
  50. @Web.setting
  51. def delete(self):
  52. self.drop('record_type')
  53. class data_path(Load):
  54. @Web.auth
  55. @Web.setting
  56. def get(self):
  57. self.set(
  58. name = u'记录数据'
  59. ,path = '/record/data'
  60. ,width = '600'
  61. ,height = '600'
  62. ,edit = False
  63. ,add = False
  64. ,search = (('label-1','cdate-time-start','cdate-time-end','record_type_id-select-'), (u'日期范围',u'开始时间',u'截止时间',u'选择类型'))
  65. ,thead = (u'操作名', u'记录类型', u'用户', u'更新时间')
  66. ,tbody = ('name', 'type', 'uid', 'cdate')
  67. ,state = False
  68. )
  69. self.data['common']['search_record_type_id-select-'] = self.service('common').list('record_type')
  70. self.list('record')
  71. if self.data['list']:
  72. for key, value in enumerate(self.data['list']):
  73. typeData = self.service('common').one('record_type', id=value['record_type_id'])
  74. self.data['list'][key]['type'] = typeData['name']
  75. self.show('list')