summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-01-14 08:27:34 +0100
committerDan McGee <dan@archlinux.org>2013-01-14 08:27:34 +0100
commitff6db38f1dc6ed1eb53454a7e16615ec1ad76d7a (patch)
treebbb8cf15d4499566de879682e1521d2dde325f29
parent6f0ae6746baea657ee6d7c21ac0813a04f825443 (diff)
downloadarchweb-ff6db38f1dc6ed1eb53454a7e16615ec1ad76d7a.tar.gz
archweb-ff6db38f1dc6ed1eb53454a7e16615ec1ad76d7a.tar.xz
Ensure URLs without check data work on mirror details page
Less noticeable in production as the templates don't show '@@@INVALID@@@' there, but we were trying to access attributes that don't actually exist on certain mirror objects. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--mirrors/views.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/mirrors/views.py b/mirrors/views.py
index 545e355..30df547 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -176,13 +176,17 @@ def mirror_details(request, name):
raise Http404
status_info = get_mirror_statuses(mirror_ids=[mirror.id])
- checked_urls = [url for url in status_info['urls'] \
- if url.mirror_id == mirror.id]
- all_urls = mirror.urls.select_related('protocol')
- # get each item from checked_urls and supplement with anything in all_urls
- # if it wasn't there
- all_urls = set(checked_urls).union(all_urls)
- all_urls = sorted(all_urls, key=attrgetter('url'))
+ checked_urls = {url for url in status_info['urls'] \
+ if url.mirror_id == mirror.id}
+ all_urls = set(mirror.urls.select_related('protocol'))
+ # Add dummy data for URLs that we haven't checked recently
+ other_urls = all_urls.difference(checked_urls)
+ print other_urls
+ for url in other_urls:
+ for attr in ('last_sync', 'completion_pct', 'delay', 'duration_avg',
+ 'duration_stddev', 'score'):
+ setattr(url, attr, None)
+ all_urls = sorted(checked_urls.union(other_urls), key=attrgetter('url'))
return render(request, 'mirrors/mirror_details.html',
{'mirror': mirror, 'urls': all_urls})