Implement stackbuilder
authorMagnus Hagander <magnus@hagander.net>
Wed, 13 Jan 2010 22:12:53 +0000 (23:12 +0100)
committerMagnus Hagander <magnus@hagander.net>
Wed, 13 Jan 2010 22:12:53 +0000 (23:12 +0100)
pgweb/downloads/admin.py
pgweb/downloads/models.py
pgweb/downloads/views.py
pgweb/urls.py

index 3c48d53dd65b2df41adb26fb9ce08e6c224976f0..083ccf66388f825b74d3bac5566a754f236e55bd 100644 (file)
@@ -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)
index 86f03ea4afe1e8e86949bd6782204d95235e6d1a..f10dde1c4882ec9a049b46d5bc10953e06f40baa 100644 (file)
@@ -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', )
+
index 28b073fe7a70ffadc70ba52dc6fa8ffb03db52fe..2784aeb4ef8bb87d6ed435265999273a81ced3c4 100644 (file)
@@ -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
+
index 075c9ff9102137f39901991c8812f943c0f7de9b..4f6ad90e518a4488da2fa0d938c19ece2264ec38 100644 (file)
@@ -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'),