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()
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()
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
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
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
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 = []
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 = []
from models import Role, database r = Role() r.name = 'conversationee' r.description = 'day-to-day system user' with database.transaction(): r.save()