"""
Administration interface of the Dashboard application
"""

from django.contrib import admin
from django.contrib.contenttypes import generic
from django.utils.translation import ugettext as _

from launch_control.dashboard_app.models import (
        HardwareDevice,
        NamedAttribute,
        SoftwarePackage,
        )


class SoftwarePackageAdmin(admin.ModelAdmin):
    list_display = ('name', 'version')
    search_fields = ('name', 'version')


class HardwareDeviceAdmin(admin.ModelAdmin):
    class NamedAttributeInline(generic.GenericTabularInline):
        model = NamedAttribute
    list_display = ('description', 'device_type')
    search_fields = ('description',)
    inlines = [NamedAttributeInline]


admin.site.register(HardwareDevice, HardwareDeviceAdmin)
admin.site.register(SoftwarePackage, SoftwarePackageAdmin)

@@ -56,16 +56,41 @@
 on%0A%22%22%22%0A%0A
+from django import forms%0A
 from dja
@@ -114,16 +114,16 @@
 t admin%0A
-
 from dja
@@ -264,16 +264,54 @@
 mport (%0A
+        Bundle,%0A        BundleStream,%0A
         
@@ -383,24 +383,1448 @@
         )%0A%0A%0A
+class BundleAdmin(admin.ModelAdmin):%0A%0A    def bundle_stream_pathname(self, bundle):%0A        return bundle.bundle_stream.pathname%0A    bundle_stream_pathname.short_description = _(%22Bundle stream%22)%0A%0A    list_display = ('bundle_stream_pathname', 'uploaded_by', 'uploaded_on',%0A            'content_filename', 'is_deserialized')%0A    date_hierarchy = 'uploaded_on'%0A    fieldsets = (%0A            ('Document', %7B%0A                'fields': ('content', 'content_filename')%7D),%0A            ('Upload Details', %7B%0A                'fields': ('bundle_stream', 'uploaded_by')%7D),%0A            )%0A%0A%0A%0Aclass BundleStreamAdminForm(forms.ModelForm):%0A    class Meta:%0A        model = BundleStream%0A%0A    def clean(self):%0A        cleaned_data = self.cleaned_data%0A        print cleaned_data%0A        if (cleaned_data.get('user', '') is not None and%0A                cleaned_data.get('group') is not None):%0A            raise forms.ValidationError('BundleStream cannot have both user '%0A                    'and name set at the same time')%0A        return super(BundleStreamAdminForm, self).clean()%0A%0A%0Aclass BundleStreamAdmin(admin.ModelAdmin):%0A    form = BundleStreamAdminForm%0A    list_display = ('user', 'group', 'slug', 'name', 'pathname')%0A    prepopulated_fields = %7B%22slug%22: (%22name%22,)%7D%0A    fieldsets = (%0A            (None, %7B%0A                'fields': ('name', 'slug')%7D),%0A            ('Ownership', %7B%0A                'fields': ('user', 'group')%7D),%0A            )%0A%0A%0A
 class Softwa
@@ -2202,16 +2202,110 @@
 line%5D%0A%0A%0A
+admin.site.register(Bundle, BundleAdmin)%0Aadmin.site.register(BundleStream, BundleStreamAdmin)%0A
 admin.si

Add BundleStream and Bundle admin