summaryrefslogtreecommitdiffstats
path: root/mirrors
diff options
context:
space:
mode:
Diffstat (limited to 'mirrors')
-rw-r--r--mirrors/urls.py1
-rw-r--r--mirrors/views.py8
2 files changed, 8 insertions, 1 deletions
diff --git a/mirrors/urls.py b/mirrors/urls.py
index 857e99e..4e92941 100644
--- a/mirrors/urls.py
+++ b/mirrors/urls.py
@@ -5,6 +5,7 @@ urlpatterns = patterns('mirrors.views',
(r'^status/$', 'status', {}, 'mirror-status'),
(r'^status/json/$', 'status_json', {}, 'mirror-status-json'),
(r'^status/tier/(?P<tier>\d+)/$', 'status', {}, 'mirror-status-tier'),
+ (r'^status/tier/(?P<tier>\d+)/json/$', 'status_json', {}, 'mirror-status-tier-json'),
(r'^(?P<name>[\.\-\w]+)/$', 'mirror_details'),
(r'^(?P<name>[\.\-\w]+)/json/$', 'mirror_details_json'),
)
diff --git a/mirrors/views.py b/mirrors/views.py
index 30df547..c0ed667 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -279,9 +279,15 @@ class ExtendedMirrorStatusJSONEncoder(MirrorStatusJSONEncoder):
return super(ExtendedMirrorStatusJSONEncoder, self).default(obj)
-def status_json(request):
+def status_json(request, tier=None):
+ if tier is not None:
+ tier = int(tier)
+ if tier not in [t[0] for t in Mirror.TIER_CHOICES]:
+ raise Http404
status_info = get_mirror_statuses()
data = status_info.copy()
+ if tier is not None:
+ data['urls'] = [url for url in data['urls'] if url.mirror.tier == tier]
data['version'] = 3
to_json = json.dumps(data, ensure_ascii=False, cls=MirrorStatusJSONEncoder)
response = HttpResponse(to_json, content_type='application/json')