origin.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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-','load_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.commonList('origin_batch')
  24. if self.data['list']:
  25. for key, value in enumerate(self.data['list']):
  26. farm = self.service('common').one('farm', id=value['farm_id'])
  27. self.data['list'][key]['farm'] = farm['name']
  28. device = self.service('common').one('device_info', id=value['device_id'])
  29. self.data['list'][key]['device'] = device['name']
  30. land = self.service('common').one('farm_work_land', id=value['land_id'])
  31. self.data['list'][key]['land'] = land['name']
  32. self.commonView('list')
  33. class batch_update_path(Load):
  34. @tornado.web.authenticated
  35. def get(self):
  36. self.common(
  37. path = '/origin/batch'
  38. ,label = (u'所属农场',u'产品名称', u'种植时间',u'采收时间',u'设备',u'地块',u'图像记录')
  39. ,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')
  40. ,update_device_id = self.service('common').list('device_info')
  41. ,update_land_id = self.service('common').list('farm_work_land')
  42. ,update_farm_id = Demeter.config['setting']['farmList']
  43. )
  44. self.commonOne('origin_batch')
  45. self.commonView('update')
  46. @tornado.web.authenticated
  47. def post(self):
  48. self.commonUpdate('origin_batch')
  49. @tornado.web.authenticated
  50. def delete(self):
  51. self.commonDelete('origin_batch')