summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mirrors/models.py6
-rw-r--r--mirrors/views.py11
-rw-r--r--templates/mirrors/mirror_details.html58
-rw-r--r--templates/mirrors/mirrors.html3
-rw-r--r--urls.py1
5 files changed, 78 insertions, 1 deletions
diff --git a/mirrors/models.py b/mirrors/models.py
index d8d1a3e5..85423303 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 9380f810..34385a98 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()
diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html
new file mode 100644
index 00000000..90baa75d
--- /dev/null
+++ b/templates/mirrors/mirror_details.html
@@ -0,0 +1,58 @@
+{% extends "base.html" %}
+
+{% block title %}Arch Linux - {{ mirror.name }} - Mirror Details{% endblock %}
+
+{% block content %}
+<!-- TODO: ids and classes -->
+<div id="pkgdetails" class="box">
+
+ <h2>Mirror Details: {{ mirror.name }}</h2>
+
+ <table id="pkginfo">
+ <tr>
+ <th>Name:</th>
+ <td>{{ mirror.name }}</td>
+ </tr><tr>
+ <th>Tier:</th>
+ <td>{{ mirror.get_tier_display }}</td>
+ </tr><tr>
+ <th>Upstream:</th>
+ <!-- TODO: linking to non-public mirrors -->
+ <td>{% if mirror.upstream %}
+ <a href="{{ mirror.upstream.get_absolute_url }}"
+ title="Mirror details for {{ mirror.upstream.name }}">{{ mirror.upstream.name }}</a>
+ {% else %}None{% endif %}</td>
+ </tr><tr>
+ <th>Downstream:</th>
+ {% with mirror.downstream as ds_mirrors %}
+ <td>{% if ds_mirrors %}
+ {% for ds in ds_mirrors %}
+ <a href="{{ ds.get_absolute_url }}"
+ title="Mirror details for {{ ds.name }}">{{ ds.name }}</a><br/>
+ {% endfor %}
+ {% else %}None{% endif %}
+ </td>
+ {% endwith %}
+ </tr><tr>
+ <th>Country:</th>
+ <td>{{ mirror.country }}</td>
+ </tr><tr>
+ <th>Has ISOs:</th>
+ <td>{{ mirror.isos|yesno }}</td>
+ </tr><tr>
+ <th>Protocols:</th>
+ <td>{{ mirror.supported_protocols }}</td>
+ </tr><tr>
+ <th>Mirror URLs:</th>
+ {% with mirror.urls.all as urls %}
+ <td>{% if urls %}
+ {% for u in urls %}
+ <a href="{{ u.url }}">{{ u.url }}</a><br/>
+ {% endfor %}
+ {% else %}None{% endif %}
+ </td>
+ {% endwith %}
+ </tr>
+ </table>
+</div>
+{% endblock %}
diff --git a/templates/mirrors/mirrors.html b/templates/mirrors/mirrors.html
index 253efe53..56f23db5 100644
--- a/templates/mirrors/mirrors.html
+++ b/templates/mirrors/mirrors.html
@@ -24,7 +24,8 @@
<tbody>
{% for mirror in mirror_list %}
<tr class="{% cycle 'odd' 'even' %}">
- <td>{{mirror.name}}</td>
+ <td><a href="{{ mirror.get_absolute_url }}"
+ title="Mirror details for {{ mirror.name }}">{{ mirror.name }}</a></td>
<td>{{mirror.get_tier_display}}</td>
<td>{{mirror.country}}</td>
<td>{{mirror.isos|yesno}}</td>
diff --git a/urls.py b/urls.py
index dde7abba..5c792035 100644
--- a/urls.py
+++ b/urls.py
@@ -73,6 +73,7 @@ urlpatterns = patterns('',
(r'^mirrors/$', 'mirrors.views.mirrors', {}, 'mirrors-list'),
(r'^mirrors/status/$', 'mirrors.views.status', {}, 'mirror-status'),
+ (r'^mirrors/(?P<name>[\.\-\w]+)/$', 'mirrors.views.mirror_details'),
(r'^mirrorlist/$', 'mirrors.views.generate_mirrorlist', {}, 'mirrorlist'),
(r'^mirrorlist/all/$', 'mirrors.views.find_mirrors', {'countries': ['all']}),