# -*- 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','farm_id-select-','category_id-select-'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'劳作分类')) ,thead = (u'所属农场', u'劳作时间', u'劳作分类', u'劳作方式', u'劳作地块', u'劳作用量', u'更新时间') ,tbody = ('farm','workdate', 'category', 'method', 'land', 'amount', 'cdate') ,state = False ) self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList'] 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']): farm = self.service('common').one('farm', id=value['farm_id']) #self.data['list'][key]['workdate'] = Demeter.date(value['workdate']) self.data['list'][key]['farm'] = farm['name'] 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'劳作地块',u'图像记录') ,update = ('farm_id-select-required', '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') ,update_farm_id = self.service('common').list('farm', search={'eros_status':2}) ) 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','farm_id-select-','category_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'劳作分类',u'劳作内容')) ,thead = (u'所属农场',u'劳作内容', u'劳作分类', u'更新时间') ,tbody = ('farm','name', 'category', 'cdate') ,state = False ) self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList'] 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']): farm = self.service('common').one('farm', id=value['farm_id']) self.data['list'][key]['farm'] = farm['name'] 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'劳作内容',u'劳作分类') ,update = ('farm_id-select-required', 'name-input-required','category_id-select-required') ,update_category_id = self.service('common').list('farm_work_category') ,update_farm_id = self.service('common').list('farm', search={'eros_status':2}) ) 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','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'分类名称')) ,thead = (u'所属农场',u'分类名称', u'更新时间') ,tbody = ('farm', 'name', 'cdate') ,state = False ) self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList'] self.list('farm_work_category') 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.show('list') class category_update_path(Load): @Web.auth @Web.setting def get(self): self.set( path = '/work/category' ,label = (u'所属农场', u'分类名称') ,update = ('farm_id-select-required', 'name-input-required') ,update_farm_id = self.service('common').list('farm', search={'eros_status':2}) ) 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','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'地块名称')) ,thead = (u'所属农场',u'地块名称', u'更新时间') ,tbody = ('farm', 'name', 'cdate') ,state = False ) self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList'] self.list('farm_work_land') 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.show('list') class land_update_path(Load): @Web.auth @Web.setting def get(self): self.set( path = '/work/land' ,label = (u'所属农场', u'地块名称') ,update = ('farm_id-select-required','name-input-required') ,update_farm_id = self.service('common').list('farm', search={'eros_status':2}) ) 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')