Example #1
0
    def run(self):
        admin_role = Role()
        admin_role.name = 'admin'
        admin_role.description = 'Umsjónarhlutverk með aðgang að notendastillingum'

        user_role = Role()
        user_role.name = 'Notandi'
        user_role.description = 'Venjulegur notandi með grunn aðgang'

        db.session.add(admin_role)
        db.session.add(user_role)
        db.session.commit()
Example #2
0
def seed_roles(db):
    print("++ Seeding roles")
    role_usr = Role()
    role_usr.name = "user"
    role_usr.description = "Simple user"

    role_adm = Role()
    role_adm.name = "admin"
    role_adm.description = "Admin user"

    db.session.add(role_usr)
    db.session.add(role_adm)
    db.session.commit()
Example #3
0
def create_role(name, desc):
    role = Role.from_name(db.session, name)
    if not role:
        role = Role(name=name, description=desc)
    else:
        role.description = desc
    db.session.add(role)
    return role
Example #4
0
def seed_users(db):
    print("++ Seeding users")
    role_usr = Role()
    role_usr.name = "user"
    role_usr.description = "Simple user"

    role_adm = Role()
    role_adm.name = "admin"
    role_adm.description = "Admin user"

    db.session.add(role_usr)
    db.session.add(role_adm)

    user_datastore.create_user(
        email="*****@*****.**", password="******", name="toto", timezone="UTC", roles=[role_adm]
    )
    db.session.commit()
    return
Example #5
0
def create_role_body(errors, form):
    role = Role()
    role.name = form.name.data
    role.description = form.description.data

    try:
        db.session.add(role)
        db.session.commit()
    except:
        errors.append("Can't save in db role id{}".format(role.id))

    return errors
Example #6
0
    def exitRolefragment(self, ctx):
        role = Role()
        role.source = self.context[-1]
        role.description = self.stack.pop()
        role.contact = self.stack.pop()
        status = self.stack.pop()
        if status == 'active':
            role.status = Role.ACTIVE
        elif status == 'disabled':
            role.status = Role.DISABLED
        else:
            role.status = Role.WORKING
        role.save()

        # Now that the role exists, we can create the other rows
        # which have FK constraints
        for row in self.rows:
            row.save()

        self.rows = []
Example #7
0
    def exitRolefragment(self, ctx):
        role = Role()
        role.source = self.context[-1]
        role.description = self.stack.pop()
        role.contact = self.stack.pop()
        status = self.stack.pop()
        if status == 'active' :
            role.status = Role.ACTIVE
        elif status == 'disabled' :
            role.status = Role.DISABLED
        else :
            role.status = Role.WORKING
        role.save() 

        # Now that the role exists, we can create the other rows
        # which have FK constraints 
        for row in self.rows :
            row.save()

        self.rows = []
Example #8
0
from models import Role, database

r = Role()
r.name = 'conversationee'
r.description = 'day-to-day system user'

with database.transaction():
	r.save()