Python flask_security.RoleMixin() Examples

The following are 2 code examples of flask_security.RoleMixin(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module flask_security , or try the search function .
Example #1
Source File:    From flask-security with MIT License 6 votes vote down vote up
def test_modify_permissions_unsupported(app, datastore):
    from tests.conftest import PonyUserDatastore

    ds = datastore
    if hasattr(datastore.role_model, "permissions"):
        # already tested this
    if isinstance(datastore, PonyUserDatastore):
        # sigh - Pony doesn't use RoleMixin.

    init_app_with_options(app, ds)

    with app.app_context():
        t3 = ds.find_role("test3")

        with raises(NotImplementedError):
        with raises(NotImplementedError):
Example #2
Source File:    From FACT_core with GNU General Public License v3.0 6 votes vote down vote up
def create_user_interface(db):
    roles_users = db.Table('roles_users', db.Column('user_id', db.Integer(), db.ForeignKey('')), db.Column('role_id', db.Integer(), db.ForeignKey('')))

    class Role(db.Model, RoleMixin):
        id = db.Column(db.Integer(), primary_key=True)  # pylint: disable=invalid-name
        name = db.Column(db.String(80), unique=True)
        description = db.Column(db.String(255))

    class User(db.Model, UserMixin):
        id = db.Column(db.Integer, primary_key=True)  # pylint: disable=invalid-name
        api_key = db.Column(db.String(255), default=_build_api_key, unique=True)
        email = db.Column(db.String(255), unique=True)
        password = db.Column(db.String(255))
        active = db.Column(db.Boolean())
        confirmed_at = db.Column(db.DateTime())
        roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic'))

    return UserRoleDbInterface(db, User, Role)