Loading rolling-changelog.txt +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ change: create graphql input objects for mutations #94 change: rename PerformTeamToolAction mutation to UseTool #94 change: reach_milestone is replaced by fields activate_milestone and deactivate_milestone #98 change: add option to override some definition config values #109 change: add an optional parameter 'instructor' to file download REST API endpoint #119 new feature: REST API endpoints for database export and import #79 running_exercise/lib/file_handler.py +5 −2 Original line number Diff line number Diff line Loading @@ -65,7 +65,9 @@ def _get_file(file_path: str) -> Optional[BinaryIO]: return open(file_path, "rb") def get_uploaded_file(team_id: int, file_name: str) -> BinaryIO: def get_uploaded_file( team_id: int, file_name: str, instructor: bool ) -> BinaryIO: team = get_model(Team, id=team_id) exercise = team.exercise Loading @@ -74,6 +76,7 @@ def get_uploaded_file(team_id: int, file_name: str) -> BinaryIO: _get_definition_file_path(exercise.definition_id, file_name) ) ) is not None: if not instructor: _activate_file_milestone(team, file_name) return f Loading running_exercise/views.py +11 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,14 @@ from running_exercise.lib.file_handler import ( class GetFileView(APIView): @swagger_auto_schema( manual_parameters=[ openapi.Parameter( name="instructor", in_=openapi.IN_QUERY, type=openapi.TYPE_BOOLEAN, description="Is called by an instructor", ) ], responses={ 200: file_response("File"), 400: ERROR_RESPONSE, Loading @@ -28,15 +36,16 @@ class GetFileView(APIView): ) def get(self, request, *args, **kwargs): """ Get a file of given name. Get a file of given name. Parameter 'instructor' will default to False if not specified. """ file_name = self.kwargs.get("file_name") team_id = self.kwargs.get("team_id") instructor = bool(self.request.GET.get("instructor", False)) if file_name is None or team_id is None: raise ApiException("Invalid request, missing required parameters") opened_file = get_uploaded_file(team_id, file_name) opened_file = get_uploaded_file(team_id, file_name, instructor) # according to Django docs, the `opened_file` # should be closed automatically Loading Loading
rolling-changelog.txt +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ change: create graphql input objects for mutations #94 change: rename PerformTeamToolAction mutation to UseTool #94 change: reach_milestone is replaced by fields activate_milestone and deactivate_milestone #98 change: add option to override some definition config values #109 change: add an optional parameter 'instructor' to file download REST API endpoint #119 new feature: REST API endpoints for database export and import #79
running_exercise/lib/file_handler.py +5 −2 Original line number Diff line number Diff line Loading @@ -65,7 +65,9 @@ def _get_file(file_path: str) -> Optional[BinaryIO]: return open(file_path, "rb") def get_uploaded_file(team_id: int, file_name: str) -> BinaryIO: def get_uploaded_file( team_id: int, file_name: str, instructor: bool ) -> BinaryIO: team = get_model(Team, id=team_id) exercise = team.exercise Loading @@ -74,6 +76,7 @@ def get_uploaded_file(team_id: int, file_name: str) -> BinaryIO: _get_definition_file_path(exercise.definition_id, file_name) ) ) is not None: if not instructor: _activate_file_milestone(team, file_name) return f Loading
running_exercise/views.py +11 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,14 @@ from running_exercise.lib.file_handler import ( class GetFileView(APIView): @swagger_auto_schema( manual_parameters=[ openapi.Parameter( name="instructor", in_=openapi.IN_QUERY, type=openapi.TYPE_BOOLEAN, description="Is called by an instructor", ) ], responses={ 200: file_response("File"), 400: ERROR_RESPONSE, Loading @@ -28,15 +36,16 @@ class GetFileView(APIView): ) def get(self, request, *args, **kwargs): """ Get a file of given name. Get a file of given name. Parameter 'instructor' will default to False if not specified. """ file_name = self.kwargs.get("file_name") team_id = self.kwargs.get("team_id") instructor = bool(self.request.GET.get("instructor", False)) if file_name is None or team_id is None: raise ApiException("Invalid request, missing required parameters") opened_file = get_uploaded_file(team_id, file_name) opened_file = get_uploaded_file(team_id, file_name, instructor) # according to Django docs, the `opened_file` # should be closed automatically Loading