return [ { 'name': 'player__acount', 'label': '玩家账号', 'editor': 'com-filter-text' }, { 'name': 'agent__name', 'label': '代理人', 'editor': 'com-filter-text', 'visible': not has_permit(self.crt_user, '-agent_constraint') }, ] class RechargeForm(ModelFields): class Meta: model = Recharge exclude = [] director.update({ 'recharge': RechargePage.tableCls, 'recharge.edit': RechargeForm, }) page_dc.update({'recharge': RechargePage})
from helpers.director.shortcut import TablePage, ModelFields, ModelTable, page_dc, director from .models import FreePhone class FreePhonePage(TablePage): class tableCls(ModelTable): model = FreePhone exclude = [] class FreePhoneForm(ModelFields): def __init__(self, dc={}, pk=None, crt_user=None, nolimit=False, *args, **kw): return super().__init__(dc, pk, crt_user, nolimit= True, *args, **kw) class Meta: model = FreePhone exclude = [] director.update({ 'freephone': FreePhonePage.tableCls, 'freephone.edit': FreePhoneForm, }) page_dc.update({ 'freephone': FreePhonePage, })
from helpers.director.shortcut import director def get_permit_show(): return [ {'label':'玩家管理','children':[ {'label': '查看', 'value': 'GamePlayer',}, ]}, {'label':'代理人约束','value':'-agent_constraint'} ] director.update({ 'permit.options':get_permit_show, })
def get_label(self): return '条状图' class fieldsCls(ModelFields): class Meta: model = TBTaskBridge exclude = [] def get_context(self): return { 'bar_data': { 'kind': ['立面三乱', '黄土见天', '暴露垃圾', '河滩垃圾', '其他'], 'month': [ '2018-01', '2018-02', '2018-03', '2018-04', '2018-05', '2018-06' ], 'series': [[5, 6, 7, 4, 6, 4], [8, 2, 4, 5, 1, 2], [2, 3, 2, 1, 0, 4], [1, 4, 5, 2, 1, 4], [5, 2, 3, 6, 4, 3]] } } director.update({ 'district_pie': DistrictPie.fieldsCls, 'timetask_bar': TimeTaskBar.fieldsCls }) page_dc.update({'district_pie': DistrictPie, 'timetask_bar': TimeTaskBar})
class BannerPage(TablePage): template = 'jb_admin/table_new.html' def get_label(self): return '宣传图画' class tableCls(ModelTable): pop_edit_field = 'id' model = Banners exclude = [] def dict_head(self, head): if head['name'] == 'img': head['width'] = 500 return head class BannerForm(ModelFields): class Meta: model = Banners exclude = [] director.update({ 'banner': BannerPage.tableCls, 'banner.edit': BannerForm, }) page_dc.update({ 'banner': BannerPage, })
#ls = [] #for row in JianduCase.objects.all().values('keepersn').annotate(nums_case = Count('id')): #ls.append(row) #return ls def statistics(self, query): """ """ return query.values('keepersn', 'keepersn__name').exclude(Q(status = 5) | Q(status = 10)|\ Q(keepersn__isnull=True))\ .annotate(nums_case = Count('id'))\ .annotate(nums_simple = Count(Case(When(Q(deptcode = F('executedeptcode')) & Q( deptcode = '20601'), then= 1)) ))\ .annotate(nums_normal = F('nums_case') - F('nums_simple'))\ .annotate(nums_bujian = Count(Case(When(infotypeid = 0, then= 1))))\ .annotate(nums_shijian = Count(Case(When(infotypeid = 1, then= 1))))\ class filters(RowFilter): range_fields = ['subtime'] def dict_head(self, head): if head['name']=='subtime': head['editor']='com-date-datetimefield-range-filter' return head director.update({ 'keeper.caseStatic': KeeperCaseStatic.tableCls, }) page_dc.update({ 'keeper.caseStatic': KeeperCaseStatic, })
}) class PageForm(ModelFields): class Meta: model = Page exclude = [] def dict_head(self, head): if head['name'] == 'content': head['editor'] = 'com-field-json-edit' return head def after_save(self): save_ui_editor_data() @director_view('uie/page') def uie_page(name): inst = Page.objects.get(name=name) return json.loads(inst.content) #if 'collectstatic' in sys.argv: if 'makemigrations' not in sys.argv and\ 'migrate' not in sys.argv: check_and_import() director.update({'webpage': PagePage.tableCls, 'webpage.edit': PageForm}) page_dc.update({'webpage': PagePage})
return info.status @director_view('workerinfo/submit_info') def submit_info(): user = get_request_cache()['request'].user info, _ = WorkInfo.objects.get_or_create(user=user) if info.status != 0: raise UserWarning('认证信息不能提交审核') if not info.name or not info.contact: raise UserWarning('请完善基本信息后再提交审核') if not info.id_face1 or not info.id_face2: raise UserWarning('请完上传身份证正反面') #if not info.service_agreement: #raise UserWarning('请上传自由职业者服务者协议') info.status = 1 info.save() return info.status director.update({ 'workinfo': WorkinfoPage.tableCls, 'workinfo.edit': WorkinfoForm, 'workinfo.base': WorkinfoBase, 'workinfo.idface': WorkinfoIdFace, 'workinfo.education': Workinfo_education, 'workinfo.bankcard': WorkerBankInfo, #'workinfo.agreement':WorkinfoAgreement, }) page_dc.update({'workinfo': WorkinfoPage})
general_log.debug('uid=%s;channel=%s字幕转换:%s ====> %s' % (uid, channel, old_desp, desp)) # 可能有些 callevent没有对应的 callrecord,这里把他们设置好 obj = CallEvent.objects.create(uid=uid, channel=channel, code=code, desp=desp, sender_type=sender_type) latest = CallRecord.objects.filter(channel=OuterRef('channel')) #CallEvent.objects.filter(pk = obj.pk).annotate(record_me = Subquery(latest.values('pk')[:1])).update(record_id=F('record_me')) CallEvent.objects.filter(pk=obj.pk).update( record_id=Subquery(latest.values('pk')[:1])) if int(code) == 1: sim_signal.send('call.enter', uid=uid, channel=channel) if int(code) == 2: sim_signal.send('call.quit', uid=uid, channel=channel) @director_view('call/rtcmap') def user_rtc_map(channel, uid, rtcid): UserRtcMap.objects.create(channel=channel, uid=uid, rtcid=rtcid) director.update({ 'callrecord': CallRecordPage.tableCls, 'callevent-tab': CallEventTab }) page_dc.update({'callrecord': CallRecordPage})
{'url':'/media/userfile/mytone1.mp3',"before_second":20}, ] ''' general_log.debug('调用更新用户语音助手,接收到参数uid=%(uid)s的语音助手' % locals()) instacne = Accountinfo.objects.filter(uid=uid).first() if instacne: general_log.debug('更新用户%(uid)s的语音助手%(tone_list)s' % locals()) instacne.reject_tone = json.dumps(tone_list, ensure_ascii=False) instacne.save() else: raise UserWarning('用户不存在') @director_view('account/get-reject-tone') def get_reject_tone(uid): instacne = Accountinfo.objects.filter(uid=uid).first() if instacne: if instacne.reject_tone: return json.loads(instacne.reject_tone) else: return [] else: raise UserWarning('用户不存在') director.update({ 'accountinfo': AccountInfoPage.tableCls, 'accountinfo.edit': AccountForm }) page_dc.update({'accountinfo': AccountInfoPage})
def inn_filter(self, query): return query.annotate(nums_task = Count('ttaskinfo'), \ nums_finish_task = Count(Case(When(ttaskinfo__status = 9 , then= 1) ))) def dict_row(self, inst): return { '_case_list': '/pc/enterprise_case.caseadmin?ENT_NAME=%s' % inst.ENT_NAME, 'nums_task': inst.nums_task, 'nums_finish_task': inst.nums_finish_task, } class filters(RowFilter): range_fields = ['ttaskinfo__discovertime'] def getExtraHead(self): return [{ 'name': 'ttaskinfo__discovertime', 'editor': 'com-date-range-filter', 'label': '日期', }] director.update({ 'Enterprise.table': EnterprisePage.tableCls, }) page_dc.update({ 'Enterprise.table': EnterprisePage, })
'cfg_baidu_API_KEY':get_json('cfg_baidu_API_KEY',''), 'cfg_baidu_SECRECT_KEY':get_json('cfg_baidu_SECRECT_KEY','') } def save_form(self): set_json('cfg_channel_heartbeat',self.kw.get('cfg_channel_heartbeat')) set_json('cfg_push_call_record',self.kw.get('cfg_push_call_record')) set_json('cfg_baidu_APPID',self.kw.get('cfg_baidu_APPID')) set_json('cfg_baidu_API_KEY',self.kw.get('cfg_baidu_API_KEY')) set_json('cfg_baidu_SECRECT_KEY',self.kw.get('cfg_baidu_SECRECT_KEY')) @director_view('system/config') def get_config(): return { 'channel_heartbeat':get_json('cfg_channel_heartbeat',30), 'agora_appid':settings.AGORA.get('appID'), 'baiduai_key':{ 'APPID':get_json('cfg_baidu_APPID',''), 'API_KEY':get_json('cfg_baidu_API_KEY',''), 'SECRECT_KEY':get_json('cfg_baidu_SECRECT_KEY',''), } } director.update({ 'config':ConfigFormPage.fieldsCls }) page_dc.update({ 'config':ConfigFormPage })
#def get_heads(self): #return [ #{'name': 'slogan', 'label': '推广口号','editor': 'blocktext','style': 'width:30em;height:8em',}, #{'name': 'danyuan', 'label': '但愿','editor': 'linetext',}, #{'name':'pp','label':'测试标签','editor':'com-field-table-list', #'table_heads':[{'name':'a','label':'显示一','editor':'com-table-pop-fields-local'}, #{'name':'b','label':'显示二'}, #{'name': 'op', 'label': '', 'editor': 'com-table-change-order',}], #'fields_heads':[{'name':'a','label':'显示一','editor':'linetext'}, #{'name':'b','label':'显示二','editor':'linetext'}] #} #] #class BaseInfo2(BaseTabFields): #def get_heads(self): #return [ #{'name': 'bige', 'label': '逼格','editor': 'linetext',}, #{'name': 'danyuan', 'label': '但愿','editor': 'linetext',} #] director.update({ 'simcms.page.page1': Page1, 'simcms.page.page1.pageconent': PageContent, }) cms_page.update({ 'expo_cms_page1': Page1, })
from helpers.director.shortcut import TablePage, ModelTable, page_dc, director, ModelFields from ..models import MainPageItem class MainPageItemPage(TablePage): def get_label(self): return '主页设置' def get_template(self, prefer=None): return 'jb_admin/table.html' class tableCls(ModelTable): model = MainPageItem exclude = ['id'] pop_edit_field = 'label' class MainPageForm(ModelFields): class Meta: model = MainPageItem exclude = [] director.update({ 'mainpage_cfg': MainPageItemPage.tableCls, 'mainpage_cfg.edit': MainPageForm, }) page_dc.update({ 'mainpage_cfg': MainPageItemPage, })
'title': _('用户注册'), #'init_express':'scope.row._director_name="mb-login-form"', #'after_save':'cfg.toast("登录成功");setTimeout(function(){location=search_args.next},1500)' }) return { 'editor_ctx': ctx, 'editor': 'live_fields', } class fieldsCls(ModelFieldsMobile, RegistFormPage.fieldsCls): nolimit = True class Meta: model = User fields = [ 'username', 'password', ] def dict_head(self, head): if head['name'] == 'password': head['editor'] = 'com-field-password' head['fv_rule'] = _('密码:') if head['name'] == 'username': head['placeholder'] = _('用户名/手机号码') return head director.update({'mb-regist-form': MobileRegist.fieldsCls}) mb_page_dc.update({'regist': MobileRegist})
from .models import StoreRecord class StoreRecordPage(TablePage): def get_label(self): return '积分商城记录' def get_template(self, prefer=None): return 'jb_admin/table.html' class tableCls(ModelTable): model = StoreRecord exclude = [] class filters(RowFilter): names = ['player__acount'] icontains = ['player__acount'] range_fields = ['createtime'] def getExtraHead(self): return [{ 'name': 'player__acount', 'label': '玩家', }] director.update({ 'admin_store': StoreRecordPage.tableCls, }) page_dc.update({'admin_store': StoreRecordPage})
'''cfg.show_load();scope.ps.vc.row.status=2; scope.ps.vc.submit().then(()=>{ cfg.hide_load(); cfg.toast("操作成功"); scope.ps.vc.par_row.status=2 }) ''' }, { 'editor': 'com-op-van-btn', 'type': 'info', 'label': '项目完结', 'show': 'scope.vc.row.status==3', 'action': '''cfg.show_load();scope.ps.vc.row.status=4; scope.ps.vc.submit().then(()=>{ cfg.hide_load(); cfg.toast("操作成功"); scope.ps.vc.par_row.status=4 })''' }] director.update({ 'applyrecord': ApplyRecordPage.tableCls, 'applyrecord.edit': ApplyRecordFrom, 'applyrecord.company': ApplyRecordFormCompany, }) page_dc.update({'applyrecord': ApplyRecordPage})
'old_selected': old_selected, 'last': inst.dispatched.last, 'last_time': localstr(inst.dispatched.last_time) } return dc # return { # 'blocks':[to_dict(x,form=True) for x in inst.blocks.all()] # } tableCls = BlockGroupTable template = 'geoscope/blockgroup_dispatch.html' director.update({ 'geoscope.blockpolygon.edit': BlockPolygonFormPage.BlockPolygonForm, }) model_dc[BlockPolygon] = {'fields': BlockPolygonFormPage.BlockPolygonForm} model_dc[BlockGroup] = { 'fields': BlockGroupFormPage.BlockGroupFormPage_normal.BlockGroupForm } page_dc.update({ 'geoscope.blockpolygon': BlockPolygonTablePage, 'geoscope.blockpolygon.edit': BlockPolygonFormPage, 'geoscope.blockgroup': BlockGroupTablePage, 'geoscope.blockgroup.edit': BlockGroupFormPage, 'geoscope.dispatch': BlockGroupDispatchPage, })
'label': '全部已读', 'editor': 'com-btn', 'click_express': 'cfg.show_load();ex.director_call("act_log.system_message.all_read",{}).then(()=>{cfg.hide_load(2000);scope.ps.search()})' }] return ops class filters(RowFilter): names = ['read', 'level'] range_fields = ['createtime'] class SystemMessageForm(ModelFields): class Meta: model = SystemMessage exclude = [] @director_view('act_log.system_message.all_read') def system_message_all_read(): SystemMessage.objects.filter(read=False).update(read=True) director.update({ 'system_message': SystemMessagePage.tableCls, 'system_message.edit': SystemMessageForm, }) page_dc.update({'system_message': SystemMessagePage})
from helpers.director.shortcut import TablePage, ModelTable, ModelFields, page_dc, director from .models import YewuGroup class YewuGroupPage(TablePage): template = 'jb_admin/table.html' def get_label(self): return '业务分组' class tableCls(ModelTable): pop_edit_field = 'id' model = YewuGroup exclude = [] class YewuGroupForm(ModelFields): class Meta: model = YewuGroup exclude = [] director.update({ 'yewugroup': YewuGroupPage.tableCls, 'yewugroup.edit': YewuGroupForm, }) page_dc.update({ 'yewugroup': YewuGroupPage, })
#group = ImageGroup.objects.get(pk = group_id) #group.images.add(*images) #group.save() #@director_view('imagegroup/insert_image') #def insert_image(group_id,images): #group = ImageGroup.objects.get(pk = group_id) #ls =list( SourceImage.objects.filter(pk__in=images) ) #group.images.add(*ls) #@director_view('imagegroup/list') #def get_imagegroup_list(): #out = [ sim_dict(x) for x in ImageGroup.objects.filter(status = 1)] #return out #@director_view('imagegroup/images') #def get_imagegroup_images(id): #out = [sim_dict(x) for x in SourceImage.objects.filter(imagegroup=id)] #return out director.update({ 'imagegroup_grid': ImageGroupPage.tableCls, 'imagegroup_grid.edit': ImageGroupForm, 'imagegroup_grid.ImageList': ImageList, 'imagegroup_grid.imagepicker': ImagePicker, 'imagegroup_grid.saver': ImagegroupSaver }) page_dc.update({'imagegroup_grid': ImageGroupPage})
#}) #return options @director_view('get_new_guy_gift') def get_new_guy_gift(account,block): '''account_id='wyh99999 ''' options =[] crt_user = get_request_cache()['request'].user block_inst = GameBlock.objects.get(pk = block) if not GamePlayer.objects.filter(acount=account,block = block_inst).exists(): if not TbCharacter.objects.using(block_inst.db).filter(account_id=account).exists(): raise UserWarning(_('没有找到角色!') ) elif not GamePlayer.objects.filter(agent__account = crt_user,block = block_inst,acount=account,new_guy_gift=False).exists(): raise UserWarning(_('该用户不属于本代理或已经领取过新人福利。') ) for inst in TbCharacter.objects.using(block_inst.db).filter(account_id=account): options.append({ 'value':inst.pc_id,'label':inst.pc_name }) return options director.update({ 'recharge_mb.form':RechargeForm, 'recharge_mb.new_guy_gift':NewPlayerGift, }) mb_page.update({ 'home':Home })
#{'name': 'danyuan', 'label': '但愿','editor': 'linetext',}, #{'name':'pp','label':'测试标签','editor':'com-field-table-list', #'table_heads':[{'name':'a','label':'显示一','editor':'com-table-pop-fields-local'}, #{'name':'b','label':'显示二'}, #{'name': 'op', 'label': '', 'editor': 'com-table-change-order',}], #'fields_heads':[{'name':'a','label':'显示一','editor':'linetext'}, #{'name':'b','label':'显示二','editor':'linetext'}] #} #] class BaseInfo2(BaseTabFields): def get_heads(self): return [ {'name': 'bige', 'label': '逼格','editor': 'linetext',}, {'name': 'danyuan', 'label': '但愿','editor': 'linetext',} ] director.update({ 'simcms.page.home': Home, 'simcms.page.home.base': BaseInfo, 'simcms.page.home.base2': BaseInfo2, }) cms_page.update({ 'expo_cms_home': Home, })
#{'name':'content','editor':'com-example-content',}, #], #'full_width':True, #'image_url':static_url('image/server-2160321_1280.webp'), #'class':'my-top-image', #'css':''' .my-top-image .head{height:70px} #.my-top-image .head img{height:370px} #.my-top-image .content{margin-bottom:40px} #''', ##'inn_editor':'com-example-content', #}, ] } class ExampleInfoList(ModelTable): model = ExampleInfo exclude = [] nolimit = True def inn_filter(self, query): return query.filter(kind=self.kw.get('kind')) director.update({ 'example-list':ExampleInfoList }) web_page_dc.update({ 'example':ExamplePage, })
row = ModelFields.get_row(self) row['create_time'] = self.instance.create_time.strftime( '%Y-%m-%d %H:%M:%S') row['proc_time'] = self.instance.proc_time.strftime( '%Y-%m-%d %H:%M:%S') return row def get_heads(self): heads = ModelFields.get_heads(self) heads.append({ 'name': 'create_time', 'label': '创建时间', 'type': 'linetext', 'readonly': True }) return heads def save_form(self): ModelFields.save_form(self) self.instance.manager = self.crt_user self.instance.save() director.update({ 'dianzi_weilan.realtime_warning': RealTimeWaringPage.tableCls, 'dianzi_weilan.realtime_warning.edit': RealTimeWarningForm, }) page_dc.update({ 'dianzi_weilan.realtime_warning': RealTimeWaringPage, })
}, { 'name': 'new_name', 'label': '新名称', 'editor': 'linetext', 'required': True, }], }, ] def get_row(self): return { '_director_name': self.get_director_name(), 'cunwei_names': get_value('cunwei_names'), 'enterprise_names': get_value('enterprise_names'), 'hotline_name_map': get_value('hotline_name_map'), } def save_form(self): ls = ['cunwei_names', 'enterprise_names', 'hotline_name_map'] for k, v in self.kw.items(): if k in ls: set_value(k, v) director.update({ 'HotlineData': HotlineData.fieldsCls, }) page_dc.update({ 'HotlineData': HotlineData, })
if head['name'] =='colors': head.update({ 'editor':'com-field-table-list', 'table_heads':[{'name':'color1','label':'色彩值','editor':'com-table-pop-fields-local'}, {'name':'show_color','label':'色彩','editor':'com-table-color-color','value_field':'color1'}, {'name':'order','label':'','editor':'com-table-change-order'}], 'fields_heads':[{'name':'color1','label':'选择色彩','editor':'com-field-color','required':True}] }) return head def clean_save(self): self.instance.kind =0 @director_view('palette/all') def get_palette(): rows = [] for inst in Palette.objects.all(): dc={ 'colors':json.loads(inst.colors) if inst.colors else [] } rows.append(sim_dict(inst,filt_attr=dc)) return rows director.update({ 'palette':PalettePage.tableCls, 'palette.edit':PaletteForm }) page_dc.update({ 'palette':PalettePage })
def dict_head(self, head): if head['name'] == 'inst_pk': head['editor'] = 'com-filter-exact-text' head['options'] =[] return head def clean_search_args(self, search_args): if search_args.get('content'): if getattr(settings,'DB_FULL_SEARCH',False): search_args['content__search'] = search_args.pop('content') return search_args class BackendOperationForm(ModelFields): class Meta: model = BackendOperation exclude = [] def dict_head(self, head): head['readonly'] = True return head director.update({ 'backendoperation_log':BackendOperationPage.tableCls, 'backendoperation_log.edit':BackendOperationForm }) page_dc.update({ 'backendoperation_log':BackendOperationPage })
row_dict[k]['count_wei'] = v for k, v in pda_dict.items(): if k not in row_dict: dc = { 'three': k, 'count_keeper': v, } rows.append(dc) row_dict[k] = dc else: row_dict[k]['count_keeper'] = v return rows def getRowFilters(self): return [{ 'name': 'data_time', 'label': '日期', 'editor': 'com-filter-date', }] director.update({ 'hotline_report': Hotline.tableCls, 'GridReport': GridReport.tableCls, }) page_dc.update({ 'hotline_report': Hotline, 'GridReport': GridReport, })
for group in InspectorGrop.objects.filter(kind=2): #for group in InspectorWorkGroup.objects.all(): ls.append({ 'label': group.name, 'inspectors': [x.pk for x in group.inspector.all()] }) head['editor'] = 'com-field-select-work-inspector' head['groups'] = ls return head director.update({ 'dianzi_weilan': Weilan.tableCls, 'dianzi_weilan.edit': WeilanForm.BlockGroupFormPage_normal.BlockGroupForm, 'dianzi_weilan.warning': OutBlockWaringPage.tableCls, 'dianzi_weilan.warning.edit': OutBlockWarningFormPage.fieldCls, 'dianzi_weilan.groupweilanrel': GroupWeilanRel.tableCls, 'dianzi_weilan.groupweilanrel.edit': GroupWeilanRelFormPage.fieldsCls, 'dianzi_weilan.workinspector': WorkinspectorPage.tableCls, 'dianzi_weilan.workinspector.edit': InspectorWorkScheduleForm, }) #model_dc[InspectorGroupAndWeilanRel]={'fields':GroupWeilanRelFormPage.fieldsCls} #model_dc[OutBlockWarning]={'fields':OutBlockWarningFormPage.fieldCls} #model_dc[WorkInspector]={'fields':WorkinspectorFormPage.fieldsCls} page_dc.update({ 'dianzi_weilan.blockgroup': Weilan, 'dianzi_weilan.blockgroup.edit': WeilanForm, 'dianzi_weilan.groupweilanrel': GroupWeilanRel, 'dianzi_weilan.groupweilanrel.edit': GroupWeilanRelFormPage, 'dianzi_weilan.warning': OutBlockWaringPage, 'dianzi_weilan.warning.edit': OutBlockWarningFormPage,