From 1c6099f4b27f31c100b8bfa0d18f439075cceff0 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 23 Sep 2010 18:15:00 -0500 Subject: 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 --- devel/views.py | 7 ------ mirrors/models.py | 3 ++- mirrors/views.py | 6 +++++ templates/devel/mirrorlist.html | 49 --------------------------------------- templates/mirrors/mirrors.html | 51 +++++++++++++++++++++++++++++++++++++++++ urls.py | 4 ++-- 6 files changed, 61 insertions(+), 59 deletions(-) delete mode 100644 templates/devel/mirrorlist.html create mode 100644 templates/mirrors/mirrors.html 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 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 @@ def __unicode__(self): 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/devel/mirrorlist.html deleted file mode 100644 index 9ae65639..00000000 --- a/templates/devel/mirrorlist.html +++ /dev/null @@ -1,49 +0,0 @@ -{% extends "base.html" %} -{% block title %}Arch Linux - Mirror Overview{% endblock %} - -{% block content %} -
- -

Mirror List

- - - - - - - - - - - - - - - - - - {% for mirror in mirror_list %} - - - - - - - - - - - - - {% endfor %} - -
ServerTierCountryAdmin EmailPublicActiveISOsProtocolsRsync IPsNotes
{{mirror.name}}{{mirror.get_tier_display}}{{mirror.country}}{{mirror.admin_email}}{{mirror.public|yesno}}{{mirror.active|yesno}}{{mirror.isos|yesno}}{{mirror.supported_protocols}}{{mirror.rsync_ips.count}}{{mirror.notes}}
-
-{% load cdn %}{% jquery %} - - -{% endblock %} diff --git a/templates/mirrors/mirrors.html b/templates/mirrors/mirrors.html new file mode 100644 index 00000000..253efe53 --- /dev/null +++ b/templates/mirrors/mirrors.html @@ -0,0 +1,51 @@ +{% extends "base.html" %} +{% block title %}Arch Linux - Mirror Overview{% endblock %} + +{% block content %} +
+

Mirror Overview

+ + + + + + + + + {% if user.is_authenticated %} + + + + + + {% endif %} + + + + {% for mirror in mirror_list %} + + + + + + + {% if user.is_authenticated %} + + + + + + {% endif %} + + {% endfor %} + +
ServerTierCountryISOsProtocolsPublicActiveRsync IPsAdmin EmailNotes
{{mirror.name}}{{mirror.get_tier_display}}{{mirror.country}}{{mirror.isos|yesno}}{{mirror.supported_protocols}}{{mirror.public|yesno}}{{mirror.active|yesno}}{{mirror.rsync_ips.all|join:', '}}{{mirror.admin_email}}{{mirror.notes|linebreaks}}
+
+{% load cdn %}{% jquery %} + + +{% endblock %} diff --git a/urls.py b/urls.py index d754c9af..dde7abba 100644 --- a/urls.py +++ b/urls.py @@ -71,8 +71,8 @@ (r'^news/(?P[-\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']}), -- cgit v1.2.3-54-g00ecf