Skip to content

Commit

Permalink
Fix pre-commit ci errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Jan 14, 2025
1 parent 725a84a commit 6f5e9e8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 38 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ ignore = [
"PLR09",
# magic number comparison
"PLR2004",
# fixtures not returning anything should have leading underscore
"PT004",
# mutable class attrs annotated as typing.ClassVar
"RUF012",
# missing docstring
Expand Down
30 changes: 15 additions & 15 deletions tin/apps/assignments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class Folder(models.Model):
def __str__(self):
return self.name

def get_absolute_url(self):
return reverse("assignments:show_folder", args=[self.course.id, self.id])

def __repr__(self):
return self.name

def get_absolute_url(self):
return reverse("assignments:show_folder", args=[self.course.id, self.id])


class AssignmentQuerySet(models.query.QuerySet):
def filter_permissions(self, user, *perms: Literal["-", "r", "w"]):
Expand Down Expand Up @@ -186,12 +186,12 @@ class Assignment(models.Model):
def __str__(self):
return self.name

def get_absolute_url(self):
return reverse("assignments:show", args=(self.id,))

def __repr__(self):
return self.name

def get_absolute_url(self):
return reverse("assignments:show", args=(self.id,))

def make_assignment_dir(self) -> None:
"""Creates the directory where the assignment grader scripts go."""
assignment_path = os.path.join(settings.MEDIA_ROOT, f"assignment-{self.id}")
Expand Down Expand Up @@ -445,12 +445,12 @@ class Meta:
def __str__(self):
return f"Quiz for {self.assignment}"

def get_absolute_url(self):
return reverse("assignments:show", args=(self.assignment.id,))

def __repr__(self):
return f"Quiz for {self.assignment}"

def get_absolute_url(self):
return reverse("assignments:show", args=(self.assignment.id,))

def issues_for_student(self, student):
return (
sum(lm.severity for lm in self.assignment.log_messages.filter(student=student))
Expand Down Expand Up @@ -487,12 +487,12 @@ class QuizLogMessage(models.Model):
def __str__(self):
return f"{self.content} for {self.assignment} by {self.student}"

def get_absolute_url(self):
return reverse("assignments:student_submission", args=(self.assignment.id, self.student.id))

def __repr__(self):
return f"{self.content} for {self.assignment} by {self.student}"

def get_absolute_url(self):
return reverse("assignments:student_submission", args=(self.assignment.id, self.student.id))


def moss_base_file_path(obj, _): # pylint: disable=unused-argument
assert obj.assignment.id is not None
Expand Down Expand Up @@ -553,6 +553,9 @@ class MossResult(models.Model):
def __str__(self):
return f"Moss result for {self.assignment}"

def __repr__(self):
return f"Moss result for {self.assignment}"

@property
def extension(self):
return "java" if self.language == "java" else "py"
Expand All @@ -561,9 +564,6 @@ def extension(self):
def download_folder(self):
return os.path.join(settings.MEDIA_ROOT, "moss-runs", f"moss-{self.id}")

def __repr__(self):
return f"Moss result for {self.assignment}"


def run_action(command: list[str]) -> str:
"""Runs a command.
Expand Down
18 changes: 9 additions & 9 deletions tin/apps/courses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ class Course(models.Model):
def __str__(self):
return self.name

def get_absolute_url(self):
return reverse("courses:show", args=[self.id])

def __repr__(self):
return self.name

def get_absolute_url(self):
return reverse("courses:show", args=[self.id])

def get_teacher_str(self) -> str:
"""Get a string of the last names of all teachers in a course"""
return ", ".join(t.last_name for t in self.teacher.all())
Expand Down Expand Up @@ -112,12 +112,12 @@ class Period(models.Model):
def __str__(self):
return self.name

def get_absolute_url(self):
return reverse("courses:students", args=[self.course.id]) + f"?period={self.id}"

def __repr__(self):
return self.name

def get_absolute_url(self):
return reverse("courses:students", args=[self.course.id]) + f"?period={self.id}"


class StudentImportUser(models.Model):
"""A student that is to be added to a course when they log in"""
Expand All @@ -144,12 +144,12 @@ class Meta:
def __str__(self):
return f"Import into {self.course.name}"

def get_absolute_url(self):
return reverse("courses:import_students", args=[self.course.id])

def __repr__(self):
return f"Import into {self.course.name}"

def get_absolute_url(self):
return reverse("courses:import_students", args=[self.course.id])

def queue_users(self, usernames):
"""Add usernames to a queue of students to add to a course"""
for username in usernames:
Expand Down
11 changes: 2 additions & 9 deletions tin/apps/submissions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,11 @@ def __str__(self):
(self.grade_percent if self.has_been_graded else "not graded"),
)

__repr__ = __str__

def get_absolute_url(self):
return reverse("submissions:show", args=[self.id])

def __repr__(self):
return "{}{} [{}]: {} ({})".format(
("[INCOMPLETE] " if not self.complete else ""),
self.student.username,
self.date_submitted.strftime("%Y-%m-%d %H:%M:%S"),
self.assignment.name,
(self.grade_percent if self.has_been_graded else "not graded"),
)

@property
def is_on_time(self):
return self.date_submitted <= self.assignment.due
Expand Down
6 changes: 3 additions & 3 deletions tin/apps/venvs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class Venv(models.Model):
def __str__(self):
return self.name

def get_absolute_url(self):
return reverse("venvs:show", args=[self.id])

def __repr__(self):
return f"<Virtualenv: {self.name}>"

def get_absolute_url(self):
return reverse("venvs:show", args=[self.id])

@property
def path(self):
return os.path.join(settings.MEDIA_ROOT, "venvs", f"venv-{self.id}")
Expand Down

0 comments on commit 6f5e9e8

Please sign in to comment.