1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- demeter web page
- name:farm.py 农场相关页面
- author:rabin
- """
- from __load__ import *
- class farm_path(Load):
- @tornado.web.authenticated
- def get(self):
- self.common(
- name = u'农场' #中文名
- ,path = '/farm/farm' #路径
- ,width = '600' # 新增页面的宽度
- ,height = '600' # 新增页面的高度
- ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'农场名称')) #搜索
- ,thead = (u'农场名称', u'功能列表') #表头
- ,tbody = ('name', 'func') #表内容
- ,state = False #启用回收站
- )
- menu = (
- {'name':'网关管理', 'url':'/device/gateway'}
- ,{'name':'设备管理', 'url':'/device/info'}
- ,{'name':'农事管理', 'url':'/work/work'}
- ,{'name':'农事分类', 'url':'/work/category'}
- ,{'name':'地块管理', 'url':'/work/land'}
- ,{'name':'批次管理', 'url':'/origin/batch'}
- ,{'name':'用户管理', 'url':'/farm/user'}
- ,{'name':'打印机管理', 'url':'/device/printer'}
- ,{'name':'消息提醒', 'url':'/msg/msg'}
- )
- self.commonList('farm')
- if self.data['list']:
- for key, value in enumerate(self.data['list']):
- id = str(value['id'])
- param = '?farm=' + id + '&search_farm_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.commonView('list')
- class farm_update_path(Load):
- @tornado.web.authenticated
- def get(self):
- self.common(
- path = '/farm/farm'
- ,label = (u'农场名称',u'农场地址',u'联系人',u'联系电话',u'农场图片')
- ,update = ('name-input-required','address-input-required','master_name-input-required','tel-input-required','pic-pic-required')
- )
- self.commonOne('farm')
- self.commonView('update')
- @tornado.web.authenticated
- def post(self):
- id = self.commonUpdate('farm')
- Demeter.config['setting']['farmList'] = self.service('common').list('farm')
- class user_path(Load):
- @tornado.web.authenticated
- def get(self):
- self.common(
- name = u'用户'
- ,path = '/farm/user'
- ,width = '600'
- ,height = '400'
- ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间','选择农场',u'用户名称'))
- ,thead = (u'所属农场', u'用户名称', u'用户手机号', u'更新时间')
- ,tbody = ('farm','username', 'mobile', 'cdate')
- ,state = True
- )
- self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
- self.commonList('farm_user')
- if self.data['list']:
- for key, value in enumerate(self.data['list']):
- farm = self.service('common').one('farm', id=value['farm_id'])
- self.data['list'][key]['farm'] = farm['name']
- self.commonView('list')
- class user_update_path(Load):
- @tornado.web.authenticated
- def get(self):
- self.common(
- path = '/farm/user'
- ,label = (u'所属农场',u'账号姓名',u'手机号',u'安全码')
- ,update = ('farm_id-select-required','username-input-required','mobile-input-phone','password-password-')
- ,update_farm_id = Demeter.config['setting']['farmList']
- )
- self.commonOne('farm_user')
- self.commonView('update')
- @tornado.web.authenticated
- def post(self):
- self.commonUpdate('farm_user', '手机号已经被注册', mobile=self.data['update']['mobile'])
- @tornado.web.authenticated
- def delete(self):
- self.commonDelete('farm_user')
|