] apis_for_admins = [ # "{}.admin_add_comment_extension".format(bp_name), "{}.admin_get_comment_extension".format(bp_name), "{}.admin_update_comment_extension".format(bp_name), "{}.admin_list_comment_groups".format(bp_name), "{}.admin_remove_group".format(bp_name), "{}.admin_get_group_comments".format(bp_name), "{}.admin_remove_comment".format(bp_name), "{}.admin_remove_comments".format(bp_name) ] blueprint = Blueprint(bp_name, __name__) route_inject(blueprint, urls) @blueprint.before_app_first_request def before_first_request(): from .models import (Comment, CommentGroup, CommentExtension) current_app.mongodb_database.register([ Comment, CommentGroup, CommentExtension]) @blueprint.before_request def before_request(): if request.endpoint in apis_for_visitors: verify_outer() elif request.endpoint in apis_for_admins: verify_token()
from .models import ExtUser from .routes import urlpatterns from ..helpers import verify_token bp_name = "user" open_api_endpoints = [ "{}.get_oauth_access_code".format(bp_name), "{}.get_oauth_access_token".format(bp_name) ] blueprint = Blueprint(bp_name, __name__) route_inject(blueprint, urlpatterns) @blueprint.before_app_first_request def before_first_request(): current_app.mongodb_database.register(ExtUser) @blueprint.before_request def before_request(): if request.endpoint in open_api_endpoints: pass else: verify_token()
from __future__ import absolute_import from flask import Blueprint, current_app from .models import Profile, Post, History, Role, Member from .routes import urlpatterns from apiresps import APIError from utils.api_utils import make_json_response from utils.helpers import route_inject from ..helpers import verify_token bp_name = "newsletter" blueprint = Blueprint(bp_name, __name__) route_inject(blueprint, urlpatterns) model_list = [Profile, Post, History, Role, Member] @blueprint.before_app_first_request def before_first_request(): current_app.mongodb_database.register(model_list) @blueprint.before_request def before_request(): verify_token() @blueprint.errorhandler(APIError)
] apis_for_admins = [ # "{}.admin_add_comment_extension".format(bp_name), "{}.admin_get_comment_extension".format(bp_name), "{}.admin_update_comment_extension".format(bp_name), "{}.admin_list_comment_groups".format(bp_name), "{}.admin_remove_group".format(bp_name), "{}.admin_get_group_comments".format(bp_name), "{}.admin_remove_comment".format(bp_name), "{}.admin_remove_comments".format(bp_name) ] blueprint = Blueprint(bp_name, __name__) route_inject(blueprint, urls) @blueprint.before_app_first_request def before_first_request(): from .models import (Comment, CommentGroup, CommentExtension) current_app.mongodb_database.register( [Comment, CommentGroup, CommentExtension]) @blueprint.before_request def before_request(): if request.endpoint in apis_for_visitors: verify_outer() elif request.endpoint in apis_for_admins: verify_token()