farm.py 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. @tornado.web.authenticated
  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':'/device/gateway'}
  24. ,{'name':'设备管理', 'url':'/device/info'}
  25. ,{'name':'农事管理', 'url':'/work/work'}
  26. ,{'name':'农事分类', 'url':'/work/category'}
  27. ,{'name':'地块管理', 'url':'/work/land'}
  28. ,{'name':'批次管理', 'url':'/origin/batch'}
  29. ,{'name':'用户管理', 'url':'/farm/user'}
  30. ,{'name':'打印机管理', 'url':'/device/printer'}
  31. ,{'name':'消息提醒', 'url':'/msg/msg'}
  32. )
  33. self.commonList('farm')
  34. if self.data['list']:
  35. for key, value in enumerate(self.data['list']):
  36. id = str(value['id'])
  37. param = '?farm=' + id + '&search_farm_id-select-=' + id
  38. self.data['list'][key]['func'] = ''
  39. for i in menu:
  40. self.data['list'][key]['func'] = self.data['list'][key]['func'] + '<a href="'+i['url']+''+param+'">'+i['name']+'</a>&nbsp;&nbsp;&nbsp;&nbsp;'
  41. self.commonView('list')
  42. class farm_update_path(Load):
  43. @tornado.web.authenticated
  44. def get(self):
  45. self.common(
  46. path = '/farm/farm'
  47. ,label = (u'农场名称',u'农场地址',u'联系人',u'联系电话',u'农场图片')
  48. ,update = ('name-input-required','address-input-required','master_name-input-required','tel-input-required','pic-pic-required')
  49. )
  50. self.commonOne('farm')
  51. self.commonView('update')
  52. @tornado.web.authenticated
  53. def post(self):
  54. id = self.commonUpdate('farm')
  55. Demeter.config['setting']['farmList'] = self.service('common').list('farm')
  56. class user_path(Load):
  57. @tornado.web.authenticated
  58. def get(self):
  59. self.common(
  60. name = u'用户'
  61. ,path = '/farm/user'
  62. ,width = '600'
  63. ,height = '400'
  64. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间','选择农场',u'用户名称'))
  65. ,thead = (u'所属农场', u'用户名称', u'用户手机号', u'更新时间')
  66. ,tbody = ('farm','username', 'mobile', 'cdate')
  67. ,state = True
  68. )
  69. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  70. self.commonList('farm_user')
  71. if self.data['list']:
  72. for key, value in enumerate(self.data['list']):
  73. farm = self.service('common').one('farm', id=value['farm_id'])
  74. self.data['list'][key]['farm'] = farm['name']
  75. self.commonView('list')
  76. class user_update_path(Load):
  77. @tornado.web.authenticated
  78. def get(self):
  79. self.common(
  80. path = '/farm/user'
  81. ,label = (u'所属农场',u'账号姓名',u'手机号',u'安全码')
  82. ,update = ('farm_id-select-required','username-input-required','mobile-input-phone','password-password-')
  83. ,update_farm_id = Demeter.config['setting']['farmList']
  84. )
  85. self.commonOne('farm_user')
  86. self.commonView('update')
  87. @tornado.web.authenticated
  88. def post(self):
  89. self.commonUpdate('farm_user', '手机号已经被注册', mobile=self.data['update']['mobile'])
  90. @tornado.web.authenticated
  91. def delete(self):
  92. self.commonDelete('farm_user')