fixed some templating issues
This commit is contained in:
parent
f13132d0c7
commit
5a83ccfc07
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -7,6 +7,7 @@
|
|||||||
# Feel free to rename the models, but don't rename db_table values or field names.
|
# Feel free to rename the models, but don't rename db_table values or field names.
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
|
|
||||||
class Author(models.Model):
|
class Author(models.Model):
|
||||||
@ -224,9 +225,9 @@ class Book(models.Model):
|
|||||||
through='BookRatingLink',
|
through='BookRatingLink',
|
||||||
through_fields=('book', 'rating'))
|
through_fields=('book', 'rating'))
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def rating(self):
|
def rating(self):
|
||||||
return self.rating.first()
|
return self.ratings.first()
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
"""Returns the url to access a particular instance of MyModelName."""
|
"""Returns the url to access a particular instance of MyModelName."""
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<ul id="dropdown-tags" class="dropdown-content">
|
<ul id="dropdown-tags" class="dropdown-content">
|
||||||
{% for tag in unique_tags %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@ -113,7 +113,8 @@
|
|||||||
<p>You don't have permission to view this.</p>
|
<p>You don't have permission to view this.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-action center">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></td>
|
<td><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></td>
|
||||||
<td>{{book.author_sort}}</td>
|
<td>{{book.author_sort}}</td>
|
||||||
<td> {% for rating in book.ratings.all %}
|
<td>
|
||||||
|
{% for rating in book.ratings.all %}
|
||||||
{{rating}}
|
{{rating}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
|
@ -17,9 +17,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></td>
|
<td><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></td>
|
||||||
<td>{{book.author_sort}}</td>
|
<td>{{book.author_sort}}</td>
|
||||||
<td> {% for rating in book.rating.all %}
|
<td>
|
||||||
{{rating}}
|
{{rating}}
|
||||||
{% endfor %}
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% for tag in book.tags.all %}
|
{% for tag in book.tags.all %}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% for tag in book.tag.all %}
|
{% for tag in book.tags.all %}
|
||||||
{{tag}},
|
{{tag}},
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user