From 556586671bbe35aea1eedd3c84c49828e0396364 Mon Sep 17 00:00:00 2001 From: Theo Ouzhinski Date: Tue, 11 Dec 2018 21:41:09 -0500 Subject: [PATCH] Check that latest submission exists && fix if --- tin/apps/assignments/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tin/apps/assignments/views.py b/tin/apps/assignments/views.py index 3cd8ec97..23b9a0c7 100644 --- a/tin/apps/assignments/views.py +++ b/tin/apps/assignments/views.py @@ -31,7 +31,7 @@ def show_view(request, assignment_id): "assignment": assignment, "submissions": submissions, "latest_submission": latest_submission, - "latest_submission_url": reverse('submissions:show_json', args=(latest_submission.id,)), + "latest_submission_url": reverse('submissions:show_json', args=(latest_submission.id,)) if latest_submission else None, }, ) else: @@ -102,7 +102,7 @@ def edit_view(request, assignment_id): if request.method == "POST": if request.FILES.get("grader_file"): if request.FILES["grader_file"].size <= settings.SUBMISSION_SIZE_LIMIT: - if assignment.grader_file is not None: + if assignment.grader_file.name: old_grader_file_path = assignment.grader_file.path #LEAVE THIS HERE grader_form = GraderFileSubmissionForm(request.POST, request.FILES, instance = assignment) @@ -112,7 +112,7 @@ def edit_view(request, assignment_id): except UnicodeDecodeError: grader_file_errors = "Please don't upload binary files." else: - if assignment.grader_file is not None: + if assignment.grader_file.name: if os.path.exists(old_grader_file_path): os.remove(old_grader_file_path)