summaryrefslogtreecommitdiff
path: root/mirrors
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-12-15 13:22:41 -0600
committerDan McGee <dan@archlinux.org>2013-12-15 13:28:13 -0600
commit79aef280ddf0c704fd40d0077822a8ff7548437e (patch)
tree706e88b3e072402feeb1baee7e6cbaa658226aeb /mirrors
parent3c7b02753a4f742eeb66b8deea2fc3f179b87b8e (diff)
Add mirror URL details page
This will allow those that care about mirrors to zoom into URL-level details for each mirror and examine the individual check results. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors')
-rw-r--r--mirrors/models.py2
-rw-r--r--mirrors/urls.py1
-rw-r--r--mirrors/views.py19
3 files changed, 22 insertions, 0 deletions
diff --git a/mirrors/models.py b/mirrors/models.py
index d2c64c51..57664562 100644
--- a/mirrors/models.py
+++ b/mirrors/models.py
@@ -161,6 +161,8 @@ class MirrorLog(models.Model):
error = models.TextField(blank=True, default='')
def delay(self):
+ if self.last_sync is None:
+ return None
# sanity check, this shouldn't happen
if self.check_time < self.last_sync:
return timedelta()
diff --git a/mirrors/urls.py b/mirrors/urls.py
index 7cf76aa1..b1054380 100644
--- a/mirrors/urls.py
+++ b/mirrors/urls.py
@@ -9,6 +9,7 @@ urlpatterns = patterns('mirrors.views',
(r'^locations/json/$', 'locations_json', {}, 'mirror-locations-json'),
(r'^(?P<name>[\.\-\w]+)/$', 'mirror_details'),
(r'^(?P<name>[\.\-\w]+)/json/$', 'mirror_details_json'),
+ (r'^(?P<name>[\.\-\w]+)/(?P<url_id>\d+)/$', 'url_details'),
)
# vim: set ts=4 sw=4 et:
diff --git a/mirrors/views.py b/mirrors/views.py
index 9e05e5fc..b2e75b25 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -186,6 +186,7 @@ def mirror_details(request, name):
}
return render(request, 'mirrors/mirror_details.html', context)
+
def mirror_details_json(request, name):
authorized = request.user.is_authenticated()
mirror = get_object_or_404(Mirror, name=name)
@@ -199,6 +200,24 @@ def mirror_details_json(request, name):
return response
+def url_details(request, name, url_id):
+ url = get_object_or_404(MirrorUrl, id=url_id, mirror__name=name)
+ mirror = url.mirror
+ authorized = request.user.is_authenticated()
+ if not authorized and \
+ (not mirror.public or not mirror.active or not url.active):
+ raise Http404
+ error_cutoff = timedelta(days=7)
+ cutoff_time = now() - error_cutoff
+ logs = MirrorLog.objects.filter(url=url, check_time__gte=cutoff_time).order_by('-check_time')
+
+ context = {
+ 'url': url,
+ 'logs': logs,
+ }
+ return render(request, 'mirrors/url_details.html', context)
+
+
def status(request, tier=None):
if tier is not None:
tier = int(tier)