Skip to content
Snippets Groups Projects
Select Git revision
  • 98a6855db1d8b197774c3cc8a4cb34f8a844fccf
  • main default protected
  • develop protected
  • test-ci
  • CE-3627-adapt-alertbanner
  • login-dialog-always-diplays-error
  • CE-3563-duration-staging
  • CE-3563-duration
  • CE-3519-updates
  • CE-3401-admin-page-improvements
  • CE-2550-remove-query-params-navigation
  • CE-3057-batch-jobs-UI-changes
  • CE-3115_Fetch-network-and-network-scope-async
  • CE-2986-async-dataready
  • CE-2912-MaintenanceModeBanner
  • ce2755-version-string-none
  • INFRA-8754
  • CE-2298-upgrade-node
  • 5.2.0
  • 5.3.0
  • 5.4.0
  • 5.2.0-rc1
  • 5.1.0
  • 5.1.0-rc7
  • 5.1.0-rc3
  • 5.1.0-rc4
  • 5.1.0-rc5
  • 5.1.0-rc6
  • 5.1.0-rc2
  • 5.1.0-rc1
  • 5.0.0
  • 5.0.0-rc3
  • 5.0.0-rc2
  • 5.0.0-rc1
  • 4.1.0
  • 4.1.0-rc3
  • 4.1.0-rc1
  • 4.1.0-rc2
38 results

config.js

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    plugins.py 1.12 KiB
    # -*- coding: utf-8 -*-
    """
    app.plugins
    ~~~~~~~~~~~
    
    This module implements SQLAlchemy-Continuum plugins.
    
    FlaskUserPlugin offers way of integrating Flask framework with
    SQLAlchemy-Continuum. FlaskUser-Plugin adds a `user_id` column for Transaction model.
    
    This plugin is based on the official FlaskPlugin with the following modifications:
        - no remote_addr column
        - the user_id is taken from flask_jwt_extended (API) or flask_login (web UI)
    
    The `user_id` column is automatically populated when the transaction object is created.
    
    :copyright: original (c) 2012, Konsta Vesterinen
    :copyright: modified (c) 2017 European Spallation Source ERIC
    :license: BSD 2-Clause, see LICENSE for more details.
    
    """
    
    from sqlalchemy_continuum.plugins import Plugin
    from . import utils
    
    
    class FlaskUserPlugin(Plugin):
        def __init__(self, current_user_id_factory=None):
            self.current_user_id_factory = (
                utils.fetch_current_user_id
                if current_user_id_factory is None
                else current_user_id_factory
            )
    
        def transaction_args(self, uow, session):
            return {"user_id": self.current_user_id_factory()}