예제 #1
0
    def get(self):
        """
        ---
        summary: List of user groups
        description: |
            Returns list of user groups and members.
        security:
            - bearerAuth: []
        tags:
            - auth
        responses:
            200:
                description: List of user groups
                content:
                  application/json:
                    schema: GroupListResponseSchema
        """
        objs = (db.session.query(Group).options(
            joinedload(Group.members,
                       Member.user)).filter(g.auth_user.is_member(
                           Group.id)).filter(Group.name != "public").filter(
                               Group.private.is_(False))).all()

        schema = GroupListResponseSchema()
        return schema.dump({"groups": objs})
예제 #2
0
    def get(self):
        """
        ---
        summary: List of groups
        description: |
            Returns list of all groups and members.

            Requires `manage_users` capability.
        security:
            - bearerAuth: []
        tags:
            - group
        responses:
            200:
                description: List of groups
                content:
                  application/json:
                    schema: GroupListResponseSchema
            403:
                description: When user doesn't have `manage_users` capability.
        """
        objs = (db.session.query(Group).options(
            joinedload(Group.members), joinedload(Group.members,
                                                  Member.user))).all()
        schema = GroupListResponseSchema()
        return schema.dump({"groups": objs})
예제 #3
0
    def get(self):
        """
        ---
        summary: List of user groups
        description: |
            Returns list of user groups and members.
        security:
            - bearerAuth: []
        tags:
            - auth
        responses:
            200:
                description: List of user groups
                content:
                  application/json:
                    schema: GroupListResponseSchema
            503:
                description: |
                    Request canceled due to database statement timeout.
        """
        objs = (db.session.query(Group).options(
            joinedload(Group.members,
                       Member.user)).filter(g.auth_user.is_member(
                           Group.id)).filter(Group.workspace.is_(True)).filter(
                               Group.private.is_(False))).all()

        schema = GroupListResponseSchema()
        return schema.dump({"groups": objs})