models_bases Package¶
models_bases
Package¶
Base models for Zinnia
-
zinnia.models_bases.
load_model_class
(model_path)¶ Load by import a class by a string path like: ‘module.models.MyModel’. This mecanizm allows extension and customization of the Entry model class.
entry
Module¶
Base entry models for Zinnia
-
class
zinnia.models_bases.entry.
AbstractEntry
(*args, **kwargs)¶ Bases:
zinnia.models_bases.entry.CoreEntry
,zinnia.models_bases.entry.ContentEntry
,zinnia.models_bases.entry.DiscussionsEntry
,zinnia.models_bases.entry.RelatedEntry
,zinnia.models_bases.entry.ExcerptEntry
,zinnia.models_bases.entry.ImageEntry
,zinnia.models_bases.entry.FeaturedEntry
,zinnia.models_bases.entry.AuthorsEntry
,zinnia.models_bases.entry.CategoriesEntry
,zinnia.models_bases.entry.TagsEntry
,zinnia.models_bases.entry.LoginRequiredEntry
,zinnia.models_bases.entry.PasswordRequiredEntry
,zinnia.models_bases.entry.ContentTemplateEntry
,zinnia.models_bases.entry.DetailTemplateEntry
Final abstract entry model class assembling all the abstract entry model classes into a single one.
In this manner we can override some fields without reimplemting all the AbstractEntry.
Parameters: - title (CharField) – Title
- slug (SlugField) – Used to build the entry’s URL.
- status (IntegerField) – Status
- start_publication (DateTimeField) – Start date of publication.
- end_publication (DateTimeField) – End date of publication.
- creation_date (DateTimeField) – Used to build the entry’s URL.
- last_update (DateTimeField) – Last update
- content (TextField) – Content
- comment_enabled (BooleanField) – Allows comments if checked.
- pingback_enabled (BooleanField) – Allows pingbacks if checked.
- trackback_enabled (BooleanField) – Allows trackbacks if checked.
- comment_count (IntegerField) – Comment count
- pingback_count (IntegerField) – Pingback count
- trackback_count (IntegerField) – Trackback count
- excerpt (TextField) – Optional element.
- image (ImageField) – Used for illustration.
- featured (BooleanField) – Featured
- tags (TagField) – Tags
- login_required (BooleanField) – Only authenticated users can view the entry.
- password (CharField) – Protects the entry with a password.
- content_template (CharField) – Template used to display the entry’s content.
- detail_template (CharField) – Template used to display the entry’s detail page.
-
AbstractEntry.
categories
¶
-
AbstractEntry.
get_content_template_display
(*moreargs, **morekwargs)¶
-
AbstractEntry.
get_detail_template_display
(*moreargs, **morekwargs)¶
-
AbstractEntry.
get_next_by_creation_date
(*moreargs, **morekwargs)¶
-
AbstractEntry.
get_next_by_last_update
(*moreargs, **morekwargs)¶
-
AbstractEntry.
get_previous_by_creation_date
(*moreargs, **morekwargs)¶
-
AbstractEntry.
get_previous_by_last_update
(*moreargs, **morekwargs)¶
-
AbstractEntry.
get_status_display
(*moreargs, **morekwargs)¶
-
AbstractEntry.
objects
¶
-
AbstractEntry.
published
¶
-
AbstractEntry.
sites
¶
-
class
zinnia.models_bases.entry.
AuthorsEntry
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Abstract model class to add relationship between the entries and their authors.
-
class
zinnia.models_bases.entry.
CategoriesEntry
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Abstract model class to categorize the entries.
-
CategoriesEntry.
categories
¶
-
-
class
zinnia.models_bases.entry.
ContentEntry
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Abstract content model class providing field and methods to write content inside an entry.
Parameters: content (TextField) – Content -
ContentEntry.
html_content
¶ Returns the “content” field formatted in HTML.
-
ContentEntry.
html_preview
¶ Returns a preview of the “content” field formmated in HTML.
-
ContentEntry.
word_count
¶ Counts the number of words used in the content.
-
-
class
zinnia.models_bases.entry.
ContentTemplateEntry
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Abstract model class to display entry’s content with a custom template.
Parameters: content_template (CharField) – Template used to display the entry’s content. -
ContentTemplateEntry.
get_content_template_display
(*moreargs, **morekwargs)¶
-
-
class
zinnia.models_bases.entry.
CoreEntry
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Abstract core entry model class providing the fields and methods required for publishing content over time.
Parameters: - title (CharField) – Title
- slug (SlugField) – Used to build the entry’s URL.
- status (IntegerField) – Status
- start_publication (DateTimeField) – Start date of publication.
- end_publication (DateTimeField) – End date of publication.
- creation_date (DateTimeField) – Used to build the entry’s URL.
- last_update (DateTimeField) – Last update
-
class
Meta
¶ CoreEntry’s meta informations.
-
abstract
= False¶
-
app_label
= u'zinnia'¶
-
get_latest_by
= u'creation_date'¶
-
index_together
= [[u'slug', u'creation_date']]¶
-
ordering
= [u'-creation_date']¶
-
permissions
= ((u'can_view_all', u'Can view all entries'), (u'can_change_status', u'Can change status'), (u'can_change_author', u'Can change author(s)'))¶
-
verbose_name
= <django.utils.functional.__proxy__ object>¶
-
verbose_name_plural
= <django.utils.functional.__proxy__ object>¶
-
-
CoreEntry.
STATUS_CHOICES
= ((0, <django.utils.functional.__proxy__ object>), (1, <django.utils.functional.__proxy__ object>), (2, <django.utils.functional.__proxy__ object>))¶
-
CoreEntry.
get_absolute_url
(*args, **kwargs)¶ Builds and returns the entry’s URL based on the slug and the creation date.
-
CoreEntry.
get_next_by_creation_date
(*moreargs, **morekwargs)¶
-
CoreEntry.
get_next_by_last_update
(*moreargs, **morekwargs)¶
-
CoreEntry.
get_previous_by_creation_date
(*moreargs, **morekwargs)¶
-
CoreEntry.
get_previous_by_last_update
(*moreargs, **morekwargs)¶
-
CoreEntry.
get_status_display
(*moreargs, **morekwargs)¶
-
CoreEntry.
is_actual
¶ Checks if an entry is within his publication period.
-
CoreEntry.
is_visible
¶ Checks if an entry is visible and published.
-
CoreEntry.
next_entry
¶ Returns the next published entry if exists.
-
CoreEntry.
objects
¶
-
CoreEntry.
previous_entry
¶ Returns the previous published entry if exists.
-
CoreEntry.
previous_next_entries
¶ Returns and caches a tuple containing the next and previous published entries. Only available if the entry instance is published.
-
CoreEntry.
published
¶
-
CoreEntry.
short_url
¶ Returns the entry’s short url.
-
CoreEntry.
sites
¶
-
class
zinnia.models_bases.entry.
DetailTemplateEntry
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Abstract model class to display entries with a custom template if needed on the detail page.
Parameters: detail_template (CharField) – Template used to display the entry’s detail page. -
DetailTemplateEntry.
get_detail_template_display
(*moreargs, **morekwargs)¶
-
-
class
zinnia.models_bases.entry.
DiscussionsEntry
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Abstract discussion model class providing the fields and methods to manage the discussions (comments, pingbacks, trackbacks).
Parameters: - comment_enabled (BooleanField) – Allows comments if checked.
- pingback_enabled (BooleanField) – Allows pingbacks if checked.
- trackback_enabled (BooleanField) – Allows trackbacks if checked.
- comment_count (IntegerField) – Comment count
- pingback_count (IntegerField) – Pingback count
- trackback_count (IntegerField) – Trackback count
-
DiscussionsEntry.
comments
¶ Returns a queryset of the published comments.
-
DiscussionsEntry.
comments_are_open
¶ Checks if the comments are open with the AUTO_CLOSE_COMMENTS_AFTER setting.
-
DiscussionsEntry.
discussion_is_still_open
(discussion_type, auto_close_after)¶ Checks if a type of discussion is still open are a certain number of days.
-
DiscussionsEntry.
discussions
¶ Returns a queryset of the published discussions.
-
DiscussionsEntry.
pingbacks
¶ Returns a queryset of the published pingbacks.
-
DiscussionsEntry.
pingbacks_are_open
¶ Checks if the pingbacks are open with the AUTO_CLOSE_PINGBACKS_AFTER setting.
-
DiscussionsEntry.
trackbacks
¶ Return a queryset of the published trackbacks.
-
DiscussionsEntry.
trackbacks_are_open
¶ Checks if the trackbacks are open with the AUTO_CLOSE_TRACKBACKS_AFTER setting.
-
class
zinnia.models_bases.entry.
ExcerptEntry
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Abstract model class to add an excerpt to the entries.
Parameters: excerpt (TextField) – Optional element.
-
class
zinnia.models_bases.entry.
FeaturedEntry
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Abstract model class to mark entries as featured.
Parameters: featured (BooleanField) – Featured
-
class
zinnia.models_bases.entry.
ImageEntry
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Abstract model class to add an image to the entries.
Parameters: image (ImageField) – Used for illustration.
-
class
zinnia.models_bases.entry.
LoginRequiredEntry
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Abstract model class to restrcit the display of the entry on authenticated users.
Parameters: login_required (BooleanField) – Only authenticated users can view the entry.
-
class
zinnia.models_bases.entry.
PasswordRequiredEntry
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Abstract model class to restrict the display of the entry to users knowing the password.
Parameters: password (CharField) – Protects the entry with a password.
-
class
zinnia.models_bases.entry.
RelatedEntry
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Abstract model class for making manual relations between the differents entries.
Returns only related entries published.