score.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. # -*- coding: utf-8 -*-
  2. """
  3. demeter web page
  4. name:score.py 积分相关
  5. author:rabin
  6. """
  7. from .__load__ import *
  8. class score_path(Load):
  9. @Web.auth
  10. @Web.setting
  11. def get(self):
  12. self.set(
  13. name = u'积分设置'
  14. ,path = '/score/score'
  15. ,width = '600'
  16. ,height = '600'
  17. ,search = (('label-1','cdate-time-start','cdate-time-end'), (u'日期范围',u'开始时间',u'截止时间'))
  18. ,thead = (u'积分名', u'规则', u'更新时间')
  19. ,tbody = ('name', 'func', 'cdate')
  20. ,state = True
  21. )
  22. menu = (
  23. {'name':'规则列表', 'url':'/score/score_rule'},
  24. )
  25. self.list('score')
  26. if self.data['list']:
  27. for key, value in enumerate(self.data['list']):
  28. id = str(value['id'])
  29. param = '?score_id=' + id + '&search_score_id-select-=' + id
  30. self.data['list'][key]['func'] = ''
  31. for i in menu:
  32. self.data['list'][key]['func'] = self.data['list'][key]['func'] + '<a href="'+i['url']+''+param+'">'+i['name']+'</a>&nbsp;&nbsp;&nbsp;&nbsp;'
  33. self.show('list')
  34. class score_update_path(Load):
  35. @Web.auth
  36. @Web.setting
  37. def get(self):
  38. self.set(
  39. path = '/score/score'
  40. ,label = (u'积分名称',)
  41. ,update = ('name-input-required',)
  42. )
  43. self.one('score')
  44. self.show('update')
  45. @Web.auth
  46. @Web.setting
  47. def post(self):
  48. self.update('score')
  49. @Web.auth
  50. @Web.setting
  51. def delete(self):
  52. self.drop('score')
  53. class score_rule_path(Load):
  54. @Web.auth
  55. @Web.setting
  56. def get(self):
  57. id = str(self.input('score_id'))
  58. param = '?score_id=' + id + '&search_score_id-select-=' + id
  59. self.set(
  60. name = u'积分规则设置'
  61. ,path = '/score/score_rule'
  62. ,width = '600'
  63. ,height = '600'
  64. ,search = (('label-1','cdate-time-start','cdate-time-end','search_score_id-select-','record_type_id-select-'), (u'日期范围',u'开始时间',u'截止时间', u'选择积分', u'选择记录点类型'))
  65. ,thead = (u'积分名', u'记录点类型', u'规则', u'更新时间')
  66. ,tbody = ('name', 'type', 'rule', 'cdate')
  67. ,state = True
  68. )
  69. self.data['common']['search_record_type_id-select-'] = self.service('common').list('record_type')
  70. self.data['common']['search_score_id-select-'] = self.service('common').list('score')
  71. self.list('score_rule')
  72. if self.data['list']:
  73. for key, value in enumerate(self.data['list']):
  74. typeData = self.service('common').one('record_type', id=value['record_type_id'])
  75. self.data['list'][key]['type'] = typeData['name']
  76. score = self.service('common').one('score', id=value['score_id'])
  77. self.data['list'][key]['name'] = score['name']
  78. self.show('list')
  79. class score_rule_update_path(Load):
  80. @Web.auth
  81. @Web.setting
  82. def get(self):
  83. self.set(
  84. path = '/score/score_rule'
  85. ,label = (u'积分ID', u'记录点类型', u'积分规则公式')
  86. ,update = ('score_id-select-required','record_type_id-select-required','rule-text-required')
  87. ,update_record_type_id = self.service('common').list('record_type')
  88. ,update_score_id = self.service('common').list('score')
  89. )
  90. self.one('score_rule')
  91. self.show('update')
  92. @Web.auth
  93. @Web.setting
  94. def post(self):
  95. self.update('score_rule')
  96. @Web.auth
  97. @Web.setting
  98. def delete(self):
  99. self.drop('score_rule')
  100. class level_path(Load):
  101. @Web.auth
  102. @Web.setting
  103. def get(self):
  104. id = str(self.input('score_id'))
  105. param = '?score_id=' + id + '&search_score_id-select-=' + id
  106. self.set(
  107. name = u'等级设置'
  108. ,path = '/score/level'
  109. ,width = '600'
  110. ,height = '600'
  111. ,search = (('label-1','cdate-time-start','cdate-time-end','search_score_id-select-'), (u'日期范围',u'开始时间',u'截止时间', u'选择积分'))
  112. ,thead = (u'等级名',u'积分名', u'规则', u'更新时间')
  113. ,tbody = ('name', 'score', 'rule', 'cdate')
  114. ,state = True
  115. )
  116. self.data['common']['search_score_id-select-'] = self.service('common').list('score')
  117. self.list('level')
  118. if self.data['list']:
  119. for key, value in enumerate(self.data['list']):
  120. score = self.service('common').one('score', id=value['score_id'])
  121. self.data['list'][key]['score'] = score['name']
  122. self.show('list')
  123. class level_update_path(Load):
  124. @Web.auth
  125. @Web.setting
  126. def get(self):
  127. self.set(
  128. path = '/score/level'
  129. ,label = (u'等级名', u'积分ID', u'规则公式')
  130. ,update = ('name-input-required','score_id-select-required','rule-text-required')
  131. ,update_score_id = self.service('common').list('score')
  132. )
  133. self.one('level')
  134. self.show('update')
  135. @Web.auth
  136. @Web.setting
  137. def post(self):
  138. self.update('level')
  139. @Web.auth
  140. @Web.setting
  141. def delete(self):
  142. self.drop('level')