summaryrefslogtreecommitdiff
path: root/mirrors
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2014-01-11 13:37:12 -0600
committerDan McGee <dan@archlinux.org>2014-01-11 13:37:12 -0600
commitfe37b46c50b60a8302e70ccef3ab34306fd8ea39 (patch)
tree9f713ff22724c2306a6f74af7fbca21cdbea8440 /mirrors
parent3827215fa3335f8da3c82d4d098eb402b6d29dbc (diff)
Add a 'last_modified' function for mirror status pagesrelease_2014-01-11
We can use this on both the HTML and JSON views of this data to prevent recomputation for smart clients that respect the modified date header. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors')
-rw-r--r--mirrors/views.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/mirrors/views.py b/mirrors/views.py
index 34336165..5429cea2 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -11,6 +11,7 @@ from django.http import Http404, HttpResponse
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.timezone import now
from django.views.decorators.csrf import csrf_exempt
+from django.views.decorators.http import condition
from django_countries.countries import COUNTRIES
from .models import (Mirror, MirrorUrl, MirrorProtocol, MirrorLog,
@@ -220,6 +221,11 @@ def url_details(request, name, url_id):
return render(request, 'mirrors/url_details.html', context)
+def status_last_modified(request, *args, **kwargs):
+ return MirrorLog.objects.values_list('check_time', flat=True).latest()
+
+
+@condition(last_modified_func=status_last_modified)
def status(request, tier=None):
if tier is not None:
tier = int(tier)
@@ -297,6 +303,7 @@ class ExtendedMirrorStatusJSONEncoder(MirrorStatusJSONEncoder):
return super(ExtendedMirrorStatusJSONEncoder, self).default(obj)
+@condition(last_modified_func=status_last_modified)
def status_json(request, tier=None):
if tier is not None:
tier = int(tier)