def get(cls, submitID): '''Get submission by submit uuid''' try: user_mail = get_jwt_identity() submission_record = FileModel.find_by_submitID(submitUUID=submitID) assert submission_record.email == user_mail download_path = submission_record.filePath return send_file(download_path, as_attachment=True) except Exception as e: print(e) return {"message": "Internal Server Error!"}, HTTPStatus.INTERNAL_SERVER_ERROR
def patch(cls, submitID): '''Change user submission show on leaderboard or not by uuid''' try: user_mail = get_jwt_identity() submission_record = FileModel.find_by_submitID(submitUUID=submitID) assert submission_record.email == user_mail task_id = submission_record.task.value # == mapping[task] if submission_record.showOnLeaderboard == Show.YES: FileModel.unset_show_attribute_by_submitID(submitUUID=submitID) return {"message": "Remove from the leaderboard!", "submitID": submitID}, HTTPStatus.OK else: FileModel.set_show_attribute_by_submitID(submitUUID=submitID) return {"message": "Shown on the leaderboard!", "submitID": submitID}, HTTPStatus.OK except Exception as e: print(e) return {"message": "Internal Server Error!"}, HTTPStatus.INTERNAL_SERVER_ERROR