origin.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. ,search = (('farm_id-select-','land_id-select-'), (u'选择农场',u'地块'))
  19. ,thead = (u'所属农场', u'产品名称', u'种植时间', u'采收时间', u'设备网关', u'地块')
  20. ,tbody = ('farm','name', 'zzdate', 'csdate', 'device', 'land')
  21. ,state = True
  22. )
  23. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  24. self.data['common']['search_land_id-select-'] = self.service('common').list('farm_work_land')
  25. farm_list = {}
  26. for value in self.data['common']['search_farm_id-select-']:
  27. farm_list[value['id']] = value
  28. farm_work_land = {}
  29. for value in self.data['common']['search_land_id-select-']:
  30. farm_work_land[value['id']] = value
  31. gateway = {}
  32. gateway_list = self.service('common').list('device_gateway')
  33. for value in gateway_list:
  34. gateway[value['id']] = value
  35. self.commonList('origin_batch')
  36. if self.data['list']:
  37. for key, value in enumerate(self.data['list']):
  38. farm = farm_list[value['farm_id']]
  39. self.data['list'][key]['farm'] = farm['name']
  40. device = gateway[value['gateway_id']]
  41. self.data['list'][key]['device'] = device['name']
  42. land = farm_work_land[value['land_id']]
  43. if land:
  44. self.data['list'][key]['land'] = land['name']
  45. self.commonView('list')
  46. class batch_update_path(Load):
  47. @Web.auth
  48. @Web.setting
  49. def get(self):
  50. self.common(
  51. path = '/origin/batch'
  52. ,label = (u'所属农场',u'产品名称', u'种植时间',u'采收时间',u'设备网关',u'地块',u'图像记录')
  53. ,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')
  54. ,update_gateway_id = self.service('common').list('device_gateway')
  55. ,update_land_id = self.service('common').list('farm_work_land')
  56. ,update_farm_id = Demeter.config['setting']['farmList']
  57. )
  58. self.commonOne('origin_batch')
  59. self.commonView('update')
  60. @Web.auth
  61. @Web.setting
  62. def post(self):
  63. self.commonUpdate('origin_batch')
  64. @Web.auth
  65. @Web.setting
  66. def delete(self):
  67. self.commonDelete('origin_batch')