#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
    demeter load
    author:rabin
"""
from demeter.web import *

class Load(Base):
	KEYS = ('user', 'farm')

	def setting(self):
		self.info()

	def info(self):
		ajax = self.input('ajax')
		if ajax:
			self.data['ajax'] = True
		else:
			self.data['ajax'] = False
		self.data['auth'] = True
		if 'user' in self.data['setting'] and self.data['setting']['user'] > 0:
			self.data['setting']['userInfo'] = self.service('common').one('farm_user', id=self.data['setting']['user'])

		self.data['setting']['web'] = self.service('common').one('web_set', id=1)
		self.data['setting']['menu'] = self.service('common').list('web_menu')

		cur = 'main'
		if '/' in self.request.uri:
			temp = self.request.uri.split('?')
			temp = temp[0].split('/')
			slen = len(temp)
			if slen > 1 and temp[1]:
				cur = temp[1]
		self.data['setting']['cur'] = cur