def create_ui_blueprint(app): """Register blueprint routes on app.""" routes = app.config["RDM_COMMUNITIES_ROUTES"] blueprint = Blueprint("invenio_app_rdm_communities", __name__, template_folder="../templates", static_folder='../static') blueprint.add_url_rule( routes["community-detail"], view_func=communities_detail, ) @blueprint.before_app_first_request def register_menus(): """Register community menu items.""" communities = current_menu.submenu('communities') communities.submenu('search').register( 'invenio_app_rdm_communities.communities_detail', text=_('Search'), order=1, expected_args=["pid_value"], **dict(icon="search", permissions=True)) # Register error handlers blueprint.register_error_handler(PermissionDeniedError, record_permission_denied_error) blueprint.register_error_handler(PIDDeletedError, record_tombstone_error) blueprint.register_error_handler(PIDDoesNotExistError, not_found_error) # Register context processor blueprint.app_context_processor(search_app_context) return blueprint
def create_ui_blueprint(app): """Register blueprint routes on app.""" routes = app.config.get("APP_RDM_USER_DASHBOARD_ROUTES") blueprint = Blueprint("invenio_app_rdm_users", __name__, template_folder="../templates", static_folder='../static') blueprint.add_url_rule( routes["uploads"], view_func=uploads, ) # Settings tab routes blueprint.add_url_rule( routes["communities"], view_func=communities, ) blueprint.add_url_rule( routes["requests"], view_func=requests, ) @blueprint.before_app_first_request def register_menus(): """Register community menu items.""" user_dashboard = current_menu.submenu('dashboard') user_dashboard.submenu('uploads').register( 'invenio_app_rdm_users.uploads', text=_('Uploads'), order=1, ) user_dashboard.submenu('communities').register( 'invenio_app_rdm_users.communities', text=_('Communities'), order=2, ) user_dashboard.submenu('requests').register( 'invenio_app_rdm_users.requests', text=_('Requests'), order=3, ) # Register context processor blueprint.app_context_processor(search_app_context) return blueprint
def init_bp(app): """Initialize app.""" bp = Blueprint("geo_knowledge_hub_bp", __name__) def define_user_profile(): is_knowledge_provider = False if "identity" in g: is_knowledge_provider = provider_user_permission().can() return { "is_knowledge_provider": is_knowledge_provider, "current_user_profile": current_user_invenio_profile(), } # Registering the user context processor bp.app_context_processor(define_user_profile) app.register_blueprint(bp)
redirect, url_for, ) from yoti_python_sdk import Client from .context_storage import activity_details_storage from .decorators import yoti_authenticated from .context_processors import yoti_context from .settings import get_config_value from .helpers import is_cookie_session flask_yoti_blueprint = Blueprint('flask_yoti', __name__, template_folder='templates') flask_yoti_blueprint.secret_key = os.urandom(24) flask_yoti_blueprint.app_context_processor(yoti_context) @flask_yoti_blueprint.route('/auth') def auth(): token = request.args.get('token') if not token: return render_template('yoti_auth.html') client_sdk_id = get_config_value('YOTI_CLIENT_SDK_ID') key_file_path = get_config_value('YOTI_KEY_FILE_PATH') client = Client(client_sdk_id, key_file_path) activity_details = client.get_activity_details(token) session['yoti_user_id'] = activity_details.user_id if not is_cookie_session(session): session['activity_details'] = dict(activity_details)
def create_blueprint(app): """Register blueprint routes on app.""" routes = app.config.get("APP_RDM_ROUTES") blueprint = Blueprint( "invenio_app_rdm_records", __name__, template_folder="../templates", ) # Record URL rules blueprint.add_url_rule( routes["record_detail"], view_func=record_detail, ) blueprint.add_url_rule( routes["record_latest"], view_func=record_latest, ) rdm_records_ext = app.extensions['invenio-rdm-records'] schemes = rdm_records_ext.records_service.config.pids_providers.keys() schemes = ','.join(schemes) if schemes: blueprint.add_url_rule( routes["record_from_pid"].format(schemes=schemes), view_func=record_from_pid, ) blueprint.add_url_rule( routes["record_export"], view_func=record_export, ) blueprint.add_url_rule( routes["record_file_preview"], view_func=record_file_preview, ) blueprint.add_url_rule( routes["record_file_download"], view_func=record_file_download, ) blueprint.add_url_rule( routes["deposit_create"], view_func=deposit_create, ) blueprint.add_url_rule( routes["deposit_edit"], view_func=deposit_edit, ) # Register error handlers blueprint.register_error_handler(PIDDeletedError, record_tombstone_error) blueprint.register_error_handler(PIDDoesNotExistError, not_found_error) blueprint.register_error_handler(PIDUnregistered, not_found_error) blueprint.register_error_handler(KeyError, not_found_error) blueprint.register_error_handler(PermissionDeniedError, record_permission_denied_error) # Register template filters blueprint.add_app_template_filter(can_list_files) blueprint.add_app_template_filter(make_files_preview_compatible) blueprint.add_app_template_filter(pid_url) blueprint.add_app_template_filter(select_preview_file) blueprint.add_app_template_filter(to_previewer_files) blueprint.add_app_template_filter(has_previewable_files) blueprint.add_app_template_filter(order_entries) blueprint.add_app_template_filter(get_scheme_label) # Register context processor blueprint.app_context_processor(search_app_context) return blueprint
from flask import Blueprint from . import views, errors main = Blueprint('main', __name__) main.add_url_rule('/index', 'index', views.index) main.add_url_rule('/device', 'device', views.device, methods=['GET', 'POST']) main.add_url_rule('/device/add_device', 'add_device', views.add_device, methods=['GET', 'POST']) main.add_url_rule('/bulletin', 'bulletin', views.bulletin) main.add_url_rule('/alarm', 'alarm', views.alarm) main.add_url_rule('/push_port', 'push_port', views.push_port, methods=['POST']) main.add_url_rule('/alarm/confirm_one/<id>', 'confirm_one', views.confirm_one) main.app_context_processor(views.get_context_data) main.errorhandler(404)(errors.page_not_found) main.errorhandler(401)(errors.handle_unauthorized) main.errorhandler(403)(errors.handle_forbidden)
menu.get('view_permissions') == "administrators" and permissions.is_admin() ): active_menu.append(menu) return sorted(active_menu, key=itemgetter('parent_order', 'order')) def get_parent_name(parent_slug): parent_slug = re.sub('\s+', '_', parent_slug.lower()) top_menu = g.db.settings.find_one( { 'top_level_menu.slug': parent_slug }, { 'top_level_menu.$': 1, '_id': 0 } ) if top_menu: return top_menu.get('top_level_menu')[0].get('name') return dict( app_title=app_title(), app_footer=app_footer(), app_email=app_email(), app_well=app_well(), check_app_email=check_app_email(), get_menu=get_menu(), check_if_admin=check_if_admin(), get_parent_name=get_parent_name ) bp.app_context_processor(utility_processor)