CMS

Admin

Debug lists and forms for all models

Apps

class integreat_cms.cms.apps.CmsConfig(app_name, app_module)[source]

Bases: AppConfig

This class represents the Django-configuration of the backend.

See django.apps.AppConfig for more information.

Parameters:

name – The name of the app

__init__(app_name, app_module)[source]
classmethod create(entry)[source]

Factory that creates an app config from an entry in INSTALLED_APPS.

default_auto_field[source]
get_model(model_name, require_ready=True)[source]

Return the model with the given case-insensitive model_name.

Raise LookupError if no model exists with this name.

get_models(include_auto_created=False, include_swapped=False)[source]

Return an iterable of models.

By default, the following models aren’t included:

  • auto-created models for many-to-many relations without an explicit intermediate table,

  • models that have been swapped out.

Set the corresponding keyword argument to True to include such models. Keyword arguments aren’t documented; they’re a private API.

import_models()[source]
name: Final[str] = 'integreat_cms.cms'[source]

Full Python path to the application

ready() None[source]

Monkeypatch the checking of internal URLs

Return type:

None

verbose_name: Final[Promise] = 'CMS'[source]

Human-readable name for the application

Auth

class integreat_cms.cms.auth.WPBCryptPasswordHasher[source]

Bases: BCryptSHA256PasswordHasher

A PHP (and WordPress) compatible BCrypt password hasher that supports hashes with $2y$10$. See https://www.php.net/manual/en/function.password-hash.php. For PHP style hashes only verification is supported.

__init__()[source]
algorithm: str = 'bcrypt_php'[source]
decode(encoded)[source]

Return a decoded database value.

The result is a dictionary and should contain algorithm, hash, and salt. Extra keys can be algorithm specific like iterations or work_factor.

digest(*, usedforsecurity=True)[source]

Returns a sha256 hash object; optionally initialized with a string

encode(password, salt)[source]

Create an encoded database value.

The result is normally formatted as “algorithm$salt$hash” and must be fewer than 128 characters.

harden_runtime(password, encoded)[source]

Bridge the runtime gap between the work factor supplied in encoded and the work factor suggested by this hasher.

Taking PBKDF2 as an example, if encoded contains 20000 iterations and self.iterations is 30000, this method should run password through another 10000 iterations of PBKDF2. Similar approaches should exist for any hasher that has a work factor. If not, this method should be defined as a no-op to silence the warning.

library: tuple[str, ...] = ('bcrypt', 'bcrypt')[source]
must_update(encoded)[source]
rounds: int = 10[source]
safe_summary(encoded)[source]

Return a summary of safe values.

The result is a dictionary and will be used where the password field must be displayed to construct a safe representation of the password.

salt()[source]

Generate a cryptographically secure nonce salt in ASCII with an entropy of at least salt_entropy bits.

salt_entropy = 128[source]
verify(password: str, encoded: str) bool[source]

Validate that entered password matches stored hash

Parameters:
  • password (str) – the plain text password

  • encoded (str) – the hashed and salted password, i.e. from database

Returns:

entered password matches the hash

Return type:

bool

Decorators

Django view decorators can be used to restrict the execution of a view function on certain conditions.

For more information, see View decorators.

integreat_cms.cms.decorators.modify_mfa_authenticated(function: Callable) Callable[source]

This decorator can be used to make sure a user can only modify his 2FA settings when he has a valid 2FA session.

Parameters:

function (Callable) – The view function which should be protected

Returns:

The decorated function

Return type:

Callable

integreat_cms.cms.decorators.permission_required(permission: str) Callable[source]

Decorator for views that checks whether a user has a particular permission enabled. If not, the PermissionDenied exception is raised.

Parameters:

permission (str) – The required permission

Returns:

The decorated function

Return type:

Callable

integreat_cms.cms.decorators.region_permission_required(function: Callable) Callable[source]

This decorator can be used to make sure a view can only be retrieved by users of the requested region.

Parameters:

function (Callable) – The view function which should be protected

Returns:

The decorated function

Return type:

Callable

Linklists

Bases: Linklist

Base class for content translation link lists

__init__()[source]
classmethod content_type()[source]
static extract_url_from_field(obj, field_name)[source]
classmethod filter_callable(objects: QuerySet) QuerySet[source]

Get only translations in active languages

Parameters:

objects (QuerySet) – Objects to be filtered

Returns:

Objects that passed the filter

Return type:

QuerySet

get_urls_from_field_list(obj, field_list)[source]
html_fields: list[str] = ['content'][source]
ignore_empty = [][source]
image_fields = [][source]
images(obj)[source]
object_exclude = None[source]
object_filter = None[source]
classmethod objects()[source]
url_fields = [][source]
urls(obj)[source]

Bases: NonArchivedLinkList

Class for selecting the EventTranslation model for link checks

__init__()[source]
classmethod content_type()[source]
static extract_url_from_field(obj, field_name)[source]
classmethod filter_callable(objects: QuerySet) QuerySet[source]

Get only translations of upcoming events in active languages

Parameters:

objects (QuerySet) – Objects to be filtered

Returns:

Objects that passed the filter

Return type:

QuerySet

get_urls_from_field_list(obj, field_list)[source]
html_fields: list[str] = ['content'][source]
ignore_empty = [][source]
image_fields = [][source]
images(obj)[source]
model[source]

alias of EventTranslation

object_exclude = None[source]
object_filter = None[source]
classmethod objects()[source]
url_fields = [][source]
urls(obj)[source]

Bases: ActiveLanguageLinklist

Class for excluding archived events and locations

__init__()[source]
classmethod content_type()[source]
static extract_url_from_field(obj, field_name)[source]
classmethod filter_callable(objects: QuerySet) QuerySet[source]

Get only latest translations for non-archived events/locations in active languages

Parameters:

objects (QuerySet) – Objects to be filtered

Returns:

Objects that passed the filter

Return type:

QuerySet

get_urls_from_field_list(obj, field_list)[source]
html_fields: list[str] = ['content'][source]
ignore_empty = [][source]
image_fields = [][source]
images(obj)[source]
object_exclude = None[source]
object_filter = None[source]
classmethod objects()[source]
url_fields = [][source]
urls(obj)[source]

Bases: NonArchivedLinkList

Class for selecting the POITranslation model for link checks

__init__()[source]
classmethod content_type()[source]
static extract_url_from_field(obj, field_name)[source]
classmethod filter_callable(objects: QuerySet) QuerySet[source]

Get only latest translations for non-archived events/locations in active languages

Parameters:

objects (QuerySet) – Objects to be filtered

Returns:

Objects that passed the filter

Return type:

QuerySet

get_urls_from_field_list(obj, field_list)[source]
html_fields: list[str] = ['content'][source]
ignore_empty = [][source]
image_fields = [][source]
images(obj)[source]
model[source]

alias of POITranslation

object_exclude = None[source]
object_filter = None[source]
classmethod objects()[source]
url_fields = [][source]
urls(obj)[source]

Bases: ActiveLanguageLinklist

Class for selecting the PageTranslation model for link checks

__init__()[source]
classmethod content_type()[source]
static extract_url_from_field(obj, field_name)[source]
classmethod filter_callable(objects: QuerySet) QuerySet[source]

Get only latest versions for non-archived pages in active languages

Parameters:

objects (QuerySet) – Objects to be filtered

Returns:

Objects that passed the filter

Return type:

QuerySet

get_urls_from_field_list(obj, field_list)[source]
html_fields: list[str] = ['content'][source]
ignore_empty = [][source]
image_fields = [][source]
images(obj)[source]
model[source]

alias of PageTranslation

object_exclude = None[source]
object_filter = None[source]
classmethod objects()[source]
url_fields = [][source]
urls(obj)[source]

Rules

We use django-rules to add custom permissions for specific pages.

For a given user and page, the following permissions are added:

See the project’s README to learn more.

integreat_cms.cms.rules.is_page_author(user: User, page: Page | None) bool[source]

This predicate checks whether the given user is one of the authors of the given page.

Parameters:
  • user (User) – The user who’s permission should be checked

  • page (Page | None) – The requested page

Returns:

Whether or not user is an author of page

Return type:

bool

integreat_cms.cms.rules.is_page_editor(user: User, page: Page | None) bool[source]

This predicate checks whether the given user is one of the editors of the given page.

Parameters:
  • user (User) – The user who’s permission should be checked

  • page (Page | None) – The requested page

Returns:

Whether or not user is an editor of page

Return type:

bool

integreat_cms.cms.rules.can_edit_all_pages(user: User, page: Page | None) bool[source]

This predicate checks whether the given user can edit all pages.

Parameters:
  • user (User) – The user who’s permission should be checked

  • page (Page | None) – The page parameter is used for the region check

Returns:

Whether or not user can edit all pages

Return type:

bool

integreat_cms.cms.rules.can_publish_all_pages(user: User, page: Page | None) bool[source]

This predicate checks whether the given user can publish all pages.

Parameters:
  • user (User) – The user who’s permission should be checked

  • page (Page | None) – The page parameter is used for the region check

Returns:

Whether or not user can publish all pages

Return type:

bool

integreat_cms.cms.rules.is_in_responsible_organization(user: User, page: Page | None) bool[source]

This predicate checks whether the given user is a member of the page’s responsible organization.

Parameters:
  • user (User) – The user who’s permission should be checked

  • page (Page | None) – The requested page

Returns:

Whether or not user is a member of page.organization

Return type:

bool

integreat_cms.cms.rules.can_delete_chat_message(user: User, chat_message: ChatMessage) bool[source]

This predicate checks whether the given user can delete a given chat message

Parameters:
  • user (User) – The user who’s permission should be checked

  • chat_message (ChatMessage) – The requested chat message

Returns:

Whether or not user is allowed to delete chat_message

Return type:

bool