Exemple #1
0
 def post(self):
     jti = get_raw_jwt()['jti']
     try:
         token_service.revoke_token(jti)
         return {'msg': 'Refresh token has been revoked'}
     except Exception as e:
         print(e)
         return InternalError().to_json()
Exemple #2
0
 def get(self, current_user, subject, group_id):
     try:
         progress = tutor_service.get_group_progress(current_user, subject, group_id)
         return progress
     except BaseException as e:
         return e.to_json()
     except Exception as e:
         print(e)
         return InternalError().to_json()
Exemple #3
0
 def get(self, current_user):
     try:
         associations = tutor_service.get_associations(current_user)
         return associations
     except BaseException as e:
         return e.to_json()
     except Exception as e:
         print(e)
         return InternalError().to_json()
Exemple #4
0
 def get(self, current_user, subject):
     try:
         progress = student_service.get_subject_progress(current_user, subject)
         return progress
     except BaseException as e:
         return e.to_json()
     except Exception as e:
         print(e)
         return InternalError().to_json()
Exemple #5
0
 def get(self, current_user):
     try:
         subjects = student_service.get_subjects(current_user)
         return subjects
     except BaseException as e:
         return e.to_json()
     except Exception as e:
         print(e)
         return InternalError().to_json()
Exemple #6
0
 def get(self, current_user, subject, group_id):
     try:
         checkpoints = tutor_service.get_checkpoints(current_user, subject, group_id)
         print(checkpoints)
         return checkpoints
     except BaseException as e:
         return e.to_json()
     except Exception as e:
         print(e)
         return InternalError().to_json()
Exemple #7
0
 def post(self, current_user, subject, group_id):
     data = request.get_json()
     try:
         tutor_service.update_group_progress(current_user, subject, group_id, data)
         return {
             'msg': 'Table succesfully updated'
         }
     except BaseException as e:
         return e.to_json()
     except Exception as e:
         print(e)
         return InternalError().to_json()
Exemple #8
0
 def post(self, current_user):
     data = association_parser.parse_args()
     try:
         tutor_service.add_association(current_user, **data)
         return {
             'msg': 'Association successfully created'
         }
     except BaseException as e:
         return e.to_json()
     except Exception as e:
         print(e)
         return InternalError().to_json()
Exemple #9
0
 def post(self, current_user, subject, group_id):
     #TODO допилить парсер
     data = request.get_json()
     try:
         tutor_service.add_checkpoints(current_user, subject, group_id, data)
         return {
             'msg': 'Checkpoints succesfully created'
         }
     except BaseException as e:
         return e.to_json()
     except Exception as e:
         print(e)
         return InternalError().to_json()
Exemple #10
0
 def post(self):
     data = tutor_info_parser.parse_args()
     try:
         tutor_service.create_tutor(data)
         access_token = token_service.create_access_token(identity=data['username'])
         refresh_token = token_service.create_refresh_token(identity=data['username'])
         return {
             'msg': 'Tutor {} was created'.format(data['username']),
             'access_token': access_token,
             'refresh_token': refresh_token
         }
     except BaseException as e:
         return e.to_json()
     except Exception as e:
         print(e)
         return InternalError().to_json()
Exemple #11
0
 def post(self):
     data = user_login_parser.parse_args()
     try:
         user_service.authenticate(data['username'], data['password'])
         access_token = token_service.create_access_token(
             identity=data['username'])
         refresh_token = token_service.create_refresh_token(
             identity=data['username'])
         return {
             'msg': 'Logged in as {}'.format(data['username']),
             'access_token': access_token,
             'refresh_token': refresh_token
         }
     except BaseException as e:
         return e.to_json()
     except Exception as e:
         print(e)
         return InternalError().to_json()
Exemple #12
0
def error_handler(e):
    if isinstance(e, BaseException):
        return e.to_response()
    else:
        print_exc()
        return InternalError().to_response()