work.py 4.9 KB

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