Commits

Matthew Schinckel committed c9b61af

Initial import

Comments (0)

Files changed (12)

Empty file added.
+recursive-include update_manager *
+==============================
+Update Manager
+==============================
+
+Update Manager is a pluggable/reusable django app that allows for
+managing release versions, and which users should update to which version,
+of external software.
+
+It was developed for use by the ROSS System, which uses a django-based
+backend, but could be used by any system.
+
+Update Manager does not update django, or any django apps.
+
+Requirements
+============
+
+Django
+
+
+Installation
+============
+
+Install using pip or setup.py
+
+Put update_manager into your settings.INSTALLED_APPS.
+
+Create a Software Package using the admin interface.
Empty file added.

update_manager/__init__.py

Empty file added.

update_manager/api.py

Empty file added.

update_manager/models/__init__.py

+"""
+.. autoclass:: SoftwarePackage
+    :members:
+.. autoclass:: ReleaseVersion
+    :members:
+.. autoclass:: UpgradeGroup
+    :members:
+"""
+
+from software_package import SoftwarePackage
+from release_version import ReleaseVersion
+from upgrade_group import UpgradeGroup

update_manager/models/release_version.py

+from django.db import models
+
+class ReleaseVersion(models.Model):
+    software_package = models.ForeignKey('SoftwarePackage')
+    version = models.CharField(max_length=128)
+    url = models.URLField()
+    
+    class Meta:
+        app_label = 'update_manager'
+    
+    

update_manager/models/software_package.py

+from django.db import models
+
+class SoftwarePackage(models.Model):
+    name = models.CharField(max_length=100, unique=True)
+    default_release_version = models.ForeignKey('ReleaseVersion', 
+        null=True, blank=True
+    )
+    
+    class Meta:
+        app_label = 'update_manager'
+    
+    

update_manager/models/update_group.py

+from django.db import models
+
+class UpdateGroup(models.Model):
+    users = models.ManyToManyField('auth.User', null=True, blank=True)
+    upgrade = models.ForeignKey('ReleaseVersion')
+    
+    class Meta:
+        app_label = 'update_manager'
+    
+    

update_manager/urls.py

+from django.conf.urls.defaults import patterns, url
+
+import views
+
+urlpatterns = patterns('',
+    url('^check/$', views.check_for_upgrade, name='update_manager:check_for_upgrade'),
+)

update_manager/views.py

+from django.http import HttpResponse
+from models import SoftwarePackage, ReleaseVersion, UpgradeGroup
+
+def check_for_upgrade(request):
+    if request.method != "POST":
+        response = HttpResponse()
+        response.status_code = 405
+        response['Allowed'] = "[POST]"
+        return response
+    
+    user = request.user
+    package = SoftwarePackage.objects.get(name=request.POST.get('name'))
+    try:
+        target_version = UpgradeGroup.objects.get(
+            users__contains=user,
+            release_version__software_package=package
+        ).release_version
+    except UpgradeGroup.DoesNotExist:
+        target_version = package.default_release_version
+    
+    response = HttpResponse()
+    
+    if target_version.version == request.POST.get('installed'):
+        response.status_code = 204
+    else:
+        response.status_code = 302
+        response['Location'] = target_version.url
+    
+    return response