Skip to content

Commit

Permalink
Prevent error 500 for listing files without grader (#50)
Browse files Browse the repository at this point in the history
For an example of the error, run `test_incorrect_files` from #40 locally
  • Loading branch information
JasonGrace2282 authored Jun 29, 2024
1 parent e94c535 commit 1715111
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
8 changes: 2 additions & 6 deletions tin/apps/assignments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,8 @@ def venv_fully_created(self):
return self.venv and self.venv.fully_created

@property
def grader_log_filename(self):
return (
upload_grader_file_path(self, "").rsplit(".", 1)[0] + ".log"
if self.grader_file
else None
)
def grader_log_filename(self) -> str:
return f"{upload_grader_file_path(self, '').rsplit('.', 1)[0]}.log"

def quiz_open_for_student(self, student):
is_teacher = self.course.teacher.filter(id=student.id).exists()
Expand Down
5 changes: 1 addition & 4 deletions tin/apps/assignments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ def show_view(request, assignment_id):
"assignment": assignment,
"students_and_submissions": students_and_submissions,
"log_file_exists": (
assignment.grader_log_filename is not None
and os.path.exists(
os.path.join(settings.MEDIA_ROOT, assignment.grader_log_filename)
)
os.path.exists(os.path.join(settings.MEDIA_ROOT, assignment.grader_log_filename))
),
"is_student": course.is_student_in_course(request.user),
"is_teacher": request.user in course.teacher.all(),
Expand Down

0 comments on commit 1715111

Please sign in to comment.