def get_group(self, name): # type: (str) -> Optional[Group] group = SQLGroup.get(self.session, name=name) if not group: return None return Group( name=group.groupname, description=group.description, join_policy=GroupJoinPolicy(group.canjoin), )
def get_group(self, name): # type: (str) -> Optional[Group] group = SQLGroup.get(self.session, name=name) if not group: return None user = SQLUser.get(self.session, name=name) is_role_user = user.role_user if user else False return Group( name=group.groupname, description=group.description, email_address=group.email_address, join_policy=GroupJoinPolicy(group.canjoin), enabled=group.enabled, is_role_user=is_role_user, )
def _get_groups(session, user_metadata): # type: (Session, Dict[str, Dict[str, Any]]) -> Tuple[Dict[str, Group], Dict[str, Group]] sql_groups = session.query(SQLGroup) groups = {} # type: Dict[str, Group] disabled_groups = {} # type: Dict[str, Group] for sql_group in sql_groups: if sql_group.groupname in user_metadata: is_role_user = user_metadata[sql_group.groupname]["role_user"] else: is_role_user = False group = Group( name=sql_group.groupname, description=sql_group.description, email_address=sql_group.email_address, join_policy=GroupJoinPolicy(sql_group.canjoin), enabled=sql_group.enabled, is_role_user=is_role_user, ) if group.enabled: groups[group.name] = group else: disabled_groups[group.name] = group return groups, disabled_groups