diff --git a/create_debug_users.py b/create_debug_users.py index c061cf76..98eb0ce4 100755 --- a/create_debug_users.py +++ b/create_debug_users.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import os -import sys import subprocess +import sys if not __file__.endswith("shell.py"): subprocess.call( diff --git a/tin/apps/assignments/admin.py b/tin/apps/assignments/admin.py index 63c1a5fc..c6fc480f 100644 --- a/tin/apps/assignments/admin.py +++ b/tin/apps/assignments/admin.py @@ -60,7 +60,14 @@ def end_time(self, obj): @admin.register(Quiz) class QuizAdmin(admin.ModelAdmin): date_hierarchy = "assignment__due" - list_display = ("assignment", "course_name", "folder_name", "due", "action", "visible") + list_display = ( + "assignment", + "course_name", + "folder_name", + "due", + "action", + "visible", + ) list_filter = ("action",) ordering = ("-assignment__due",) save_as = True @@ -102,7 +109,14 @@ def assignment(self, obj): @admin.register(MossResult) class MossResultAdmin(admin.ModelAdmin): date_hierarchy = "date" - list_display = ("date", "assignment", "course_name", "language", "user_id", "status") + list_display = ( + "date", + "assignment", + "course_name", + "language", + "user_id", + "status", + ) list_filter = ("assignment__course", "language", "user_id") ordering = ("-date",) save_as = True diff --git a/tin/apps/assignments/forms.py b/tin/apps/assignments/forms.py index 665ea418..3bcf7e04 100644 --- a/tin/apps/assignments/forms.py +++ b/tin/apps/assignments/forms.py @@ -6,7 +6,12 @@ class AssignmentForm(forms.ModelForm): - QUIZ_ACTIONS = (("-1", "No"), ("0", "Log only"), ("1", "Color Change"), ("2", "Lock")) + QUIZ_ACTIONS = ( + ("-1", "No"), + ("0", "Log only"), + ("1", "Color Change"), + ("2", "Lock"), + ) due = forms.DateTimeInput() is_quiz = forms.ChoiceField(choices=QUIZ_ACTIONS) diff --git a/tin/apps/assignments/models.py b/tin/apps/assignments/models.py index 1b51f041..b3ca2d04 100644 --- a/tin/apps/assignments/models.py +++ b/tin/apps/assignments/models.py @@ -391,7 +391,8 @@ def __repr__(self): def get_absolute_url(self): return reverse( - "assignments:student_submission", args=(self.quiz.assignment.id, self.student.id) + "assignments:student_submission", + args=(self.quiz.assignment.id, self.student.id), ) diff --git a/tin/apps/assignments/urls.py b/tin/apps/assignments/urls.py index 6a7a3407..e818a017 100644 --- a/tin/apps/assignments/urls.py +++ b/tin/apps/assignments/urls.py @@ -10,7 +10,11 @@ path("/edit", views.edit_view, name="edit"), path("/delete", views.delete_view, name="delete"), path("/grader", views.manage_grader_view, name="manage_grader"), - path("/grader/download", views.download_grader_view, name="download_grader"), + path( + "/grader/download", + views.download_grader_view, + name="download_grader", + ), path("/files", views.manage_files_view, name="manage_files"), path( "/files/download/", @@ -46,9 +50,17 @@ ), path("/moss", views.moss_view, name="moss"), path("/download_log", views.download_log_view, name="download_log"), - path("folder//", views.show_folder_view, name="show_folder"), + path( + "folder//", + views.show_folder_view, + name="show_folder", + ), path("add/folder/", views.create_folder_view, name="add_folder"), - path("edit/folder//", views.edit_folder_view, name="edit_folder"), + path( + "edit/folder//", + views.edit_folder_view, + name="edit_folder", + ), path( "delete/folder//", views.delete_folder_view, diff --git a/tin/apps/assignments/views.py b/tin/apps/assignments/views.py index 9b24cb0e..d440465c 100644 --- a/tin/apps/assignments/views.py +++ b/tin/apps/assignments/views.py @@ -1,6 +1,5 @@ import csv import datetime -import json import logging import os import subprocess @@ -729,7 +728,10 @@ def quiz_report_view(request, assignment_id): if not assignment.quiz.ended_for_student(request.user): LogMessage.objects.create( - quiz=assignment.quiz, student=request.user, content=content, severity=severity + quiz=assignment.quiz, + student=request.user, + content=content, + severity=severity, ) if severity >= settings.QUIZ_ISSUE_THRESHOLD: diff --git a/tin/apps/auth/oauth.py b/tin/apps/auth/oauth.py index 43b31644..6cfecad8 100644 --- a/tin/apps/auth/oauth.py +++ b/tin/apps/auth/oauth.py @@ -21,7 +21,8 @@ def get_scope(self): def get_user_details(self, response): profile = self.get_json( - "https://ion.tjhsst.edu/api/profile", params={"access_token": response["access_token"]} + "https://ion.tjhsst.edu/api/profile", + params={"access_token": response["access_token"]}, ) # fields used to populate/update User model return { diff --git a/tin/apps/courses/urls.py b/tin/apps/courses/urls.py index 24dba788..656aae45 100644 --- a/tin/apps/courses/urls.py +++ b/tin/apps/courses/urls.py @@ -9,15 +9,31 @@ path("", views.show_view, name="show"), path("add/", views.create_view, name="create"), path("/edit", views.edit_view, name="edit"), - path("/import", views.import_select_course_view, name="import_select_course"), + path( + "/import", + views.import_select_course_view, + name="import_select_course", + ), path( "/import/", views.import_from_selected_course, name="import_from_selected_course", ), path("/students", views.students_view, name="students"), - path("/students/import", views.import_students_view, name="import_students"), - path("/students/manage", views.manage_students_view, name="manage_students"), + path( + "/students/import", + views.import_students_view, + name="import_students", + ), + path( + "/students/manage", + views.manage_students_view, + name="manage_students", + ), path("/add_period", views.add_period_view, name="add_period"), - path("/edit_period/", views.edit_period_view, name="edit_period"), + path( + "/edit_period/", + views.edit_period_view, + name="edit_period", + ), ] diff --git a/tin/apps/courses/views.py b/tin/apps/courses/views.py index 452bfedd..e02845d7 100644 --- a/tin/apps/courses/views.py +++ b/tin/apps/courses/views.py @@ -101,7 +101,9 @@ def edit_view(request, course_id): form = CourseForm(instance=course) return render( - request, "courses/edit_create.html", {"form": form, "course": course, "nav_item": "Edit"} + request, + "courses/edit_create.html", + {"form": form, "course": course, "nav_item": "Edit"}, ) diff --git a/tin/apps/docs/views.py b/tin/apps/docs/views.py index fe909358..45031c96 100644 --- a/tin/apps/docs/views.py +++ b/tin/apps/docs/views.py @@ -28,5 +28,7 @@ def graders_view(request): @teacher_or_superuser_required def sample_graders_view(request): return render( - request, "docs/sample_graders.html", {"docs_app": True, "nav_item": "Sample graders"} + request, + "docs/sample_graders.html", + {"docs_app": True, "nav_item": "Sample graders"}, ) diff --git a/tin/apps/submissions/forms.py b/tin/apps/submissions/forms.py index f9af42ff..ae2e98f8 100644 --- a/tin/apps/submissions/forms.py +++ b/tin/apps/submissions/forms.py @@ -53,7 +53,9 @@ class FilterForm(forms.Form): label="Folders", queryset=Folder.objects.all().order_by("name"), required=False ) assignments = CustomModelMultipleChoiceField( - label="Assignments", queryset=Assignment.objects.all().order_by("name"), required=False + label="Assignments", + queryset=Assignment.objects.all().order_by("name"), + required=False, ) periods = CustomModelMultipleChoiceField( label="Periods", queryset=Period.objects.all().order_by("name"), required=False diff --git a/tin/apps/submissions/models.py b/tin/apps/submissions/models.py index 762993cc..6e376116 100644 --- a/tin/apps/submissions/models.py +++ b/tin/apps/submissions/models.py @@ -336,7 +336,9 @@ class PublishedSubmission(models.Model): date = models.DateTimeField(auto_now_add=True) assignment = models.ForeignKey( - "assignments.Assignment", on_delete=models.CASCADE, related_name="final_submissions" + "assignments.Assignment", + on_delete=models.CASCADE, + related_name="final_submissions", ) student = models.ForeignKey( get_user_model(), on_delete=models.CASCADE, related_name="final_submissions" diff --git a/tin/apps/submissions/tasks.py b/tin/apps/submissions/tasks.py index b24a5795..f8f1f1af 100644 --- a/tin/apps/submissions/tasks.py +++ b/tin/apps/submissions/tasks.py @@ -131,7 +131,11 @@ def run_submission(submission_id): if not settings.DEBUG or shutil.which("firejail") is not None: whitelist = [os.path.dirname(grader_path)] - read_only = [grader_path, submission_path, os.path.dirname(submission_wrapper_path)] + read_only = [ + grader_path, + submission_path, + os.path.dirname(submission_wrapper_path), + ] if submission.assignment.venv_fully_created: whitelist.append(submission.assignment.venv.path) read_only.append(submission.assignment.venv.path) diff --git a/tin/apps/submissions/urls.py b/tin/apps/submissions/urls.py index 17651e76..79687f78 100644 --- a/tin/apps/submissions/urls.py +++ b/tin/apps/submissions/urls.py @@ -24,7 +24,11 @@ path("/publish", views.publish_view, name="publish"), path("/unpublish", views.unpublish_view, name="unpublish"), path("filter", views.filter_view, name="filter"), - path("set-aborted-complete", views.set_aborted_complete_view, name="set_aborted_complete"), + path( + "set-aborted-complete", + views.set_aborted_complete_view, + name="set_aborted_complete", + ), path( "set-past-timeout-complete", views.set_past_timeout_complete_view, diff --git a/tin/apps/submissions/views.py b/tin/apps/submissions/views.py index c475847e..f343715c 100644 --- a/tin/apps/submissions/views.py +++ b/tin/apps/submissions/views.py @@ -142,7 +142,9 @@ def edit_comment_view(request, submission_id, comment_id): return redirect("submissions:show", submission.id) before_submissions = Submission.objects.filter( - student=submission.student, assignment=submission.assignment, id__lt=submission.id + student=submission.student, + assignment=submission.assignment, + id__lt=submission.id, ) submission_number = before_submissions.count() + 1 diff --git a/tin/apps/venvs/models.py b/tin/apps/venvs/models.py index 49190aea..71f8dbf7 100644 --- a/tin/apps/venvs/models.py +++ b/tin/apps/venvs/models.py @@ -1,10 +1,9 @@ import logging import os import subprocess -import sys from django.conf import settings -from django.db import IntegrityError, models +from django.db import models from django.urls import reverse from ... import sandboxing diff --git a/tin/apps/venvs/tasks.py b/tin/apps/venvs/tasks.py index 39ac833c..8dd5f708 100644 --- a/tin/apps/venvs/tasks.py +++ b/tin/apps/venvs/tasks.py @@ -6,7 +6,7 @@ from django.conf import settings -from .models import Venv, VenvCreationError, VenvExistsError +from .models import Venv, VenvCreationError logger = logging.getLogger(__name__) diff --git a/tin/apps/venvs/urls.py b/tin/apps/venvs/urls.py index 7ee081dc..5e6edf7d 100644 --- a/tin/apps/venvs/urls.py +++ b/tin/apps/venvs/urls.py @@ -8,5 +8,9 @@ path("", views.index_view, name="index"), path("", views.show_view, name="show"), path("add", views.create_view, name="add"), - path("/install_packages", views.install_packages_view, name="install_packages"), + path( + "/install_packages", + views.install_packages_view, + name="install_packages", + ), ] diff --git a/tin/apps/venvs/views.py b/tin/apps/venvs/views.py index 5bfdaf8a..4ca7d088 100644 --- a/tin/apps/venvs/views.py +++ b/tin/apps/venvs/views.py @@ -1,7 +1,6 @@ from django import http from django.shortcuts import get_object_or_404, redirect, render -from ..assignments.models import Assignment from ..auth.decorators import teacher_or_superuser_required from .forms import VenvForm from .models import Venv @@ -89,7 +88,9 @@ def edit_view(request, venv_id): def install_packages_view(request, venv_id): if request.method == "POST": venv = get_object_or_404( - Venv.objects.filter_editable(request.user), id=venv_id, installing_packages=False + Venv.objects.filter_editable(request.user), + id=venv_id, + installing_packages=False, ) venv.installing_packages = True diff --git a/tin/templates/venvs/show.html b/tin/templates/venvs/show.html index 8f2f13b2..ac8c1b3f 100644 --- a/tin/templates/venvs/show.html +++ b/tin/templates/venvs/show.html @@ -20,7 +20,7 @@

{{ venv.name }}

If it takes more than a few minutes, please contact the Tin maintainers by emailing {{ DEVELOPER_EMAIL }} {% else %}

Installed packages

- + {% if venv.installing_packages %}

This virtual environment is currently installing or upgrading packages. This list may be incomplete.

@@ -49,7 +49,7 @@

Installed packages

{% endif %} {% endwith %} - +

Install packages

{% if venv.installing_packages %}

@@ -72,7 +72,7 @@

Install packages

{% endif %} - + {% if venv.package_installation_output and not venv.installing_packages %}

Last package installation output

{{ venv.package_installation_output }}