コード例 #1
0
def process_schema_upgrade(context, request):
    run = request.POST.get("action", "").lower()
    if run != "update":
        request.notify("error", "Error", "Invalid operation")
        return morpfw.redirect(request.link(context))
    dbsync = IndexDatabaseSyncAdapter(context.collection, request)
    if dbsync.need_update:
        dbsync.update()
    request.notify("success", "Success", "Database updated")
    return morpfw.redirect(request.link(context))
コード例 #2
0
def verify(context, request):
    token = request.GET.get('token', None)
    if not token:
        raise HTTPNotFound()
    tokenprovider = SignedTokenProvider()
    payload = tokenprovider.load_token(token)

    if not payload:
        raise HTTPNotFound()

    if 'userid' not in payload:
        raise HTTPNotFound()

    user = morpfw.get_user_by_userid(request, payload['userid'])
    if not user:
        raise HTTPNotFound()

    key = user['nonce'].encode('utf-8')

    if not tokenprovider.verify_payload(key, payload):
        raise HTTPNotFound()

    xattr = user.xattrprovider()
    xattr.update({'morpfw.email.validated': True})

    return morpfw.redirect(request.relative_url('/'))
コード例 #3
0
def schema_upgrade(context, request):
    dbsync = IndexDatabaseSyncAdapter(context.collection, request)
    if not dbsync.need_update:
        return morpfw.redirect(request.link(context))
    code = dbsync.migration_code
    formatter = HtmlFormatter()
    highlighted = highlight(code, PythonLexer(), formatter)
    return {
        "need_update": dbsync.need_update,
        "code": code,
        "highlighted_code": highlighted,
        "highlight_styles": formatter.get_style_defs(".highlight"),
    }
コード例 #4
0
def process_listing(context, request):
    page_name = request.GET.get("page", "general")
    page = request.app.config.setting_page_registry.get(request, page_name)
    pages = request.app.config.setting_page_registry.values(request)
    pages = [v for v in pages if v.enabled(context, request)]
    error = page.process_form(context, request)
    if not error:
        request.notify("success", "Settings saved",
                       "Configuration have been successfully updated")
        return morpfw.redirect(request.url)
    return {
        "current_page": page_name,
        "pages": pages,
        "page_title": "Settings",
        "form_title": page.title,
        "form": error["form"],
        "form_data": error["form_data"],
    }