origin.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 = (('land_id-select-'), (u'地块'))
  20. ,thead = (u'产品名称', u'种植时间', u'采收时间', u'地块')
  21. ,tbody = ('name', 'zzdate', 'csdate', 'land')
  22. ,state = False
  23. )
  24. self.data['common']['search_land_id-select-'] = self.service('common').list('farm_work_land')
  25. self.list('origin_batch')
  26. if self.data['list']:
  27. for key, value in enumerate(self.data['list']):
  28. land = self.service('common').one('farm_work_land', id=value['land_id'])
  29. self.data['list'][key]['land'] = land['name']
  30. self.show('list')
  31. class batch_update_path(Load):
  32. @Web.auth
  33. @Web.setting
  34. def get(self):
  35. self.set(
  36. path = '/origin/batch'
  37. ,label = (u'产品名称', u'种植时间',u'采收时间',u'设备网关',u'地块',u'图像记录')
  38. ,update = ('name-input-required', 'zzdate-date-required', 'csdate-date-required','gateway_id-select-required','land_id-select-required','pic-pic-required')
  39. ,update_gateway_id = self.service('common').list('device_gateway', order='hardware_id asc')
  40. ,update_land_id = self.service('common').list('farm_work_land')
  41. )
  42. self.one('origin_batch')
  43. self.show('update')
  44. @Web.auth
  45. @Web.setting
  46. def post(self):
  47. self.update('origin_batch')
  48. @Web.auth
  49. @Web.setting
  50. def delete(self):
  51. self.drop('origin_batch')