Source

django-swingcms / swingcms / cms / forms.py

Diff from to

swingcms/cms/forms.py

 from sys import getsizeof # required python 2.6 or higher
 
 from django import forms
+from django.contrib.contenttypes.models import ContentType
 from django.core.exceptions import ValidationError
 from django.utils.html import escape, conditional_escape
 from django.utils.translation import ugettext_lazy as _
 from django.forms.util import flatatt
 
 import settings
+from loading import swingcache
 from cms.code import list_to_choices, strip_tags, thumbify
 from cms import models
 
                   'in_navigation', 'in_sitemap', 'template', "keywords", 'description')
 
 
-##################
-##  COLLECTION  ##
-##################
+#################
+##  COLLECTOR  ##
+#################
 
 
 class CollectorForm(BaseContentForm):
                                    max_length=2048, required=False,
                                    widget=forms.Textarea({'rows':20,'cols':80}))
     order_field = forms.ChoiceField(choices=(), initial='dt_addition')
-    param_dt_field = forms.ChoiceField(choices=(), initial='dt_addition')
+    param_dt_field = forms.ChoiceField(choices=(), initial='dt_addition', required=False)
 
     def __init__(self, *args, **kwargs):
 
         super(CollectorForm, self).__init__(*args, **kwargs)
-        self.fields['order_field'].choices = list_to_choices(ALL_FIELD_NAMES)
-        self.fields['param_dt_field'].choices = list_to_choices(swingcms.DATETIME_FIELD_NAMES)
-        self.fields['param_contenttypes'].choices = list_to_choices(settings.COLLECTIBLE)
+        self.fields['order_field'].choices = list_to_choices(swingcache.FIELD_NAMES)
+        self.fields['param_dt_field'].choices = list_to_choices(swingcache.DATETIME_FIELD_NAMES)
         self.fields['param_folders'].choices = models.Folder.objects.all().values_list('id','name')
+        collectible = ContentType.objects.filter(model__in=settings.COLLECTIBLE)
+        self.fields['param_contenttypes'].choices = collectible.values_list('id','name')
 
     class Meta:
 
         model = models.Collector
         fields = ('name', 'title', 'subtitle', 'introduction', 'language', 'order_field',
                   'order_direction', 'limit', 'dt_validity', 'dt_expired', 'categories',
-                  'template', "keywords", 'description',
+                  'template', "keywords", 'description', 'layout',
 
                   'datetime_criterion', 'param_dt_field', 'param_dt_operator', 'param_delta_year',
                   'param_delta_month', 'param_delta_day',