This commit is contained in:
MassiveAtoms 2020-07-15 12:20:35 -03:00
parent d57f677bd3
commit 14f14a2f33
10 changed files with 101 additions and 8 deletions

View File

@ -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',

View File

@ -59,12 +59,19 @@
<ul class="left">
<li><a href="{% url 'books' %}">Books</a></li>
<li><a class="dropdown-trigger" href="#!" data-target="dropdown-authors">Authors<i
<li><a class="dropdown-trigger" href={% url 'authors' %} data-target="dropdown-authors">Authors<i
class="material-icons right">arrow_drop_down</i></a></li>
<li><a class="dropdown-trigger" href="#!" data-target="dropdown-ratings">Ratings<i
<li><a class="dropdown-trigger" href={% url "ratings" %} data-target="dropdown-ratings">Ratings<i
class="material-icons right">arrow_drop_down</i></a></li>
<li><a class="dropdown-trigger" href="#!" data-target="dropdown-tags">Tags<i
<li><a class="dropdown-trigger" href={% url "tags" %} data-target="dropdown-tags">Tags<i
class="material-icons right">arrow_drop_down</i></a></li>
<li><a class="dropdown-trigger" href={% url "series" %} data-target="dropdown-series">Series<i
class="material-icons right">arrow_drop_down</i></a></li>
<li><a class="dropdown-trigger" href={% url "publishers" %} data-target="dropdown-pubishers">Publishers<i
class="material-icons right">arrow_drop_down</i></a></li>
<li><a href="{% url 'search' %}">Advanced search</a></li>
<li>
<!-- stefan, this div. can we have this int the navbar? -->
@ -94,6 +101,17 @@
{% endfor %}
</ul>
<ul id="dropdown-series" class="dropdown-content">
{% for tag in unique_series %}
<li><a href="{{tag.get_absolute_url}}">{{tag}} ({{tag.num_books}})</a></li>
{% endfor %}
</ul>
<ul id="dropdown-pubishers" class="dropdown-content">
{% for pub in unique_publishers %}
<li><a href="{{pub.get_absolute_url}}">{{pub}} ({{pub.num_books}})</a></li>
{% endfor %}
</ul>
{% else %}
<li><a href="{% url 'sign-up'%}?next={{request.path}}">Sign up</a></li>
<li><a href="{% url 'login'%}?next={{request.path}}">Login</a></li>

View File

@ -16,6 +16,7 @@
<th class="rating" onclick="sortTable(2)">Rating</th>
<th class="tags" onclick="sortTable(3)">Tags</th>
<th class="added" onclick="sortTable(4)">Added</th>
<th class="added" onclick="sortTable(5)">Published</th>
</tr>
{% for book in book_list %}
<tr>
@ -30,7 +31,8 @@
{{tag}},
{% endfor %}
</td>
<td>{{book.timestamp}}</td>
<td>{{book.timestamp | timesince}} ago</td> <!-- YES, very good sorting here.... // DEBUG fix js so it can sort this -->
<td>{{book.pubdate.year}}</td>
</tr>
{% endfor %}
</table>

View File

@ -0,0 +1,38 @@
{% extends "base.html" %}
{% block content %}
<h1>{{Series}} </h1>
<table id="books" class="highlight centered">
<tr>
<!--When a header is clicked, run the sortTable function, with a parameter, 0 for sorting by names, 1 for sorting by country:-->
<th class="title" onclick="sortTable(0)">Title</th>
<th class="author" onclick="sortTable(1)">Author</th>
<th class="rating" onclick="sortTable(2)">Rating</th>
<th class="tags" onclick="sortTable(3)">Tags</th>
<th class="added" onclick="sortTable(4)">Added</th>
</tr>
{% for book in books %}
<tr>
<td><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></td>
<td>{{book.author_sort}}</td>
<td> {% for rating in book.rating.all %}
{{rating}}
{% endfor %}
</td>
<td>
{% for tag in book.tags.all %}
{{tag}},
{% endfor %}
</td>
<td>{{book.timestamp}}</td>
</tr>
{% endfor %}
</table>
{% endblock %}

View File

@ -0,0 +1,17 @@
{% extends "base.html" %}
{% block content %}
<h1>Author List</h1>
{% if series_list %}
<ul>
{% for series in series_list %}
<li>
<a href="{{ series.get_absolute_url }}">{{ series.name }}</a>
</li>
{% endfor %}
</ul>
{% else %}
<p>There are no series in the library.</p>
{% endif %}
{% endblock %}

View File

@ -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/<int:pk>', views.AuthorDetailView.as_view(), name='author-detail-view'),
path('book/<int:pk>', views.BookDetailView.as_view(), name='book-detail-view'),
path('publisher/<int:pk>', views.PublisherDetailView.as_view(), name='publisher-detail-view'),
path('rating/<int:pk>', views.RatingDetailView.as_view(), name='rating-detail-view'),
path('series/<int:pk>', views.SeriesDetailView.as_view(), name='series-detail-view'),
path('tag/<int:pk>', views.TagDetailView.as_view(), name='tag-detail-view'),
path('results/', views.ResultsView.as_view(), name='results'),

View File

@ -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