Skip to content
Snippets Groups Projects
Commit 0043ecc4 authored by Julian's avatar Julian
Browse files

Fix User-Group and Role-Group relationship config

parent 17b99372
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ from uffd.user.models import User ...@@ -8,7 +8,7 @@ from uffd.user.models import User
class RoleGroup(db.Model): class RoleGroup(db.Model):
__tablename__ = 'role_groups' __tablename__ = 'role_groups'
role_id = Column(Integer(), ForeignKey('role.id', onupdate='CASCADE', ondelete='CASCADE'), primary_key=True) role_id = Column(Integer(), ForeignKey('role.id', onupdate='CASCADE', ondelete='CASCADE'), primary_key=True)
role = relationship('Role') role = relationship('Role', back_populates='groups')
group_id = Column(Integer(), ForeignKey('group.id', onupdate='CASCADE', ondelete='CASCADE'), primary_key=True) group_id = Column(Integer(), ForeignKey('group.id', onupdate='CASCADE', ondelete='CASCADE'), primary_key=True)
group = relationship('Group') group = relationship('Group')
requires_mfa = Column(Boolean(), default=False, nullable=False) requires_mfa = Column(Boolean(), default=False, nullable=False)
...@@ -94,7 +94,7 @@ class Role(db.Model): ...@@ -94,7 +94,7 @@ class Role(db.Model):
members = relationship('User', secondary='role_members', back_populates='roles') members = relationship('User', secondary='role_members', back_populates='roles')
groups = relationship('RoleGroup', collection_class=RoleGroupMap, cascade='all, delete-orphan') groups = relationship('RoleGroup', collection_class=RoleGroupMap, cascade='all, delete-orphan', back_populates='role')
# Roles that are managed externally (e.g. by Ansible) can be locked to # Roles that are managed externally (e.g. by Ansible) can be locked to
# prevent accidental editing of name, moderator group, included roles # prevent accidental editing of name, moderator group, included roles
......
...@@ -84,7 +84,7 @@ class User(db.Model): ...@@ -84,7 +84,7 @@ class User(db.Model):
mail = Column(String(128), nullable=False) mail = Column(String(128), nullable=False)
pwhash = Column(String(256), nullable=True) pwhash = Column(String(256), nullable=True)
is_service_user = Column(Boolean(), default=False, nullable=False) is_service_user = Column(Boolean(), default=False, nullable=False)
groups = relationship('Group', secondary='user_groups') groups = relationship('Group', secondary='user_groups', back_populates='members')
roles = relationship('Role', secondary='role_members', back_populates='members') roles = relationship('Role', secondary='role_members', back_populates='members')
@property @property
...@@ -169,7 +169,7 @@ class Group(db.Model): ...@@ -169,7 +169,7 @@ class Group(db.Model):
unix_gid = Column(Integer(), unique=True, nullable=False, default=get_next_unix_gid) unix_gid = Column(Integer(), unique=True, nullable=False, default=get_next_unix_gid)
name = Column(String(32), unique=True, nullable=False) name = Column(String(32), unique=True, nullable=False)
description = Column(String(128), nullable=False, default='') description = Column(String(128), nullable=False, default='')
members = relationship('User', secondary='user_groups') members = relationship('User', secondary='user_groups', back_populates='groups')
def set_name(self, value): def set_name(self, value):
if len(value) > 32 or len(value) < 1: if len(value) > 32 or len(value) < 1:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment