origin.py 2.0 KB

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