+ txt = self.title
+ astr = self.authors_str()
+ if astr:
+ txt = f"{astr} – {txt}"
+ tstr = self.translators_str()
+ if tstr:
+ txt = f"{txt} (tłum. {tstr})"
+ return txt
+
+ def get_absolute_url(self):
+ return reverse("catalogue_book", args=[self.slug])
+
+ def authors_str(self):
+ return ", ".join(str(author) for author in self.authors.all())
+
+ def translators_str(self):
+ return ", ".join(str(author) for author in self.translators.all())
+
+ def get_document_books(self):
+ DBook = apps.get_model("documents", "Book")
+ return DBook.objects.filter(dc_slug=self.slug)
+
+
+class Collection(models.Model):
+ name = models.CharField(max_length=255)
+ slug = models.SlugField(max_length=255, unique=True)
+
+ def __str__(self):
+ return self.name