# Path: toughwlan/manage/base.py
# ADMIN_MENUS = (MenuSys, MenuRes, MenuUser) = (u"系统管理", u"资源管理", u"用户管理")
# MENU_ICONS = {
#     u"系统管理": "fa fa-cog",
#     u"资源管理": "fa fa-desktop",
#     u"用户管理": "fa fa-users"
# }
# class BaseHandler(cyclone.web.RequestHandler):
#     def __init__(self, *argc, **argkw):
#     def initialize(self):
#     def on_finish(self):
#     def get_error_html(self, status_code=500, **kwargs):
#     def render(self, template_name, **template_vars):
#     def render_error(self, **template_vars):
#     def render_json(self, **template_vars):
#     def render_string(self, template_name, **template_vars):
#     def render_from_string(self, template_string, **template_vars):
#     def get_page_data(self, query):
#     def get_page_url(self, page, form_id=None):
#     def set_session_user(self, username, ipaddr, opr_type, login_time):
#     def clear_session(self):
#     def get_current_user(self):
#     def get_params(self):
#     def get_params_obj(self, obj):
#     def add_oplog(self,message):
# 
# Path: toughwlan/models.py
# def get_metadata(db_engine):
# class SystemSession(DeclarativeBase):
# class SystemCache(DeclarativeBase):
# class TrwOperator(DeclarativeBase):
# class TrwOperatorRule(DeclarativeBase):
# class TrwParam(DeclarativeBase):
# class TrwIsp(DeclarativeBase):
# class TrwIspService(DeclarativeBase):
# class TrwBas(DeclarativeBase):
# class TrwDomain(DeclarativeBase):
# class TrwDomainAttr(DeclarativeBase):
# class TrwSsid(DeclarativeBase):
# class TrwRadius(DeclarativeBase):
# class TrwTemplate(DeclarativeBase):
# class TrwOperateLog(DeclarativeBase):
# class TrwOSTypes(DeclarativeBase):
# 
# Path: toughwlan/manage/resource/domain_form.py
# def domain_add_vform(tpls=[],isps=[]):
# def domain_update_vform(tpls=[],isps=[]):
# def ssid_add_form():


import cyclone.web
from toughlib import utils
from toughwlan.manage.base import BaseHandler, MenuRes
from toughlib.permit import permit
from toughwlan import models
from toughwlan.manage.resource import domain_form
        self.render("domain_list.html", page_data=self.get_page_data(self.db.query(models.TrwDomain)))

@permit.route(r"/domain/detail", u"域信息详情", MenuRes, order=5.0001)
class DomainDetailHandler(BaseHandler):
    @cyclone.web.authenticated
    def get(self):
        domain_id = self.get_argument("domain_id")
        domain = self.db.query(models.TrwDomain).get(domain_id)
        attrs = self.db.query(models.TrwDomainAttr).filter_by(
            domain_code=domain.domain_code,isp_code=domain.isp_code)
        ssids = self.db.query(models.TrwSsid).filter_by(
            domain_code=domain.domain_code,isp_code=domain.isp_code)
        self.render("domain_detail.html", domain=domain, attrs=attrs,ssids=ssids)


@permit.route(r"/domain/add", u"域信息新增", MenuRes, order=5.0002)
class AddHandler(BaseHandler):
    @cyclone.web.authenticated
    def get(self):
        tpls = [(t.tpl_name, t.tpl_desc) for t in self.db.query(models.TrwTemplate)]
        isps = [(t.isp_code, t.isp_name) for t in self.db.query(models.TrwIsp)]
        self.render("base_form.html", form=domain_form.domain_add_vform(tpls=tpls,isps=isps))

    @cyclone.web.authenticated
    def post(self):
        tpls = [(t.tpl_name, t.tpl_desc) for t in self.db.query(models.TrwTemplate)]
        isps = [(t.isp_code, t.isp_name) for t in self.db.query(models.TrwIsp)]
        form = domain_form.domain_add_vform(tpls=tpls, isps=isps)
        if not form.validates(source=self.get_params()):
            return self.render("base_form.html", form=form)

# Path: toughwlan/manage/base.py
# ADMIN_MENUS = (MenuSys, MenuRes, MenuUser) = (u"系统管理", u"资源管理", u"用户管理")
# MENU_ICONS = {
#     u"系统管理": "fa fa-cog",
#     u"资源管理": "fa fa-desktop",
#     u"用户管理": "fa fa-users"
# }
# class BaseHandler(cyclone.web.RequestHandler):
#     def __init__(self, *argc, **argkw):
#     def initialize(self):
#     def on_finish(self):
#     def get_error_html(self, status_code=500, **kwargs):
#     def render(self, template_name, **template_vars):
#     def render_error(self, **template_vars):
#     def render_json(self, **template_vars):
#     def render_string(self, template_name, **template_vars):
#     def render_from_string(self, template_string, **template_vars):
#     def get_page_data(self, query):
#     def get_page_url(self, page, form_id=None):
#     def set_session_user(self, username, ipaddr, opr_type, login_time):
#     def clear_session(self):
#     def get_current_user(self):
#     def get_params(self):
#     def get_params_obj(self, obj):
#     def add_oplog(self,message):
# 
# Path: toughwlan/models.py
# def get_metadata(db_engine):
# class SystemSession(DeclarativeBase):
# class SystemCache(DeclarativeBase):
# class TrwOperator(DeclarativeBase):
# class TrwOperatorRule(DeclarativeBase):
# class TrwParam(DeclarativeBase):
# class TrwIsp(DeclarativeBase):
# class TrwIspService(DeclarativeBase):
# class TrwBas(DeclarativeBase):
# class TrwDomain(DeclarativeBase):
# class TrwDomainAttr(DeclarativeBase):
# class TrwSsid(DeclarativeBase):
# class TrwRadius(DeclarativeBase):
# class TrwTemplate(DeclarativeBase):
# class TrwOperateLog(DeclarativeBase):
# class TrwOSTypes(DeclarativeBase):
# 
# Path: toughwlan/manage/resource/domain_form.py
# def domain_add_vform(tpls=[],isps=[]):
# def domain_update_vform(tpls=[],isps=[]):
# def ssid_add_form():


# Path: toughwlan/manage/resource/domain.py
import cyclone.web
from toughlib import utils
from toughwlan.manage.base import BaseHandler, MenuRes
from toughlib.permit import permit
from toughwlan import models
from toughwlan.manage.resource import domain_form

        self.render("domain_list.html", page_data=self.get_page_data(self.db.query(models.TrwDomain)))

@permit.route(r"/domain/detail", u"域信息详情", MenuRes, order=5.0001)
class DomainDetailHandler(BaseHandler):
    @cyclone.web.authenticated
    def get(self):
        domain_id = self.get_argument("domain_id")
        domain = self.db.query(models.TrwDomain).get(domain_id)
        attrs = self.db.query(models.TrwDomainAttr).filter_by(
            domain_code=domain.domain_code,isp_code=domain.isp_code)
        ssids = self.db.query(models.TrwSsid).filter_by(
            domain_code=domain.domain_code,isp_code=domain.isp_code)
        self.render("domain_detail.html", domain=domain, attrs=attrs,ssids=ssids)


@permit.route(r"/domain/add", u"域信息新增", MenuRes, order=5.0002)
class AddHandler(BaseHandler):
    @cyclone.web.authenticated
    def get(self):
        tpls = [(t.tpl_name, t.tpl_desc) for t in self.db.query(models.TrwTemplate)]
        isps = [(t.isp_code, t.isp_name) for t in self.db.query(models.TrwIsp)]
        self.render("base_form.html", form=domain_form.domain_add_vform(tpls=tpls,isps=isps))

    @cyclone.web.authenticated
    def post(self):
        tpls = [(t.tpl_name, t.tpl_desc) for t in self.db.query(models.TrwTemplate)]
        isps = [(t.isp_code, t.isp_name) for t in self.db.query(models.TrwIsp)]
        form = domain_form.domain_add_vform(tpls=tpls, isps=isps)
        if not form.validates(source=self.get_params()):
            return self.render("base_form.html", form=form)

        if self.db.query(models.TrwDomain.id).filter_by(