origin.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. @tornado.web.authenticated
  11. def get(self):
  12. self.common(
  13. name = u'溯源批次'
  14. ,path = '/origin/batch'
  15. ,width = '600'
  16. ,height = '600'
  17. ,search = (('farm_id-select-','land_id-select-'), (u'选择农场',u'地块'))
  18. ,thead = (u'所属农场', u'产品名称', u'种植时间', u'采收时间', u'设备', u'地块')
  19. ,tbody = ('farm','name', 'zzdate', 'csdate', 'device', 'land')
  20. ,state = True
  21. )
  22. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  23. self.data['common']['search_land_id-select-'] = self.service('common').list('farm_work_land')
  24. self.commonList('origin_batch')
  25. if self.data['list']:
  26. for key, value in enumerate(self.data['list']):
  27. farm = self.service('common').one('farm', id=value['farm_id'])
  28. self.data['list'][key]['farm'] = farm['name']
  29. device = self.service('common').one('device_info', id=value['device_id'])
  30. self.data['list'][key]['device'] = device['name']
  31. land = self.service('common').one('farm_work_land', id=value['land_id'])
  32. self.data['list'][key]['land'] = land['name']
  33. self.commonView('list')
  34. class batch_update_path(Load):
  35. @tornado.web.authenticated
  36. def get(self):
  37. self.common(
  38. path = '/origin/batch'
  39. ,label = (u'所属农场',u'产品名称', u'种植时间',u'采收时间',u'设备',u'地块',u'图像记录')
  40. ,update = ('farm_id-select-required','name-input-required', 'zzdate-date-required', 'csdate-date-required','device_id-select-required','land_id-select-required','pic-pic-required')
  41. ,update_device_id = self.service('common').list('device_info')
  42. ,update_land_id = self.service('common').list('farm_work_land')
  43. ,update_farm_id = Demeter.config['setting']['farmList']
  44. )
  45. self.commonOne('origin_batch')
  46. self.commonView('update')
  47. @tornado.web.authenticated
  48. def post(self):
  49. self.commonUpdate('origin_batch')
  50. @tornado.web.authenticated
  51. def delete(self):
  52. self.commonDelete('origin_batch')