work.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter web page
  5. name:work.py 农事相关页面
  6. author:rabin
  7. """
  8. from __load__ import *
  9. class work_path(Load):
  10. @tornado.web.authenticated
  11. def get(self):
  12. self.common(
  13. name = u'农事'
  14. ,path = '/work/work'
  15. ,width = '600'
  16. ,height = '600'
  17. ,search = (('label-1','workdate-time-start','workdate-time-end','farm_id-select-','category_id-select-'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'劳作方式'))
  18. ,thead = (u'所属农场', u'劳作时间', u'劳作方式', u'劳作地块', u'劳作用量', u'更新时间')
  19. ,tbody = ('farm','workdate', 'category', 'land', 'amount', 'content', 'cdate')
  20. ,state = True
  21. )
  22. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  23. self.commonList('device_gateway')
  24. self.data['common']['search_category_id-select-'] = self.service('common').list('farm_work_category')
  25. self.commonList('farm_work')
  26. if self.data['list']:
  27. for key, value in enumerate(self.data['list']):
  28. farm = self.service('common').one('farm', id=value['farm_id'])
  29. self.data['list'][key]['farm'] = farm['name']
  30. category = self.service('common').one('farm_work_category', id=value['category_id'])
  31. self.data['list'][key]['category'] = category['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 work_update_path(Load):
  36. @tornado.web.authenticated
  37. def get(self):
  38. self.common(
  39. path = '/work/work'
  40. ,label = (u'所属农场',u'劳作时间',u'劳作方式',u'劳作用量',u'劳作地块',u'图像记录',u'劳作内容')
  41. ,update = ('farm_id-select-required', 'workdate-date-required','category_id-select-required-method_id','amount-input-required','land_id-select-required','pic-pic-required','content-text-required')
  42. ,update_category_id = self.service('common').list('farm_work_category')
  43. ,update_land_id = self.service('common').list('farm_work_land')
  44. ,update_farm_id = Demeter.config['setting']['farmList']
  45. )
  46. self.commonOne('farm_work')
  47. self.commonView('update')
  48. @tornado.web.authenticated
  49. def post(self):
  50. self.commonUpdate('farm_work')
  51. @tornado.web.authenticated
  52. def delete(self):
  53. self.commonDelete('farm_work')
  54. class category_path(Load):
  55. @tornado.web.authenticated
  56. def get(self):
  57. self.common(
  58. name = u'劳作方式'
  59. ,path = '/work/category'
  60. ,width = '600'
  61. ,height = '200'
  62. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'方式名称'))
  63. ,thead = (u'所属农场',u'方式名称', u'更新时间')
  64. ,tbody = ('farm', 'name', 'cdate')
  65. ,state = True
  66. )
  67. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  68. self.commonList('farm_work_category')
  69. if self.data['list']:
  70. for key, value in enumerate(self.data['list']):
  71. farm = self.service('common').one('farm', id=value['farm_id'])
  72. self.data['list'][key]['farm'] = farm['name']
  73. self.commonView('list')
  74. class category_update_path(Load):
  75. @tornado.web.authenticated
  76. def get(self):
  77. self.common(
  78. path = '/work/category'
  79. ,label = (u'所属农场', u'方式名称')
  80. ,update = ('farm_id-select-required', 'name-input-required')
  81. ,update_farm_id = Demeter.config['setting']['farmList']
  82. )
  83. self.commonOne('farm_work_category')
  84. self.commonView('update')
  85. @tornado.web.authenticated
  86. def post(self):
  87. self.commonUpdate('farm_work_category')
  88. @tornado.web.authenticated
  89. def delete(self):
  90. self.commonDelete('farm_work_category')
  91. class land_path(Load):
  92. @tornado.web.authenticated
  93. def get(self):
  94. self.common(
  95. name = u'地块'
  96. ,path = '/work/land'
  97. ,width = '600'
  98. ,height = '200'
  99. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'地块名称'))
  100. ,thead = (u'所属农场',u'地块名称', u'更新时间')
  101. ,tbody = ('farm', 'name', 'cdate')
  102. ,state = True
  103. )
  104. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  105. self.commonList('farm_work_land')
  106. if self.data['list']:
  107. for key, value in enumerate(self.data['list']):
  108. farm = self.service('common').one('farm', id=value['farm_id'])
  109. self.data['list'][key]['farm'] = farm['name']
  110. self.commonView('list')
  111. class land_update_path(Load):
  112. @tornado.web.authenticated
  113. def get(self):
  114. self.common(
  115. path = '/work/land'
  116. ,label = (u'所属农场', u'地块名称')
  117. ,update = ('farm_id-select-required','name-input-required')
  118. ,update_farm_id = Demeter.config['setting']['farmList']
  119. )
  120. self.commonOne('farm_work_land')
  121. self.commonView('update')
  122. @tornado.web.authenticated
  123. def post(self):
  124. self.commonUpdate('farm_work_land')
  125. @tornado.web.authenticated
  126. def delete(self):
  127. self.commonDelete('farm_work_land')