# -*- coding: utf-8 -*- """ demeter web page name:work.py 农事相关页面 author:rabin """ from .__load__ import * class work_path(Load): @Web.auth @Web.setting def get(self): self.set( name = u'农事' ,path = '/work/work' ,width = '600' ,height = '600' ,add = False ,edit = False ,search = (('label-1','workdate-time-start','workdate-time-end','category_id-select-'), (u'日期范围',u'开始时间',u'截止时间',u'劳作分类')) ,thead = (u'劳作时间', u'劳作分类', u'劳作方式', u'劳作地块', u'劳作用量', u'更新时间') ,tbody = ('workdate', 'category', 'method', 'land', 'amount', 'cdate') ,state = False ) self.list('device_gateway') self.data['common']['search_category_id-select-'] = self.service('common').list('farm_work_category') self.list('farm_work') if self.data['list']: for key, value in enumerate(self.data['list']): category = self.service('common').one('farm_work_category', id=value['category_id']) self.data['list'][key]['category'] = category['name'] method = self.service('common').one('farm_work_method', id=value['method_id']) self.data['list'][key]['method'] = method['name'] land = self.service('common').one('farm_work_land', id=value['land_id']) self.data['list'][key]['land'] = land['name'] self.show('list') class work_update_path(Load): @Web.auth @Web.setting def get(self): self.set( path = '/work/work' ,label = (u'劳作时间',u'劳作类别',u'劳作方式',u'劳作用量',u'劳作地块',u'图像记录') ,update = ('workdate-date-required','category_id-select-required-method_id','method_id-select-required--category_id','amount-input-required','land_id-select-required','pic-pic-required') ,update_category_id = self.service('common').list('farm_work_category') ,update_method_id = self.service('common').list('farm_work_method') ,update_land_id = self.service('common').list('farm_work_land') ) self.one('farm_work') self.show('update') @Web.auth @Web.setting def post(self): self.update('farm_work') @Web.auth @Web.setting def delete(self): self.drop('farm_work') class method_path(Load): @Web.auth @Web.setting def get(self): self.set( name = u'劳作方法' ,path = '/work/method' ,width = '800' ,height = '300' ,add = False ,edit = False ,search = (('label-1','cdate-time-start','cdate-time-end','category_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'劳作分类',u'劳作内容')) ,thead = (u'劳作内容', u'劳作分类', u'更新时间') ,tbody = ('name', 'category', 'cdate') ,state = False ) self.data['common']['search_category_id-select-'] = self.service('common').list('farm_work_category') self.list('farm_work_method') if self.data['list']: for key, value in enumerate(self.data['list']): category = self.service('common').one('farm_work_category', id=value['category_id']) self.data['list'][key]['category'] = category['name'] self.show('list') class method_update_path(Load): @Web.auth @Web.setting def get(self): self.set( path = '/work/method' ,label = (u'劳作内容',u'劳作分类') ,update = ('name-input-required','category_id-select-required') ,update_category_id = self.service('common').list('farm_work_category') ) self.one('farm_work_method') self.show('update') @Web.auth @Web.setting def post(self): self.update('farm_work_method') @Web.auth @Web.setting def delete(self): self.drop('farm_work_method') class category_path(Load): @Web.auth @Web.setting def get(self): self.set( name = u'劳作分类' ,path = '/work/category' ,width = '600' ,height = '300' ,add = False ,edit = False ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'分类名称')) ,thead = (u'分类名称', u'更新时间') ,tbody = ('name', 'cdate') ,state = False ) self.list('farm_work_category') self.show('list') class category_update_path(Load): @Web.auth @Web.setting def get(self): self.set( path = '/work/category' ,label = (u'分类名称') ,update = ('name-input-required') ) self.one('farm_work_category') self.show('update') @Web.auth @Web.setting def post(self): self.update('farm_work_category') @Web.auth @Web.setting def delete(self): self.drop('farm_work_category') class land_path(Load): @Web.auth @Web.setting def get(self): self.set( name = u'地块' ,path = '/work/land' ,width = '600' ,height = '300' ,add = False ,edit = False ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'地块名称')) ,thead = (u'地块名称', u'更新时间') ,tbody = ('name', 'cdate') ,state = False ) self.list('farm_work_land') self.show('list') class land_update_path(Load): @Web.auth @Web.setting def get(self): self.set( path = '/work/land' ,label = (u'地块名称',) ,update = ('name-input-required',) ) self.one('farm_work_land') self.show('update') @Web.auth @Web.setting def post(self): self.update('farm_work_land') @Web.auth @Web.setting def delete(self): self.drop('farm_work_land')