def delete_study(self, request): study = Study.get_by_id(request.id) if not study: raise endpoints.NotFoundException( "The study ID: " + str(request.id) + " doesn't exist") study.key.delete() return message_types.VoidMessage()
def update_study(self, request): study = Study.get_by_id(request.id) if not study: raise endpoints.NotFoundException( "The study ID: " + str(request.id) + " doesn't exist") if not request.title: raise endpoints.BadRequestException('The data: title, country are obligatory.') study = StudyHelper.update(study.key, request.title) if not study: raise endpoints.BadRequestException('It was not possible to create the study') return StudyListResponse(studies=[StudyApiHelper().to_message(study.get())])
def query_all(cls): return Study.query().order(Study.country).fetch()
def get_study(self, request): study = Study.get_by_id(request.id) if not study: raise endpoints.NotFoundException( "The study ID: " + str(request.id) + " doesn't exist") return StudyListResponse(studies=[StudyApiHelper().to_message(study)])
def get_studies(self, request): studies = Study.query().fetch() return StudyListResponse( studies=[StudyApiHelper().to_message(study) for study in studies if studies])