コード例 #1
0
ファイル: manage.py プロジェクト: cloveses/easy_cms
def editctx(lid, nid):
    login_verify()
    name = request.get_cookie('name', secret=secret)
    user_type = request.get_cookie('user_type', secret=secret)
    uid = request.get_cookie('id', secret=secret)
    power = cmstools.get_power(uid)
    if request.method == "GET":
        if nid:
            news = cmstools.get_one_news(nid, uid, user_type)
            if news:
                return template('tpls/editctx.tpl',
                                id=uid,
                                lid=lid,
                                name=name,
                                power=power,
                                user_type=user_type,
                                news=news)
        redirect('/ctxmgr/' + lid)
    elif request.method == "POST":
        title = request.forms.getunicode('title')
        txt = request.forms.getunicode('txt')
        uid = request.get_cookie('id', secret=secret)
        if nid:
            cmstools.edit_news(nid, uid, title, txt)
        redirect('/ctxmgr/' + lid)
コード例 #2
0
ファイル: manage.py プロジェクト: cloveses/easy_cms
def editctx(lid,nid):
    login_verify()
    name = request.get_cookie('name',secret=secret)
    user_type = request.get_cookie('user_type',secret=secret)
    uid = request.get_cookie('id',secret=secret)
    power = cmstools.get_power(uid)
    if request.method == "GET":
        if nid:
            news = cmstools.get_one_news(nid,uid,user_type)
            if news:
                return template('tpls/editctx.tpl',
                    id=uid,
                    lid=lid,
                    name=name,
                    power=power,
                    user_type=user_type,
                    news=news)
        redirect('/ctxmgr/' + lid)
    elif request.method == "POST":
        title = request.forms.getunicode('title')
        txt = request.forms.getunicode('txt')
        uid = request.get_cookie('id',secret=secret)
        if nid:
            cmstools.edit_news(nid,uid,title,txt)
        redirect('/ctxmgr/' + lid)
コード例 #3
0
ファイル: manage.py プロジェクト: cloveses/easy_cms
def ctxmgr(lid='', page=0):
    uid = request.get_cookie('id', secret=secret)
    login_verify()
    if request.method == 'GET':
        name = request.get_cookie('name', secret=secret)
        user_type = request.get_cookie('user_type', secret=secret)
        power = cmstools.get_power(uid)
        powers = []
        next_lvls = []
        bread_nav_dec = []
        if power:
            for p in power:
                powers.append(cmstools.get_sub_lvls(str(p.id)))
        if powers and lid:
            bread_nav = cmstools.get_bread_nav(lid)
            ids = set().union(*powers)
            ids = {str(i.id) for i in ids}
            for bn in bread_nav:
                if bn[0] in ids:
                    bread_nav_dec.append(bn)
            next_lvls = cmstools.get_next_lvls(lid)
        news = cmstools.get_news(lid)
        return template('tpls/ctxmgr.tpl',
                        name=name,
                        id=uid,
                        lid=lid,
                        user_type=user_type,
                        power=power,
                        bread_nav=bread_nav_dec,
                        next_lvls=next_lvls,
                        news=news)
    elif request.method == "POST":
        action = request.forms.getunicode('action')
        if action == "add":
            add_ctx()
        elif action == "release":
            print('.........', action)
            release()
コード例 #4
0
ファイル: manage.py プロジェクト: cloveses/easy_cms
def ctxmgr(lid='',page=0):
    uid = request.get_cookie('id',secret=secret)
    login_verify()
    if request.method == 'GET':
        name = request.get_cookie('name',secret=secret)
        user_type = request.get_cookie('user_type',secret=secret)
        power = cmstools.get_power(uid)
        powers = []
        next_lvls = []
        bread_nav_dec = []
        if power:
            for p in power:
                powers.append(cmstools.get_sub_lvls(str(p.id)))
        if powers and lid:
            bread_nav = cmstools.get_bread_nav(lid)
            ids = set().union(*powers)
            ids = {str(i.id) for i in ids}
            for bn in bread_nav:
                if bn[0] in ids:
                    bread_nav_dec.append(bn)
            next_lvls = cmstools.get_next_lvls(lid)
        news = cmstools.get_news(lid)
        return template('tpls/ctxmgr.tpl',
            name=name,
            id=uid,
            lid=lid,
            user_type=user_type,
            power=power,
            bread_nav=bread_nav_dec,
            next_lvls=next_lvls,
            news=news)
    elif request.method == "POST":
        action = request.forms.getunicode('action')
        if action == "add":
            add_ctx()
        elif action == "release":
            print('.........',action)
            release()