123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- # -*- coding: utf-8 -*-
- """
- demeter web page
- name:farm.py 农场相关页面
- author:rabin
- """
- from .__load__ import *
- farm = {
- 'id' : int(Demeter.config['setting']['farm'])
- }
- class info_path(Load):
- @Web.auth
- @Web.setting
- def get(self):
- id = str(farm['id'])
- param = '?farm=' + id
- self.set(
- path = '/farm/info' + param
- ,label = (u'农场名称',u'农场图片',u'农场位置',u'联系电话',u'联系地址',u'农场主姓名',u'农场主照片',u'欢迎语',u'农场介绍')
- ,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-请输入农场介绍')
- )
- self.one('farm', id=farm['id'])
- self.show('set')
- @Web.auth
- @Web.setting
- def post(self):
- self.update('farm', id=farm['id'])
- class product_path(Load):
- @Web.auth
- @Web.setting
- def get(self):
- self.set(
- name = u'产品'
- ,path = '/farm/product'
- ,width = '600'
- ,height = '500'
- ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'产品名称'))
- ,thead = (u'产品名称', u'图片', u'种植面积', u'平均亩产', u'更新时间')
- ,tbody = ('name', 'pic', 'area', 'yields', 'cdate')
- ,state = True
- )
- self.list('farm_product')
- if self.data['list']:
- for key, value in enumerate(self.data['list']):
- if self.data['list'][key]['pic']:
- self.data['list'][key]['pic'] = '<img src="'+self.data['list'][key]['pic']+'" width="200"/>'
- else:
- self.data['list'][key]['pic'] = '暂无图片'
- self.show('list')
- class product_update_path(Load):
- @Web.auth
- @Web.setting
- def get(self):
- self.set(
- path = '/farm/product'
- ,label = (u'产品名称', u'种植面积', u'平均亩产', u'特点', u'使用须知', u'图片')
- ,update = ('name-input-required','area-input-required','yields-input-required','charact-input-required','notice-input-required','pic-pic-required')
- )
- self.one('farm_product')
- self.show('update')
- @Web.auth
- @Web.setting
- def post(self):
- self.data['update']['farm_id'] = farm['id']
- self.update('farm_product')
- @Web.auth
- @Web.setting
- def delete(self):
- self.drop('farm_product')
- class user_path(Load):
- @Web.auth
- @Web.setting
- def get(self):
- self.set(
- name = u'用户'
- ,path = '/farm/user'
- ,width = '600'
- ,height = '400'
- ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'用户名称'))
- ,thead = (u'UID', u'用户名称', u'用户手机号', u'更新时间')
- ,tbody = ('id', 'username', 'mobile', 'cdate')
- ,state = True
- )
- self.list('farm_user')
- self.show('list')
- class user_update_path(Load):
- @Web.auth
- @Web.setting
- def get(self):
- self.set(
- path = '/farm/user'
- ,label = (u'账号姓名',u'手机号',u'安全码')
- ,update = ('username-input-required','mobile-input-phone','password-password-')
- )
- self.one('farm_user')
- self.show('update')
- @Web.auth
- @Web.setting
- def post(self):
- self.data['update']['farm_id'] = farm['id']
- self.update('farm_user', '手机号已经被注册', mobile=self.data['update']['mobile'])
- @Web.auth
- @Web.setting
- def delete(self):
- self.drop('farm_user')
|