Пример #1
0
 def post(self, **kwargs):
     try:
         student = self.create_student_interactor.set_params(
             **kwargs).execute()
         body = StudentSerializer.serialize(student)
         status = HTTP_STATUS_OK_CODE
     except InvalidEntityException as e:
         body = InvalidEntityExceptionSerializer.serialize(e)
         status = HTTP_BAD_REQUEST_STATUS_CODE
     return body, status
Пример #2
0
 def get(self, **kwargs):
     body = []
     try:
         students = self.get_all_students_interactor.set_params(
             **kwargs).execute()
         if students:
             for student in students:
                 body.append(StudentSerializer.serialize(student))
         status = HTTP_STATUS_OK_CODE
     except InvalidEntityException as e:
         body = InvalidEntityExceptionSerializer.serialize(e)
         status = HTTP_BAD_REQUEST_STATUS_CODE
     return body, status
Пример #3
0
 def get(self, **kwargs):
     body = {}
     data = []
     try:
         response = self.get_all_courses_interactor.set_params(
             **kwargs).execute()
         if response['courses']:
             body['allPages'] = response['allPages']
             body['offset'] = response['offset']
             for course in response['courses']:
                 try:
                     if course.title:
                         data.append(CourseSerializer.serialize(course))
                 except:
                     data.append(StudentSerializer.serialize(course))
         body['data'] = data
         status = HTTP_STATUS_OK_CODE
     except InvalidEntityException as e:
         body = InvalidEntityExceptionSerializer.serialize(e)
         status = HTTP_BAD_REQUEST_STATUS_CODE
     return body, status