Skip to content

Commit

Permalink
chore: download submission
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed May 13, 2024
1 parent 89128c6 commit 74fbb0d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/api/views/project_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _create_groups(self, request, **_):
"message": gettext("project.success.groups.created"),
})

@action(detail=True, methods=["get"])
@action(detail=True)
def structure_checks(self, request, **_):
"""Returns the structure checks for the given project"""
project = self.get_object()
Expand Down Expand Up @@ -120,7 +120,7 @@ def _add_structure_check(self, request: Request, **_):

return Response(serializer.data)

@action(detail=True, methods=["get"])
@action(detail=True)
def extra_checks(self, request, **_):
"""Returns the extra checks for the given project"""
project = self.get_object()
Expand Down Expand Up @@ -155,7 +155,7 @@ def _add_extra_check(self, request: Request, **_):
"message": gettext("project.success.extra_check.add")
})

@action(detail=True, methods=["get"], permission_classes=[IsAdminUser | ProjectGroupPermission])
@action(detail=True, permission_classes=[IsAdminUser | ProjectGroupPermission])
def submission_status(self, request, **_):
"""Returns the current submission status for the given project
This includes:
Expand Down
8 changes: 8 additions & 0 deletions backend/api/views/submission_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from django.http import FileResponse
from rest_framework import viewsets
from rest_framework.decorators import action
from rest_framework.mixins import RetrieveModelMixin

from ..models.submission import Submission
Expand All @@ -9,3 +11,9 @@
class SubmissionViewSet(RetrieveModelMixin, viewsets.GenericViewSet):
queryset = Submission.objects.all()
serializer_class = SubmissionSerializer

@action(detail=True)
def zip(self, request, **_):
submission: Submission = self.get_object()

return FileResponse(open(submission.zip.path, "rb"), as_attachment=True)

0 comments on commit 74fbb0d

Please sign in to comment.