Skip to content

Commit

Permalink
user annotations per manifest on collection page
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmundy committed Sep 27, 2019
1 parent 0141823 commit 11430e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 7 additions & 1 deletion apps/readux/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ def get_context_data(self, **kwargs):
context['volumes'] = q.all
context['manifest_query_set'] = q
context['user_annotation'] = UserAnnotation.objects.filter(owner_id=self.request.user.id)
context['user_annotation_count'] = UserAnnotation.objects.filter(owner_id=self.request.user.id).count()
annocount_list = []
for volume in q:
user_annotation_count = UserAnnotation.objects.filter(owner_id=self.request.user.id).filter(canvas__manifest__id=volume.id).count()
annocount_list.append({volume.pid: user_annotation_count})
context['user_annotation_count'] = annocount_list
print(volume.pid)
print(user_annotation_count)
value = 0
context['value'] = value
context.update({
Expand Down
10 changes: 7 additions & 3 deletions apps/templates/collection.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ <h2>{{volumes|length}} volume{{volumes|length|pluralize}} in this collection</h2

<div class="uk-container">
{% for volume in volumes %}


{% if volume.canvas_set.first.pid is null %}
<div><div id="grid"><div id="grid-image-volume">
<img src='{% static 'images/image_not_found.jpg' %}'/>
</div><div id="grid-metaforimage"><p>
{{ volume.label }}
{{ volume.label }} {% if user_annotation_count > 0 %}Anno: {{ user_annotation_count }}{% endif %}
<br/>
Author: {{volume.author}}<br/>
Date: {{volume.published_date}}<br/>
Expand All @@ -42,8 +44,8 @@ <h2>{{volumes|length}} volume{{volumes|length|pluralize}} in this collection</h2
</a>
</div><div id="grid-metaforimage"><p>
<a class="nav-link" href="{% url 'page' volume.pid volume.canvas_set.first.pid %}">
{{ volume.label }}
</a>
{{ volume.label }}
</a> Anno: {% for value in user_annotation_count %}{% if volume.pid in value %}{{ value|safe|slice:"-3:-1" }}{% endif %}{% endfor %}
<!--
{% if volume.volume_annotation_count > 0 %}
<span class="count" title="{{ volume.volume_annotation_count }} annotation{{ volume.volume_annotation_count|pluralize }}">
Expand All @@ -58,6 +60,8 @@ <h2>{{volumes|length}} volume{{volumes|length|pluralize}} in this collection</h2
</div></div>
{% endif %}
{% endfor %}


</div>
</div>
{% endblock content %}

0 comments on commit 11430e6

Please sign in to comment.