farm.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter web page
  5. name:farm.py 农场相关页面
  6. author:rabin
  7. """
  8. from __load__ import *
  9. class farm_path(Load):
  10. @Web.auth
  11. def get(self):
  12. self.common(
  13. name = u'农场' #中文名
  14. ,path = '/farm/farm' #路径
  15. ,width = '600' # 新增页面的宽度
  16. ,height = '600' # 新增页面的高度
  17. ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'农场名称')) #搜索
  18. ,thead = (u'农场名称', u'功能列表') #表头
  19. ,tbody = ('name', 'func') #表内容
  20. ,state = False #启用回收站
  21. )
  22. menu = (
  23. {'name':'基础资料', 'url':'/farm/info'}
  24. ,{'name':'网关管理', 'url':'/device/gateway'}
  25. ,{'name':'设备管理', 'url':'/device/info'}
  26. ,{'name':'农事管理', 'url':'/work/work'}
  27. ,{'name':'农事分类', 'url':'/work/category'}
  28. ,{'name':'地块管理', 'url':'/work/land'}
  29. ,{'name':'批次管理', 'url':'/origin/batch'}
  30. ,{'name':'用户管理', 'url':'/farm/user'}
  31. ,{'name':'打印机管理', 'url':'/device/printer'}
  32. ,{'name':'消息提醒', 'url':'/msg/msg'}
  33. )
  34. self.commonList('farm')
  35. if self.data['list']:
  36. for key, value in enumerate(self.data['list']):
  37. id = str(value['id'])
  38. param = '?farm=' + id + '&search_farm_id-select-=' + id
  39. self.data['list'][key]['func'] = ''
  40. for i in menu:
  41. self.data['list'][key]['func'] = self.data['list'][key]['func'] + '<a href="'+i['url']+''+param+'">'+i['name']+'</a>&nbsp;&nbsp;&nbsp;&nbsp;'
  42. self.commonView('list')
  43. class farm_update_path(Load):
  44. @Web.auth
  45. def get(self):
  46. self.common(
  47. path = '/farm/farm'
  48. ,label = (u'农场名称',u'农场地址',u'联系人',u'联系电话',u'农场图片')
  49. ,update = ('name-input-required','address-input-required','master_name-input-required','tel-input-required','pic-pic-required')
  50. )
  51. self.commonOne('farm')
  52. self.commonView('update')
  53. @Web.auth
  54. def post(self):
  55. id = self.commonUpdate('farm')
  56. Demeter.config['setting']['farmList'] = self.service('common').list('farm')
  57. class info_path(Load):
  58. @Web.auth
  59. def get(self):
  60. id = str(Demeter.config['setting']['farm'])
  61. param = '?farm=' + id + '&search_farm_id-select-=' + id
  62. self.common(
  63. path = '/farm/info' + param
  64. ,label = (u'农场名称',u'农场图片',u'联系电话',u'农场地址',u'联系人',u'农场介绍')
  65. ,update = ('name-input-required','pic-pic-required-1000px*300~450px','tel-input-required','address-input-required','master_name-input-required',u'info-text-required-请输入农场介绍')
  66. )
  67. self.commonOne('farm', id=Demeter.config['setting']['farm'])
  68. self.commonView('set')
  69. @Web.auth
  70. def post(self):
  71. self.commonUpdate('farm', id=Demeter.config['setting']['farm'])
  72. class user_path(Load):
  73. @Web.auth
  74. def get(self):
  75. self.common(
  76. name = u'用户'
  77. ,path = '/farm/user'
  78. ,width = '600'
  79. ,height = '400'
  80. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间','选择农场',u'用户名称'))
  81. ,thead = (u'所属农场', u'用户名称', u'用户手机号', u'更新时间')
  82. ,tbody = ('farm','username', 'mobile', 'cdate')
  83. ,state = True
  84. )
  85. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  86. self.commonList('farm_user')
  87. if self.data['list']:
  88. for key, value in enumerate(self.data['list']):
  89. farm = self.service('common').one('farm', id=value['farm_id'])
  90. self.data['list'][key]['farm'] = farm['name']
  91. self.commonView('list')
  92. class user_update_path(Load):
  93. @Web.auth
  94. def get(self):
  95. self.common(
  96. path = '/farm/user'
  97. ,label = (u'所属农场',u'账号姓名',u'手机号',u'安全码')
  98. ,update = ('farm_id-select-required','username-input-required','mobile-input-phone','password-password-')
  99. ,update_farm_id = Demeter.config['setting']['farmList']
  100. )
  101. self.commonOne('farm_user')
  102. self.commonView('update')
  103. @Web.auth
  104. def post(self):
  105. self.commonUpdate('farm_user', '手机号已经被注册', mobile=self.data['update']['mobile'])
  106. @Web.auth
  107. def delete(self):
  108. self.commonDelete('farm_user')