work.py 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. @Web.auth
  11. def get(self):
  12. self.common(
  13. name = u'农事'
  14. ,path = '/work/work'
  15. ,width = '600'
  16. ,height = '600'
  17. ,add = False
  18. ,edit = False
  19. ,search = (('label-1','workdate-time-start','workdate-time-end','farm_id-select-','category_id-select-'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'劳作分类'))
  20. ,thead = (u'所属农场', u'劳作时间', u'劳作分类', u'劳作方式', u'劳作地块', u'劳作用量', u'更新时间')
  21. ,tbody = ('farm','workdate', 'category', 'method', 'land', 'amount', 'cdate')
  22. ,state = False
  23. )
  24. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  25. self.commonList('device_gateway')
  26. self.data['common']['search_category_id-select-'] = self.service('common').list('farm_work_category')
  27. self.commonList('farm_work')
  28. if self.data['list']:
  29. for key, value in enumerate(self.data['list']):
  30. farm = self.service('common').one('farm', id=value['farm_id'])
  31. #self.data['list'][key]['workdate'] = Demeter.date(value['workdate'])
  32. self.data['list'][key]['farm'] = farm['name']
  33. category = self.service('common').one('farm_work_category', id=value['category_id'])
  34. self.data['list'][key]['category'] = category['name']
  35. method = self.service('common').one('farm_work_method', id=value['method_id'])
  36. self.data['list'][key]['method'] = method['name']
  37. land = self.service('common').one('farm_work_land', id=value['land_id'])
  38. self.data['list'][key]['land'] = land['name']
  39. self.commonView('list')
  40. class work_update_path(Load):
  41. @Web.auth
  42. def get(self):
  43. self.common(
  44. path = '/work/work'
  45. ,label = (u'所属农场',u'劳作时间',u'劳作类别',u'劳作方式',u'劳作用量',u'劳作地块',u'图像记录')
  46. ,update = ('farm_id-select-required', 'workdate-date-required','category_id-select-required-method_id','method_id-select-required--category_id','amount-input-required','land_id-select-required','pic-pic-required')
  47. ,update_category_id = self.service('common').list('farm_work_category')
  48. ,update_method_id = self.service('common').list('farm_work_method')
  49. ,update_land_id = self.service('common').list('farm_work_land')
  50. ,update_farm_id = Demeter.config['setting']['farmList']
  51. )
  52. self.commonOne('farm_work')
  53. self.commonView('update')
  54. @Web.auth
  55. def post(self):
  56. self.commonUpdate('farm_work')
  57. @Web.auth
  58. def delete(self):
  59. self.commonDelete('farm_work')
  60. class method_path(Load):
  61. @Web.auth
  62. def get(self):
  63. self.common(
  64. name = u'劳作方法'
  65. ,path = '/work/method'
  66. ,width = '800'
  67. ,height = '300'
  68. ,add = False
  69. ,edit = False
  70. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','category_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'劳作分类',u'劳作内容'))
  71. ,thead = (u'所属农场',u'劳作内容', u'劳作分类', u'更新时间')
  72. ,tbody = ('farm','name', 'category', 'cdate')
  73. ,state = False
  74. )
  75. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  76. self.data['common']['search_category_id-select-'] = self.service('common').list('farm_work_category')
  77. self.commonList('farm_work_method')
  78. if self.data['list']:
  79. for key, value in enumerate(self.data['list']):
  80. farm = self.service('common').one('farm', id=value['farm_id'])
  81. self.data['list'][key]['farm'] = farm['name']
  82. category = self.service('common').one('farm_work_category', id=value['category_id'])
  83. self.data['list'][key]['category'] = category['name']
  84. self.commonView('list')
  85. class method_update_path(Load):
  86. @Web.auth
  87. def get(self):
  88. self.common(
  89. path = '/work/method'
  90. ,label = (u'所属农场', u'劳作内容',u'劳作分类')
  91. ,update = ('farm_id-select-required', 'name-input-required','category_id-select-required')
  92. ,update_category_id = self.service('common').list('farm_work_category')
  93. ,update_farm_id = Demeter.config['setting']['farmList']
  94. )
  95. self.commonOne('farm_work_method')
  96. self.commonView('update')
  97. @Web.auth
  98. def post(self):
  99. self.commonUpdate('farm_work_method')
  100. @Web.auth
  101. def delete(self):
  102. self.commonDelete('farm_work_method')
  103. class category_path(Load):
  104. @Web.auth
  105. def get(self):
  106. self.common(
  107. name = u'劳作分类'
  108. ,path = '/work/category'
  109. ,width = '600'
  110. ,height = '300'
  111. ,add = False
  112. ,edit = False
  113. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'分类名称'))
  114. ,thead = (u'所属农场',u'分类名称', u'更新时间')
  115. ,tbody = ('farm', 'name', 'cdate')
  116. ,state = False
  117. )
  118. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  119. self.commonList('farm_work_category')
  120. if self.data['list']:
  121. for key, value in enumerate(self.data['list']):
  122. farm = self.service('common').one('farm', id=value['farm_id'])
  123. self.data['list'][key]['farm'] = farm['name']
  124. self.commonView('list')
  125. class category_update_path(Load):
  126. @Web.auth
  127. def get(self):
  128. self.common(
  129. path = '/work/category'
  130. ,label = (u'所属农场', u'分类名称')
  131. ,update = ('farm_id-select-required', 'name-input-required')
  132. ,update_farm_id = Demeter.config['setting']['farmList']
  133. )
  134. self.commonOne('farm_work_category')
  135. self.commonView('update')
  136. @Web.auth
  137. def post(self):
  138. self.commonUpdate('farm_work_category')
  139. @Web.auth
  140. def delete(self):
  141. self.commonDelete('farm_work_category')
  142. class land_path(Load):
  143. @Web.auth
  144. def get(self):
  145. self.common(
  146. name = u'地块'
  147. ,path = '/work/land'
  148. ,width = '600'
  149. ,height = '300'
  150. ,add = False
  151. ,edit = False
  152. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'地块名称'))
  153. ,thead = (u'所属农场',u'地块名称', u'更新时间')
  154. ,tbody = ('farm', 'name', 'cdate')
  155. ,state = False
  156. )
  157. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  158. self.commonList('farm_work_land')
  159. if self.data['list']:
  160. for key, value in enumerate(self.data['list']):
  161. farm = self.service('common').one('farm', id=value['farm_id'])
  162. self.data['list'][key]['farm'] = farm['name']
  163. self.commonView('list')
  164. class land_update_path(Load):
  165. @Web.auth
  166. def get(self):
  167. self.common(
  168. path = '/work/land'
  169. ,label = (u'所属农场', u'地块名称')
  170. ,update = ('farm_id-select-required','name-input-required')
  171. ,update_farm_id = Demeter.config['setting']['farmList']
  172. )
  173. self.commonOne('farm_work_land')
  174. self.commonView('update')
  175. @Web.auth
  176. def post(self):
  177. self.commonUpdate('farm_work_land')
  178. @Web.auth
  179. def delete(self):
  180. self.commonDelete('farm_work_land')