Exemplo n.º 1
0
_check_conf = (
    # morias common block
    ("morias", "db", Sql),
    ("news", "in_menu", bool, True),
)


def _call_conf(cfg, parser):
    if cfg.news_in_menu:
        user_sections.append(Item("/news", label="News"))


module_rights = ("news_editor", "news_author")
rights.update(module_rights)

content_menu.append(Item("/admin/news", label="News", symbol="news", rights=module_rights))


@app.route("/admin/news")
def admin_news(req):
    check_login(req)
    match_right(req, module_rights)

    show = req.args.getfirst("show", "", uni)

    pager = Pager(sort="desc")
    pager.bind(req.args)

    kwargs = {}

    if show == "ready":
Exemplo n.º 2
0
from admin import content_menu

_check_conf = (
    # morias common block
    ('morias', 'db', Sql, None),
    ('redirects', 'timestamp', unicode, 'tmp/redirects.timestamp'),
)


def _call_conf(cfg, parser):
    refresh_links(cfg, cfg.redirects_timestamp, False)

timestamp = -1
module_right = 'menu_modify'
rights.add(module_right)
content_menu.append(Item('/admin/redirects', label="Redirects",
                         symbol="redirects", rights=[module_right]))


@app.pre_process()
def load_redirects(req):
    if req.uri_rule in ('_debug_info_', '_send_file_', '_directory_index_'):
        return  # this methods no need this pre process
    refresh_links(req, req.cfg.redirects_timestamp)


def refresh_links(req, cfg_timestamp, clear=True):
    """ refresh redirect links from db if timestamp is change """
    global timestamp

    check = check_timestamp(req, cfg_timestamp)
    if check > timestamp:       # if last load was in past to timestamp file