Skip to content

Commit

Permalink
frontend works also
Browse files Browse the repository at this point in the history
  • Loading branch information
RunoBoy committed May 7, 2024
1 parent c23761d commit 72c44fe
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions backend/pigeonhole/apps/submissions/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fnmatch
import json as JSON
import os
import shutil
import zipfile
Expand Down Expand Up @@ -68,10 +69,12 @@ def create(self, request, *args, **kwargs):
group_id = request.data["group_id"]
group = get_object_or_404(Group, group_id=group_id)
data = request.data.copy() # Create a mutable copy
# backup = request.data["file_urls"]
# data["file_urls"] = JSON.dumps([key for key in request.FILES])
# if len(data["file_urls"]) == 0:
# data["file_urls"] = backup
if len(request.FILES) != 0:
file_urls = []
for key in request.FILES:
file_urls.append(key)
else:
file_urls = request.data["file_urls"].split(",")

serializer = SubmissionsSerializer(data=data)
serializer.is_valid(raise_exception=True)
Expand Down Expand Up @@ -117,11 +120,11 @@ def create(self, request, *args, **kwargs):
)

project = Project.objects.get(project_id=group.project_id.project_id)

# return Response(",".join(file_urls), status=status.HTTP_201_CREATED)
if project.file_structure is None or project.file_structure == "":
complete_message = {"message": "Submission successful"}
else:
violations = check_restrictions(request.data["file_urls"].split(","), project.file_structure.split(","))
violations = check_restrictions(file_urls, project.file_structure.split(","))

if not violations:
complete_message = {"message": "Submission successful"}
Expand Down

0 comments on commit 72c44fe

Please sign in to comment.