Exemplo n.º 1
0
 def GET(self):
     site_info = reader.get_site_setting()
     if site_info == None:
         site_info = site_setting()
         site_info.site_name = 'demo'
         site_info.site_slogan = ''
         site_info.author = 'chimchar'
         site_info.google_analytic_id = ''
         writer.set_site_setting(site_info)
     site_info.site_domain = web.ctx.host
     template_values = {
             'site_info': site_info
             }
     path = os.path.join(os.path.dirname(__file__), 'tpl', 'writer')
     return template_render('auth.html', path, template_values)
Exemplo n.º 2
0
def set_site_setting(s):
    session = connect_db()
    q = session.query(site_setting)

    if q.count() == 0:
        new = site_setting()
        new.site_name = s.site_name
        new.site_slogan = s.site_slogan
        new.author = s.author
        new.google_analytic_id = s.google_analytic_id
        session.add(new)
        session.commit()
    else:
        update = q.one()
        update.site_name = s.site_name
        update.site_slogan = s.site_slogan
        update.author = s.author
        update.google_analytic_id = s.google_analytic_id
        session.commit()
    return
Exemplo n.º 3
0
    def POST(self):
        site_info = reader.get_site_setting()
        if site_info == None:
            site_info = site_setting()
            site_info.site_name = 'demo'
            site_info.site_slogan = ''
            site_info.author = 'chimchar'
            site_info.google_analytic_id = ''
            writer.set_site_setting(site_info)
        site_info.site_domain = web.ctx.host
        template_values = {
                'site_info': site_info
                }
        path = os.path.join(os.path.dirname(__file__), 'tpl', 'writer')

        pwd = web.input().passwd
        sha1 = hashlib.sha1(pwd).hexdigest()
        if (sha1 == SECRET):
            web.setcookie('is_pass', sha1, 3600)
            web.redirect('/overview')
        else:
            template_values['message'] = 'Secret pharse WRONG!'
            return template_render('auth.html', path, template_values)