class DecimalField(BaseFieldEntry): max_value = schema.IntegerField(blank=True, null=True) min_value = schema.IntegerField(blank=True, null=True) max_digits = schema.IntegerField(blank=True, null=True) decimal_places = schema.IntegerField(blank=True, null=True) field_class = schema.DecimalField class Meta: typed_key = 'DecimalField'
class ThumbnailFieldEntrySchema(schema.Schema): key = schema.SlugField() format = schema.CharField(blank=True, null=True, choices=IMAGE_FORMATS) quality = schema.IntegerField(blank=True, null=True) width = schema.IntegerField(blank=True, null=True) height = schema.IntegerField(blank=True, null=True) upscale = schema.BooleanField( default=False, help_text='Upsize the image if it doesn\'t match the width and height') crop = schema.CharField(blank=True, null=True, choices=CROP_CHOICES) autocrop = schema.BooleanField( default=False, help_text='Remove white space from around the image') def __unicode__(self): return self.key or repr(self)
class ListViewPoint(BaseViewPoint, TemplateMixin): paginate_by = schema.IntegerField(blank=True, null=True) #order_by = schema.CharField(blank=True) view_class = PointListView def get_urls(self): params = self.to_primitive(self) object_class = self.get_object_class() index = self.get_index() urlpatterns = patterns( '', url( r'^$', self.view_class.as_view(document=object_class, queryset=index, view_point=self, configuration=params, paginate_by=self.paginate_by), #order_by=self.order_by), name='index', ), ) return urlpatterns class Meta: typed_key = 'dockitcms.listview' @classmethod def get_admin_form_class(cls): return ListViewPointForm
class TemporaryDocumentInfo(schema.Schema): user = schema.ModelReferenceField(User, blank=True, null=True) created = schema.DateTimeField(default=datetime.datetime.now) object_collection = schema.CharField() object_id = schema.CharField() number_of_changes = schema.IntegerField(default=0)
class ListViewPoint(BaseViewPoint, IndexMixin): paginate_by = schema.IntegerField(blank=True, null=True) #order_by = schema.CharField(blank=True) default_endpoint_name = 'list' view_endpoint_class = ListEndpoint class Meta: typed_key = 'dockitcms.listview' @classmethod def get_admin_form_class(cls): return ListViewPointForm
class ListingViewPoint(ViewPoint, CanonicalMixin, IndexMixin): slug_field = schema.SlugField(blank=True) list_template_source = schema.CharField(choices=TEMPLATE_SOURCE_CHOICES, default='name') list_template_name = schema.CharField(default='dockitcms/list.html', blank=True) list_template_html = schema.TextField(blank=True) list_content = schema.TextField(blank=True, help_text=LIST_CONTEXT_DESCRIPTION) detail_template_source = schema.CharField(choices=TEMPLATE_SOURCE_CHOICES, default='name') detail_template_name = schema.CharField(default='dockitcms/detail.html', blank=True) detail_template_html = schema.TextField(blank=True) detail_content = schema.TextField(blank=True, help_text=DETAIL_CONTEXT_DESCRIPTION) paginate_by = schema.IntegerField(blank=True, null=True) list_view_class = PointListView detail_view_class = PointDetailView def get_object_class(self): doc_cls = self.index.get_object_class() view_point = self def get_absolute_url_for_instance(instance): if view_point.slug_field: return view_point.reverse('detail', instance[view_point.slug_field]) return view_point.reverse('detail', instance.pk) if self.canonical: #TODO this does not work setattr(doc_cls, 'get_absolute_url', get_absolute_url_for_instance) assert hasattr(doc_cls, 'get_absolute_url') #TODO support model or do this gently class WrappedDoc(doc_cls): get_absolute_url = get_absolute_url_for_instance class Meta: proxy = True return WrappedDoc def _configuration_from_prefix(self, params, prefix): config = dict() for key in ('template_source', 'template_name', 'template_html', 'content'): config[key] = params.get('%s_%s' % (prefix, key), None) return config def get_urls(self): document = self.get_object_class() params = self.to_primitive(self) index = self.get_index() urlpatterns = patterns( '', url( r'^$', self.list_view_class.as_view( document=document, queryset=index, view_point=self, configuration=self._configuration_from_prefix( params, 'list'), paginate_by=params.get('paginate_by', None)), name='index', ), ) if params.get('slug_field', None): urlpatterns += patterns( '', url( r'^(?P<slug>.+)/$', self.detail_view_class.as_view( document=document, queryset=index, slug_field=params['slug_field'], view_point=self, configuration=self._configuration_from_prefix( params, 'detail'), ), name='detail', ), ) else: urlpatterns += patterns( '', url( r'^(?P<pk>.+)/$', self.detail_view_class.as_view( document=document, queryset=index, view_point=self, configuration=self._configuration_from_prefix( params, 'detail'), ), name='detail', ), ) return urlpatterns class Meta: typed_key = 'dockitcms.listing' @classmethod def get_admin_form_class(cls): return ListingViewPointForm
class AdminOptions(schema.Schema): list_display = schema.ListField(schema.CharField(), blank=True) list_per_page = schema.IntegerField(default=100)