setup skeleton page for bookshelf

adam
aundus 2020-12-20 15:05:51 -05:00
parent 6add1abaed
commit b3692810b6
7 changed files with 30 additions and 1 deletions

View File

@ -4,4 +4,11 @@ from .models import Bookshelf, Book, BookshelfToBook
admin.site.register(Bookshelf)
admin.site.register(Book)
admin.site.register(BookshelfToBook)
# admin.site.register(BookshelfToBook)
class TemplateAdmin(admin.ModelAdmin):
change_form_template = 'mgmt/templates/bookshelves.html'
admin.site.register(BookshelfToBook, TemplateAdmin)

View File

@ -0,0 +1,2 @@
{% extends "mgmt/base_site.html" %}
{% block title %}Test page{% endblock %}

View File

@ -0,0 +1,8 @@
from .models import Book, Bookshelf, BookshelfToBook
from django.http import HttpResponse
def booksInBookshelf(request, bookshelfId):
idList = BookshelfToBook.objects.filter(fk_bookshelves=bookshelfId).values_list('fk_books', flat=True)
books = Book.objects.filter(id__in=idList)
return HttpResponse(books)

View File

@ -15,7 +15,19 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path
from django.conf.urls import url
from bookshelf_management.apps.mgmt import views
urlpatterns = [
path('admin/', admin.site.urls),
path('bookshelves/<int:bookshelfId>', views.booksInBookshelf, name='detail')
]
# class CustomAdminSite(admin.AdminSite):
# def get_urls(self):
# urls = super(CustomAdminSite, self).get_urls()
# custom_urls = [
# url('admin/bookshelves$',
# self.admin_view(organization_admin.preview), name="preview"),
# ]
# return urls + custom_urls