origin.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # -*- coding: utf-8 -*-
  2. """
  3. demeter web page
  4. name:origin.py 溯源相关页面
  5. author:rabin
  6. """
  7. from .__load__ import *
  8. class batch_path(Load):
  9. @Web.auth
  10. @Web.setting
  11. def get(self):
  12. self.set(
  13. name = u'溯源批次'
  14. ,path = '/origin/batch'
  15. ,width = '600'
  16. ,height = '600'
  17. ,add = False
  18. ,edit = False
  19. ,search = (('farm_id-select-','land_id-select-'), (u'选择农场',u'地块'))
  20. ,thead = (u'所属农场', u'产品名称', u'种植时间', u'采收时间', u'地块')
  21. ,tbody = ('farm','name', 'zzdate', 'csdate', 'land')
  22. ,state = False
  23. )
  24. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  25. self.data['common']['search_land_id-select-'] = self.service('common').list('farm_work_land')
  26. self.list('origin_batch')
  27. if self.data['list']:
  28. for key, value in enumerate(self.data['list']):
  29. farm = self.service('common').one('farm', id=value['farm_id'])
  30. self.data['list'][key]['farm'] = farm['name']
  31. land = self.service('common').one('farm_work_land', id=value['land_id'])
  32. self.data['list'][key]['land'] = land['name']
  33. self.show('list')
  34. class batch_update_path(Load):
  35. @Web.auth
  36. @Web.setting
  37. def get(self):
  38. self.set(
  39. path = '/origin/batch'
  40. ,label = (u'所属农场',u'产品名称', u'种植时间',u'采收时间',u'设备网关',u'地块',u'图像记录')
  41. ,update = ('farm_id-select-required','name-input-required', 'zzdate-date-required', 'csdate-date-required','gateway_id-select-required','land_id-select-required','pic-pic-required')
  42. ,update_gateway_id = self.service('common').list('device_gateway', order='hardware_id asc')
  43. ,update_land_id = self.service('common').list('farm_work_land')
  44. ,update_farm_id = self.service('common').list('farm', search={'eros_status':2})
  45. )
  46. self.one('origin_batch')
  47. self.show('update')
  48. @Web.auth
  49. @Web.setting
  50. def post(self):
  51. self.update('origin_batch')
  52. @Web.auth
  53. @Web.setting
  54. def delete(self):
  55. self.drop('origin_batch')