work.py 4.4 KB

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