Skip to content

Commit

Permalink
whitespace/line endings fix from pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed May 6, 2024
1 parent db0beb2 commit bc818e5
Show file tree
Hide file tree
Showing 20 changed files with 104 additions and 31 deletions.
2 changes: 1 addition & 1 deletion create_debug_users.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import os
import sys
import subprocess
import sys

if not __file__.endswith("shell.py"):
subprocess.call(
Expand Down
18 changes: 16 additions & 2 deletions tin/apps/assignments/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion tin/apps/assignments/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion tin/apps/assignments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)


Expand Down
18 changes: 15 additions & 3 deletions tin/apps/assignments/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
path("<int:assignment_id>/edit", views.edit_view, name="edit"),
path("<int:assignment_id>/delete", views.delete_view, name="delete"),
path("<int:assignment_id>/grader", views.manage_grader_view, name="manage_grader"),
path("<int:assignment_id>/grader/download", views.download_grader_view, name="download_grader"),
path(
"<int:assignment_id>/grader/download",
views.download_grader_view,
name="download_grader",
),
path("<int:assignment_id>/files", views.manage_files_view, name="manage_files"),
path(
"<int:assignment_id>/files/download/<int:file_id>",
Expand Down Expand Up @@ -46,9 +50,17 @@
),
path("<int:assignment_id>/moss", views.moss_view, name="moss"),
path("<int:assignment_id>/download_log", views.download_log_view, name="download_log"),
path("folder/<int:course_id>/<int:folder_id>", views.show_folder_view, name="show_folder"),
path(
"folder/<int:course_id>/<int:folder_id>",
views.show_folder_view,
name="show_folder",
),
path("add/folder/<int:course_id>", views.create_folder_view, name="add_folder"),
path("edit/folder/<int:course_id>/<int:folder_id>", views.edit_folder_view, name="edit_folder"),
path(
"edit/folder/<int:course_id>/<int:folder_id>",
views.edit_folder_view,
name="edit_folder",
),
path(
"delete/folder/<int:course_id>/<int:folder_id>",
views.delete_folder_view,
Expand Down
6 changes: 4 additions & 2 deletions tin/apps/assignments/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import csv
import datetime
import json
import logging
import os
import subprocess
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion tin/apps/auth/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 20 additions & 4 deletions tin/apps/courses/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,31 @@
path("<int:course_id>", views.show_view, name="show"),
path("add/", views.create_view, name="create"),
path("<int:course_id>/edit", views.edit_view, name="edit"),
path("<int:course_id>/import", views.import_select_course_view, name="import_select_course"),
path(
"<int:course_id>/import",
views.import_select_course_view,
name="import_select_course",
),
path(
"<int:course_id>/import/<int:other_course_id>",
views.import_from_selected_course,
name="import_from_selected_course",
),
path("<int:course_id>/students", views.students_view, name="students"),
path("<int:course_id>/students/import", views.import_students_view, name="import_students"),
path("<int:course_id>/students/manage", views.manage_students_view, name="manage_students"),
path(
"<int:course_id>/students/import",
views.import_students_view,
name="import_students",
),
path(
"<int:course_id>/students/manage",
views.manage_students_view,
name="manage_students",
),
path("<int:course_id>/add_period", views.add_period_view, name="add_period"),
path("<int:course_id>/edit_period/<int:period_id>", views.edit_period_view, name="edit_period"),
path(
"<int:course_id>/edit_period/<int:period_id>",
views.edit_period_view,
name="edit_period",
),
]
4 changes: 3 additions & 1 deletion tin/apps/courses/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
)


Expand Down
4 changes: 3 additions & 1 deletion tin/apps/docs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
)
4 changes: 3 additions & 1 deletion tin/apps/submissions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tin/apps/submissions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion tin/apps/submissions/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion tin/apps/submissions/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
path("<int:submission_id>/publish", views.publish_view, name="publish"),
path("<int:submission_id>/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,
Expand Down
4 changes: 3 additions & 1 deletion tin/apps/submissions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions tin/apps/venvs/models.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tin/apps/venvs/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from django.conf import settings

from .models import Venv, VenvCreationError, VenvExistsError
from .models import Venv, VenvCreationError

logger = logging.getLogger(__name__)

Expand Down
6 changes: 5 additions & 1 deletion tin/apps/venvs/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
path("", views.index_view, name="index"),
path("<int:venv_id>", views.show_view, name="show"),
path("add", views.create_view, name="add"),
path("<int:venv_id>/install_packages", views.install_packages_view, name="install_packages"),
path(
"<int:venv_id>/install_packages",
views.install_packages_view,
name="install_packages",
),
]
5 changes: 3 additions & 2 deletions tin/apps/venvs/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tin/templates/venvs/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h2 class="left">{{ venv.name }}</h2>
<p>If it takes more than a few minutes, please contact the Tin maintainers by emailing <a href="mailto:{{ DEVELOPER_EMAIL }}">{{ DEVELOPER_EMAIL }}</a>
{% else %}
<h3>Installed packages</h3>

{% if venv.installing_packages %}
<p class="italic">This virtual environment is currently installing or upgrading packages. This list may be
incomplete.</p>
Expand Down Expand Up @@ -49,7 +49,7 @@ <h3>Installed packages</h3>
{% endif %}
{% endwith %}
</table>

<h3>Install packages</h3>
{% if venv.installing_packages %}
<p class="italic">
Expand All @@ -72,7 +72,7 @@ <h3>Install packages</h3>
<input type="submit" value="Install packages"{% if venv.installing_packages %} disabled{% endif %}>
</form>
{% endif %}

{% if venv.package_installation_output and not venv.installing_packages %}
<h3>Last package installation output</h3>
<pre><code class="nohljsln">{{ venv.package_installation_output }}</code></pre>
Expand Down

0 comments on commit bc818e5

Please sign in to comment.