summaryrefslogtreecommitdiff
path: root/mirrors
diff options
context:
space:
mode:
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)