Exemple #1
0
def navsite_add(request):
    ac_navsite = "am-active"
    title = "填写新网站"
    site_class_mysql = site_class.objects.order_by("class_code")
    site_group_mysql = site_group.objects.order_by("group_code")
    site_name = request.POST.get("site_name","")
    site_url =  request.POST.get("site_url","")
    site_class_req =  request.POST.get("site_class","")
    site_group_req =  request.POST.get("site_group","")
    site_onhome = request.POST.get("site_onhome","")
    site_onhome = site_onhome and True or False
    site_describe =  request.POST.get("site_describe","")
    if not site_name:
        return render_to_response("nav/navigate_addsiteinfos.html",locals())
    else:
        # print site_name
        # print site_url
        # print site_class_req
        print site_group_req
        print site_onhome
        # print site_describe
        try:
            site_class_id = site_class.objects.get(id=site_class_req)
            site_group_id = site_group.objects.get(id=site_group_req)
            Site = site(
                name=site_name,
                url=site_url,
                url_class_id=site_class_id,
                url_group_id=site_group_id,
                is_onhome=site_onhome,
                describe=site_describe
            )
            Site.save()
            msg = '0'
        except Exception,e:
            traceback.print_exc()
            print e
            msg = e
        return render_to_response("nav/navigate_addsiteinfos.html",locals())
Exemple #2
0
def navsite_add(request):
    ac_navsite = "am-active"
    title = "填写新网站"
    site_class_mysql = site_class.objects.order_by("class_code")
    site_group_mysql = site_group.objects.order_by("group_code")
    site_name = request.POST.get("site_name", "")
    site_url = request.POST.get("site_url", "")
    site_class_req = request.POST.get("site_class", "")
    site_group_req = request.POST.get("site_group", "")
    site_onhome = request.POST.get("site_onhome", "")
    site_onhome = site_onhome and True or False
    site_describe = request.POST.get("site_describe", "")
    if not site_name:
        return render_to_response("nav/navigate_addsiteinfos.html", locals())
    else:
        # print site_name
        # print site_url
        # print site_class_req
        print site_group_req
        print site_onhome
        # print site_describe
        try:
            site_class_id = site_class.objects.get(id=site_class_req)
            site_group_id = site_group.objects.get(id=site_group_req)
            Site = site(name=site_name,
                        url=site_url,
                        url_class_id=site_class_id,
                        url_group_id=site_group_id,
                        is_onhome=site_onhome,
                        describe=site_describe)
            Site.save()
            msg = '0'
        except Exception, e:
            traceback.print_exc()
            print e
            msg = e
        return render_to_response("nav/navigate_addsiteinfos.html", locals())
Exemple #3
0
# -*- coding: utf-8 -*-

from models import site
from dao import containsSiteConfig
from dao import save
from dao import remove



global_site = [site('Google','http://google.com/','fa-google'),site('facebook','http://facebook.com','fa-facebook-official'),site('twitter','http://twitter.com','fa-twitter')]

def init_site() :
    # remove('site_config')
    for each_site in global_site:
        if not containsSiteConfig(each_site.site_name) :
            save(each_site)