diff --git a/ram/bookshelf/admin.py b/ram/bookshelf/admin.py
index 5c297b8..f2d7e70 100644
--- a/ram/bookshelf/admin.py
+++ b/ram/bookshelf/admin.py
@@ -35,6 +35,7 @@ class BookAdmin(SortableAdminBase, admin.ModelAdmin):
"number_of_pages",
"published",
)
+ autocomplete_fields = ("authors", "publisher")
readonly_fields = ("creation_time", "updated_time")
search_fields = ("title", "publisher__name", "authors__last_name")
list_filter = ("publisher__name", "authors")
@@ -101,6 +102,7 @@ class CatalogAdmin(SortableAdminBase, admin.ModelAdmin):
"get_scales",
"published",
)
+ autocomplete_fields = ("manufacturer",)
readonly_fields = ("creation_time", "updated_time")
search_fields = ("manufacturer__name", "years", "scales__scale")
list_filter = ("manufacturer__name", "publication_year", "scales__scale")
diff --git a/ram/bookshelf/migrations/0016_basebook_book_catalogue.py b/ram/bookshelf/migrations/0016_basebook_book_catalogue.py
index 0be21a2..5e44540 100644
--- a/ram/bookshelf/migrations/0016_basebook_book_catalogue.py
+++ b/ram/bookshelf/migrations/0016_basebook_book_catalogue.py
@@ -127,8 +127,6 @@ class Migration(migrations.Migration):
(
"manufacturer",
models.ForeignKey(
- blank=True,
- null=True,
on_delete=django.db.models.deletion.CASCADE,
to="metadata.manufacturer",
),
diff --git a/ram/bookshelf/models.py b/ram/bookshelf/models.py
index 83c32c9..a632bdf 100644
--- a/ram/bookshelf/models.py
+++ b/ram/bookshelf/models.py
@@ -108,15 +108,16 @@ class Book(BaseBook):
return self.publisher.name
def get_absolute_url(self):
- return reverse("book", kwargs={"uuid": self.uuid})
+ return reverse(
+ "bookshelf_item",
+ kwargs={"selector": "book", "uuid": self.uuid}
+ )
class Catalog(BaseBook):
manufacturer = models.ForeignKey(
Manufacturer,
on_delete=models.CASCADE,
- null=True,
- blank=True,
)
years = models.CharField(max_length=12)
scales = models.ManyToManyField(Scale)
@@ -125,8 +126,15 @@ class Catalog(BaseBook):
ordering = ["manufacturer", "publication_year"]
def __str__(self):
- scales = "/".join([s.scale for s in self.scales.all()])
+ scales = self.get_scales
return "%s %s %s" % (self.manufacturer.name, self.years, scales)
def get_absolute_url(self):
- return reverse("catalog", kwargs={"uuid": self.uuid})
+ return reverse(
+ "bookshelf_item",
+ kwargs={"selector": "catalog", "uuid": self.uuid}
+ )
+
+ @property
+ def get_scales(self):
+ return "/".join([s.scale for s in self.scales.all()])
diff --git a/ram/portal/templates/bookshelf/book.html b/ram/portal/templates/bookshelf/book.html
index 23f73fd..4d4fc43 100644
--- a/ram/portal/templates/bookshelf/book.html
+++ b/ram/portal/templates/bookshelf/book.html
@@ -1,4 +1,5 @@
{% extends 'base.html' %}
+{% load dynamic_url %}
{% block header %}
{% if book.tags.all %}
@@ -57,24 +58,39 @@
{{ book.description | safe }}
+ {% if type == "catalog" %}
+
Catalog
+ {% elif type == "book" %}
Book
+ {% endif %}