123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- # -*- coding: utf-8 -*-
- """
- demeter web page
- name:score.py 积分相关
- author:rabin
- """
- from .__load__ import *
- class score_path(Load):
- @Web.auth
- @Web.setting
- def get(self):
- self.set(
- name = u'积分设置'
- ,path = '/score/score'
- ,width = '600'
- ,height = '600'
- ,search = (('label-1','cdate-time-start','cdate-time-end'), (u'日期范围',u'开始时间',u'截止时间'))
- ,thead = (u'积分名', u'规则', u'更新时间')
- ,tbody = ('name', 'func', 'cdate')
- ,state = True
- )
- menu = (
- {'name':'规则列表', 'url':'/score/score_rule'},
- )
- self.list('score')
- if self.data['list']:
- for key, value in enumerate(self.data['list']):
- id = str(value['id'])
- param = '?score_id=' + id + '&search_score_id-select-=' + id
- self.data['list'][key]['func'] = ''
- for i in menu:
- self.data['list'][key]['func'] = self.data['list'][key]['func'] + '<a href="'+i['url']+''+param+'">'+i['name']+'</a> '
- self.show('list')
- class score_update_path(Load):
- @Web.auth
- @Web.setting
- def get(self):
- self.set(
- path = '/score/score'
- ,label = (u'积分名称',)
- ,update = ('name-input-required',)
- )
- self.one('score')
- self.show('update')
- @Web.auth
- @Web.setting
- def post(self):
- self.update('score')
- @Web.auth
- @Web.setting
- def delete(self):
- self.drop('score')
- class score_rule_path(Load):
- @Web.auth
- @Web.setting
- def get(self):
- id = str(self.input('score_id'))
- param = '?score_id=' + id + '&search_score_id-select-=' + id
- self.set(
- name = u'积分规则设置'
- ,path = '/score/score_rule'
- ,width = '600'
- ,height = '600'
- ,search = (('label-1','cdate-time-start','cdate-time-end','search_score_id-select-','record_type_id-select-'), (u'日期范围',u'开始时间',u'截止时间', u'选择积分', u'选择记录点类型'))
- ,thead = (u'积分名', u'记录点类型', u'规则', u'更新时间')
- ,tbody = ('name', 'type', 'rule', 'cdate')
- ,state = True
- )
- self.data['common']['search_record_type_id-select-'] = self.service('common').list('record_type')
- self.data['common']['search_score_id-select-'] = self.service('common').list('score')
- self.list('score_rule')
- if self.data['list']:
- for key, value in enumerate(self.data['list']):
- typeData = self.service('common').one('record_type', id=value['record_type_id'])
- self.data['list'][key]['type'] = typeData['name']
- score = self.service('common').one('score', id=value['score_id'])
- self.data['list'][key]['name'] = score['name']
- self.show('list')
- class score_rule_update_path(Load):
- @Web.auth
- @Web.setting
- def get(self):
- self.set(
- path = '/score/score_rule'
- ,label = (u'积分ID', u'记录点类型', u'积分规则公式')
- ,update = ('score_id-select-required','record_type_id-select-required','rule-text-required')
- ,update_record_type_id = self.service('common').list('record_type')
- ,update_score_id = self.service('common').list('score')
- )
- self.one('score_rule')
- self.show('update')
- @Web.auth
- @Web.setting
- def post(self):
- self.update('score_rule')
- @Web.auth
- @Web.setting
- def delete(self):
- self.drop('score_rule')
- class level_path(Load):
- @Web.auth
- @Web.setting
- def get(self):
- id = str(self.input('score_id'))
- param = '?score_id=' + id + '&search_score_id-select-=' + id
- self.set(
- name = u'等级设置'
- ,path = '/score/level'
- ,width = '600'
- ,height = '600'
- ,search = (('label-1','cdate-time-start','cdate-time-end','search_score_id-select-'), (u'日期范围',u'开始时间',u'截止时间', u'选择积分'))
- ,thead = (u'等级名',u'积分名', u'规则', u'更新时间')
- ,tbody = ('name', 'score', 'rule', 'cdate')
- ,state = True
- )
- self.data['common']['search_score_id-select-'] = self.service('common').list('score')
- self.list('level')
- if self.data['list']:
- for key, value in enumerate(self.data['list']):
- score = self.service('common').one('score', id=value['score_id'])
- self.data['list'][key]['score'] = score['name']
- self.show('list')
- class level_update_path(Load):
- @Web.auth
- @Web.setting
- def get(self):
- self.set(
- path = '/score/level'
- ,label = (u'等级名', u'积分ID', u'规则公式')
- ,update = ('name-input-required','score_id-select-required','rule-text-required')
- ,update_score_id = self.service('common').list('score')
- )
- self.one('level')
- self.show('update')
- @Web.auth
- @Web.setting
- def post(self):
- self.update('level')
- @Web.auth
- @Web.setting
- def delete(self):
- self.drop('level')
|