From 53c6fcc07ee1287b7db0f3d266f1691fb91002b6 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Wed, 29 Mar 2023 09:44:58 +0200 Subject: [PATCH] fix ruff --- src/articles/models.py | 10 +++++----- src/attachments/models.py | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/articles/models.py b/src/articles/models.py index ce40c49..db14f93 100644 --- a/src/articles/models.py +++ b/src/articles/models.py @@ -83,6 +83,11 @@ class Article(models.Model): def __str__(self) -> str: return self.title + def save(self, *args: Any, **kwargs: Any) -> None: + if not self.slug: + self.slug = slugify(self.title) + return super().save(*args, **kwargs) + def get_absolute_url(self) -> str: return reverse("article-detail", kwargs={"slug": self.slug}) @@ -117,11 +122,6 @@ class Article(models.Model): self.save() return self - def save(self, *args: Any, **kwargs: Any) -> None: - if not self.slug: - self.slug = slugify(self.title) - return super().save(*args, **kwargs) - @property def draft_public_url(self) -> str: url = self.get_absolute_url() + f"?draft_key={self.draft_key}" diff --git a/src/attachments/models.py b/src/attachments/models.py index 39ca9cf..74d3ac1 100644 --- a/src/attachments/models.py +++ b/src/attachments/models.py @@ -48,20 +48,6 @@ class Attachment(models.Model): def __str__(self) -> str: return f"{self.description} ({self.original_file.name})" - def reprocess(self) -> None: - self.processed_file = None # type: ignore[assignment] - self.save() - - @property - def original_file_url(self) -> str: - return reverse("attachments:original", kwargs={"pk": self.pk}) - - @property - def processed_file_url(self) -> str | None: - if self.processed_file: - return reverse("attachments:processed", kwargs={"pk": self.pk}) - return None - def save(self, *args: Any, **kwargs: Any) -> None: super().save(*args, **kwargs) @@ -136,3 +122,17 @@ class Attachment(models.Model): temp_path.unlink() temp_dir.rmdir() return super().save(*args, **kwargs) + + @property + def original_file_url(self) -> str: + return reverse("attachments:original", kwargs={"pk": self.pk}) + + @property + def processed_file_url(self) -> str | None: + if self.processed_file: + return reverse("attachments:processed", kwargs={"pk": self.pk}) + return None + + def reprocess(self) -> None: + self.processed_file = None # type: ignore[assignment] + self.save()