farm.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # -*- coding: utf-8 -*-
  2. """
  3. demeter web page
  4. name:farm.py 农场相关页面
  5. author:rabin
  6. """
  7. from .__load__ import *
  8. farm = {
  9. 'id' : int(Demeter.config['setting']['farm'])
  10. }
  11. class info_path(Load):
  12. @Web.auth
  13. @Web.setting
  14. def get(self):
  15. id = str(farm['id'])
  16. param = '?farm=' + id
  17. self.set(
  18. path = '/farm/info' + param
  19. ,label = (u'农场名称',u'农场图片',u'农场位置',u'联系电话',u'联系地址',u'农场主姓名',u'农场主照片',u'欢迎语',u'农场介绍')
  20. ,update = ('name-input-required','pic-pic-required-1000px*300~450px','location-input-required','tel-input-required','address-input-required','master_name-input-required','master_pic-pic-required-300px*450px','welcome-input-',u'info-text-required-请输入农场介绍')
  21. )
  22. self.one('farm', id=farm['id'])
  23. self.show('set')
  24. @Web.auth
  25. @Web.setting
  26. def post(self):
  27. self.update('farm', id=farm['id'])
  28. class product_path(Load):
  29. @Web.auth
  30. @Web.setting
  31. def get(self):
  32. self.set(
  33. name = u'产品'
  34. ,path = '/farm/product'
  35. ,width = '600'
  36. ,height = '500'
  37. ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'产品名称'))
  38. ,thead = (u'产品名称', u'图片', u'种植面积', u'平均亩产', u'更新时间')
  39. ,tbody = ('name', 'pic', 'area', 'yields', 'cdate')
  40. ,state = True
  41. )
  42. self.list('farm_product')
  43. if self.data['list']:
  44. for key, value in enumerate(self.data['list']):
  45. if self.data['list'][key]['pic']:
  46. self.data['list'][key]['pic'] = '<img src="'+self.data['list'][key]['pic']+'" width="200"/>'
  47. else:
  48. self.data['list'][key]['pic'] = '暂无图片'
  49. self.show('list')
  50. class product_update_path(Load):
  51. @Web.auth
  52. @Web.setting
  53. def get(self):
  54. self.set(
  55. path = '/farm/product'
  56. ,label = (u'产品名称', u'种植面积', u'平均亩产', u'特点', u'使用须知', u'图片')
  57. ,update = ('name-input-required','area-input-required','yields-input-required','charact-input-required','notice-input-required','pic-pic-required')
  58. )
  59. self.one('farm_product')
  60. self.show('update')
  61. @Web.auth
  62. @Web.setting
  63. def post(self):
  64. self.data['update']['farm_id'] = farm['id']
  65. self.update('farm_product')
  66. @Web.auth
  67. @Web.setting
  68. def delete(self):
  69. self.drop('farm_product')
  70. class user_path(Load):
  71. @Web.auth
  72. @Web.setting
  73. def get(self):
  74. self.set(
  75. name = u'用户'
  76. ,path = '/farm/user'
  77. ,width = '600'
  78. ,height = '400'
  79. ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'用户名称'))
  80. ,thead = (u'UID', u'用户名称', u'用户手机号', u'更新时间')
  81. ,tbody = ('id', 'username', 'mobile', 'cdate')
  82. ,state = True
  83. )
  84. self.list('farm_user')
  85. self.show('list')
  86. class user_update_path(Load):
  87. @Web.auth
  88. @Web.setting
  89. def get(self):
  90. self.set(
  91. path = '/farm/user'
  92. ,label = (u'账号姓名',u'手机号',u'安全码')
  93. ,update = ('username-input-required','mobile-input-phone','password-password-')
  94. )
  95. self.one('farm_user')
  96. self.show('update')
  97. @Web.auth
  98. @Web.setting
  99. def post(self):
  100. self.data['update']['farm_id'] = farm['id']
  101. self.update('farm_user', '手机号已经被注册', mobile=self.data['update']['mobile'])
  102. @Web.auth
  103. @Web.setting
  104. def delete(self):
  105. self.drop('farm_user')