def get(self, project_id, task_id): """ Get a task's metadata --- tags: - tasks produces: - application/json parameters: - in: header name: Authorization description: Base64 encoded session token required: false type: string default: Token sessionTokenHere== - in: header name: Accept-Language description: Language user is requesting type: string required: true default: en - name: project_id in: path description: Project ID the task is associated with required: true type: integer default: 1 - name: task_id in: path description: Unique task ID required: true type: integer default: 1 responses: 200: description: Task found 404: description: Task not found 500: description: Internal Server Error """ try: preferred_locale = request.environ.get("HTTP_ACCEPT_LANGUAGE") token = request.environ.get("HTTP_AUTHORIZATION") # Login isn't required here, but if we have a token we can find out if the user can undo the task if token: verify_token(token[6:]) user_id = tm.authenticated_user_id task = MappingService.get_task_as_dto(task_id, project_id, preferred_locale, user_id) return task.to_primitive(), 200 except NotFound: return {"Error": "Task Not Found"}, 404 except Exception as e: error_msg = f"TasksRestAPI - unhandled error: {str(e)}" current_app.logger.critical(error_msg) return {"Error": "Unable to fetch task"}, 500
def get(self, project_id, task_id): """ Get a task's metadata --- tags: - tasks produces: - application/json parameters: - in: header name: Accept-Language description: Language user is requesting type: string required: true default: en - name: project_id in: path description: Project ID the task is associated with required: true type: integer default: 1 - name: task_id in: path description: Unique task ID required: true type: integer default: 1 responses: 200: description: Task found 404: description: Task not found 500: description: Internal Server Error """ try: preferred_locale = request.environ.get("HTTP_ACCEPT_LANGUAGE") task = MappingService.get_task_as_dto(task_id, project_id, preferred_locale) return task.to_primitive(), 200 except NotFound: return {"Error": "Task Not Found"}, 404 except Exception as e: error_msg = f"TasksRestAPI - unhandled error: {str(e)}" current_app.logger.critical(error_msg) return {"Error": "Unable to fetch task"}, 500