Views#

class lotus.views.ArticleIndexView(*args, **kwargs)[source]#

Paginated list of articles.

model#

alias of Article

get_queryset()[source]#

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

class lotus.views.ArticleDetailView(*args, **kwargs)[source]#

Article detail.

model#

alias of Article

get_queryset()[source]#

Get the base queryset which may include the basic publication filter depending preview mode.

Preview mode is enabled from a flag in session and only for staff user. If it is disabled publication criterias are applied on lookups.

Also apply lookup against “preview” mode.

get_object(queryset=None)[source]#

Apply the right filters to get the article object.

class lotus.views.AuthorIndexView(**kwargs)[source]#

List of authors which have contributed at least to one article.

model#

alias of Author

get_queryset()[source]#

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

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.

model#

alias of Author

listed_model#

alias of Article

pk_url_kwarg = None#
get_queryset_for_object()[source]#

Build queryset base to get Author.

get_queryset()[source]#

Build queryset base to list Author articles.

Depend on “self.object” to list the Author related objects.

class lotus.views.CategoryIndexView(**kwargs)[source]#

List of categories

model#

alias of Category

get_queryset()[source]#

Build queryset base with language filtering to list categories.

class lotus.views.CategoryDetailView(*args, **kwargs)[source]#

Category detail and its related article list.

model#

alias of Category

listed_model#

alias of Article

pk_url_kwarg = None#
get_queryset_for_object()[source]#

Build queryset base with language filtering to get Category.

get_queryset()[source]#

Build queryset base to list Category articles.

Depend on “self.object” to list the Category related objects filtered on its language.

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

get_queryset()[source]#

Build complex queryset to get all tags which have published articles.

Published articles are determined with the common publication criterias.

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.

allowed_preview_mode(request)[source]#

Force preview mode for querysets.

get_context_data(**kwargs)[source]#

Force preview mode in context (without tampering preview mode in session).

TODO: Control user staff right to use this

get(request, *args, **kwargs)[source]#

Ensure that user is allowed to use this view.

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.

get_redirect_url(*args, **kwargs)[source]#

Return the URL redirect to. Keyword arguments from the URL pattern match generating the redirect request are provided as kwargs to this method.

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

listed_model#

alias of Article

pk_url_kwarg = None#
get_queryset_for_object()[source]#

Build queryset base to get Tag.

get_queryset()[source]#

Build queryset base to list Tag articles.

Depend on “self.object” to list the Tag related objects.

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 q is 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.

test_func()[source]#

Limit to admin only

get_queryset()[source]#

Filter the queryset with GET[‘q’].

post(request, *args, **kwargs)[source]#

POST request is forbidden since DAL would create a tag for a missing value.

class lotus.views.admin.ArticleAdminTranslateView(**kwargs)[source]#

Display a form to select a language to translate an article to.

model#

alias of Article

class lotus.views.admin.CategoryAdminTranslateView(**kwargs)[source]#

Display a form to select a language to translate a category to.

model#

alias of Category

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 model correctly set to your model, if your view has no model then this mixin is probably useless.

Also, there is an additional useful context variable title to set yourself in your view since its value is totally related to the view itself.

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 mode and template_name attributes 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.

get_object(queryset=None)[source]#

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_context_data(**kwargs)[source]#

Append specific admin context