admin Package

admin Package

Admin of Zinnia

category Module

CategoryAdmin for Zinnia

class zinnia.admin.category.CategoryAdmin(model, admin_site)

Bases: django.contrib.admin.options.ModelAdmin

Admin for Category model.

fields = ('title', 'parent', 'description', 'slug')
form

alias of CategoryAdminForm

get_tree_path(category)

Return the category’s tree path in HTML.

list_display = ('title', 'slug', 'get_tree_path', 'description')
list_filter = ('parent',)
media
prepopulated_fields = {'slug': ('title',)}
search_fields = ('title', 'description')

entry Module

EntryAdmin for Zinnia

class zinnia.admin.entry.EntryAdmin(model, admin_site)

Bases: django.contrib.admin.options.ModelAdmin

Admin for Entry model.

actions = [u'make_mine', u'make_published', u'make_hidden', u'close_comments', u'close_pingbacks', u'close_trackbacks', u'ping_directories', u'put_on_top', u'mark_featured', u'unmark_featured']
actions_on_bottom = True
actions_on_top = True
close_comments(request, queryset)

Close the comments for selected entries.

close_pingbacks(request, queryset)

Close the pingbacks for selected entries.

close_trackbacks(request, queryset)

Close the trackbacks for selected entries.

date_hierarchy = u'publication_date'
fieldsets = ((<django.utils.functional.__proxy__ object at 0x7fdf5040cf50>, {u'fields': ((u'title', u'status'), u'lead', u'content')}), (<django.utils.functional.__proxy__ object at 0x7fdf50411390>, {u'fields': (u'image', u'image_caption'), u'classes': (u'collapse', u'collapse-closed')}), (<django.utils.functional.__proxy__ object at 0x7fdf5012d250>, {u'fields': (u'publication_date', u'sites', (u'start_publication', u'end_publication')), u'classes': (u'collapse', u'collapse-closed')}), (<django.utils.functional.__proxy__ object at 0x7fdf5012d2d0>, {u'fields': (u'comment_enabled', u'pingback_enabled', u'trackback_enabled'), u'classes': (u'collapse', u'collapse-closed')}), (<django.utils.functional.__proxy__ object at 0x7fdf5012d350>, {u'fields': (u'login_required', u'password'), u'classes': (u'collapse', u'collapse-closed')}), (<django.utils.functional.__proxy__ object at 0x7fdf5012d390>, {u'fields': (u'content_template', u'detail_template'), u'classes': (u'collapse', u'collapse-closed')}), (<django.utils.functional.__proxy__ object at 0x7fdf5012dfd0>, {u'fields': (u'featured', u'excerpt', u'authors', u'related'), u'classes': (u'collapse', u'collapse-closed')}), (None, {u'fields': (u'categories', u'tags', u'slug')}))
filter_horizontal = (u'categories', u'authors', u'related')
form

alias of EntryAdminForm

formfield_for_manytomany(db_field, request, **kwargs)

Filter the disposable authors.

get_actions(request)

Define actions by user’s permissions.

get_authors(entry)

Return the authors in HTML.

get_categories(entry)

Return the categories linked in HTML.

get_changeform_initial_data(request)

Provide initial datas when creating an entry.

get_is_visible(entry)

Admin wrapper for entry.is_visible.

get_queryset(request)

Make special filtering by user’s permissions.

get_readonly_fields(request, obj=None)

Return readonly fields by user’s permissions.

get_short_url(entry)

Return the short url in HTML.

get_sites(entry)

Return the sites linked in HTML.

get_tags(entry)

Return the tags linked in HTML.

get_title(entry)

Return the title with word count and number of comments.

list_display = (u'get_title', u'get_authors', u'get_categories', u'get_tags', u'get_sites', u'get_is_visible', u'featured', u'get_short_url', u'publication_date')
list_filter = (<class 'zinnia.admin.filters.CategoryListFilter'>, <class 'zinnia.admin.filters.AuthorListFilter'>, u'publication_date', u'sites', u'status')
make_hidden(request, queryset)

Set entries selected as hidden.

make_mine(request, queryset)

Set the entries to the current user.

make_published(request, queryset)

Set entries selected as published.

Mark selected as featured post.

media
ping_directories(request, queryset, messages=True)

Ping web directories for selected entries.

prepopulated_fields = {u'slug': (u'title',)}
put_on_top(request, queryset)

Put the selected entries on top at the current date.

radio_fields = {u'content_template': 2, u'detail_template': 2}
search_fields = (u'title', u'excerpt', u'content', u'tags')

Un-Mark selected featured posts.

fields Module

Fields for Zinnia admin

class zinnia.admin.fields.MPTTModelChoiceIterator(field)

Bases: django.forms.models.ModelChoiceIterator

MPTT version of ModelChoiceIterator.

choice(obj)

Overloads the choice method to add the position of the object in the tree for future sorting.

class zinnia.admin.fields.MPTTModelMultipleChoiceField(level_indicator='|--', *args, **kwargs)

Bases: django.forms.models.ModelMultipleChoiceField

MPTT version of ModelMultipleChoiceField.

choices

Override the _get_choices method to use MPTTModelChoiceIterator.

label_from_instance(obj)

Create labels which represent the tree level of each node when generating option labels.

filters Module

Filters for Zinnia admin

class zinnia.admin.filters.AuthorListFilter(request, params, model, model_admin)

Bases: zinnia.admin.filters.RelatedPublishedFilter

List filter for EntryAdmin with published authors only.

lookup_key = 'authors__id'
model

alias of Author

parameter_name = 'author'
title = <django.utils.functional.__proxy__ object>
class zinnia.admin.filters.CategoryListFilter(request, params, model, model_admin)

Bases: zinnia.admin.filters.RelatedPublishedFilter

List filter for EntryAdmin about categories with published entries.

lookup_key = 'categories__id'
model

alias of Category

parameter_name = 'category'
title = <django.utils.functional.__proxy__ object>
class zinnia.admin.filters.RelatedPublishedFilter(request, params, model, model_admin)

Bases: django.contrib.admin.filters.SimpleListFilter

Base filter for related objects to published entries.

lookup_key = None
lookups(request, model_admin)

Return published objects with the number of entries.

model = None
queryset(request, queryset)

Return the object’s entries if a value is set.

forms Module

Forms for Zinnia admin

class zinnia.admin.forms.CategoryAdminForm(*args, **kwargs)

Bases: django.forms.models.ModelForm

Form for Category’s Admin.

class Meta

CategoryAdminForm’s Meta.

fields = u'__all__'
model

alias of Category

CategoryAdminForm.admin_site = <django.contrib.admin.sites.AdminSite object>
CategoryAdminForm.base_fields = OrderedDict([('title', <django.forms.fields.CharField object at 0x7fdf5042da50>), ('slug', <django.forms.fields.SlugField object at 0x7fdf5042db90>), ('description', <django.forms.fields.CharField object at 0x7fdf5042dc90>), ('parent', <mptt.forms.TreeNodeChoiceField object at 0x7fdf5042d750>)])
CategoryAdminForm.clean_parent()

Check if category parent is not selfish.

CategoryAdminForm.declared_fields = OrderedDict([('parent', <mptt.forms.TreeNodeChoiceField object at 0x7fdf5042d750>)])
CategoryAdminForm.media
class zinnia.admin.forms.EntryAdminForm(*args, **kwargs)

Bases: django.forms.models.ModelForm

Form for Entry’s Admin.

class Meta

EntryAdminForm’s Meta.

fields = u'__all__'
model

alias of Entry

widgets = {'excerpt': <class 'zinnia.admin.widgets.MiniTextarea'>, 'image_caption': <class 'zinnia.admin.widgets.MiniTextarea'>, 'lead': <class 'zinnia.admin.widgets.MiniTextarea'>, 'tags': <class 'zinnia.admin.widgets.TagAutoComplete'>}
EntryAdminForm.admin_site = <django.contrib.admin.sites.AdminSite object>
EntryAdminForm.base_fields = OrderedDict([('title', <django.forms.fields.CharField object at 0x7fdf5043f310>), ('slug', <django.forms.fields.SlugField object at 0x7fdf5043f450>), ('status', <django.forms.fields.TypedChoiceField object at 0x7fdf5043f610>), ('publication_date', <django.forms.fields.DateTimeField object at 0x7fdf5043f6d0>), ('start_publication', <django.forms.fields.DateTimeField object at 0x7fdf5043f790>), ('end_publication', <django.forms.fields.DateTimeField object at 0x7fdf5042de10>), ('sites', <django.forms.models.ModelMultipleChoiceField object at 0x7fdf5042de50>), ('creation_date', <django.forms.fields.DateTimeField object at 0x7fdf5043fa10>), ('last_update', <django.forms.fields.DateTimeField object at 0x7fdf5043fa90>), ('content', <django.forms.fields.CharField object at 0x7fdf5043fb90>), ('comment_enabled', <django.forms.fields.BooleanField object at 0x7fdf5043fc90>), ('pingback_enabled', <django.forms.fields.BooleanField object at 0x7fdf5043fd50>), ('trackback_enabled', <django.forms.fields.BooleanField object at 0x7fdf5043fe10>), ('comment_count', <django.forms.fields.IntegerField object at 0x7fdf5043ff10>), ('pingback_count', <django.forms.fields.IntegerField object at 0x7fdf50448050>), ('trackback_count', <django.forms.fields.IntegerField object at 0x7fdf50448190>), ('related', <django.forms.models.ModelMultipleChoiceField object at 0x7fdf50448290>), ('lead', <django.forms.fields.CharField object at 0x7fdf50448550>), ('excerpt', <django.forms.fields.CharField object at 0x7fdf504485d0>), ('image', <django.forms.fields.ImageField object at 0x7fdf504486d0>), ('image_caption', <django.forms.fields.CharField object at 0x7fdf50448790>), ('featured', <django.forms.fields.BooleanField object at 0x7fdf504488d0>), ('authors', <django.forms.models.ModelMultipleChoiceField object at 0x7fdf50448a10>), ('categories', <zinnia.admin.fields.MPTTModelMultipleChoiceField object at 0x7fdf5042dd10>), ('tags', <tagging.forms.TagField object at 0x7fdf50448e50>), ('login_required', <django.forms.fields.BooleanField object at 0x7fdf50448f90>), ('password', <django.forms.fields.CharField object at 0x7fdf50454050>), ('content_template', <django.forms.fields.TypedChoiceField object at 0x7fdf50454210>), ('detail_template', <django.forms.fields.TypedChoiceField object at 0x7fdf50454350>)])
EntryAdminForm.declared_fields = OrderedDict([('categories', <zinnia.admin.fields.MPTTModelMultipleChoiceField object at 0x7fdf5042dd10>)])
EntryAdminForm.media

widgets Module

Widgets for Zinnia admin

class zinnia.admin.widgets.MPTTFilteredSelectMultiple(verbose_name, is_stacked=False, attrs=None, choices=())

Bases: django.contrib.admin.widgets.FilteredSelectMultiple

MPTT version of FilteredSelectMultiple.

media

MPTTFilteredSelectMultiple’s Media.

render_option(selected_choices, option_value, option_label, sort_fields)

Overrides the render_option method to handle the sort_fields argument.

render_options(selected_choices)

This is copy’n’pasted from django.forms.widgets Select(Widget) change to the for loop and render_option so they will unpack and use our extra tuple of mptt sort fields (if you pass in some default choices for this field, make sure they have the extra tuple too!).

class zinnia.admin.widgets.MiniTextarea(attrs=None)

Bases: django.contrib.admin.widgets.AdminTextareaWidget

Vertically shorter version of the admin textarea widget.

media
rows = 2
class zinnia.admin.widgets.TagAutoComplete(attrs=None)

Bases: django.contrib.admin.widgets.AdminTextInputWidget

Tag widget with autocompletion based on select2.

get_tags()

Returns the list of tags to auto-complete.

media

TagAutoComplete’s Media.

render(name, value, attrs=None)

Render the default widget and initialize select2.