diff --git a/CalibreWebCompanion/library/admin.py b/CalibreWebCompanion/library/admin.py
index 69776b3..282586e 100644
--- a/CalibreWebCompanion/library/admin.py
+++ b/CalibreWebCompanion/library/admin.py
@@ -1,16 +1,16 @@
from django.contrib import admin
-from .models import Authors, Books, Languages, Publishers, Series, Tags
+from .models import Author, Book, Language, Publisher, Series, Tag
# Register your models here.
-@admin.register(Authors)
+@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
list_display = (["name"])
-@admin.register(Languages)
+@admin.register(Language)
class LanguageAdmin(admin.ModelAdmin):
list_display = (["id", "lang_code"])
-@admin.register(Publishers)
+@admin.register(Publisher)
class PublisherAdmin(admin.ModelAdmin):
list_display = (["id","name"])
@@ -18,10 +18,10 @@ class PublisherAdmin(admin.ModelAdmin):
class SeriesAdmin(admin.ModelAdmin):
list_display = (["id","name"])
-@admin.register(Tags)
+@admin.register(Tag)
class TagAdmin(admin.ModelAdmin):
list_display = (["id","name"])
-@admin.register(Books)
+@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
list_display = (["id","title", "author_sort"])
\ No newline at end of file
diff --git a/CalibreWebCompanion/library/calibredb.py b/CalibreWebCompanion/library/calibredb.py
deleted file mode 100644
index a0cdb7c..0000000
--- a/CalibreWebCompanion/library/calibredb.py
+++ /dev/null
@@ -1,107 +0,0 @@
-from sqlalchemy import create_engine
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy.orm import sessionmaker
-engine = create_engine('sqlite:///C://Users//MassiveAtoms//Documents//Calibre Library//metadata.db.', echo=True)
-Base = declarative_base(engine)
-########################################################################
-
-class Author(Base): # needed
- """"""
- __tablename__ = 'authors'
- __table_args__ = {'autoload':True}
- # has int id, text name, sort
-
-class Comment(Base): # needed
- """"""
- __tablename__ = 'comments'
- __table_args__ = {'autoload':True}
- # has int id, int book, text text
-
-# class Data(Base): # maybe
-# """"""
-# __tablename__ = 'data'
-# __table_args__ = {'autoload':True}
-# # has int id, int book, text format, text name
-
-class Identifier(Base): # needed
- """"""
- __tablename__ = 'identifiers'
- __table_args__ = {'autoload':True}
- # has int id, int book, text value
-
-class Publisher(Base): # needed
- """"""
- __tablename__ = 'publishers'
- __table_args__ = {'autoload':True}
- # has int id, text name
-
-class Rating(Base): # needed
- """"""
- __tablename__ = 'ratings'
- __table_args__ = {'autoload':True}
- # has int id, int rating
-
-class Series(Base): # needed
- """"""
- __tablename__ = 'series'
- __table_args__ = {'autoload':True}
- # has int id, text name
-
-class Tag(Base): # needed
- """"""
- __tablename__ = 'tags'
- __table_args__ = {'autoload':True}
- # has int id, text name
-
-class Book(Base): # needed
- """"""
- __tablename__ = 'books'
- __table_args__ = {'autoload':True}
- # has int id, text title, text sort, time timestamp, time pubdate,
- # float series_index, text path
-
-class Book_author_link(Base): # needed
- """"""
- __tablename__ = 'books_authors_link'
- __table_args__ = {'autoload':True}
- # has int id, id book, id author
-
-class Book_publisher_link(Base): # needed
- """"""
- __tablename__ = 'books_publishers_link'
- __table_args__ = {'autoload':True}
- # has int id, id book, id publisher
-
-class Book_rating_link(Base): # needed
- """"""
- __tablename__ = 'books_ratings_link'
- __table_args__ = {'autoload':True}
- # has int id, id book, id rating
-
-class Book_series_link(Base): # needed
- """"""
- __tablename__ = 'books_series_link'
- __table_args__ = {'autoload':True}
- # has int id, id book, id series
-
-class Book_tags_link(Base): # needed
- """"""
- __tablename__ = 'books_tags_link'
- __table_args__ = {'autoload':True}
- # has int id, id book, id tag
-
-
-#----------------------------------------------------------------------
-def loadSession():
- """"""
- metadata = Base.metadata
- Session = sessionmaker(bind=engine)
- session = Session()
- return session
-
-if __name__ == "__main__":
- session = loadSession()
- res = session.query(Book).all()
- for i in res:
- print(i.id, i.title, i.sort, i.timestamp, i.pubdate, i.series_index, i.path)
-
diff --git a/CalibreWebCompanion/library/context_processors.py b/CalibreWebCompanion/library/context_processors.py
index b523dfc..bee6b0f 100644
--- a/CalibreWebCompanion/library/context_processors.py
+++ b/CalibreWebCompanion/library/context_processors.py
@@ -1,12 +1,12 @@
-from .models import Authors, Tags, Publishers, Languages, Ratings, Series
+from .models import Author, Tag, Publisher, Language, Rating, Series
def filters(request):
- unique_authors = Authors.objects.all().order_by('sort')
- unique_tags = Tags.objects.all().order_by('name')
- unique_publishers = Publishers.objects.all().order_by('name')
- unique_languages = Languages.objects.all()
- unique_ratings = Ratings.objects.all().order_by('rating')
+ unique_authors = Author.objects.all().order_by('sort')
+ unique_tags = Tag.objects.all().order_by('name')
+ unique_publishers = Publisher.objects.all().order_by('name')
+ unique_languages = Language.objects.all()
+ unique_ratings = Rating.objects.all().order_by('rating')
unique_series = Series.objects.all().order_by('sort')
return {
diff --git a/CalibreWebCompanion/library/models.py b/CalibreWebCompanion/library/models.py
index a9177c9..757f43b 100644
--- a/CalibreWebCompanion/library/models.py
+++ b/CalibreWebCompanion/library/models.py
@@ -9,7 +9,7 @@ from django.db import models
from django.urls import reverse
-class Authors(models.Model):
+class Author(models.Model):
name = models.TextField()
sort = models.TextField(blank=True, null=True)
link = models.TextField()
@@ -28,8 +28,8 @@ class Authors(models.Model):
-class Comments(models.Model):
- book = models.ForeignKey("Books", db_column="book", on_delete=models.CASCADE)
+class Comment(models.Model):
+ book = models.ForeignKey("Book", db_column="book", on_delete=models.CASCADE)
text = models.TextField()
@@ -57,7 +57,7 @@ class Data(models.Model):
]
-class Identifiers(models.Model):
+class Identifier(models.Model):
book = models.IntegerField()
type = models.TextField()
val = models.TextField()
@@ -71,7 +71,7 @@ class Identifiers(models.Model):
db_table = 'identifiers'
-class Languages(models.Model):
+class Language(models.Model):
lang_code = models.TextField()
def get_absolute_url(self):
@@ -90,12 +90,12 @@ class Languages(models.Model):
]
-class Publishers(models.Model):
+class Publisher(models.Model):
name = models.TextField()
sort = models.TextField(blank=True, null=True)
released = models.ManyToManyField(
- "Books",
- through='BooksPublishersLink',
+ "Book",
+ through='BookPublisherLink',
through_fields=('publisher', 'book'),
related_name="released"
)
@@ -116,7 +116,7 @@ class Publishers(models.Model):
]
-class Ratings(models.Model):
+class Rating(models.Model):
rating = models.IntegerField(blank=True, null=True)
def get_absolute_url(self):
"""Returns the url to access a particular instance of MyModelName."""
@@ -151,7 +151,7 @@ class Series(models.Model):
]
-class Tags(models.Model):
+class Tag(models.Model):
name = models.TextField()
def get_absolute_url(self):
"""Returns the url to access a particular instance of MyModelName."""
@@ -169,7 +169,7 @@ class Tags(models.Model):
]
-class Books(models.Model):
+class Book(models.Model):
title = models.TextField()
sort = models.TextField(blank=True, null=True)
# This field type is a guess.
@@ -186,28 +186,28 @@ class Books(models.Model):
has_cover = models.BooleanField(blank=True, null=True)
last_modified = models.TextField() # This field type is a guess.
authors = models.ManyToManyField(
- Authors,
- through='BooksAuthorsLink',
+ Author,
+ through='BookAuthorLink',
through_fields=('book', 'author'))
languages = models.ManyToManyField(
- Languages,
- through='BooksLanguagesLink',
+ Language,
+ through='BookLanguageLink',
through_fields=('book', 'lang_code'))
publishers = models.ManyToManyField(
- Publishers,
- through='BooksPublishersLink',
+ Publisher,
+ through='BookPublisherLink',
through_fields=('book', 'publisher'))
series = models.ManyToManyField(
Series,
- through='BooksSeriesLink',
+ through='BookSeriesLink',
through_fields=('book', 'series'))
tags = models.ManyToManyField(
- Tags,
- through='BooksTagsLink',
+ Tag,
+ through='BookTagLink',
through_fields=('book', 'tag'))
ratings = models.ManyToManyField(
- Ratings,
- through='BooksRatingsLink',
+ Rating,
+ through='BookRatingLink',
through_fields=('book', 'rating'))
def get_absolute_url(self):
"""Returns the url to access a particular instance of MyModelName."""
@@ -226,10 +226,10 @@ class Books(models.Model):
]
-class BooksAuthorsLink(models.Model):
- book = models.ForeignKey(Books, db_column="book", on_delete=models.CASCADE)
+class BookAuthorLink(models.Model):
+ book = models.ForeignKey(Book, db_column="book", on_delete=models.CASCADE)
author = models.ForeignKey(
- Authors, db_column="author", on_delete=models.CASCADE)
+ Author, db_column="author", on_delete=models.CASCADE)
class Meta:
managed = False
@@ -240,10 +240,10 @@ class BooksAuthorsLink(models.Model):
]
-class BooksLanguagesLink(models.Model):
- book = models.ForeignKey(Books, db_column="book", on_delete=models.CASCADE)
+class BookLanguageLink(models.Model):
+ book = models.ForeignKey(Book, db_column="book", on_delete=models.CASCADE)
lang_code = models.ForeignKey(
- Languages, db_column="lang_code", on_delete=models.CASCADE)
+ Language, db_column="lang_code", on_delete=models.CASCADE)
item_order = models.IntegerField()
class Meta:
@@ -256,10 +256,10 @@ class BooksLanguagesLink(models.Model):
]
-class BooksPublishersLink(models.Model):
- book = models.ForeignKey(Books, db_column="book", on_delete=models.CASCADE)
+class BookPublisherLink(models.Model):
+ book = models.ForeignKey(Book, db_column="book", on_delete=models.CASCADE)
publisher = models.ForeignKey(
- Publishers, db_column="publisher", on_delete=models.CASCADE)
+ Publisher, db_column="publisher", on_delete=models.CASCADE)
class Meta:
managed = False
@@ -271,18 +271,18 @@ class BooksPublishersLink(models.Model):
]
-class BooksRatingsLink(models.Model): # TODO add this somehow
- book = models.ForeignKey(Books, db_column="book", on_delete=models.CASCADE)
+class BookRatingLink(models.Model): # TODO add this somehow
+ book = models.ForeignKey(Book, db_column="book", on_delete=models.CASCADE)
rating = models.ForeignKey(
- Ratings, db_column="rating", on_delete=models.CASCADE)
+ Rating, db_column="rating", on_delete=models.CASCADE)
class Meta:
managed = False
db_table = 'books_ratings_link'
-class BooksSeriesLink(models.Model):
- book = models.ForeignKey(Books, db_column="book", on_delete=models.CASCADE)
+class BookSeriesLink(models.Model):
+ book = models.ForeignKey(Book, db_column="book", on_delete=models.CASCADE)
series = models.ForeignKey(
Series, db_column="series", on_delete=models.CASCADE)
@@ -295,9 +295,9 @@ class BooksSeriesLink(models.Model):
]
-class BooksTagsLink(models.Model):
- book = models.ForeignKey(Books, db_column="book", on_delete=models.CASCADE)
- tag = models.ForeignKey(Tags, db_column="tag", on_delete=models.CASCADE)
+class BookTagLink(models.Model):
+ book = models.ForeignKey(Book, db_column="book", on_delete=models.CASCADE)
+ tag = models.ForeignKey(Tag, db_column="tag", on_delete=models.CASCADE)
class Meta:
managed = False
@@ -308,7 +308,7 @@ class BooksTagsLink(models.Model):
]
-# class BooksPluginData(models.Model):
+# class BookPluginData(models.Model):
# book = models.IntegerField()
# name = models.TextField()
# val = models.TextField()
diff --git a/CalibreWebCompanion/library/templates/library/authors_detail.html b/CalibreWebCompanion/library/templates/library/author_detail.html
similarity index 97%
rename from CalibreWebCompanion/library/templates/library/authors_detail.html
rename to CalibreWebCompanion/library/templates/library/author_detail.html
index 85ca59c..bfdeac7 100644
--- a/CalibreWebCompanion/library/templates/library/authors_detail.html
+++ b/CalibreWebCompanion/library/templates/library/author_detail.html
@@ -2,7 +2,7 @@
{% block content %}
{% load static %}
-
{{authors}}
+{{author}}
diff --git a/CalibreWebCompanion/library/templates/library/authors_list.html b/CalibreWebCompanion/library/templates/library/author_list.html
similarity index 70%
rename from CalibreWebCompanion/library/templates/library/authors_list.html
rename to CalibreWebCompanion/library/templates/library/author_list.html
index 2da171f..be14c9a 100644
--- a/CalibreWebCompanion/library/templates/library/authors_list.html
+++ b/CalibreWebCompanion/library/templates/library/author_list.html
@@ -3,15 +3,15 @@
{% block content %}
{% load static %}
Author List
- {% if authors_list %}
+ {% if author_list %}
- {% for author in authors_list %}
+ {% for author in author_list %}
-
{{ author.name }}
{% endfor %}
{% else %}
- There are no authors in the library.
+ There are no author in the library.
{% endif %}
{% endblock %}
\ No newline at end of file
diff --git a/CalibreWebCompanion/library/templates/library/books_detail.html b/CalibreWebCompanion/library/templates/library/book_detail.html
similarity index 63%
rename from CalibreWebCompanion/library/templates/library/books_detail.html
rename to CalibreWebCompanion/library/templates/library/book_detail.html
index 9265b46..851133f 100644
--- a/CalibreWebCompanion/library/templates/library/books_detail.html
+++ b/CalibreWebCompanion/library/templates/library/book_detail.html
@@ -2,19 +2,19 @@
{% block content %}
{% load static %}
-{{books.title}} by
- {% if books.authors %}
- {% for author in books.authors.all %}
+{{book.title}} by
+ {% if book.authors %}
+ {% for author in book.authors.all %}
{{author.name}}
{%endfor%}
{% else %}
- {{books.author_sort}}
+ {{book.author_sort}}
{%endif%}
Published by
- {% if books.publishers %}
- {% for pub in books.publishers.all %}
+ {% if book.publishers %}
+ {% for pub in book.publishers.all %}
{{pub.name}}
{%endfor%}
{% else %}
@@ -23,16 +23,16 @@
{%endif%}
Tags:
- {% if books.tags %}
- {% for tag in books.tags.all %}
+ {% if book.tags %}
+ {% for tag in book.tags.all %}
{{tag.name}},
{%endfor%}
{% else %}
{%endif%}
Rating:
- {% if books.ratings %}
- {% for rating in books.ratings.all %}
+ {% if book.ratings %}
+ {% for rating in book.ratings.all %}
{{rating}}
{%endfor%}
{% else %}
@@ -40,8 +40,11 @@
{{book.publisher}}
-{{comment}}
-
+
+
+{% autoescape off %}
+{{comment}}
+{% endautoescape %}
{% endblock %}
\ No newline at end of file
diff --git a/CalibreWebCompanion/library/templates/library/books_list.html b/CalibreWebCompanion/library/templates/library/book_list.html
similarity index 96%
rename from CalibreWebCompanion/library/templates/library/books_list.html
rename to CalibreWebCompanion/library/templates/library/book_list.html
index 147c59a..e281bcb 100644
--- a/CalibreWebCompanion/library/templates/library/books_list.html
+++ b/CalibreWebCompanion/library/templates/library/book_list.html
@@ -13,7 +13,7 @@
Tags |
Added |
- {% for book in books_list %}
+ {% for book in book_list %}
{{ book.title }} |
{{book.author_sort}} |
diff --git a/CalibreWebCompanion/library/templates/library/publishers_detail.html b/CalibreWebCompanion/library/templates/library/publisher_detail.html
similarity index 90%
rename from CalibreWebCompanion/library/templates/library/publishers_detail.html
rename to CalibreWebCompanion/library/templates/library/publisher_detail.html
index ff23d0b..0e9f161 100644
--- a/CalibreWebCompanion/library/templates/library/publishers_detail.html
+++ b/CalibreWebCompanion/library/templates/library/publisher_detail.html
@@ -2,9 +2,9 @@
{% block content %}
{% load static %}
-{{publishers}}
+{{publisher}}
-{% if publishers.released %}
+{% if publisher.released %}
@@ -14,7 +14,7 @@
Tags |
Added |
- {% for book in publishers.released.all %}
+ {% for book in publisher.released.all %}
{{ book.title }} |
{{book.author_sort}} |
diff --git a/CalibreWebCompanion/library/templates/library/publishers_list.html b/CalibreWebCompanion/library/templates/library/publisher_list.html
similarity index 69%
rename from CalibreWebCompanion/library/templates/library/publishers_list.html
rename to CalibreWebCompanion/library/templates/library/publisher_list.html
index a9557be..e1e92e4 100644
--- a/CalibreWebCompanion/library/templates/library/publishers_list.html
+++ b/CalibreWebCompanion/library/templates/library/publisher_list.html
@@ -3,15 +3,15 @@
{% block content %}
{% load static %}
Publishers List
- {% if publishers_list %}
+ {% if publisher_list %}
- {% for publisher in publishers_list %}
+ {% for publisher in publisher_list %}
-
{{ publisher.name }}
{% endfor %}
{% else %}
- There are no publishers in the library.
+ There are no publisher in the library.
{% endif %}
{% endblock %}
\ No newline at end of file
diff --git a/CalibreWebCompanion/library/templates/library/ratings_detail.html b/CalibreWebCompanion/library/templates/library/rating_detail.html
similarity index 92%
rename from CalibreWebCompanion/library/templates/library/ratings_detail.html
rename to CalibreWebCompanion/library/templates/library/rating_detail.html
index d1b6c4e..e2ccc5f 100644
--- a/CalibreWebCompanion/library/templates/library/ratings_detail.html
+++ b/CalibreWebCompanion/library/templates/library/rating_detail.html
@@ -3,7 +3,7 @@
{% block content %}
{% load static %}
-{{ratings}}
+{{rating}}
{% if books %}
@@ -18,7 +18,7 @@
{{ book.title }} |
{{book.author_sort}} |
- {% for rating in book.ratings.all %}
+ | {% for rating in book.rating.all %}
{{rating}}
{% endfor %}
|
diff --git a/CalibreWebCompanion/library/templates/library/ratings_list.html b/CalibreWebCompanion/library/templates/library/rating_list.html
similarity index 70%
rename from CalibreWebCompanion/library/templates/library/ratings_list.html
rename to CalibreWebCompanion/library/templates/library/rating_list.html
index b4d09f4..c3db6fb 100644
--- a/CalibreWebCompanion/library/templates/library/ratings_list.html
+++ b/CalibreWebCompanion/library/templates/library/rating_list.html
@@ -3,15 +3,15 @@
{% block content %}
{% load static %}
Ratings List
- {% if ratings_list %}
+ {% if rating_list %}
- {% for rating in ratings_list %}
+ {% for rating in rating_list %}
-
{{ rating.rating }}
{% endfor %}
{% else %}
- There are no ratings in the library.
+ There are no rating in the library.
{% endif %}
{% endblock %}
\ No newline at end of file
diff --git a/CalibreWebCompanion/library/templates/library/tags_detail.html b/CalibreWebCompanion/library/templates/library/tag_detail.html
similarity index 93%
rename from CalibreWebCompanion/library/templates/library/tags_detail.html
rename to CalibreWebCompanion/library/templates/library/tag_detail.html
index 662baa1..f997b61 100644
--- a/CalibreWebCompanion/library/templates/library/tags_detail.html
+++ b/CalibreWebCompanion/library/templates/library/tag_detail.html
@@ -3,7 +3,7 @@
{% block content %}
{% load static %}
-{{tags}}
+{{tag}}
{% if books %}
@@ -23,7 +23,7 @@
{% endfor %}
- {% for tag in book.tags.all %}
+ {% for tag in book.tag.all %}
{{tag}},
{% endfor %}
|
diff --git a/CalibreWebCompanion/library/templates/library/tags_list.html b/CalibreWebCompanion/library/templates/library/tag_list.html
similarity index 72%
rename from CalibreWebCompanion/library/templates/library/tags_list.html
rename to CalibreWebCompanion/library/templates/library/tag_list.html
index 7d26ee9..d85ddb7 100644
--- a/CalibreWebCompanion/library/templates/library/tags_list.html
+++ b/CalibreWebCompanion/library/templates/library/tag_list.html
@@ -3,15 +3,15 @@
{% block content %}
{% load static %}
Tags List
- {% if tags_list %}
+ {% if tag_list %}
- {% for tag in tags_list %}
+ {% for tag in tag_list %}
-
{{ tag.name }}
{% endfor %}
{% else %}
- There are no tags in the library.
+ There are no tag in the library.
{% endif %}
{% endblock %}
\ No newline at end of file
diff --git a/CalibreWebCompanion/library/templatetags/__init__.py b/CalibreWebCompanion/library/templatetags/__init__.py
deleted file mode 100644
index 3eaef43..0000000
--- a/CalibreWebCompanion/library/templatetags/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from . import custom
\ No newline at end of file
diff --git a/CalibreWebCompanion/library/templatetags/custom.py b/CalibreWebCompanion/library/templatetags/custom.py
deleted file mode 100644
index 3662f74..0000000
--- a/CalibreWebCompanion/library/templatetags/custom.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from django import template
-from ..models import Books
-
-register = template.Library
-print("I ACTUALLY CAME HEReEe")
-
-@register.simple_tag
-def dummy():
- return Books.objects.count()
\ No newline at end of file
diff --git a/CalibreWebCompanion/library/views.py b/CalibreWebCompanion/library/views.py
index 8c4a891..c785d89 100644
--- a/CalibreWebCompanion/library/views.py
+++ b/CalibreWebCompanion/library/views.py
@@ -1,68 +1,72 @@
from django.shortcuts import render
from django.views import generic
-from .models import Authors, Books, Comments, Ratings, BooksAuthorsLink, Publishers, Tags, BooksTagsLink, BooksRatingsLink, Data
+from .models import Author, Book, Comment, Rating, BookAuthorLink, Publisher, Tag, BookTagLink, BookRatingLink, Data
from django.http import HttpResponseRedirect
from .forms import SearchForm
from django.db import models
from django.db.models import Q
+
class SearchView(generic.TemplateView):
template_name = 'search.html'
-class ResultsView(generic.ListView): # no clue if this is secure.
- # according to this https://stackoverflow.com/questions/13574043/how-do-django-forms-sanitize-text-input-to-prevent-sql-injection-xss-etc
+
+class ResultsView(generic.ListView): # no clue if this is secure.
+ # according to this https://stackoverflow.com/questions/13574043/how-do-django-forms-sanitize-text-input-to-prevent-sql-injection-xss-etc
# it is
- model = Books
+ model = Book
template_name = 'results.html'
- def get_queryset(self): # new
+
+ def get_queryset(self): # new
title = self.request.GET.get('title')
author = self.request.GET.get('author')
- return Books.objects.filter(
+ return Book.objects.filter(
Q(sort__icontains=title) and Q(author_sort__icontains=author)
)
+
class AuthorListView(generic.ListView):
- model = Authors
+ model = Author
class BookListView(generic.ListView):
- model = Books
+ model = Book
class PublisherListView(generic.ListView):
- model = Publishers
+ model = Publisher
class RatingListView(generic.ListView):
- model = Ratings
+ model = Rating
class TagListView(generic.ListView):
- model = Tags
+ model = Tag
class AuthorDetailView(generic.DetailView):
- model = Authors
+ model = Author
def get_context_data(self, **kwargs):
# Call the base implementation first to get the context
context = super(AuthorDetailView, self).get_context_data(**kwargs)
# Create any data and add it to the context
- books = BooksAuthorsLink.objects.filter(author=context["object"].id)
- context['books'] = context['books'] = sorted(
+ books = BookAuthorLink.objects.filter(author=context["object"].id)
+ context['books'] = sorted(
[b.book for b in books.all()], key=lambda x: x.title)
return context
class BookDetailView(generic.DetailView):
- model = Books
+ model = Book
def get_context_data(self, **kwargs):
# Call the base implementation first to get the context
context = super(BookDetailView, self).get_context_data(**kwargs)
# Create any data and add it to the context
try:
- context['comment'] = Comments.objects.get(
+ context['comment'] = Comment.objects.get(
book=context["object"].id).text
except:
pass
@@ -73,30 +77,30 @@ class BookDetailView(generic.DetailView):
class PublisherDetailView(generic.DetailView):
- model = Publishers
+ model = Publisher
class RatingDetailView(generic.DetailView):
- model = Ratings
+ model = Rating
def get_context_data(self, **kwargs):
# Call the base implementation first to get the context
context = super(RatingDetailView, self).get_context_data(**kwargs)
# Create any data and add it to the context
- books = BooksRatingsLink.objects.filter(rating=context["object"].id)
+ books = BookRatingLink.objects.filter(rating=context["object"].id)
context['books'] = sorted(
[b.book for b in books.all()], key=lambda x: x.title)
return context
class TagDetailView(generic.DetailView):
- model = Tags
+ model = Tag
def get_context_data(self, **kwargs):
# Call the base implementation first to get the context
context = super(TagDetailView, self).get_context_data(**kwargs)
# Create any data and add it to the context
- books = BooksTagsLink.objects.filter(tag=context["object"].id)
+ books = BookTagLink.objects.filter(tag=context["object"].id)
context['books'] = sorted(
[b.book for b in books.all()], key=lambda x: x.title)
return context