Beispiel #1
0
 def mutate(self, info, name, groups=None, role=None):
     _groups = []
     if groups is not None:
         existing_groups = [g.name for g in Group.get_query(info).all()]
         for g in groups:
             assert g in existing_groups, f'Group {g} does not exist. ' \
                                          f'Existing groups: {existing_groups}'
             _groups.append(
                 Group.get_query(info).filter(
                     models.Group.name == g).first())
     user = models.User(name=name, role=role, groups=_groups)
     db_session.add(user)
     db_session.commit()
     return CreateUser(user=user, ok=True)
Beispiel #2
0
 def mutate(self, info, name):
     group = Group.get_query(info).filter(models.Group.name == name).first()
     db_session.delete(group)
     db_session.commit()
     return DeleteGroup(ok=True)
Beispiel #3
0
 def mutate(self, info, name, new_name):
     group = Group.get_query(info).filter(models.Group.name == name).first()
     group.name = new_name
     db_session.add(group)
     db_session.commit()
     return UpdateGroup(group=group, ok=True)