diff --git a/pgweb/downloads/admin.py b/pgweb/downloads/admin.py index fcee1d27..3f417b4d 100644 --- a/pgweb/downloads/admin.py +++ b/pgweb/downloads/admin.py @@ -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 index 00000000..2d9f05b3 --- /dev/null +++ b/pgweb/downloads/migrations/0002_remove_mirrors.py @@ -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', + ), + ] diff --git a/pgweb/downloads/models.py b/pgweb/downloads/models.py index b4f69335..bc97db37 100644 --- a/pgweb/downloads/models.py +++ b/pgweb/downloads/models.py @@ -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) diff --git a/pgweb/downloads/views.py b/pgweb/downloads/views.py index a6bca49d..17595a89 100644 --- a/pgweb/downloads/views.py +++ b/pgweb/downloads/views.py @@ -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 diff --git a/pgweb/urls.py b/pgweb/urls.py index c6746159..b5510ec9 100644 --- a/pgweb/urls.py +++ b/pgweb/urls.py @@ -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'),