]> git.parisson.com Git - telemeta.git/commitdiff
fix various field management
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 20 Nov 2014 16:25:25 +0000 (17:25 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 20 Nov 2014 16:25:25 +0000 (17:25 +0100)
telemeta/forms/media.py
telemeta/models/instrument.py
telemeta/views/resource.py

index aeb6937b46dd187fca2806b85bf05043f01c9d4b..8120f7267e35234670ba4aa8127dee6d56ae9fd0 100644 (file)
@@ -56,13 +56,6 @@ class MediaFondsForm(ModelForm):
         js = ['/admin/django/jsi18n/',]
 
 
-class MediaFondsRelatedForm(ModelForm):
-
-    class Meta:
-        model = MediaFondsRelated
-        exclude = ('mime_type',)
-
-
 class MediaCorpusForm(ModelForm):
 
     queryset = MediaCollection.objects.all()
@@ -78,13 +71,6 @@ class MediaCorpusForm(ModelForm):
         js = ('/admin/django/jsi18n/',)
 
 
-class MediaCorpusRelatedForm(ModelForm):
-
-    class Meta:
-        model = MediaCorpusRelated
-        exclude = ('mime_type',)
-
-
 class MediaCollectionForm(ModelForm):
 
     def __init__(self, *args, **kwargs):
@@ -101,13 +87,6 @@ class MediaCollectionForm(ModelForm):
         return self.cleaned_data['doctype_code'] or 0
 
 
-class MediaCollectionRelatedForm(ModelForm):
-
-    class Meta:
-        model = MediaCollectionRelated
-        exclude = ('mime_type',)
-
-
 class MediaItemForm(ModelForm):
 
     class Meta:
@@ -122,30 +101,6 @@ class MediaItemForm(ModelForm):
         return self.cleaned_data['code'] or None
 
 
-class MediaItemRelatedForm(ModelForm):
-
-    class Meta:
-        model = MediaItemRelated
-        exclude = ('mime_type',)
-
-
-class MediaItemKeywordForm(ModelForm):
-
-    class Meta:
-        model = MediaItemKeyword
-
-
-class MediaItemPerformanceForm(ModelForm):
-
-    class Meta:
-        model = MediaItemPerformance
-
-    def __init__(self, *args, **kwds):
-        super(MediaItemPerformanceForm, self).__init__(*args, **kwds)
-        self.fields['instrument'].queryset = Instrument.objects.order_by('name')
-        self.fields['alias'].queryset = InstrumentAlias.objects.order_by('name')
-
-
 class PlaylistForm(ModelForm):
 
     class Meta:
@@ -155,27 +110,31 @@ class PlaylistForm(ModelForm):
 class FondsRelatedInline(InlineFormSet):
 
     model = MediaFondsRelated
+    exclude = ['mime_type']
 
 
 class CorpusRelatedInline(InlineFormSet):
 
     model = MediaCorpusRelated
+    exclude = ['mime_type']
 
 
 class CollectionRelatedInline(InlineFormSet):
 
     model = MediaCollectionRelated
+    exclude = ['mime_type']
 
 
-class CollectionIdentifierInline(InlineFormSet):
+class ItemRelatedInline(InlineFormSet):
 
-    model = MediaCollectionIdentifier
-    max_num = 1
+    model = MediaItemRelated
+    exclude = ['mime_type']
 
 
-class ItemRelatedInline(InlineFormSet):
+class CollectionIdentifierInline(InlineFormSet):
 
-    model = MediaItemRelated
+    model = MediaCollectionIdentifier
+    max_num = 1
 
 
 class ItemPerformanceInline(InlineFormSet):
index f84cc57c98929a1ec2f7d4c961d4cc8a8a98efd1..4f8858d9d42bf3925d429918c8d0c6f3d7ff4594 100644 (file)
@@ -44,6 +44,7 @@ class Instrument(ModelCore):
 
     class Meta(MetaCore):
         db_table = 'instruments'
+        ordering = ['name']
 
     def __unicode__(self):
         return self.name
@@ -55,36 +56,37 @@ class InstrumentAlias(ModelCore):
     class Meta(MetaCore):
         db_table = 'instrument_aliases'
         verbose_name_plural = _('instrument aliases')
+        ordering = ['name']
 
     def __unicode__(self):
         return self.name
 
 class InstrumentRelation(ModelCore):
     "Instrument family"
-    instrument        = ForeignKey('Instrument', related_name="parent_relation", 
+    instrument        = ForeignKey('Instrument', related_name="parent_relation",
                                    verbose_name=_('instrument'))
-    parent_instrument = ForeignKey('Instrument', related_name="child_relation", 
+    parent_instrument = ForeignKey('Instrument', related_name="child_relation",
                                    verbose_name=_('parent instrument'))
 
     class Meta(MetaCore):
         db_table = 'instrument_relations'
         unique_together = (('instrument', 'parent_instrument'),)
-    
+
     def __unicode__(self):
         sep = ' > '
         return self.parent_instrument.name + sep + self.instrument.name
 
 class InstrumentAliasRelation(ModelCore):
     "Instrument family other name"
-    alias      = ForeignKey('InstrumentAlias', related_name="other_name", 
+    alias      = ForeignKey('InstrumentAlias', related_name="other_name",
                             verbose_name=_('alias'))
-    instrument = ForeignKey('Instrument', related_name="relation", 
+    instrument = ForeignKey('Instrument', related_name="relation",
                             verbose_name=_('instrument'))
 
     def __unicode__(self):
         sep = ' : '
         return self.alias.name + sep + self.instrument.name
-        
+
     class Meta(MetaCore):
         db_table = 'instrument_alias_relations'
         unique_together = (('alias', 'instrument'),)
index d6f0eb077065ead37d93971bf21529f6a0a20021..77077d9d44b0d13417bd80976430b911c332e352 100644 (file)
@@ -45,14 +45,12 @@ class ResourceView(object):
                 {'model': MediaCorpus,
                 'form' : MediaCorpusForm,
                 'related': MediaCorpusRelated,
-                'related_form': MediaCorpusRelatedForm,
                 'parent': MediaFonds,
                 },
             'fonds':
                 {'model': MediaFonds,
                 'form' : MediaFondsForm,
                 'related': MediaFondsRelated,
-                'related_form': MediaFondsRelatedForm,
                 'parent': None,
                 }
             }
@@ -192,7 +190,6 @@ class ResourceMixin(View):
                 {'model': MediaCorpus,
                 'form' : MediaCorpusForm,
                 'related': MediaCorpusRelated,
-                'related_form': MediaCorpusRelatedForm,
                 'parent': MediaFonds,
                 'inlines': [CorpusRelatedInline,]
                 },
@@ -200,7 +197,6 @@ class ResourceMixin(View):
                 {'model': MediaFonds,
                 'form' : MediaFondsForm,
                 'related': MediaFondsRelated,
-                'related_form': MediaFondsRelatedForm,
                 'parent': None,
                 'inlines': [FondsRelatedInline,]
                 }