diff --git a/CalibreWebCompanion/library/__pycache__/models.cpython-38.pyc b/CalibreWebCompanion/library/__pycache__/models.cpython-38.pyc index 8b6e950..4daacd3 100644 Binary files a/CalibreWebCompanion/library/__pycache__/models.cpython-38.pyc and b/CalibreWebCompanion/library/__pycache__/models.cpython-38.pyc differ diff --git a/CalibreWebCompanion/library/__pycache__/urls.cpython-38.pyc b/CalibreWebCompanion/library/__pycache__/urls.cpython-38.pyc index e3f0bc4..9f84413 100644 Binary files a/CalibreWebCompanion/library/__pycache__/urls.cpython-38.pyc and b/CalibreWebCompanion/library/__pycache__/urls.cpython-38.pyc differ diff --git a/CalibreWebCompanion/library/__pycache__/views.cpython-38.pyc b/CalibreWebCompanion/library/__pycache__/views.cpython-38.pyc index 3bc74bc..8fe7e25 100644 Binary files a/CalibreWebCompanion/library/__pycache__/views.cpython-38.pyc and b/CalibreWebCompanion/library/__pycache__/views.cpython-38.pyc differ diff --git a/CalibreWebCompanion/library/models.py b/CalibreWebCompanion/library/models.py index 0943333..d4a0545 100644 --- a/CalibreWebCompanion/library/models.py +++ b/CalibreWebCompanion/library/models.py @@ -174,9 +174,9 @@ class Book(models.Model): title = models.TextField() sort = models.TextField(blank=True, null=True) # This field type is a guess. - timestamp = models.TextField(blank=True, null=True) + timestamp = models.DateTimeField(blank=True, null=True) # This field type is a guess. - pubdate = models.TextField(blank=True, null=True) + pubdate = models.DateTimeField(blank=True, null=True) series_index = models.FloatField() author_sort = models.TextField(blank=True, null=True) isbn = models.TextField(blank=True, null=True) @@ -185,7 +185,7 @@ class Book(models.Model): flags = models.IntegerField() uuid = models.TextField(blank=True, null=True) has_cover = models.BooleanField(blank=True, null=True) - last_modified = models.TextField() # This field type is a guess. + last_modified = models.DateTimeField() # This field type is a guess. authors = models.ManyToManyField( Author, through='BookAuthorLink', diff --git a/CalibreWebCompanion/library/templates/base.html b/CalibreWebCompanion/library/templates/base.html index 02f5c14..1dbb70d 100644 --- a/CalibreWebCompanion/library/templates/base.html +++ b/CalibreWebCompanion/library/templates/base.html @@ -59,12 +59,19 @@ + + + {% else %}
  • Sign up
  • Login
  • diff --git a/CalibreWebCompanion/library/templates/library/book_list.html b/CalibreWebCompanion/library/templates/library/book_list.html index c05a32d..0750391 100644 --- a/CalibreWebCompanion/library/templates/library/book_list.html +++ b/CalibreWebCompanion/library/templates/library/book_list.html @@ -16,6 +16,7 @@ Rating Tags Added + Published {% for book in book_list %} @@ -30,7 +31,8 @@ {{tag}}, {% endfor %} - {{book.timestamp}} + {{book.timestamp | timesince}} ago + {{book.pubdate.year}} {% endfor %} diff --git a/CalibreWebCompanion/library/templates/library/series_detail.html b/CalibreWebCompanion/library/templates/library/series_detail.html new file mode 100644 index 0000000..f824015 --- /dev/null +++ b/CalibreWebCompanion/library/templates/library/series_detail.html @@ -0,0 +1,38 @@ +{% extends "base.html" %} + +{% block content %} + +

    {{Series}}

    + + + + + + + + + + + + {% for book in books %} + + + + + + + + {% endfor %} +
    TitleAuthorRatingTagsAdded
    {{ book.title }}{{book.author_sort}} {% for rating in book.rating.all %} + {{rating}} + {% endfor %} + + {% for tag in book.tags.all %} + {{tag}}, + {% endfor %} + {{book.timestamp}}
    + + + + +{% endblock %} \ No newline at end of file diff --git a/CalibreWebCompanion/library/templates/library/series_list.html b/CalibreWebCompanion/library/templates/library/series_list.html new file mode 100644 index 0000000..c2060e0 --- /dev/null +++ b/CalibreWebCompanion/library/templates/library/series_list.html @@ -0,0 +1,17 @@ +{% extends "base.html" %} + +{% block content %} + +

    Author List

    + {% if series_list %} + + {% else %} +

    There are no series in the library.

    + {% endif %} +{% endblock %} \ No newline at end of file diff --git a/CalibreWebCompanion/library/urls.py b/CalibreWebCompanion/library/urls.py index 6a5e2a1..5271440 100644 --- a/CalibreWebCompanion/library/urls.py +++ b/CalibreWebCompanion/library/urls.py @@ -9,11 +9,14 @@ urlpatterns = [ path('publishers/', views.PublisherListView.as_view(), name='publishers'), path('ratings/', views.RatingListView.as_view(), name='ratings'), path('tags/', views.TagListView.as_view(), name='tags'), + path('series/', views.SeriesListView.as_view(), name='series'), + path('author/', views.AuthorDetailView.as_view(), name='author-detail-view'), path('book/', views.BookDetailView.as_view(), name='book-detail-view'), path('publisher/', views.PublisherDetailView.as_view(), name='publisher-detail-view'), path('rating/', views.RatingDetailView.as_view(), name='rating-detail-view'), + path('series/', views.SeriesDetailView.as_view(), name='series-detail-view'), path('tag/', views.TagDetailView.as_view(), name='tag-detail-view'), path('results/', views.ResultsView.as_view(), name='results'), diff --git a/CalibreWebCompanion/library/views.py b/CalibreWebCompanion/library/views.py index 271e4be..146e306 100644 --- a/CalibreWebCompanion/library/views.py +++ b/CalibreWebCompanion/library/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render from django.views import generic -from .models import Author, Book, Comment, Rating, BookAuthorLink, Publisher, Tag, BookTagLink, BookRatingLink, Data, Identifier +from .models import Author, Book, Comment, Rating, BookAuthorLink, Publisher, Tag, BookTagLink, BookRatingLink, Data, Identifier, Series from django.http import HttpResponseRedirect from .forms import SearchForm, UserCreationForm from django.db import models @@ -79,6 +79,9 @@ class PublisherListView(generic.ListView): class RatingListView(generic.ListView): model = Rating +class SeriesListView(generic.ListView): # make url entry and template, sometime + model = Series + class TagListView(generic.ListView): model = Tag @@ -152,3 +155,15 @@ class TagDetailView(generic.DetailView): books = books.filter(tags=context["object"].id) context['books'] = sorted(books, key=lambda x: x.title) return context + +class SeriesDetailView(generic.DetailView): + model = Series + + def get_context_data(self, **kwargs): + # Call the base implementation first to get the context + context = super(SeriesDetailView, self).get_context_data(**kwargs) + # Create any data and add it to the context + books = Book.objects.prefetch_related("tags", "ratings") + books = books.filter(series=context["object"].id) + context['books'] = sorted(books, key=lambda x: x.title) + return context \ No newline at end of file