summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-04-24 23:22:23 -0500
committerDan McGee <dan@archlinux.org>2012-04-25 00:00:36 -0500
commit116751e4bab183b3cca93ab13f7f4f21c752be4e (patch)
tree4eff5a95519b85352e92516f33bf1897dc90a8a8
parent206000df736fde75a49c3178a8522d17f30a955e (diff)
Rename mirror country fields to country_old in prep for normalization
We're going to move to using ISO 2 character codes via django countries, so start by moving the old data out of the way first. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--mirrors/admin.py4
-rw-r--r--mirrors/migrations/0013_rename_country_fields.py68
-rw-r--r--mirrors/models.py8
-rw-r--r--mirrors/utils.py8
-rw-r--r--mirrors/views.py8
-rw-r--r--public/views.py2
-rw-r--r--templates/mirrors/mirror_details.html2
-rw-r--r--templates/mirrors/mirrors.html2
-rw-r--r--templates/public/download.html4
9 files changed, 87 insertions, 19 deletions
diff --git a/mirrors/admin.py b/mirrors/admin.py
index a2b59b41..e8c7e280 100644
--- a/mirrors/admin.py
+++ b/mirrors/admin.py
@@ -62,9 +62,9 @@ class MirrorAdminForm(forms.ModelForm):
class MirrorAdmin(admin.ModelAdmin):
form = MirrorAdminForm
- list_display = ('name', 'tier', 'country', 'active', 'public',
+ list_display = ('name', 'tier', 'country_old', 'active', 'public',
'isos', 'admin_email')
- list_filter = ('tier', 'active', 'public', 'country')
+ list_filter = ('tier', 'active', 'public', 'country_old')
search_fields = ('name',)
inlines = [
MirrorUrlInlineAdmin,
diff --git a/mirrors/migrations/0013_rename_country_fields.py b/mirrors/migrations/0013_rename_country_fields.py
new file mode 100644
index 00000000..96bb732b
--- /dev/null
+++ b/mirrors/migrations/0013_rename_country_fields.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ db.rename_column('mirrors_mirror', 'country', 'country_old')
+ db.rename_column('mirrors_mirrorurl', 'country', 'country_old')
+
+ def backwards(self, orm):
+ db.rename_column('mirrors_mirror', 'country_old', 'country')
+ db.rename_column('mirrors_mirrorurl', 'country_old', 'country')
+
+ models = {
+ 'mirrors.mirror': {
+ 'Meta': {'ordering': "('country_old', 'name')", 'object_name': 'Mirror'},
+ 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'admin_email': ('django.db.models.fields.EmailField', [], {'max_length': '255', 'blank': 'True'}),
+ 'country_old': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'isos': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+ 'notes': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'rsync_password': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}),
+ 'rsync_user': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}),
+ 'tier': ('django.db.models.fields.SmallIntegerField', [], {'default': '2'}),
+ 'upstream': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mirrors.Mirror']", 'null': 'True', 'on_delete': 'models.SET_NULL'})
+ },
+ 'mirrors.mirrorlog': {
+ 'Meta': {'object_name': 'MirrorLog'},
+ 'check_time': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}),
+ 'duration': ('django.db.models.fields.FloatField', [], {'null': 'True'}),
+ 'error': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_success': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'last_sync': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+ 'url': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'logs'", 'to': "orm['mirrors.MirrorUrl']"})
+ },
+ 'mirrors.mirrorprotocol': {
+ 'Meta': {'ordering': "('protocol',)", 'object_name': 'MirrorProtocol'},
+ 'default': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_download': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'protocol': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '10'})
+ },
+ 'mirrors.mirrorrsync': {
+ 'Meta': {'object_name': 'MirrorRsync'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ip': ('django.db.models.fields.CharField', [], {'max_length': '24'}),
+ 'mirror': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'rsync_ips'", 'to': "orm['mirrors.Mirror']"})
+ },
+ 'mirrors.mirrorurl': {
+ 'Meta': {'object_name': 'MirrorUrl'},
+ 'country_old': ('mirrors.models.NullCharField', [], {'db_index': 'True', 'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'has_ipv4': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'has_ipv6': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'mirror': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'urls'", 'to': "orm['mirrors.Mirror']"}),
+ 'protocol': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'urls'", 'on_delete': 'models.PROTECT', 'to': "orm['mirrors.MirrorProtocol']"}),
+ 'url': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['mirrors']
diff --git a/mirrors/models.py b/mirrors/models.py
index 86905eea..46753fac 100644
--- a/mirrors/models.py
+++ b/mirrors/models.py
@@ -24,7 +24,7 @@ class Mirror(models.Model):
name = models.CharField(max_length=255, unique=True)
tier = models.SmallIntegerField(default=2, choices=TIER_CHOICES)
upstream = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
- country = models.CharField(max_length=255, db_index=True)
+ country_old = models.CharField(max_length=255, db_index=True)
admin_email = models.EmailField(max_length=255, blank=True)
public = models.BooleanField(default=True)
active = models.BooleanField(default=True)
@@ -34,7 +34,7 @@ class Mirror(models.Model):
notes = models.TextField(blank=True)
class Meta:
- ordering = ('country', 'name')
+ ordering = ('country_old', 'name')
def __unicode__(self):
return self.name
@@ -68,7 +68,7 @@ class MirrorUrl(models.Model):
protocol = models.ForeignKey(MirrorProtocol, related_name="urls",
editable=False, on_delete=models.PROTECT)
mirror = models.ForeignKey(Mirror, related_name="urls")
- country = NullCharField(max_length=255, null=True, blank=True,
+ country_old = NullCharField(max_length=255, null=True, blank=True,
db_index=True)
has_ipv4 = models.BooleanField("IPv4 capable", default=True,
editable=False)
@@ -87,7 +87,7 @@ class MirrorUrl(models.Model):
@property
def real_country(self):
- return self.country or self.mirror.country
+ return self.country_old or self.mirror.country_old
def clean(self):
try:
diff --git a/mirrors/utils.py b/mirrors/utils.py
index ddecb095..aa1e9f76 100644
--- a/mirrors/utils.py
+++ b/mirrors/utils.py
@@ -89,13 +89,13 @@ def get_mirror_errors(cutoff=default_cutoff):
errors = MirrorLog.objects.filter(
is_success=False, check_time__gte=cutoff_time,
url__mirror__active=True, url__mirror__public=True).values(
- 'url__url', 'url__country', 'url__protocol__protocol',
- 'url__mirror__country', 'error').annotate(
+ 'url__url', 'url__country_old', 'url__protocol__protocol',
+ 'url__mirror__country_old', 'error').annotate(
error_count=Count('error'), last_occurred=Max('check_time')
).order_by('-last_occurred', '-error_count')
errors = list(errors)
for err in errors:
- err['country'] = err['url__country'] or err['url__mirror__country']
+ err['country'] = err['url__country_old'] or err['url__mirror__country_old']
return errors
@@ -123,7 +123,7 @@ def get_mirror_url_for_download(cutoff=default_cutoff):
mirror__public=True, mirror__active=True,
protocol__protocol__iexact='HTTP')
# look first for an 'Any' URL, then fall back to any HTTP URL
- filtered_urls = mirror_urls.filter(mirror__country='Any')[:1]
+ filtered_urls = mirror_urls.filter(mirror__country_old='Any')[:1]
if not filtered_urls:
filtered_urls = mirror_urls[:1]
if not filtered_urls:
diff --git a/mirrors/views.py b/mirrors/views.py
index e93097a3..c5989d67 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -23,7 +23,7 @@ class MirrorlistForm(forms.Form):
def __init__(self, *args, **kwargs):
super(MirrorlistForm, self).__init__(*args, **kwargs)
countries = Mirror.objects.filter(active=True).values_list(
- 'country', flat=True).distinct().order_by('country')
+ 'country_old', flat=True).distinct().order_by('country_old')
self.fields['country'].choices = [('all','All')] + make_choice(
countries)
self.fields['country'].initial = ['all']
@@ -62,8 +62,8 @@ def find_mirrors(request, countries=None, protocols=None, use_status=False,
mirror__public=True, mirror__active=True,
)
if countries and 'all' not in countries:
- qset = qset.filter(Q(country__in=countries) |
- Q(mirror__country__in=countries))
+ qset = qset.filter(Q(country_old__in=countries) |
+ Q(mirror__country_old__in=countries))
ip_version = Q()
if ipv4_supported:
@@ -97,7 +97,7 @@ def find_mirrors(request, countries=None, protocols=None, use_status=False,
mimetype='text/plain')
def mirrors(request):
- mirror_list = Mirror.objects.select_related().order_by('tier', 'country')
+ mirror_list = Mirror.objects.select_related().order_by('tier', 'country_old')
if not request.user.is_authenticated():
mirror_list = mirror_list.filter(public=True, active=True)
return direct_to_template(request, 'mirrors/mirrors.html',
diff --git a/public/views.py b/public/views.py
index a85d7389..e149d921 100644
--- a/public/views.py
+++ b/public/views.py
@@ -75,7 +75,7 @@ def download(request):
'releng_pxeboot_url': settings.PXEBOOT_URL,
}
return list_detail.object_list(request,
- qset.order_by('mirror__country', 'mirror__name', 'protocol'),
+ qset.order_by('mirror__country_old', 'mirror__name', 'protocol'),
template_name="public/download.html",
template_object_name="mirror_url",
extra_context=context)
diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html
index 249b36f2..bb3b417c 100644
--- a/templates/mirrors/mirror_details.html
+++ b/templates/mirrors/mirror_details.html
@@ -21,7 +21,7 @@
</tr>
<tr>
<th>Country:</th>
- <td>{{ mirror.country }}</td>
+ <td>{{ mirror.country_old }}</td>
</tr>
<tr>
<th>Has ISOs:</th>
diff --git a/templates/mirrors/mirrors.html b/templates/mirrors/mirrors.html
index 3aff8ea6..4b59058a 100644
--- a/templates/mirrors/mirrors.html
+++ b/templates/mirrors/mirrors.html
@@ -27,7 +27,7 @@
<td><a href="{{ mirror.get_absolute_url }}"
title="Mirror details for {{ mirror.name }}">{{ mirror.name }}</a></td>
<td>{{mirror.get_tier_display}}</td>
- <td>{{mirror.country}}</td>
+ <td>{{mirror.country_old}}</td>
<td>{{mirror.isos|yesno|capfirst}}</td>
<td class="wrap">{{mirror.supported_protocols|join:", "}}</td>
{% if user.is_authenticated %}
diff --git a/templates/public/download.html b/templates/public/download.html
index 67c70be1..fbadb7c0 100644
--- a/templates/public/download.html
+++ b/templates/public/download.html
@@ -160,9 +160,9 @@
<tbody>
<tr><td colspan="2">
{% for mirror_url in mirror_url_list %}
- {% ifchanged mirror_url.mirror.country %}
+ {% ifchanged mirror_url.mirror.country_old %}
</td></tr>
- <tr><td class="mirror-country" colspan="2"><strong>{{mirror_url.mirror.country}}</strong>
+ <tr><td class="mirror-country" colspan="2"><strong>{{mirror_url.mirror.country_old}}</strong>
{% endifchanged %}
{% ifchanged mirror_url.mirror.name %}
</td></tr>