Remove old mirror selection code and data
authorMagnus Hagander <magnus@hagander.net>
Sat, 14 May 2016 19:42:38 +0000 (21:42 +0200)
committerMagnus Hagander <magnus@hagander.net>
Sat, 14 May 2016 19:42:38 +0000 (21:42 +0200)
This has not been used for many years now, so let's get rid of
it to save some maintenance.

pgweb/downloads/admin.py
pgweb/downloads/migrations/0002_remove_mirrors.py [new file with mode: 0644]
pgweb/downloads/models.py
pgweb/downloads/views.py
pgweb/urls.py

index fcee1d2778c10cdd6ec8fe3809a7f830571f08d8..3f417b4dbdec7b4983f2419535ee7fe66ee86256 100644 (file)
@@ -5,13 +5,7 @@ from django.forms import ValidationError
 import re
 
 from pgweb.util.admin import PgwebAdmin
-from models import StackBuilderApp, Mirror, Category, Product, LicenceType
-
-class MirrorAdmin(admin.ModelAdmin):
-       list_display = ('__unicode__', 'country_name', 'country_code', 'mirror_index', 'mirror_last_rsync', 'host_sponsor', )
-       list_filter = ('country_name', 'mirror_active', )
-       search_fields = ('country_name', 'host_sponsor', 'host_notes', )
-       ordering = ('country_code', )
+from models import StackBuilderApp, Category, Product, LicenceType
 
 class ProductAdmin(PgwebAdmin):
        list_display = ('name', 'org', 'approved', 'lastconfirmed',)
@@ -58,7 +52,6 @@ class StackBuilderAppAdmin(admin.ModelAdmin):
        actions = [duplicate_stackbuilderapp, ]
        form = StackBuilderAppAdminForm
 
-admin.site.register(Mirror, MirrorAdmin)
 admin.site.register(Category)
 admin.site.register(LicenceType)
 admin.site.register(Product, ProductAdmin)
diff --git a/pgweb/downloads/migrations/0002_remove_mirrors.py b/pgweb/downloads/migrations/0002_remove_mirrors.py
new file mode 100644 (file)
index 0000000..2d9f05b
--- /dev/null
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('downloads', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.DeleteModel(
+            name='Mirror',
+        ),
+    ]
index b4f693359bfb1fd01e225587fdea2e3d98826655..bc97db37bcf2a02af8df6b4cd746eb7dd3b77aea 100644 (file)
@@ -4,55 +4,6 @@ from pgweb.core.models import Organisation
 
 from datetime import datetime
 
-class Mirror(models.Model):
-       country_name = models.CharField(max_length=50, null=False, blank=False)
-       country_code = models.CharField(max_length=2, null=False, blank=False)
-       mirror_created = models.DateTimeField(null=False, blank=False, auto_now_add=True)
-       mirror_last_rsync = models.DateTimeField(null=False, blank=False, default=datetime(1970,1,1))
-       mirror_index = models.IntegerField(null=False)
-       host_addr = models.GenericIPAddressField(null=True, default='0.0.0.0')
-       host_path = models.CharField(max_length=100, null=True)
-       host_sponsor = models.CharField(max_length=100, null=True)
-       host_contact = models.CharField(max_length=100, null=True)
-       host_email = models.CharField(max_length=100, null=True)
-       host_notes = models.TextField(null=True)
-       rsync_host1 = models.CharField(max_length=100, null=True)
-       rsync_host2 = models.CharField(max_length=100, null=True)
-       mirror_active = models.BooleanField(null=False, default=True)
-       mirror_dns = models.BooleanField(null=False, default=False)
-       mirror_private = models.BooleanField(null=False, default=False)
-       host_use_cname = models.BooleanField(null=False, default=False)
-       host_cname_host = models.CharField(max_length=100, null=True)
-       mirror_primary = models.BooleanField(null=False, default=False)
-       error_count = models.IntegerField(null=False, default=0)
-       alternate_protocol = models.BooleanField(null=False, default=False)
-       alternate_at_root = models.BooleanField(null=False, default=False)
-
-       class Meta:
-               db_table='mirrors'
-
-       def __unicode__(self):
-               return "%s.%s" % (self.country_code, self.mirror_index)
-
-       def get_host_name(self):
-               if self.mirror_index == 0:
-                       return "ftp.%s.postgresql.org" % self.country_code
-               else:
-                       return "ftp%s.%s.postgresql.org" % (self.mirror_index, self.country_code)
-
-       def get_root_path(self, method):
-               if method == 'f' or not self.alternate_at_root:
-                       # FTP method, or http with same path, build complete one
-                       return ("%s/%s" % (self.get_host_name(), self.host_path)).replace('//','/').rstrip('/')
-               else:
-                       # http with alternate_at_root - thus, ignore the path element
-                       return self.get_host_name()
-
-       def get_all_protocols(self):
-               if self.alternate_protocol:
-                       return ('ftp', 'http', )
-               else:
-                       return ('ftp', )
 
 class Category(models.Model):
        catname = models.CharField(max_length=100, null=False, blank=False)
index a6bca49d19de186c8a28fdf49115a795f09302e2..17595a893675e99ba1fc58d4bda0265d7a4dc0dd 100644 (file)
@@ -14,7 +14,7 @@ from pgweb.util.contexts import NavContext
 from pgweb.util.helpers import simple_form, PgXmlHelper, HttpServerError
 from pgweb.util.misc import get_client_ip, varnish_purge, version_sort
 
-from models import Mirror, Category, Product, StackBuilderApp
+from models import Category, Product, StackBuilderApp
 from forms import ProductForm
 
 #######
@@ -127,76 +127,12 @@ def uploadftp(request):
 
 @nocache
 def mirrorselect(request, path):
-       # We have given up on the advanced mirror network things, and will just
-       # redirect this to ftp.mirrors.postgresql.org for now...
-       # Since requests hit our internal servers, we're also not going to
-       # bother logging them - logging will be handled by those servers
+       # Old access to mirrors will just redirect to the main ftp site.
+       # We don't really need it anymore, but the cost of keeping it is
+       # very low...
        return HttpResponseRedirect("https://ftp.postgresql.org/pub/%s" % path)
 
-# Accesses asking for a specific mirror will keep doing that for now.
-# At some time in the future we might consider hijacking them and sending
-# them to our master mirrors again.
-def _mirror_redirect_internal(request, scheme, host, path):
-       # Redirect!
-       newurl = "%s://%s/%s" % (scheme, host, path)
-       return HttpResponseRedirect(newurl)
 
-@nocache
-def mirror_redirect(request, mirrorid, protocol, path):
-       try:
-               mirror = Mirror.objects.get(pk=mirrorid)
-       except Mirror.DoesNotExist:
-               raise Http404("Specified mirror not found")
-
-       return _mirror_redirect_internal(
-               request,
-               protocol=='h' and 'http' or 'ftp',
-               mirror.get_root_path(protocol),
-               path,
-       )
-
-@nocache
-def mirror_redirect_old(request):
-       # Version of redirect that takes parameters in the querystring. This is
-       # only used by the stackbuilder.
-       try:
-               if not request.GET['sb'] == "1":
-                       raise Http404("Page not found, you should be using the new URL format!")
-       except:
-               raise Http404("Page not found, you should be using the new URL format!")
-
-       urlpieces = urlparse.urlparse(request.GET['url'])
-       if urlpieces.query:
-               path = "%s?%s" % (urlpieces.path, urlpieces.query)
-       else:
-               path = urlpieces.path
-
-       return _mirror_redirect_internal(
-               request,
-               urlpieces.scheme,
-               urlpieces.netloc,
-               path,
-       )
-
-def mirrors_xml(request):
-       # Same as in mirrorselect
-       all_mirrors = Mirror.objects.filter(mirror_active=True, mirror_private=False, mirror_dns=True).extra(where=["mirror_last_rsync>(now() - '48 hours'::interval)"]).order_by('country_name', 'mirror_index')       
-
-       resp = HttpResponse(content_type='text/xml')
-       x = PgXmlHelper(resp)
-       x.startDocument()
-       x.startElement('mirrors', {})
-       for m in all_mirrors:
-               for protocol in m.get_all_protocols():
-                       x.startElement('mirror', {})
-                       x.add_xml_element('country', m.country_name)
-                       x.add_xml_element('path', m.host_path)
-                       x.add_xml_element('protocol', protocol)
-                       x.add_xml_element('hostname', m.get_host_name())
-                       x.endElement('mirror')
-       x.endElement('mirrors')
-       x.endDocument()
-       return resp
 
 #######
 # Product catalogue
index c674615957bdf4b2b676040ba8a55491f6a05bbc..b5510ec910a70d2e8c17c644edd4b23f7a87891e 100644 (file)
@@ -34,9 +34,6 @@ urlpatterns = patterns('',
        (r'^download/mirrors-ftp/+(.*)$', 'pgweb.downloads.views.mirrorselect'),
        (r'^download/product-categories/$', 'pgweb.downloads.views.categorylist'),
        (r'^download/products/(\d+)(-.*)?/$', 'pgweb.downloads.views.productlist'),
-       (r'^redir/(\d+)/([hf])/([a-zA-Z0-9/\._-]+)$', 'pgweb.downloads.views.mirror_redirect'),
-       (r'^redir$', 'pgweb.downloads.views.mirror_redirect_old'),
-       (r'^mirrors.xml$', 'pgweb.downloads.views.mirrors_xml'),
        (r'^applications-v2.xml$', 'pgweb.downloads.views.applications_v2_xml'),
        (r'^download/uploadftp/', 'pgweb.downloads.views.uploadftp'),