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(-) (limited to 'templates') 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 (limited to 'templates') 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(-) (limited to 'templates') 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 From dad70d0d7c70e7973cd9e3960b24e7f9ef883c61 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 10 May 2013 18:42:00 -0500 Subject: Add a 'last touched by' column to todolist detail view This allows you to see very easily who last manipulated a package todolist item in case you have a need to know. Signed-off-by: Dan McGee --- templates/todolists/view.html | 2 ++ todolists/models.py | 3 ++- todolists/views.py | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'templates') diff --git a/templates/todolists/view.html b/templates/todolists/view.html index fc4b29ea..b26cd91c 100644 --- a/templates/todolists/view.html +++ b/templates/todolists/view.html @@ -68,6 +68,7 @@

Filter Todo List Packages

Staging Version Maintainers Status + Last Touched By @@ -95,6 +96,7 @@

Filter Todo List Packages

{{ pkg.get_status_display }} {% endif %} + {{ pkg.user|default:"" }} {% endfor %} diff --git a/todolists/models.py b/todolists/models.py index 3ea80f37..59b14616 100644 --- a/todolists/models.py +++ b/todolists/models.py @@ -47,7 +47,8 @@ def packages(self): if not hasattr(self, '_packages'): self._packages = self.todolistpackage_set.filter( removed__isnull=True).select_related( - 'pkg', 'repo', 'arch').order_by('pkgname', 'arch') + 'pkg', 'repo', 'arch', 'user__username').order_by( + 'pkgname', 'arch') return self._packages diff --git a/todolists/views.py b/todolists/views.py index d5b39934..ff75686d 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -71,12 +71,13 @@ def view(request, slug): attach_staging(todolist.packages(), todolist.pk) arches = {tp.arch for tp in todolist.packages()} repos = {tp.repo for tp in todolist.packages()} - return render(request, 'todolists/view.html', { + context = { 'list': todolist, 'svn_roots': svn_roots, 'arches': sorted(arches), 'repos': sorted(repos), - }) + } + return render(request, 'todolists/view.html', context) def list_pkgbases(request, slug, svn_root): -- cgit v1.2.3-54-g00ecf From 64a92174c056a4cca1e6b7e287ca9993bcd2be1a Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 21 May 2013 20:22:11 -0500 Subject: Begin removal of FTP mirror support FTP is a terrible protocol these days compared to HTTP. IPv6 support is spotty at best, it is much slower for the connect/begin transfer cycle, and overall just doesn't provide anything HTTP does better. Start killing bits that we've added to treat FTP as a first-class protocol and regulate it to the back seat. The expectation here is once this commit goes live to the production site, the FTP mirror URLs themselves will get removed completely from the database, and the FTP protocol object itself will get deleted. Signed-off-by: Dan McGee --- mirrors/admin.py | 1 + mirrors/fixtures/mirrorprotocols.json | 9 --------- mirrors/models.py | 2 +- mirrors/urls_mirrorlist.py | 4 +++- mirrors/views.py | 29 +++++------------------------ templates/mirrors/mirrorlist_generate.html | 2 -- 6 files changed, 10 insertions(+), 37 deletions(-) (limited to 'templates') diff --git a/mirrors/admin.py b/mirrors/admin.py index 9c88207d..d0f2f475 100644 --- a/mirrors/admin.py +++ b/mirrors/admin.py @@ -10,6 +10,7 @@ class MirrorUrlForm(forms.ModelForm): class Meta: model = MirrorUrl + def clean_url(self): # is this a valid-looking URL? url_parts = urlparse(self.cleaned_data["url"]) diff --git a/mirrors/fixtures/mirrorprotocols.json b/mirrors/fixtures/mirrorprotocols.json index 8822ef8e..1a07510b 100644 --- a/mirrors/fixtures/mirrorprotocols.json +++ b/mirrors/fixtures/mirrorprotocols.json @@ -8,15 +8,6 @@ "protocol": "http" } }, - { - "pk": 2, - "model": "mirrors.mirrorprotocol", - "fields": { - "is_download": true, - "default": false, - "protocol": "ftp" - } - }, { "pk": 3, "model": "mirrors.mirrorprotocol", diff --git a/mirrors/models.py b/mirrors/models.py index d8ac7952..91793e0a 100644 --- a/mirrors/models.py +++ b/mirrors/models.py @@ -47,7 +47,7 @@ def get_absolute_url(self): class MirrorProtocol(models.Model): protocol = models.CharField(max_length=10, unique=True) is_download = models.BooleanField(default=True, - help_text="Is protocol useful for end-users, e.g. FTP/HTTP") + help_text="Is protocol useful for end-users, e.g. HTTP") default = models.BooleanField(default=True, help_text="Included by default when building mirror list?") created = models.DateTimeField(editable=False) diff --git a/mirrors/urls_mirrorlist.py b/mirrors/urls_mirrorlist.py index 1444eca9..bba54ec9 100644 --- a/mirrors/urls_mirrorlist.py +++ b/mirrors/urls_mirrorlist.py @@ -1,9 +1,11 @@ from django.conf.urls import patterns + urlpatterns = patterns('mirrors.views', (r'^$', 'generate_mirrorlist', {}, 'mirrorlist'), (r'^all/$', 'find_mirrors', {'countries': ['all']}), - (r'^all/(?P[A-z]+)/$', 'find_mirrors_simple') + (r'^all/(?P[A-z]+)/$', 'find_mirrors_simple', + {}, 'mirrorlist_simple') ) # vim: set ts=4 sw=4 et: diff --git a/mirrors/views.py b/mirrors/views.py index d1dd9da3..22eb57b8 100644 --- a/mirrors/views.py +++ b/mirrors/views.py @@ -8,7 +8,7 @@ from django.core.serializers.json import DjangoJSONEncoder from django.db.models import Q from django.http import Http404, HttpResponse -from django.shortcuts import get_object_or_404, render +from django.shortcuts import get_object_or_404, redirect, render from django.utils.timezone import now from django.views.decorators.csrf import csrf_exempt from django_countries.countries import COUNTRIES @@ -78,18 +78,6 @@ def generate_mirrorlist(request): {'mirrorlist_form': form}) -def default_protocol_filter(original_urls): - key_func = attrgetter('country') - sorted_urls = sorted(original_urls, key=key_func) - urls = [] - for _, group in groupby(sorted_urls, key=key_func): - cntry_urls = list(group) - if any(url.protocol.default for url in cntry_urls): - cntry_urls = [url for url in cntry_urls if url.protocol.default] - urls.extend(cntry_urls) - return urls - - def status_filter(original_urls): status_info = get_mirror_statuses() scores = {u.id: u.score for u in status_info['urls']} @@ -105,7 +93,7 @@ def status_filter(original_urls): def find_mirrors(request, countries=None, protocols=None, use_status=False, - ipv4_supported=True, ipv6_supported=True, smart_protocol=False): + ipv4_supported=True, ipv6_supported=True): if not protocols: protocols = MirrorProtocol.objects.filter(is_download=True) elif hasattr(protocols, 'model') and protocols.model == MirrorProtocol: @@ -126,17 +114,12 @@ def find_mirrors(request, countries=None, protocols=None, use_status=False, ip_version |= Q(has_ipv6=True) qset = qset.filter(ip_version) - if smart_protocol: - urls = default_protocol_filter(qset) - else: - urls = qset - if not use_status: sort_key = attrgetter('country.name', 'mirror.name', 'url') - urls = sorted(urls, key=sort_key) + urls = sorted(qset, key=sort_key) template = 'mirrors/mirrorlist.txt' else: - urls = status_filter(urls) + urls = status_filter(qset) template = 'mirrors/mirrorlist_status.txt' context = { @@ -147,9 +130,7 @@ def find_mirrors(request, countries=None, protocols=None, use_status=False, def find_mirrors_simple(request, protocol): if protocol == 'smart': - # generate a 'smart' mirrorlist, one that only includes FTP mirrors if - # no HTTP mirror is available in that country. - return find_mirrors(request, smart_protocol=True) + return redirect('mirrorlist_simple', 'http', permanent=True) proto = get_object_or_404(MirrorProtocol, protocol=protocol) return find_mirrors(request, protocols=[proto]) diff --git a/templates/mirrors/mirrorlist_generate.html b/templates/mirrors/mirrorlist_generate.html index f072730e..59b0d358 100644 --- a/templates/mirrors/mirrorlist_generate.html +++ b/templates/mirrors/mirrorlist_generate.html @@ -21,10 +21,8 @@

Mirrorlist with all available mirrors

Customized by country mirrorlist

-- cgit v1.2.3-54-g00ecf From 8c614b4abb2ae0b0474744420aab6ba86383a3e9 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 21 May 2013 20:35:50 -0500 Subject: Add 'Edit Mirror' link to mirror details page For those that have permissions to do so. Makes it a heck of a lot easier to navigate around and enable or disable mirrors as necessary. Signed-off-by: Dan McGee --- templates/mirrors/mirror_details.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html index 6f0ac6c1..ccd6eb57 100644 --- a/templates/mirrors/mirror_details.html +++ b/templates/mirrors/mirror_details.html @@ -2,6 +2,7 @@ {% load static from staticfiles %} {% load mirror_status %} {% load flags %} +{% load admin_urls %} {% block title %}Arch Linux - {{ mirror.name }} - Mirror Details{% endblock %} @@ -9,9 +10,14 @@ {% block content %}
-

Mirror Details: {{ mirror.name }}

+ {% if perms.mirrors.change_mirror %} + + {% endif %} + -- cgit v1.2.3-54-g00ecf
Name: