Views¶
- class lotus.views.mixins.NoOperationBreadcrumMixin[source]¶
A dummy and empty mixin to use when ‘view_breadcrumbs’ is not available.
- class lotus.views.mixins.PreviewModeMixin[source]¶
A mixin to contain the logic for preview mode and add a context variable
preview_mode.Preview mode is only allowed for staff users which use URL with a specific argument as defined in setting
LOTUS_PREVIEW_KEYWORD.A staff user is only allowed for preview mode if its session have the right item set to
Trueexactly.The preview mode is essentially used to not filter queryset with publication criterias.
- class lotus.views.mixins.ArticleFilterMixin(*args, **kwargs)[source]¶
A mixin to share Article filtering.
- build_article_lookups(language=None, prefix=None)[source]¶
Build complex lookups to apply common publication criterias.
Also set a
self.target_dateattribute to store the date checked against as a reference for further usage (like inget_context_data).Depends on
allowed_preview_modemethod as implemented inPreviewModeMixin(that manage preview mode) and the queryset must be for a model with a manager which implementget_for_langandget_publishedmethods.- Keyword Arguments:
language (string) – Language code to filter on.
- Returns:
The lookups to give to a queryset filter.
- Return type:
tuple
- apply_article_lookups(queryset, language=None)[source]¶
Apply publication and language lookups to given queryset.
This will set a
self.target_dateattribute to store the date checked against as a reference for further usage (like inget_context_data).The queryset must be for a model with a manager which implement
get_for_langandget_publishedmethods. This support alsoallowed_preview_modemethod as implemented inPreviewModeMixin(that manage preview mode) if it is available.- Parameters:
queryset (django.db.models.QuerySet) – Base queryset to start on.
- Keyword Arguments:
language (string) – Language code to filter on.
- Returns:
Improved queryset with required filtering lookups.
- Return type:
django.db.models.QuerySet
- class lotus.views.mixins.LanguageMixin[source]¶
A mixin to provide very common logic related to language.
- class lotus.views.mixins.LotusContextStage[source]¶
Mixin to inject Lotus stage into view context.
Lotus stage is commonly used for Lotus navigation, it just indicates where a view is located from main Lotus content type views (Article, Author, Category, ..).
Views which inherits from this mixin should set view attribute
lotus_stageto a main content type in lowercase likearticles,authors,category.The default stage value is
None.Finally, the Lotus stage is just an helper for basic navigation like in a menu to highlight corresponding item. There is no code which use it so it can be ignored from custom Lotus implementation.
- class lotus.views.mixins.ArticleFilterAbstractView(*args, **kwargs)[source]¶
Abstract class which gather all the classes needed to implement filtering on criterias.
- class lotus.views.mixins.TemplateFromObjectMixin[source]¶
A mixin to get the template to render from the object attribute
template.It is intended to override the template mechanism from
TemplateResponseMixinand for a view which have an attributeobjectwhere to find the attributetemplate.
- class lotus.views.ArticleDetailView(*args, **kwargs)[source]¶
Article detail.
- class lotus.views.AuthorIndexView(**kwargs)[source]¶
List of authors which have contributed at least to one article.
- class lotus.views.AuthorDetailView(*args, **kwargs)[source]¶
Author detail and its related article list.
Opposed to article or category listing, this one list objects for language from request, not from the author language since it dont have one.
- pk_url_kwarg = None¶
- class lotus.views.CategoryDetailView(*args, **kwargs)[source]¶
Category detail and its related article list.
- pk_url_kwarg = None¶
- class lotus.views.DisabledTagIndexView(**kwargs)[source]¶
A very basic view which always return the common Http404 page.
- class lotus.views.EnabledTagIndexView(*args, **kwargs)[source]¶
List of tags that are related from at least one article.
- model¶
alias of
Tag
- class lotus.views.PreviewArticleDetailView(*args, **kwargs)[source]¶
TODO: Should force set the context var for preview mode at True without to tamper session so the user session is still in its current state but it can preview.
- class lotus.views.PreviewTogglerView(**kwargs)[source]¶
Toggle preview mode in user session.
The redirection url can not be one of the preview toggler url, this is to avoid malicious redirection loop.
Only authenticated admin user is allowed to use this view and an URL argument “next” is required to be given and not relative (not starting with
/) else it is assumed as a bad operation.
- class lotus.views.TagIndexView(*args, **kwargs)¶
This is the effective index class view which inherit either from the working index view or the dummy 404 view if Tag index is enabled or not according to settings.
- class lotus.views.TagDetailView(*args, **kwargs)[source]¶
Tag detail and its related article list.
Opposed to article or category listing, this one list objects for language from request, not from the tag language since it dont have one.
- model¶
alias of
Tag
- pk_url_kwarg = None¶
- class lotus.views.TagAutocompleteView(**kwargs)[source]¶
View to return JSON response for a tag list.
Default returns paginated list of all available tags. If request argument
qis given, the list will return tag items that start with text from argument.Worth to notice this is language agnostic, since a Tag does not have any specific language.
- class lotus.views.admin.AdminTranslateView(**kwargs)[source]¶
Mixin to display a form to select a language to translate an object to.
The form does not perform a POST request. Instead it will make a GET to the object create form with some URL argument so the create form will know it will have to prefill fields “language” and “original”, the user still have to fill everything else.
Form only displays the language which are still available (not in original and its possible translations).
Given ID is used to retrieve an object and get its original if its translation. Finally the form will always redirect to an original object.
Despite inheriting from DetailView, this is not a ready to use view, you need inherit it to define the
modeandtemplate_nameattributes correctly.- get_queryset()[source]¶
Return the QuerySet that will be used to look up the object.
This method is called by the default implementation of get_object() and may not be called if get_object() is overridden.
- class lotus.views.admin.ArticleAdminTranslateView(**kwargs)[source]¶
Display a form to select a language to translate an article to.
- class lotus.views.admin.CategoryAdminTranslateView(**kwargs)[source]¶
Display a form to select a language to translate a category to.
- class lotus.views.admin.CategoryAdminTreeView(**kwargs)[source]¶
An admin view to list a tree of categories.
Since it is a tree this view can’t enable pagination because it is not safe to cut a tree in multiple pages.
- class lotus.views.admin.CustomLotusAdminContext[source]¶
Mixin to add required context for a custom model admin view.
The view which use it must have the
modelcorrectly set to your model, if your view has no model then this mixin is probably useless.Also, there is an additional useful context variable
titleto set yourself in your view since its value is totally related to the view itself.