Add Catalogs views, but still need to fix templates (use books for now)

This commit is contained in:
2024-11-29 23:43:36 +01:00
parent 1a3b30ace3
commit 83444266cb
6 changed files with 58 additions and 7 deletions

View File

@@ -15,7 +15,7 @@ from portal.utils import get_site_conf
from portal.models import Flatpage
from roster.models import RollingStock
from consist.models import Consist
from bookshelf.models import Book
from bookshelf.models import Book, Catalog
from metadata.models import (
Company,
Manufacturer,
@@ -536,6 +536,34 @@ class GetBook(View):
)
class Catalogs(GetData):
title = "Catalogs"
item_type = "book"
def get_data(self, request):
return Catalog.objects.get_published(request.user).all()
class GetCatalog(View):
def get(self, request, uuid):
try:
catalog = Catalog.objects.get_published(request.user).get(uuid=uuid)
except ObjectDoesNotExist:
raise Http404
catalog_properties = catalog.property.get_public(request.user)
return render(
request,
"bookshelf/book.html",
{
"title": catalog,
"catalog_properties": catalog_properties,
"book": catalog,
},
)
class GetFlatpage(View):
def get(self, request, flatpage):
try: