work.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'方式名称'))
  67. ,thead = (u'方式名称', u'更新时间')
  68. ,tbody = ('name', 'cdate')
  69. ,state = True
  70. )
  71. self.commonList('farm_work_category')
  72. self.commonView('list')
  73. class category_update_path(Load):
  74. @Web.auth
  75. @Web.setting
  76. def get(self):
  77. self.common(
  78. path = '/work/category'
  79. ,label = (u'方式名称',)
  80. ,update = ('name-input-required',)
  81. )
  82. self.commonOne('farm_work_category')
  83. self.commonView('update')
  84. @Web.auth
  85. @Web.setting
  86. def post(self):
  87. self.commonUpdate('farm_work_category')
  88. @Web.auth
  89. @Web.setting
  90. def delete(self):
  91. self.commonDelete('farm_work_category')
  92. class land_path(Load):
  93. @Web.auth
  94. @Web.setting
  95. def get(self):
  96. self.common(
  97. name = u'地块'
  98. ,path = '/work/land'
  99. ,width = '600'
  100. ,height = '250'
  101. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'地块名称'))
  102. ,thead = (u'所属农场',u'地块名称', u'更新时间')
  103. ,tbody = ('farm', 'name', 'cdate')
  104. ,state = True
  105. )
  106. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  107. self.commonList('farm_work_land')
  108. if self.data['list']:
  109. for key, value in enumerate(self.data['list']):
  110. farm = self.service('common').one('farm', id=value['farm_id'])
  111. self.data['list'][key]['farm'] = farm['name']
  112. self.commonView('list')
  113. class land_update_path(Load):
  114. @Web.auth
  115. @Web.setting
  116. def get(self):
  117. self.common(
  118. path = '/work/land'
  119. ,label = (u'所属农场', u'地块名称')
  120. ,update = ('farm_id-select-required','name-input-required')
  121. ,update_farm_id = Demeter.config['setting']['farmList']
  122. )
  123. self.commonOne('farm_work_land')
  124. self.commonView('update')
  125. @Web.auth
  126. @Web.setting
  127. def post(self):
  128. self.commonUpdate('farm_work_land')
  129. @Web.auth
  130. @Web.setting
  131. def delete(self):
  132. self.commonDelete('farm_work_land')