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)
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
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
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