def setup_admin(self): permission = Permission.from_enum_member(ShopOrderPermission.view) self.db.session.add(permission) role = Role(id='shop_admin') role.permissions.add(permission) self.db.session.add(role) self.admin.roles.add(role) self.db.session.commit()
def setup_admin(self, permission): db_permission = Permission.from_enum_member(permission) self.db.session.add(db_permission) board_moderator_role = Role(id="board_moderator") self.db.session.add(board_moderator_role) board_moderator_role.permissions.add(db_permission) self.admin.roles.add(board_moderator_role) self.db.session.commit()
def setup_admin(self): export_subscribers_permission = Permission.from_enum_member( NewsletterPermission.export_subscribers) self.db.session.add(export_subscribers_permission) newsletter_admin_role = Role(id='newsletter_admin') self.db.session.add(newsletter_admin_role) newsletter_admin_role.permissions.add(export_subscribers_permission) self.admin.roles.add(newsletter_admin_role) self.db.session.commit()
def setup_admin(self): update_orders_permission = Permission.from_enum_member( ShopOrderPermission.update) self.db.session.add(update_orders_permission) shop_admin_role = Role(id='shop_admin') self.db.session.add(shop_admin_role) shop_admin_role.permissions.add(update_orders_permission) self.admin.roles.add(shop_admin_role) self.db.session.commit()
def test_creation_from_enum_member(self, enum_member, expected): actual = Permission.from_enum_member(enum_member) self.assertEqual(actual.id, expected)