work.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. @Web.setting
  12. def get(self):
  13. self.common(
  14. name = u'农事'
  15. ,path = '/work/work'
  16. ,width = '600'
  17. ,height = '600'
  18. ,search = (('label-1','workdate-time-start','workdate-time-end','farm_id-select-','category_id-select-'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'劳作方式'))
  19. ,thead = (u'所属农场', u'劳作时间', u'劳作方式', u'劳作地块', u'劳作用量', u'更新时间')
  20. ,tbody = ('farm','workdate', 'category', 'land', 'amount', 'content', 'cdate')
  21. ,state = True
  22. )
  23. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  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. @Web.auth
  37. @Web.setting
  38. def get(self):
  39. self.common(
  40. path = '/work/work'
  41. ,label = (u'所属农场',u'劳作时间',u'劳作方式',u'劳作用量',u'劳作地块',u'图像记录',u'劳作内容')
  42. ,update = ('farm_id-select-required', 'workdate-date-required','category_id-select-required','amount-input-required','land_id-select-required','pic-pic-required','content-text-required')
  43. ,update_category_id = self.service('common').list('farm_work_category')
  44. ,update_land_id = self.service('common').list('farm_work_land')
  45. ,update_farm_id = Demeter.config['setting']['farmList']
  46. )
  47. self.commonOne('farm_work')
  48. self.commonView('update')
  49. @Web.auth
  50. @Web.setting
  51. def post(self):
  52. self.commonUpdate('farm_work')
  53. @Web.auth
  54. @Web.setting
  55. def delete(self):
  56. self.commonDelete('farm_work')
  57. class category_path(Load):
  58. @Web.auth
  59. @Web.setting
  60. def get(self):
  61. self.common(
  62. name = u'劳作方式'
  63. ,path = '/work/category'
  64. ,width = '600'
  65. ,height = '250'
  66. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'方式名称'))
  67. ,thead = (u'所属农场',u'方式名称', u'更新时间')
  68. ,tbody = ('farm', 'name', 'cdate')
  69. ,state = True
  70. )
  71. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  72. self.commonList('farm_work_category')
  73. if self.data['list']:
  74. for key, value in enumerate(self.data['list']):
  75. farm = self.service('common').one('farm', id=value['farm_id'])
  76. self.data['list'][key]['farm'] = farm['name']
  77. self.commonView('list')
  78. class category_update_path(Load):
  79. @Web.auth
  80. @Web.setting
  81. def get(self):
  82. self.common(
  83. path = '/work/category'
  84. ,label = (u'所属农场', u'方式名称')
  85. ,update = ('farm_id-select-required', 'name-input-required')
  86. ,update_farm_id = Demeter.config['setting']['farmList']
  87. )
  88. self.commonOne('farm_work_category')
  89. self.commonView('update')
  90. @Web.auth
  91. @Web.setting
  92. def post(self):
  93. self.commonUpdate('farm_work_category')
  94. @Web.auth
  95. @Web.setting
  96. def delete(self):
  97. self.commonDelete('farm_work_category')
  98. class land_path(Load):
  99. @Web.auth
  100. @Web.setting
  101. def get(self):
  102. self.common(
  103. name = u'地块'
  104. ,path = '/work/land'
  105. ,width = '600'
  106. ,height = '250'
  107. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'地块名称'))
  108. ,thead = (u'所属农场',u'地块名称', u'更新时间')
  109. ,tbody = ('farm', 'name', 'cdate')
  110. ,state = True
  111. )
  112. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  113. self.commonList('farm_work_land')
  114. if self.data['list']:
  115. for key, value in enumerate(self.data['list']):
  116. farm = self.service('common').one('farm', id=value['farm_id'])
  117. self.data['list'][key]['farm'] = farm['name']
  118. self.commonView('list')
  119. class land_update_path(Load):
  120. @Web.auth
  121. @Web.setting
  122. def get(self):
  123. self.common(
  124. path = '/work/land'
  125. ,label = (u'所属农场', u'地块名称')
  126. ,update = ('farm_id-select-required','name-input-required')
  127. ,update_farm_id = Demeter.config['setting']['farmList']
  128. )
  129. self.commonOne('farm_work_land')
  130. self.commonView('update')
  131. @Web.auth
  132. @Web.setting
  133. def post(self):
  134. self.commonUpdate('farm_work_land')
  135. @Web.auth
  136. @Web.setting
  137. def delete(self):
  138. self.commonDelete('farm_work_land')