Browse Source

Fix latest document display on public site

Do not show the latest document but rather the latest non-draft document.

fix #3
Jocelyn Delalande 7 years ago
parent
commit
e484f9d8d3
1 changed files with 5 additions and 5 deletions
  1. 5 5
      publicsite/views.py

+ 5 - 5
publicsite/views.py

@@ -3,15 +3,15 @@ from costs.models import Document
 
 
 def public_document_detail(request, pk=None):
-    if pk is None:
-        doc = Document.objects.order_by('-date').first()
-    else:
-        doc = get_object_or_404(Document, pk=pk)
-
     docs = Document.objects\
                    .filter(type=Document.TYPE_FACT)\
                    .order_by('-date')
 
+    if pk is None:
+        doc = docs.order_by('-date').first()
+    else:
+        doc = get_object_or_404(Document, pk=pk)
+
     return render(request, 'publicsite/public_document_detail.html', {
         'document': doc,
         'documents': docs,