fixed some templating issues

This commit is contained in:
MassiveAtoms 2020-07-14 19:48:54 -03:00
parent f13132d0c7
commit 5a83ccfc07
8 changed files with 11 additions and 9 deletions

Binary file not shown.

View File

@ -7,6 +7,7 @@
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models
from django.urls import reverse
from django.utils.functional import cached_property
class Author(models.Model):
@ -224,9 +225,9 @@ class Book(models.Model):
through='BookRatingLink',
through_fields=('book', 'rating'))
@property
@cached_property
def rating(self):
return self.rating.first()
return self.ratings.first()
def get_absolute_url(self):
"""Returns the url to access a particular instance of MyModelName."""

View File

@ -79,7 +79,7 @@
</ul>
<ul id="dropdown-tags" class="dropdown-content">
{% for tag in unique_tags %}
<li><a href="{{tag.get_absolute_url}}">{{tag}}</a></li>
<li><a href="{{tag.get_absolute_url}}">{{tag}} ({{tag.num_books}})</a></li>
{% endfor %}
</ul>
@ -110,10 +110,11 @@
<div class="col s12 m6 offset-m3">
<div class="card">
<div class="card-content center">
<p>You don't have permission to view this.</p>
<p>You don't have permission to view this.</p>
</div>
<div class="card-action center">
<a class="waves-effect waves-light btn-large green accent-4" href="{% url 'login'%}?next={{request.path}}">Login</a>
<a class="waves-effect waves-light btn-large green accent-4"
href="{% url 'login'%}?next={{request.path}}">Login</a>
</div>
</div>
</div>

View File

@ -17,7 +17,8 @@
<tr>
<td><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></td>
<td>{{book.author_sort}}</td>
<td> {% for rating in book.ratings.all %}
<td>
{% for rating in book.ratings.all %}
{{rating}}
{% endfor %}
</td>

View File

@ -17,9 +17,8 @@
<tr>
<td><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></td>
<td>{{book.author_sort}}</td>
<td> {% for rating in book.rating.all %}
<td>
{{rating}}
{% endfor %}
</td>
<td>
{% for tag in book.tags.all %}

View File

@ -22,7 +22,7 @@
{% endfor %}
</td>
<td>
{% for tag in book.tag.all %}
{% for tag in book.tags.all %}
{{tag}},
{% endfor %}
</td>