summaryrefslogtreecommitdiffstats
path: root/mirrors
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-09-24 01:50:56 +0200
committerDan McGee <dan@archlinux.org>2010-09-25 02:39:37 +0200
commitbc5a5781bf43f81ab266bf258d4ab8bf16c9b2d0 (patch)
treedfdf1c2b1a0ad35da80d48bd614f0ae90b0c389c /mirrors
parent1c6099f4b27f31c100b8bfa0d18f439075cceff0 (diff)
downloadarchweb-bc5a5781bf43f81ab266bf258d4ab8bf16c9b2d0.tar.gz
archweb-bc5a5781bf43f81ab266bf258d4ab8bf16c9b2d0.tar.xz
Add a basic mirror details page
Still some work to do here, but this covers the basics of the public view we can show for mirrors and their associated data. The upstream and downstream links should be working OK to aid navigation, but right now we have some potential dead links for non-authenticated users if they click a link to a "private" mirror. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors')
-rw-r--r--mirrors/models.py6
-rw-r--r--mirrors/views.py11
2 files changed, 17 insertions, 0 deletions
diff --git a/mirrors/models.py b/mirrors/models.py
index d8d1a3e..8542330 100644
--- a/mirrors/models.py
+++ b/mirrors/models.py
@@ -31,6 +31,12 @@ class Mirror(models.Model):
urls__mirror=self).order_by('protocol').distinct()
return ", ".join([p.protocol for p in protocols])
+ def downstream(self):
+ return Mirror.objects.filter(upstream=self).order_by('name')
+
+ def get_absolute_url(self):
+ return '/mirrors/%s/' % self.name
+
class MirrorProtocol(models.Model):
protocol = models.CharField(max_length=10, unique=True)
def __unicode__(self):
diff --git a/mirrors/views.py b/mirrors/views.py
index 9380f81..34385a9 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -1,6 +1,8 @@
from django import forms
from django.db.models import Avg, Count, Max, Min, StdDev
from django.db.models import Q
+from django.http import Http404
+from django.shortcuts import get_object_or_404
from django.views.decorators.csrf import csrf_exempt
from django.views.generic.simple import direct_to_template
@@ -77,6 +79,15 @@ def mirrors(request):
return direct_to_template(request, 'mirrors/mirrors.html',
{'mirror_list': mirrors})
+def mirror_details(request, name):
+ mirror = get_object_or_404(Mirror, name=name)
+ if not request.user.is_authenticated() and \
+ (not mirror.public or not mirror.active):
+ # TODO: maybe this should be 403? but that would leak existence
+ raise Http404
+ return direct_to_template(request, 'mirrors/mirror_details.html',
+ {'mirror': mirror})
+
def status(request):
bad_timedelta = datetime.timedelta(days=3)
status_info = get_mirror_statuses()