From 4e872235010b1b7ad8cb6912b9e3ccf4c39a352d Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 10 May 2013 17:52:36 -0500 Subject: Simplify with statements by using new syntax Signed-off-by: Dan McGee --- templates/mirrors/status.html | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/templates/mirrors/status.html b/templates/mirrors/status.html index 283ff681..a3da1ad6 100644 --- a/templates/mirrors/status.html +++ b/templates/mirrors/status.html @@ -59,19 +59,15 @@

Mirror Status{% if tier != None %} - Tier {{ tier }}{% endif %}

Out of Sync Mirrors

- {% with bad_urls as urls %} - {% with 'outofsync_mirrors' as table_id %} + {% with urls=bad_urls table_id='outofsync_mirrors' %} {% include "mirrors/status_table.html" %} {% endwith %} - {% endwith %}

Successfully Syncing Mirrors

- {% with good_urls as urls %} - {% with 'successful_mirrors' as table_id %} + {% with urls=good_urls table_id='successful_mirrors' %} {% include "mirrors/status_table.html" %} {% endwith %} - {% endwith %}

Mirror Syncing Error Log

-- cgit v1.2.3-54-g00ecf From 76be96ac2c11604a2bfceed4212b686719620b13 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 10 May 2013 17:59:53 -0500 Subject: Pull mirror error table into inclusion template Signed-off-by: Dan McGee --- templates/mirrors/error_table.html | 23 +++++++++++++++++++++++ templates/mirrors/status.html | 24 +----------------------- templates/mirrors/status_table.html | 3 +-- 3 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 templates/mirrors/error_table.html diff --git a/templates/mirrors/error_table.html b/templates/mirrors/error_table.html new file mode 100644 index 00000000..6054814f --- /dev/null +++ b/templates/mirrors/error_table.html @@ -0,0 +1,23 @@ +{% load flags mirror_status %} + + + + + + + + + + + + + {% for log in error_logs %} + + + + + + + {% endfor %} + +
Mirror URLProtocolCountryError MessageLast OccurredOccurrences (last {{ cutoff|hours }})
{{ log.url__url }}{{ log.url__protocol__protocol }}{% country_flag log.country %}{{ log.country.name }}{{ log.error|linebreaksbr }}{{ log.last_occurred|date:'Y-m-d H:i' }}{{ log.error_count }}
diff --git a/templates/mirrors/status.html b/templates/mirrors/status.html index a3da1ad6..331c18ee 100644 --- a/templates/mirrors/status.html +++ b/templates/mirrors/status.html @@ -71,29 +71,7 @@

Successfully Syncing Mirrors

Mirror Syncing Error Log

- - - - - - - - - - - - - {% for log in error_logs %} - - - - - - - {% endfor %} - -
Mirror URLProtocolCountryError MessageLast OccurredOccurrences (last {{ cutoff|hours }})
{{ log.url__url }}{{ log.url__protocol__protocol }}{% country_flag log.country %}{{ log.country.name }}{{ log.error|linebreaksbr }}{{ log.last_occurred|date:'Y-m-d H:i' }}{{ log.error_count }}
- + {% include "mirrors/error_table.html" %} {% endblock %} diff --git a/templates/mirrors/status_table.html b/templates/mirrors/status_table.html index e848a9c9..28175420 100644 --- a/templates/mirrors/status_table.html +++ b/templates/mirrors/status_table.html @@ -1,5 +1,4 @@ -{% load mirror_status %} -{% load flags %} +{% load flags mirror_status %} -- cgit v1.2.3-54-g00ecf From 8097a1fdeff36fb3db521a3b354ea8bf576869cc Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 10 May 2013 18:10:04 -0500 Subject: Add mirror error logs to mirror details page Give a window of 7 days for logs here rather than the default 24 hours we do on the main status page since we are only retrieving details for a single mirror with a handful of URLs. This should make it easier to have all information regarding one mirror in a single location. Signed-off-by: Dan McGee --- mirrors/views.py | 11 +++++++++-- templates/mirrors/mirror_details.html | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mirrors/views.py b/mirrors/views.py index 73d40297..d1dd9da3 100644 --- a/mirrors/views.py +++ b/mirrors/views.py @@ -175,6 +175,7 @@ def mirror_details(request, name): if not request.user.is_authenticated() and \ (not mirror.public or not mirror.active): raise Http404 + error_cutoff = timedelta(days=7) status_info = get_mirror_statuses(mirror_id=mirror.id) checked_urls = {url for url in status_info['urls'] \ @@ -188,9 +189,15 @@ def mirror_details(request, name): 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}) + error_logs = get_mirror_errors(mirror_id=mirror.id, cutoff=error_cutoff) + context = { + 'mirror': mirror, + 'urls': all_urls, + 'cutoff': error_cutoff, + 'error_logs': error_logs, + } + return render(request, 'mirrors/mirror_details.html', context) def mirror_details_json(request, name): mirror = get_object_or_404(Mirror, name=name) diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html index d3e85b00..6f0ac6c1 100644 --- a/templates/mirrors/mirror_details.html +++ b/templates/mirrors/mirror_details.html @@ -106,6 +106,9 @@

Available URLs

{% endfor %}
+ +

Error Log

+ {% include "mirrors/error_table.html" %}
-- cgit v1.2.3-54-g00ecf