fix ruff
This commit is contained in:
parent
fe08c9cca9
commit
53c6fcc07e
2 changed files with 19 additions and 19 deletions
|
@ -83,6 +83,11 @@ class Article(models.Model):
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.title
|
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:
|
def get_absolute_url(self) -> str:
|
||||||
return reverse("article-detail", kwargs={"slug": self.slug})
|
return reverse("article-detail", kwargs={"slug": self.slug})
|
||||||
|
|
||||||
|
@ -117,11 +122,6 @@ class Article(models.Model):
|
||||||
self.save()
|
self.save()
|
||||||
return self
|
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
|
@property
|
||||||
def draft_public_url(self) -> str:
|
def draft_public_url(self) -> str:
|
||||||
url = self.get_absolute_url() + f"?draft_key={self.draft_key}"
|
url = self.get_absolute_url() + f"?draft_key={self.draft_key}"
|
||||||
|
|
|
@ -48,20 +48,6 @@ class Attachment(models.Model):
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"{self.description} ({self.original_file.name})"
|
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:
|
def save(self, *args: Any, **kwargs: Any) -> None:
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
@ -136,3 +122,17 @@ class Attachment(models.Model):
|
||||||
temp_path.unlink()
|
temp_path.unlink()
|
||||||
temp_dir.rmdir()
|
temp_dir.rmdir()
|
||||||
return super().save(*args, **kwargs)
|
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()
|
||||||
|
|
Reference in a new issue