summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-09-23 18:15:00 -0500
committerDan McGee <dan@archlinux.org>2010-09-24 19:39:37 -0500
commit1c6099f4b27f31c100b8bfa0d18f439075cceff0 (patch)
tree172405ceeba848ae2c6186febbbd164f6783c287
parent46dec163468f0e53b00b68f5c370b5e7b5e4cfc3 (diff)
Make general mirror list view public
Hide some columns when not logged in because they aren't relevant for the general public, but this will work nicely as a base page for all of our known mirrors. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--devel/views.py7
-rw-r--r--mirrors/models.py3
-rw-r--r--mirrors/views.py6
-rw-r--r--templates/mirrors/mirrors.html (renamed from templates/devel/mirrorlist.html)38
-rw-r--r--urls.py4
5 files changed, 30 insertions, 28 deletions
diff --git a/devel/views.py b/devel/views.py
index c974806e..577a00c4 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -10,7 +10,6 @@ from django.views.generic.simple import direct_to_template
from main.models import Package, Todolist, TodolistPkg
from main.models import Arch, Repo
from main.models import UserProfile
-from mirrors.models import Mirror
from packages.models import PackageRelation
from .utils import get_annotated_maintainers
@@ -79,12 +78,6 @@ def change_profile(request):
form = ProfileForm(initial={'email': request.user.email})
return direct_to_template(request, 'devel/profile.html', {'form': form})
-@login_required
-def mirrorlist(request):
- mirrors = Mirror.objects.select_related().order_by('tier', 'country')
- return direct_to_template(request, 'devel/mirrorlist.html',
- {'mirror_list': mirrors})
-
class NewUserForm(forms.ModelForm):
class Meta:
model = UserProfile
diff --git a/mirrors/models.py b/mirrors/models.py
index 5cab9db6..d8d1a3e5 100644
--- a/mirrors/models.py
+++ b/mirrors/models.py
@@ -27,7 +27,8 @@ class Mirror(models.Model):
return self.name
def supported_protocols(self):
- protocols = MirrorProtocol.objects.filter(urls__mirror=self).distinct()
+ protocols = MirrorProtocol.objects.filter(
+ urls__mirror=self).order_by('protocol').distinct()
return ", ".join([p.protocol for p in protocols])
class MirrorProtocol(models.Model):
diff --git a/mirrors/views.py b/mirrors/views.py
index 5c157894..9380f810 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -70,6 +70,12 @@ def find_mirrors(request, countries=None, protocols=None, use_status=False):
},
mimetype='text/plain')
+def mirrors(request):
+ mirrors = Mirror.objects.select_related().order_by('tier', 'country')
+ if not request.user.is_authenticated():
+ mirrors = mirrors.filter(public=True, active=True)
+ return direct_to_template(request, 'mirrors/mirrors.html',
+ {'mirror_list': mirrors})
def status(request):
bad_timedelta = datetime.timedelta(days=3)
diff --git a/templates/devel/mirrorlist.html b/templates/mirrors/mirrors.html
index 9ae65639..253efe53 100644
--- a/templates/devel/mirrorlist.html
+++ b/templates/mirrors/mirrors.html
@@ -3,38 +3,40 @@
{% block content %}
<div id="dev-mirrorlist" class="box">
-
- <h2>Mirror List</h2>
-
+ <h2>Mirror Overview</h2>
<table class="results">
<thead>
<tr>
<th>Server</th>
<th>Tier</th>
<th>Country</th>
- <th>Admin Email</th>
- <th>Public</th>
- <th>Active</th>
<th>ISOs</th>
<th>Protocols</th>
+ {% if user.is_authenticated %}
+ <th>Public</th>
+ <th>Active</th>
<th>Rsync IPs</th>
+ <th>Admin Email</th>
<th>Notes</th>
+ {% endif %}
</tr>
</thead>
<tbody>
{% for mirror in mirror_list %}
- <tr class="{% cycle 'odd' 'even' %}">
- <td>{{mirror.name}}</td>
- <td>{{mirror.get_tier_display}}</td>
- <td>{{mirror.country}}</td>
- <td>{{mirror.admin_email}}</td>
- <td>{{mirror.public|yesno}}</td>
- <td>{{mirror.active|yesno}}</td>
- <td>{{mirror.isos|yesno}}</td>
- <td class="wrap">{{mirror.supported_protocols}}</td>
- <td>{{mirror.rsync_ips.count}}</td>
- <td class="wrap">{{mirror.notes}}</td>
- </tr>
+ <tr class="{% cycle 'odd' 'even' %}">
+ <td>{{mirror.name}}</td>
+ <td>{{mirror.get_tier_display}}</td>
+ <td>{{mirror.country}}</td>
+ <td>{{mirror.isos|yesno}}</td>
+ <td class="wrap">{{mirror.supported_protocols}}</td>
+ {% if user.is_authenticated %}
+ <td>{{mirror.public|yesno}}</td>
+ <td>{{mirror.active|yesno}}</td>
+ <td class="wrap">{{mirror.rsync_ips.all|join:', '}}</td>
+ <td>{{mirror.admin_email}}</td>
+ <td class="wrap">{{mirror.notes|linebreaks}}</td>
+ {% endif %}
+ </tr>
{% endfor %}
</tbody>
</table>
diff --git a/urls.py b/urls.py
index d754c9af..dde7abba 100644
--- a/urls.py
+++ b/urls.py
@@ -71,8 +71,8 @@ urlpatterns = patterns('',
(r'^news/(?P<slug>[-\w]+)/delete/$', 'news.views.delete'),
(r'^news/$', 'news.views.news_list', {}, 'news-list'),
- (r'^mirrors/$', 'devel.views.mirrorlist', {}, 'mirrors-list'),
- (r'^mirrors/status/$', 'mirrors.views.status', {}, 'mirror-status'),
+ (r'^mirrors/$', 'mirrors.views.mirrors', {}, 'mirrors-list'),
+ (r'^mirrors/status/$', 'mirrors.views.status', {}, 'mirror-status'),
(r'^mirrorlist/$', 'mirrors.views.generate_mirrorlist', {}, 'mirrorlist'),
(r'^mirrorlist/all/$', 'mirrors.views.find_mirrors', {'countries': ['all']}),