mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 03:49:24 +00:00
ruff rule DJ
Co-authored-by: Bartuccio Antoine <klmp200@users.noreply.github.com>
This commit is contained in:
@ -141,6 +141,12 @@ class UV(models.Model):
|
||||
default=0,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.code
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("pedagogy:uv_detail", kwargs={"uv_id": self.id})
|
||||
|
||||
def is_owned_by(self, user):
|
||||
"""
|
||||
Can be created by superuser, root or pedagogy admin user
|
||||
@ -160,9 +166,6 @@ class UV(models.Model):
|
||||
|
||||
return int(sum(comments.values_list(field, flat=True)) / comments.count())
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("pedagogy:uv_detail", kwargs={"uv_id": self.id})
|
||||
|
||||
def has_user_already_commented(self, user):
|
||||
"""
|
||||
Help prevent multiples comments from the same user
|
||||
@ -194,9 +197,6 @@ class UV(models.Model):
|
||||
def grade_work_load_average(self):
|
||||
return self.__grade_average_generic("grade_work_load")
|
||||
|
||||
def __str__(self):
|
||||
return self.code
|
||||
|
||||
|
||||
class UVComment(models.Model):
|
||||
"""
|
||||
@ -252,6 +252,14 @@ class UVComment(models.Model):
|
||||
)
|
||||
publish_date = models.DateTimeField(_("publish date"), blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.uv} - {self.author}"
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.publish_date is None:
|
||||
self.publish_date = timezone.now()
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def is_owned_by(self, user):
|
||||
"""
|
||||
Is owned by a pedagogy admin, a superuser or the author himself
|
||||
@ -265,14 +273,6 @@ class UVComment(models.Model):
|
||||
"""
|
||||
return self.reports.exists()
|
||||
|
||||
def __str__(self):
|
||||
return "%s - %s" % (self.uv, self.author)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.publish_date is None:
|
||||
self.publish_date = timezone.now()
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
class UVResult(models.Model):
|
||||
"""
|
||||
@ -303,6 +303,9 @@ class UVResult(models.Model):
|
||||
validators=[validators.RegexValidator("[AP][0-9]{3}")],
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.user.username} ; {self.uv.code} ; {self.grade}"
|
||||
|
||||
|
||||
class UVCommentReport(models.Model):
|
||||
"""
|
||||
@ -323,6 +326,9 @@ class UVCommentReport(models.Model):
|
||||
)
|
||||
reason = models.TextField(_("reason"))
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.reporter.username} : {self.reason}"
|
||||
|
||||
@cached_property
|
||||
def uv(self):
|
||||
return self.comment.uv
|
||||
|
Reference in New Issue
Block a user