예제 #1
0
    def get(cls, uuid: str):
        org = OrganizationModel.find_by_uuid(uuid)

        if not org:
            return {"message": "Organization not found."}, 404

        return organization_schema.dump(org)
예제 #2
0
    def delete(cls, uuid: str):
        org = OrganizationModel.find_by_uuid(uuid)

        if not org:
            return {"message": "Organization not found."}, 404

        org.delete_from_db()

        return {"message": "Organization deleted!."}, 200
예제 #3
0
    def put(cls, uuid: str):
        org_request = organization_schema.load(request.get_json())
        org = OrganizationModel.find_by_uuid(uuid)

        if not org:
            return {"message": "Organization not found."}, 404

        org.name = org_request.name
        org_request.save_to_db()

        return organization_schema.dump(org_request), 200
예제 #4
0
    def post(cls, org: str, user: str):

        organization = OrganizationModel.find_by_uuid(org)
        member = UserModel.find_by_uuid(user)

        if not organization:
            return {"message": "Organization not found."}, 404

        if not member:
            return {"message": "User not found."}, 404

        organization.users.append(member)
        organization.save_to_db()

        return user