From d8117559c2ddebf799e63f9e1f20ef7b2b0d72d8 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 23 Dec 2010 13:25:44 +0530 Subject: [PATCH] admin --- pandora/archive/admin.py | 11 ++++++++--- pandora/archive/forms.py | 31 +++++++++++++++++++++++++++++++ pandora/item/admin.py | 3 +++ pandora/item/forms.py | 19 ------------------- pandora/item/models.py | 2 +- 5 files changed, 43 insertions(+), 23 deletions(-) create mode 100644 pandora/archive/forms.py diff --git a/pandora/archive/admin.py b/pandora/archive/admin.py index 4e73e88fc..48c82a1c0 100644 --- a/pandora/archive/admin.py +++ b/pandora/archive/admin.py @@ -3,19 +3,24 @@ from django.contrib import admin -#from forms import FileAdminForm, ItemAdminForm, ArchiveFileAdminForm +from forms import FileAdminForm, InstanceAdminForm import models class FileAdmin(admin.ModelAdmin): search_fields = ['name', 'video_codec'] + list_display = ['available', 'is_main', '__unicode__', 'itemId'] + list_display_links = ('__unicode__', ) - #form = FileAdminForm + def itemId(self, obj): + return '%s'%(obj.item.itemId) + + form = FileAdminForm admin.site.register(models.File, FileAdmin) class InstanceAdmin(admin.ModelAdmin): search_fields = ['name', 'folder', 'volume__name'] - #form = ArchiveFileAdminForm + form = InstanceAdminForm admin.site.register(models.Instance, InstanceAdmin) diff --git a/pandora/archive/forms.py b/pandora/archive/forms.py new file mode 100644 index 000000000..59758ad5f --- /dev/null +++ b/pandora/archive/forms.py @@ -0,0 +1,31 @@ +from ajax_filtered_fields.forms import AjaxManyToManyField, ForeignKeyByLetter +from django.conf import settings +from django import forms + +import models + +ajax_filtered_js = ( + settings.ADMIN_MEDIA_PREFIX + "js/SelectBox.js", + settings.ADMIN_MEDIA_PREFIX + "js/SelectFilter2.js", + settings.STATIC_URL + 'js/jquery/jquery.js', + settings.STATIC_URL + 'js/ajax_filtered_fields.js', +) +class FileAdminForm(forms.ModelForm): + item = ForeignKeyByLetter(models.Item, field_name='itemId') + + class Meta: + model = models.File + + class Media: + js = ajax_filtered_js + + +class InstanceAdminForm(forms.ModelForm): + file = ForeignKeyByLetter(models.File, field_name='name') + + class Meta: + model = models.Instance + + class Media: + js = ajax_filtered_js + diff --git a/pandora/item/admin.py b/pandora/item/admin.py index 8bf97d83e..09daa8f31 100644 --- a/pandora/item/admin.py +++ b/pandora/item/admin.py @@ -7,6 +7,9 @@ import models class ItemAdmin(admin.ModelAdmin): search_fields = ['itemId', 'data', 'external_data'] + list_display = ['available', 'itemId', '__unicode__'] + list_display_links = ('__unicode__', ) + admin.site.register(models.Item, ItemAdmin) class PropertyAdmin(admin.ModelAdmin): diff --git a/pandora/item/forms.py b/pandora/item/forms.py index 8ebefe94e..dc56ffea5 100644 --- a/pandora/item/forms.py +++ b/pandora/item/forms.py @@ -11,25 +11,6 @@ ajax_filtered_js = ( settings.STATIC_URL + 'js/ajax_filtered_fields.js', ) """ -class FileAdminForm(forms.ModelForm): - item = ForeignKeyByLetter(models.Item, field_name='imdb__title') - - class Meta: - model = models.File - - class Media: - js = ajax_filtered_js - -class ArchiveFileAdminForm(forms.ModelForm): - file = ForeignKeyByLetter(models.File, field_name='path') - - class Meta: - model = models.ArchiveFile - - class Media: - js = ajax_filtered_js - - class ItemAdminForm(forms.ModelForm): imdb = ForeignKeyByLetter(models.ItemImdb, field_name='title') oxdb = ForeignKeyByLetter(models.ItemOxdb, field_name='title') diff --git a/pandora/item/models.py b/pandora/item/models.py index e32790b8b..cc137acd3 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -823,7 +823,7 @@ class ItemSort(models.Model): aspectratio = models.IntegerField('Aspect Ratio', blank=True, db_index=True) bitrate = models.IntegerField(blank=True, db_index=True) pixels = models.BigIntegerField(blank=True, db_index=True) - filename = models.IntegerField(blank=True, db_index=True) + filename = models.CharField(max_length=1024, blank=True, db_index=True) files = models.IntegerField(blank=True, db_index=True) size = models.BigIntegerField(blank=True, db_index=True)