Models#

class lotus.models.translated.Translated(*args, **kwargs)[source]#

Abstract model for common content translation fields.

language#

Required language code.

lotus.models.author.safe_get_user_model()[source]#

Safe loading of the User model, customized or not.

class lotus.models.author.AuthorManagerEnabled(*args, **kwargs)[source]#

Proxy model manager to avoid overriding default User’s manager:

https://docs.djangoproject.com/en/dev/topics/db/models/#proxy-model-managers

class lotus.models.author.Author(*args, **kwargs)[source]#

Proxy model around User model gotten from django.contrib.auth.models.get_user_model.

get_absolute_url()[source]#

Builds and returns the author’s URL based on his username.

TODO: The try..except does not seems useful.

get_absolute_api_url()[source]#

Return absolute URL to the author detail viewset from API.

Returns:

An URL.

Return type:

string

COMMON_ORDER_BY = ['first_name', 'last_name']#

List of field order commonly used in frontend view/api

class lotus.models.category.Category(*args, **kwargs)[source]#

Category model.

original#

Optional original category when object is a translation.

modified#

Automatic modification date.

title#

Required unique title string.

slug#

Required unique slug string.

lead#

Optional text lead.

description#

Optional description string.

cover#

Optional cover image file.

COMMON_ORDER_BY = ['title']#

List of field order commonly used in frontend view/api

language#

Required language code.

get_absolute_url()[source]#

Return absolute URL to the category detail view.

Returns:

An URL.

Return type:

string

get_absolute_api_url()[source]#

Return absolute URL to the author detail viewset from API.

Returns:

An URL.

Return type:

string

get_edit_url()[source]#

Return absolute URL to edit article from admin.

Returns:

An URL.

Return type:

string

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

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

class lotus.models.album.Album(*args, **kwargs)[source]#

Album container for items.

title#

A required title string.

modified#

Automatic modification date.

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

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

class lotus.models.album.AlbumItem(*args, **kwargs)[source]#

Album item model.

modified#

Automatic modification date.

title#

Required title string.

order#

Optional number for order position in item list.

media#

Required media file.

COMMON_ORDER_BY = ['order', 'title']#

List of field order commonly used in frontend view/api

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

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

class lotus.models.article.Article(*args, **kwargs)[source]#

Article model.

original#

Optional original category when object is a translation.

status#

Required article status.

featured#

Optional article featured mark.

pinned#

Optional article pinned mark.

private#

Optional privacy.

publish_date#

Required publication date.

publish_time#

Required publication time.

publish_end#

Optional publication end date.

last_update#

Last edition date.

title#

Required title string.

slug#

Required unique slug string.

seo_title#

Optional SEO title string used as meta title if not blank, instead of default behavior to use article title.

lead#

Optional text lead.

introduction#

Optional text introduction.

content#

Optional text content.

cover#

Optional cover image.

image#

Optional large image.

categories#

Optional related Categories.

authors#

Optional related Authors.

related#

Optional related article.

tags = <taggit.managers._TaggableManager object>#

Optional tags

album#

Optional album relation.

COMMON_ORDER_BY = ['-pinned', '-publish_date', '-publish_time', 'title']#

List of field order commonly used in frontend view/api

language#

Required language code.

build_absolute_url(urlname)[source]#

Build object absolute URL with language prefix for url name.

Language is forced on article language.

Parameters:

urlname (string) – The URL name to reverse with kwargs to get absolute URL.

Returns:

Object absolute URL.

Return type:

string

get_absolute_url()[source]#

Return absolute URL to the article detail view.

Returns:

An URL.

Return type:

string

get_absolute_api_url()[source]#

Return absolute URL to the article detail viewset from API.

Returns:

An URL.

Return type:

string

get_absolute_preview_url()[source]#

Return absolute URL to the article detail view in forced preview mode.

Returns:

An URL.

Return type:

string

get_edit_url()[source]#

Return absolute URL to edit article from admin.

Returns:

An URL.

Return type:

string

get_authors()[source]#

Return article authors.

Returns:

List of article authors.

Return type:

queryset

get_categories()[source]#

Return article categories, results are enforced on article language.

Returns:

List of article categories.

Return type:

queryset

get_album_items()[source]#

Return album items.

Depends on use_original_album value.

Returns:

List of album items.

Return type:

queryset

Return article related articles.

Warning

On default without filter_func defined this won’t apply any publication criteria, only the language filtering.

You would need to give it a proper filtering function to ensure about results.

TODO: Concretely for now, the ‘filter_func’ is not used in HTML frontend but it should, either from a variable context or a template tag.

Keyword Arguments:

filter_func (function) – A function used to create a queryset for related articles filtered. It has been done to be given ArticleFilterMixin.apply_article_lookups so any other given function should at least expect the same arguments.

Returns:

List of related articles.

Return type:

queryset

get_tags()[source]#

Return article tags.

Returns:

List of related ‘taggit.models.Tag’ objects.

Return type:

queryset

publish_datetime()[source]#

Return a datetime from joined publish date and time.

Returns:

Publish datetime with UTC timezone.

Return type:

datetime.datetime

get_states(now=None)[source]#

Computate every publication states.

State names depend from settings.LOTUS_ARTICLE_PUBLICATION_STATE_NAMES and each state name can be disabled (never raised in states) if its key name have been removed from setting.

Keywords Arguments:
now (datetime.datetime): Commonly the current datetime ‘now’ (timezone

aware) which have been used in queryset lookup to check for publication availability. It is used to determine if article publish “start date” is to come next or if article publish “end date” is over the current date. Empty by default, there will be no state about start/end dates.

Returns:

A list of all article state names.

Return type:

list

is_published(now=None)[source]#

Check for all publication criterias for a datetime.

Keywords Arguments:
now (datetime.datetime): Datetime to match against for publication states.

Default to None so it will use current datetime.

Returns:

True if object is published else False.

Return type:

boolean

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

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.