#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
    demeter web page
    name:content.py 内容相关页面
    author:rabin
"""
from __load__ import *

class set_path(Load):
	@Web.auth
	def get(self):
		self.common(
			path = '/web/set'
			,label = (u'标题',u'关键词',u'描述',u'icp备案号',u'联系电话',u'忘记密码联系电话',u'手机端管理',u'购买方式')
			,update = ('name-input-required','keywords-input-required','description-input-required','icp-input-required','tel-input-required','passtel-input-required',u'mobile-pic--',u'buy-pic--')
		)
		self.commonOne('web_set', id=1)
		self.commonView('set')
	@Web.auth
	def post(self):
		self.commonUpdate('web_set',id=1)

class article_path(Load):
	@Web.auth
	def get(self):
		self.common(
			name = u'文章'
			,path = '/web/article'
			,width = '800'
			,height = '700'
			,search = (('label-1','cdate-time-start','cdate-time-end','category_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'文章分类',u'文章标题'))
			,thead = (u'文章标题', u'文章分类', u'更新时间')
			,tbody = ('name', 'category', 'cdate')
			,state = True
		)
		self.data['common']['search_category_id-select-'] = self.service('common').list('web_article_category')
		self.commonList('web_article')
		if self.data['list']:
			for key, value in enumerate(self.data['list']):
				category = self.service('common').one('web_article_category', id=value['category_id'])
				self.data['list'][key]['category'] = category['name']
		self.commonView('list')

class article_update_path(Load):
	@Web.auth
	def get(self):
		self.common(
			path = '/web/article'
			,label = (u'文章标题',u'文章分类',u'文章链接',u'文章图片',u'文章内容')
			,update = ('name-input-required','category_id-select-required','link-input-','pic-pic-',u'content-editor--请输入内容')
			,update_category_id = self.service('common').list('web_article_category')
		)
		self.commonOne('web_article')
		self.commonView('update')
	@Web.auth
	def post(self):
		self.commonUpdate('web_article')
	@Web.auth
	def delete(self):
		self.commonDelete('web_article')


class category_path(Load):
	@Web.auth
	def get(self):
		self.common(
			name = u'分类'
			,path = '/web/category'
			,width = '600'
			,height = '300'
			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'分类名称'))
			,thead = (u'分类名称', u'更新时间')
			,tbody = ('name', 'cdate')
			,state = True
		)
		self.commonList('web_article_category')
		self.commonView('list')

class category_update_path(Load):
	@Web.auth
	def get(self):
		self.common(
			path = '/web/category'
			,label = (u'分类名称',)
			,update = ('name-input-required',)
		)
		self.commonOne('web_article_category')
		self.commonView('update')
	@Web.auth
	def post(self):
		self.commonUpdate('web_article_category')
	@Web.auth
	def delete(self):
		self.commonDelete('web_article_category')

class help_path(Load):
	@Web.auth
	def get(self):
		self.common(
			name = u'帮助'
			,path = '/web/help'
			,width = '800'
			,height = '600'
			,search = (('label-1','cdate-time-start','cdate-time-end','category_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'帮助分类',u'帮助标题'))
			,thead = (u'帮助标题', u'帮助分类', u'更新时间')
			,tbody = ('name', 'category', 'cdate')
			,state = True
		)
		self.data['common']['search_category_id-select-'] = self.service('common').list('web_help_category')
		self.commonList('web_help')
		if self.data['list']:
			for key, value in enumerate(self.data['list']):
				category = self.service('common').one('web_help_category', id=value['category_id'])
				self.data['list'][key]['category'] = category['name']
		self.commonView('list')

class help_update_path(Load):
	@Web.auth
	def get(self):
		self.common(
			path = '/web/help'
			,label = (u'帮助标题',u'帮助分类',u'帮助内容')
			,update = ('name-input-required','category_id-select-required',u'content-editor--请输入内容')
			,update_category_id = self.service('common').list('web_help_category')
		)
		self.commonOne('web_help')
		self.commonView('update')
	@Web.auth
	def post(self):
		self.commonUpdate('web_help')
	@Web.auth
	def delete(self):
		self.commonDelete('web_help')

class help_category_path(Load):
	@Web.auth
	def get(self):
		self.common(
			name = u'分类'
			,path = '/web/help_category'
			,width = '600'
			,height = '300'
			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'分类名称'))
			,thead = (u'帮助分类名称', u'更新时间')
			,tbody = ('name', 'cdate')
			,state = True
		)
		self.commonList('web_help_category')
		self.commonView('list')

class help_category_update_path(Load):
	@Web.auth
	def get(self):
		self.common(
			path = '/web/help_category'
			,label = (u'帮助分类名称',)
			,update = ('name-input-required',)
		)
		self.commonOne('web_help_category')
		self.commonView('update')
	@Web.auth
	def post(self):
		self.commonUpdate('web_help_category')
	@Web.auth
	def delete(self):
		self.commonDelete('web_help_category')

class menu_path(Load):
	@Web.auth
	def get(self):
		self.common(
			name = u'菜单'
			,path = '/web/menu'
			,width = '600'
			,height = '300'
			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'菜单名称'))
			,thead = (u'菜单名称',u'菜单链接', u'更新时间')
			,tbody = ('name', 'link', 'cdate')
			,state = True
		)
		self.commonList('web_menu')
		self.commonView('list')

class menu_update_path(Load):
	@Web.auth
	def get(self):
		self.common(
			path = '/web/menu'
			,label = (u'菜单名称',u'菜单链接')
			,update = ('name-input-required','link-input-required')
		)
		self.commonOne('web_menu')
		self.commonView('update')
	@Web.auth
	def post(self):
		self.commonUpdate('web_menu')
	@Web.auth
	def delete(self):
		self.commonDelete('web_menu')