1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- demeter load
- author:rabin
- """
- from demeter.web import *
- class Load(Base):
- KEYS = ('admin', 'farm')
- def setting(self):
- self.search()
- self.admin()
- def admin(self):
- admin = 1
- self.data['auth'] = True
-
- if 'admin' in self.data['setting'] and self.data['setting']['admin'] > 0:
- self.data['setting']['adminInfo'] = self.service('common').one('manage_admin', id=self.data['setting']['admin'])
- if self.data['setting']['adminInfo']:
- self.data['setting']['roleInfo'] = self.service('common').one('manage_role', id=self.data['setting']['adminInfo']['role_id'])
- else:
- #self.redirect('/user/login')
- return
- if 'farm' in self.data['setting'] and self.data['setting']['farm'] > 0:
- self.data['setting']['farmInfo'] = self.service('common').one('farm', id=self.data['setting']['farm'])
- self.data['setting']['menuList'] = self.menu()
- if self.data['setting']['adminInfo']['id'] == admin:
- if 'menu' in self.data['setting']:
- del self.data['setting']['menu']
- else:
- self.data['setting']['menu'] = ['_/', '_/login', '_/main', '_/admin/log_update']
- menu = self.data['setting']['roleInfo']['auth'] + ','
- for i,j in enumerate(self.data['setting']['menuList'][1]):
- m = 0
- for n in j[0]:
- if n+',' in menu:
- l = str(i)+'_'+str(n)
- self.data['setting']['menu'].append(l)
- self.data['setting']['menu'].append(l + '_update')
- m = m + 1
- self.data['setting']['menu'] = ',' + ",".join(self.data['setting']['menu'])+','
- uri = '_' + self.request.uri + ','
- if self.data['setting']['admin'] != admin and uri not in self.data['setting']['menu']:
- self.data['auth'] = False
- self.data['setting']['web'] = Demeter.config['web']['url']
- self.data['setting']['farmList'] = self.service('common').list('farm')
- def menu(self):
- parent = [['农场与设备管理', '网站管理', '基础设置'],['', '', '']]
- child = [
- [['/farm/farm','/device/gateway','/device/info','/work/work','/work/land','/origin/batch','/farm/user','/device/printer','/msg/msg','/device/log'],['农场列表', '网关管理', '设备管理', '农场农事管理', '农场地块管理', '溯源批次管理','农场用户管理','农场打印机','消息提醒', '网关日志']]
- ,[['/web/set','/web/category','/web/article','/web/menu'],['首页内容管理', '文章分类', '发布内容文章', '菜单管理']]
- ,[['/device/type','/hardware/type','/msg/type','/work/category','/admin/admin','/admin/role','/hardware/hardware', '/admin/log'],['设备类型管理','硬件类型管理', '消息类型设置', '农事类型设置', '管理员设置', '管理权限设置','硬件设备记录', '系统日志']]
- ]
- return (parent,child)
|