From 68c2ebc8452c0a06a4c02f952f73cf74f6252e23 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Wed, 13 Jan 2010 23:12:53 +0100 Subject: [PATCH] Implement stackbuilder --- pgweb/downloads/admin.py | 6 +++++- pgweb/downloads/models.py | 34 ++++++++++++++++++++++++++++++++++ pgweb/downloads/views.py | 34 ++++++++++++++++++++++++++++++++++ pgweb/urls.py | 1 + 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/pgweb/downloads/admin.py b/pgweb/downloads/admin.py index 3c48d53d..083ccf66 100644 --- a/pgweb/downloads/admin.py +++ b/pgweb/downloads/admin.py @@ -14,8 +14,12 @@ class ProductAdmin(MarkdownPreviewAdmin): search_fields = ('name', 'description', ) ordering = ('name', ) +class StackBuilderAppAdmin(admin.ModelAdmin): + list_display = ('textid', 'name', 'platform', 'version', ) + filter_horizontal = ('dependencies', ) + admin.site.register(Mirror, MirrorAdmin) admin.site.register(Category) admin.site.register(LicenceType) admin.site.register(Product, ProductAdmin) - +admin.site.register(StackBuilderApp, StackBuilderAppAdmin) diff --git a/pgweb/downloads/models.py b/pgweb/downloads/models.py index 86f03ea4..f10dde1c 100644 --- a/pgweb/downloads/models.py +++ b/pgweb/downloads/models.py @@ -91,3 +91,37 @@ class Product(PgModel, models.Model): class Meta: ordering = ('name',) + +class StackBuilderApp(models.Model): + textid = models.CharField(max_length=100, null=False, blank=False) + version = models.CharField(max_length=20, null=False, blank=False) + platform = models.CharField(max_length=20, null=False, blank=False, + choices= (('windows', 'Windows'), ('osx', 'Mac OS X'), + ('linux', 'Linux (32-bit)'), ('linux-x64', 'Linux (64-bit)')) + ) + name = models.CharField(max_length=500, null=False, blank=False) + active = models.BooleanField(null=False, blank=False, default=True) + description = models.TextField(null=False, blank=False) + category = models.CharField(max_length=100, null=False, blank=False) + pgversion = models.CharField(max_length=5, null=False, blank=True) + edbversion = models.CharField(max_length=5, null=False, blank=True) + format = models.CharField(max_length=5, null=False, blank=False, + choices = (('bin', 'Linux .bin'), ('app', 'Mac .app'), + ('pkg', 'Mac .pkg'), ('mpkg', 'Mac .mpkg'), + ('exe', 'Windows .exe'), ('msi', 'Windows .msi')) + ) + installoptions = models.CharField(max_length=500, null=False, blank=True) + upgradeoptions = models.CharField(max_length=500, null=False, blank=True) + checksum = models.CharField(max_length=32, null=False, blank=False) + mirrorpath = models.CharField(max_length=500, null=False, blank=True) + alturl = models.URLField(max_length=500, null=False, blank=True) + dependencies = models.ManyToManyField("self", blank=True) + versionkey = models.CharField(max_length=500, null=False, blank=False) + + def __unicode__(self): + return "%s %s %s" % (self.textid, self.version, self.platform) + + class Meta: + unique_together = ('textid', 'version', 'platform', ) + ordering = ('textid', 'name', 'platform', ) + diff --git a/pgweb/downloads/views.py b/pgweb/downloads/views.py index 28b073fe..2784aeb4 100644 --- a/pgweb/downloads/views.py +++ b/pgweb/downloads/views.py @@ -223,3 +223,37 @@ def productlist(request, catid, junk=None): def productform(request, itemid): return simple_form(Product, itemid, request, ProductForm) +####### +# Stackbuilder +####### +def applications_v2_xml(request): + all_apps = StackBuilderApp.objects.select_related().filter(active=True) + + resp = HttpResponse(mimetype='text/xml') + x = PgXmlHelper(resp, skipempty=True) + x.startDocument() + x.startElement('applications', {}) + for a in all_apps: + x.startElement('application', {}) + x.add_xml_element('id', a.textid) + x.add_xml_element('platform', a.platform) + x.add_xml_element('version', a.version) + x.add_xml_element('name', a.name) + x.add_xml_element('description', a.description) + x.add_xml_element('category', a.category) + x.add_xml_element('pgversion', a.pgversion) + x.add_xml_element('edbversion', a.edbversion) + x.add_xml_element('format', a.format) + x.add_xml_element('installoptions', a.installoptions) + x.add_xml_element('upgradeoptions', a.upgradeoptions) + x.add_xml_element('checksum', a.checksum) + x.add_xml_element('mirrorpath', a.mirrorpath) + x.add_xml_element('alturl', a.alturl) + x.add_xml_element('versionkey', a.versionkey) + for dep in a.dependencies.all(): + x.add_xml_element('dependency', dep.textid) + x.endElement('application') + x.endElement('applications') + x.endDocument() + return resp + diff --git a/pgweb/urls.py b/pgweb/urls.py index 075c9ff9..4f6ad90e 100644 --- a/pgweb/urls.py +++ b/pgweb/urls.py @@ -37,6 +37,7 @@ urlpatterns = patterns('', (r'^redir/(\d+)/([hf])/([a-zA-Z0-9/\._-]+)$', 'downloads.views.mirror_redirect'), (r'^redir$', 'downloads.views.mirror_redirect_old'), (r'^mirrors.xml$', 'downloads.views.mirrors_xml'), + (r'^applications-v2.xml$', 'downloads.views.applications_v2_xml'), (r'^docs/(current|\d\.\d)/(static|interactive)/(.*).html$', 'docs.views.docpage'), (r'^docs/(current|\d\.\d)/(static|interactive)/$', 'docs.views.docsrootpage'),