Commit 07658055 authored by Michael Murtaugh's avatar Michael Murtaugh

comments listing

parent 5413ab8a
{% extends "rm/base.html" %}
{% load static %}
{% load humanize %}
{% block head %}{% endblock %}
{% block header %}
<style>
div.institutions {
float: right;
}
</style>
{% endblock %}
{% block body %}
<h1>comments</h1>
<div class="institutions">
<h3>Archives</h3>
<ul>
{%for i in institutions %}
<li>{% if i == institution %}<b>{{i.name}} ({{i.items__photos__posts__count}})</b>{% else %}<a href="?i={{i.slug}}">{{i.name}} ({{i.items__photos__posts__count}})</a>{%endif%}</li>
{%endfor%}
{% if institution %}
<li><a href="?">All</a></li>
{% endif %}
</ul>
</div>
{% for post in posts %}
<div class="post">
{{post.text}}
{% if post.file %}<div class="attachment">Attachment:<a href="{{post.file.url}}" target="extern">{{post.file.name}}</a></div>{% endif %}
<span class="time">&mdash;{{post.time|naturaltime}}</span>
<span class="photolink"><a href="{{ post.rephoto.get_default_url }}">{{post.rephoto.item.institution.slug}}-{{post.rephoto.item.code}}</a></span>
{% if user.is_authenticated %}<a class="delete" href="{% url 'post_delete' post.id %}">(delete)</a>{% endif %}
</div>
{% endfor %}
<div class="count">Showing {{posts.count}} comments</div>
{% endblock %}
......@@ -50,5 +50,8 @@ urlpatterns = [
path('leaflet/map.js', views.leaflet_map, name="leaflet-map"),
path('leaflet/tiles.json', views.leaflet_tiles, name="leaflet-tiles"),
path('comments/', views.comments, name="comments"),
# path('media/<path:path>', staticviews.serve, {'media_root': settings.MEDIA_ROOT}),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
......@@ -495,4 +495,17 @@ def leaflet_tiles (request):
def face (request, face_id):
faceobj = get_object_or_404(Face, id=face_id)
return render(request, "rm/face.html", {'face': faceobj})
\ No newline at end of file
return render(request, "rm/face.html", {'face': faceobj})
from django.db.models import Count
def comments (request):
i = request.GET.get("i")
if i:
institution = get_object_or_404(Institution, slug=i)
posts = Post.objects.filter(rephoto__item__institution__slug=i).order_by("-time")
else:
institution = None
posts = Post.objects.order_by("-time")
ii = Institution.objects.order_by("name").annotate(Count('items__photos__posts'))
return render(request, "rm/comments.html", {'posts': posts, 'institutions': ii, 'institution': institution})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment