Views

This package contains all views for the cms. Use Class-based views whenever possible. Before writing a view completely from scratch, have a look at the Built-in class-based views API and check whether anything meets your requirements.

Bulk Action Views

This module contains the base view for bulk actions

Warning

Any action modifying the database with treebeard should use @tree_mutex(MODEL_NAME) from integreat_cms.cms.utils.tree_mutex as a decorator instead of @transaction.atomic to force treebeard to actually use transactions. Otherwise, the data WILL get corrupted during concurrent treebeard calls!

class integreat_cms.cms.views.bulk_action_views.BulkActionView(**kwargs)[source]

Bases: PermissionRequiredMixin, MultipleObjectMixin, RedirectView

View for executing a bulk action and redirect to a given location

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

allow_empty = True[source]
classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

context_object_name = None[source]
delete(request, *args, **kwargs)[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
get(request, *args, **kwargs)[source]
get_allow_empty()[source]

Return True if the view should display empty lists and False if a 404 should be raised instead.

get_context_data(*, object_list=None, **kwargs)[source]

Get the context for this view.

get_context_object_name(object_list)[source]

Get the name of the item to be used in the context.

get_extra_filters() Q[source]

Get extra filters for get_queryset(). Overwrite this method to specify needed filters e.g. as in ~integreat_cms.cms.views.contact.contact_bulk_actions

Returns:

Q Object to be used as filter argument

Return type:

Q

get_login_url()[source]

Override this method to override the login_url attribute.

get_ordering()[source]

Return the field or fields to use for ordering the queryset.

get_paginate_by(queryset)[source]

Get the number of items to paginate by, or None for no pagination.

get_paginate_orphans()[source]

Return the maximum number of orphans extend the last page by when paginating.

get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]

Return an instance of the paginator for this view.

get_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required() tuple[str][source]

Override this method to override the permission_required attribute.

Returns:

The permissions that are required for views inheriting from this Mixin

Return type:

tuple[str]

get_queryset() Any[source]

Get the queryset of selected items for this bulk action

Raises:

Http404 – HTTP status 404 if no objects with the given ids exist

Returns:

The QuerySet of the filtered links

Return type:

Any

get_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_redirect_url(*args: Any, **kwargs: Any) str[source]

Retrieve url for redirection

Parameters:
  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

url to redirect to

Return type:

str

handle_no_permission()[source]
has_permission()[source]

Override this method to customize the way permissions are checked.

head(request, *args, **kwargs)[source]
http_method_names: list[str] = ['post'][source]

The list of HTTP method names that this view will accept. The bulk action form uses only POST as submission method.

http_method_not_allowed(request, *args, **kwargs)[source]
login_url = None[source]
model = None[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

ordering = None[source]
page_kwarg = 'page'[source]
paginate_by = None[source]
paginate_orphans = 0[source]
paginate_queryset(queryset, page_size)[source]

Paginate the queryset, if needed.

paginator_class[source]

alias of Paginator

patch(request, *args, **kwargs)[source]
pattern_name = None[source]
permanent = False[source]
permission_denied_message = ''[source]
permission_required = None[source]
post(request, *args, **kwargs)[source]
prefetch_public_translations: bool = False[source]

Whether the public translation objects should be prefetched

prefetch_translations: bool = False[source]

Whether the translation objects should be prefetched

put(request, *args, **kwargs)[source]
query_string = False[source]
queryset = None[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
require_change_permission: bool = True[source]

Whether the view requires change permissions

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

url = None[source]
view_is_async = False[source]
class integreat_cms.cms.views.bulk_action_views.BulkArchiveView(**kwargs)[source]

Bases: BulkActionView

Bulk action for restoring multiple objects at once

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

allow_empty = True[source]
classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

context_object_name = None[source]
delete(request, *args, **kwargs)[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
get(request, *args, **kwargs)[source]
get_allow_empty()[source]

Return True if the view should display empty lists and False if a 404 should be raised instead.

get_context_data(*, object_list=None, **kwargs)[source]

Get the context for this view.

get_context_object_name(object_list)[source]

Get the name of the item to be used in the context.

get_extra_filters() Q[source]

Get extra filters for get_queryset(). Overwrite this method to specify needed filters e.g. as in ~integreat_cms.cms.views.contact.contact_bulk_actions

Returns:

Q Object to be used as filter argument

Return type:

Q

get_login_url()[source]

Override this method to override the login_url attribute.

get_ordering()[source]

Return the field or fields to use for ordering the queryset.

get_paginate_by(queryset)[source]

Get the number of items to paginate by, or None for no pagination.

get_paginate_orphans()[source]

Return the maximum number of orphans extend the last page by when paginating.

get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]

Return an instance of the paginator for this view.

get_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required() tuple[str][source]

Override this method to override the permission_required attribute.

Returns:

The permissions that are required for views inheriting from this Mixin

Return type:

tuple[str]

get_queryset() Any[source]

Get the queryset of selected items for this bulk action

Raises:

Http404 – HTTP status 404 if no objects with the given ids exist

Returns:

The QuerySet of the filtered links

Return type:

Any

get_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_redirect_url(*args: Any, **kwargs: Any) str[source]

Retrieve url for redirection

Parameters:
  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

url to redirect to

Return type:

str

handle_no_permission()[source]
has_permission()[source]

Override this method to customize the way permissions are checked.

head(request, *args, **kwargs)[source]
http_method_names: list[str] = ['post'][source]

The list of HTTP method names that this view will accept. The bulk action form uses only POST as submission method.

http_method_not_allowed(request, *args, **kwargs)[source]
login_url = None[source]
model = None[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

ordering = None[source]
page_kwarg = 'page'[source]
paginate_by = None[source]
paginate_orphans = 0[source]
paginate_queryset(queryset, page_size)[source]

Paginate the queryset, if needed.

paginator_class[source]

alias of Paginator

patch(request, *args, **kwargs)[source]
pattern_name = None[source]
permanent = False[source]
permission_denied_message = ''[source]
permission_required = None[source]
post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect[source]

Archive multiple objects

Parameters:
  • request (HttpRequest) – The current request

  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

The redirect

Return type:

HttpResponseRedirect

prefetch_public_translations: bool = False[source]

Whether the public translation objects should be prefetched

prefetch_translations: bool = False[source]

Whether the translation objects should be prefetched

put(request, *args, **kwargs)[source]
query_string = False[source]
queryset = None[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
require_change_permission: bool = True[source]

Whether the view requires change permissions

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

url = None[source]
view_is_async = False[source]
class integreat_cms.cms.views.bulk_action_views.BulkDraftingView(**kwargs)[source]

Bases: BulkActionView

Bulk action to draft multiple pages at once

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

allow_empty = True[source]
classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

context_object_name = None[source]
delete(request, *args, **kwargs)[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
get(request, *args, **kwargs)[source]
get_allow_empty()[source]

Return True if the view should display empty lists and False if a 404 should be raised instead.

get_context_data(*, object_list=None, **kwargs)[source]

Get the context for this view.

get_context_object_name(object_list)[source]

Get the name of the item to be used in the context.

get_extra_filters() Q[source]

Get extra filters for get_queryset(). Overwrite this method to specify needed filters e.g. as in ~integreat_cms.cms.views.contact.contact_bulk_actions

Returns:

Q Object to be used as filter argument

Return type:

Q

get_login_url()[source]

Override this method to override the login_url attribute.

get_ordering()[source]

Return the field or fields to use for ordering the queryset.

get_paginate_by(queryset)[source]

Get the number of items to paginate by, or None for no pagination.

get_paginate_orphans()[source]

Return the maximum number of orphans extend the last page by when paginating.

get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]

Return an instance of the paginator for this view.

get_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required() tuple[str][source]

Override this method to override the permission_required attribute.

Returns:

The permissions that are required for views inheriting from this Mixin

Return type:

tuple[str]

get_queryset() Any[source]

Get the queryset of selected items for this bulk action

Raises:

Http404 – HTTP status 404 if no objects with the given ids exist

Returns:

The QuerySet of the filtered links

Return type:

Any

get_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_redirect_url(*args: Any, **kwargs: Any) str[source]

Retrieve url for redirection

Parameters:
  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

url to redirect to

Return type:

str

handle_no_permission()[source]
has_permission()[source]

Override this method to customize the way permissions are checked.

head(request, *args, **kwargs)[source]
http_method_names: list[str] = ['post'][source]

The list of HTTP method names that this view will accept. The bulk action form uses only POST as submission method.

http_method_not_allowed(request, *args, **kwargs)[source]
login_url = None[source]
model = None[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

ordering = None[source]
page_kwarg = 'page'[source]
paginate_by = None[source]
paginate_orphans = 0[source]
paginate_queryset(queryset, page_size)[source]

Paginate the queryset, if needed.

paginator_class[source]

alias of Paginator

patch(request, *args, **kwargs)[source]
pattern_name = None[source]
permanent = False[source]
permission_denied_message = ''[source]
permission_required = None[source]
post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]

Function to change the translation status to draft of multiple pages at once

Parameters:
  • request (HttpRequest) – The current request

  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

The redirect

Return type:

HttpResponse

prefetch_public_translations: bool = False[source]

Whether the public translation objects should be prefetched

prefetch_translations: bool = False[source]

Whether the translation objects should be prefetched

put(request, *args, **kwargs)[source]
query_string = False[source]
queryset = None[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
require_change_permission: bool = True[source]

Whether the view requires change permissions

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

url = None[source]
view_is_async = False[source]
class integreat_cms.cms.views.bulk_action_views.BulkMachineTranslationView(**kwargs)[source]

Bases: BulkActionView

Bulk action for automatically translating multiple objects

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

allow_empty = True[source]
classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

context_object_name = None[source]
delete(request, *args, **kwargs)[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
form: ModelForm | None = None[source]

the form of this bulk action

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

Return True if the view should display empty lists and False if a 404 should be raised instead.

get_context_data(*, object_list=None, **kwargs)[source]

Get the context for this view.

get_context_object_name(object_list)[source]

Get the name of the item to be used in the context.

get_extra_filters() Q[source]

Get extra filters for get_queryset(). Overwrite this method to specify needed filters e.g. as in ~integreat_cms.cms.views.contact.contact_bulk_actions

Returns:

Q Object to be used as filter argument

Return type:

Q

get_login_url()[source]

Override this method to override the login_url attribute.

get_ordering()[source]

Return the field or fields to use for ordering the queryset.

get_paginate_by(queryset)[source]

Get the number of items to paginate by, or None for no pagination.

get_paginate_orphans()[source]

Return the maximum number of orphans extend the last page by when paginating.

get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]

Return an instance of the paginator for this view.

get_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required() tuple[str][source]

Override this method to override the permission_required attribute.

Returns:

The permissions that are required for views inheriting from this Mixin

Return type:

tuple[str]

get_queryset() Any[source]

Get the queryset of selected items for this bulk action

Raises:

Http404 – HTTP status 404 if no objects with the given ids exist

Returns:

The QuerySet of the filtered links

Return type:

Any

get_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_redirect_url(*args: Any, **kwargs: Any) str[source]

Retrieve url for redirection

Parameters:
  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

url to redirect to

Return type:

str

handle_no_permission()[source]
has_permission()[source]

Override this method to customize the way permissions are checked.

head(request, *args, **kwargs)[source]
http_method_names: list[str] = ['post'][source]

The list of HTTP method names that this view will accept. The bulk action form uses only POST as submission method.

http_method_not_allowed(request, *args, **kwargs)[source]
login_url = None[source]
model = None[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

ordering = None[source]
page_kwarg = 'page'[source]
paginate_by = None[source]
paginate_orphans = 0[source]
paginate_queryset(queryset, page_size)[source]

Paginate the queryset, if needed.

paginator_class[source]

alias of Paginator

patch(request, *args, **kwargs)[source]
pattern_name = None[source]
permanent = False[source]
permission_denied_message = ''[source]
permission_required = None[source]
post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect[source]

Translate multiple objects automatically

Parameters:
  • request (HttpRequest) – The current request

  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

The redirect

Return type:

HttpResponseRedirect

prefetch_public_translations: bool = False[source]

Whether the public translation objects should be prefetched

prefetch_translations: bool = True[source]

Whether the public translation objects should be prefetched

put(request, *args, **kwargs)[source]
query_string = False[source]
queryset = None[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
require_change_permission: bool = True[source]

Whether the view requires change permissions

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

url = None[source]
view_is_async = False[source]
class integreat_cms.cms.views.bulk_action_views.BulkPublishingView(**kwargs)[source]

Bases: BulkActionView

Bulk action to publish multiple pages at once

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

allow_empty = True[source]
classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

context_object_name = None[source]
delete(request, *args, **kwargs)[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
get(request, *args, **kwargs)[source]
get_allow_empty()[source]

Return True if the view should display empty lists and False if a 404 should be raised instead.

get_context_data(*, object_list=None, **kwargs)[source]

Get the context for this view.

get_context_object_name(object_list)[source]

Get the name of the item to be used in the context.

get_extra_filters() Q[source]

Get extra filters for get_queryset(). Overwrite this method to specify needed filters e.g. as in ~integreat_cms.cms.views.contact.contact_bulk_actions

Returns:

Q Object to be used as filter argument

Return type:

Q

get_login_url()[source]

Override this method to override the login_url attribute.

get_ordering()[source]

Return the field or fields to use for ordering the queryset.

get_paginate_by(queryset)[source]

Get the number of items to paginate by, or None for no pagination.

get_paginate_orphans()[source]

Return the maximum number of orphans extend the last page by when paginating.

get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]

Return an instance of the paginator for this view.

get_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required() tuple[str][source]

Override this method to override the permission_required attribute.

Returns:

The permissions that are required for views inheriting from this Mixin

Return type:

tuple[str]

get_queryset() Any[source]

Get the queryset of selected items for this bulk action

Raises:

Http404 – HTTP status 404 if no objects with the given ids exist

Returns:

The QuerySet of the filtered links

Return type:

Any

get_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_redirect_url(*args: Any, **kwargs: Any) str[source]

Retrieve url for redirection

Parameters:
  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

url to redirect to

Return type:

str

handle_no_permission()[source]
has_permission()[source]

Override this method to customize the way permissions are checked.

head(request, *args, **kwargs)[source]
http_method_names: list[str] = ['post'][source]

The list of HTTP method names that this view will accept. The bulk action form uses only POST as submission method.

http_method_not_allowed(request, *args, **kwargs)[source]
login_url = None[source]
model = None[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

ordering = None[source]
page_kwarg = 'page'[source]
paginate_by = None[source]
paginate_orphans = 0[source]
paginate_queryset(queryset, page_size)[source]

Paginate the queryset, if needed.

paginator_class[source]

alias of Paginator

patch(request, *args, **kwargs)[source]
pattern_name = None[source]
permanent = False[source]
permission_denied_message = ''[source]
permission_required = None[source]
post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]

Function to change the translation status to publish of multiple pages at once

Parameters:
  • request (HttpRequest) – The current request

  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

The redirect

Return type:

HttpResponse

prefetch_public_translations: bool = False[source]

Whether the public translation objects should be prefetched

prefetch_translations: bool = False[source]

Whether the translation objects should be prefetched

put(request, *args, **kwargs)[source]
query_string = False[source]
queryset = None[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
require_change_permission: bool = True[source]

Whether the view requires change permissions

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

url = None[source]
view_is_async = False[source]
class integreat_cms.cms.views.bulk_action_views.BulkRestoreView(**kwargs)[source]

Bases: BulkActionView

Bulk action for restoring multiple objects at once

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

allow_empty = True[source]
classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

context_object_name = None[source]
delete(request, *args, **kwargs)[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
get(request, *args, **kwargs)[source]
get_allow_empty()[source]

Return True if the view should display empty lists and False if a 404 should be raised instead.

get_context_data(*, object_list=None, **kwargs)[source]

Get the context for this view.

get_context_object_name(object_list)[source]

Get the name of the item to be used in the context.

get_extra_filters() Q[source]

Get extra filters for get_queryset(). Overwrite this method to specify needed filters e.g. as in ~integreat_cms.cms.views.contact.contact_bulk_actions

Returns:

Q Object to be used as filter argument

Return type:

Q

get_login_url()[source]

Override this method to override the login_url attribute.

get_ordering()[source]

Return the field or fields to use for ordering the queryset.

get_paginate_by(queryset)[source]

Get the number of items to paginate by, or None for no pagination.

get_paginate_orphans()[source]

Return the maximum number of orphans extend the last page by when paginating.

get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]

Return an instance of the paginator for this view.

get_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required() tuple[str][source]

Override this method to override the permission_required attribute.

Returns:

The permissions that are required for views inheriting from this Mixin

Return type:

tuple[str]

get_queryset() Any[source]

Get the queryset of selected items for this bulk action

Raises:

Http404 – HTTP status 404 if no objects with the given ids exist

Returns:

The QuerySet of the filtered links

Return type:

Any

get_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_redirect_url(*args: Any, **kwargs: Any) str[source]

Retrieve url for redirection

Parameters:
  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

url to redirect to

Return type:

str

handle_no_permission()[source]
has_permission()[source]

Override this method to customize the way permissions are checked.

head(request, *args, **kwargs)[source]
http_method_names: list[str] = ['post'][source]

The list of HTTP method names that this view will accept. The bulk action form uses only POST as submission method.

http_method_not_allowed(request, *args, **kwargs)[source]
login_url = None[source]
model = None[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

ordering = None[source]
page_kwarg = 'page'[source]
paginate_by = None[source]
paginate_orphans = 0[source]
paginate_queryset(queryset, page_size)[source]

Paginate the queryset, if needed.

paginator_class[source]

alias of Paginator

patch(request, *args, **kwargs)[source]
pattern_name = None[source]
permanent = False[source]
permission_denied_message = ''[source]
permission_required = None[source]
post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect[source]

Restore multiple objects

Parameters:
  • request (HttpRequest) – The current request

  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

The redirect

Return type:

HttpResponseRedirect

prefetch_public_translations: bool = False[source]

Whether the public translation objects should be prefetched

prefetch_translations: bool = False[source]

Whether the translation objects should be prefetched

put(request, *args, **kwargs)[source]
query_string = False[source]
queryset = None[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
require_change_permission: bool = True[source]

Whether the view requires change permissions

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

url = None[source]
view_is_async = False[source]
class integreat_cms.cms.views.bulk_action_views.BulkUpdateBooleanFieldView(**kwargs)[source]

Bases: BulkActionView

Bulk action for toggling boolean fields of multiple objects at once

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

property action: str[source]

Called when the bulk action is performed and the action attribute was not overwritten

Raises:

NotImplementedError – If the action attribute is not implemented in the subclass

allow_empty = True[source]
classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

context_object_name = None[source]
delete(request, *args, **kwargs)[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
property field_name: str[source]

Called when the bulk action is performed and the field_name attribute was not overwritten

Raises:

NotImplementedError – If the field_name attribute is not implemented in the subclass

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

Return True if the view should display empty lists and False if a 404 should be raised instead.

get_context_data(*, object_list=None, **kwargs)[source]

Get the context for this view.

get_context_object_name(object_list)[source]

Get the name of the item to be used in the context.

get_extra_filters() Q[source]

Get extra filters for get_queryset(). Overwrite this method to specify needed filters e.g. as in ~integreat_cms.cms.views.contact.contact_bulk_actions

Returns:

Q Object to be used as filter argument

Return type:

Q

get_login_url()[source]

Override this method to override the login_url attribute.

get_ordering()[source]

Return the field or fields to use for ordering the queryset.

get_paginate_by(queryset)[source]

Get the number of items to paginate by, or None for no pagination.

get_paginate_orphans()[source]

Return the maximum number of orphans extend the last page by when paginating.

get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]

Return an instance of the paginator for this view.

get_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required() tuple[str][source]

Override this method to override the permission_required attribute.

Returns:

The permissions that are required for views inheriting from this Mixin

Return type:

tuple[str]

get_queryset() Any[source]

Get the queryset of selected items for this bulk action

Raises:

Http404 – HTTP status 404 if no objects with the given ids exist

Returns:

The QuerySet of the filtered links

Return type:

Any

get_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_redirect_url(*args: Any, **kwargs: Any) str[source]

Retrieve url for redirection

Parameters:
  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

url to redirect to

Return type:

str

handle_no_permission()[source]
has_permission()[source]

Override this method to customize the way permissions are checked.

head(request, *args, **kwargs)[source]
http_method_names: list[str] = ['post'][source]

The list of HTTP method names that this view will accept. The bulk action form uses only POST as submission method.

http_method_not_allowed(request, *args, **kwargs)[source]
login_url = None[source]
model = None[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

ordering = None[source]
page_kwarg = 'page'[source]
paginate_by = None[source]
paginate_orphans = 0[source]
paginate_queryset(queryset, page_size)[source]

Paginate the queryset, if needed.

paginator_class[source]

alias of Paginator

patch(request, *args, **kwargs)[source]
pattern_name = None[source]
permanent = False[source]
permission_denied_message = ''[source]
permission_required = None[source]
post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect[source]

Update the fields of the selected objects and redirect

Parameters:
  • request (HttpRequest) – The current request

  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

The redirect

Return type:

HttpResponseRedirect

prefetch_public_translations: bool = False[source]

Whether the public translation objects should be prefetched

prefetch_translations: bool = False[source]

Whether the translation objects should be prefetched

put(request, *args, **kwargs)[source]
query_string = False[source]
queryset = None[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
require_change_permission: bool = True[source]

Whether the view requires change permissions

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

url = None[source]
value: bool = True[source]

The value of the field (defaults to True)

view_is_async = False[source]

Content Version View

class integreat_cms.cms.views.content_version_view.ContentVersionView(**kwargs)[source]

Bases: PermissionRequiredMixin, SingleObjectMixin, TemplateView

View for browsing the content versions and restoring old content versions

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

back_to_form_label: Promise = 'Back to the form'[source]

The label of the “back to form” button

content_type = None[source]
context_object_name = None[source]
dispatch(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect | TemplateResponse[source]

Validate the versions view

Parameters:
  • request (HttpRequest) – The current request

  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Raises:

PermissionDenied – If user does not have the permission to edit the specific page

Returns:

The rendered template response

Return type:

HttpResponseRedirect | TemplateResponse

property edit_url: str[source]

The url to the form in the current language

Returns:

The edit url

extra_context = None[source]
get(request, *args, **kwargs)[source]
get_context_data(**kwargs: Any) dict[str, Any][source]

Get revision context data

Returns:

The context dictionary

Parameters:

kwargs (Any)

Return type:

dict[str, Any]

get_context_object_name(obj)[source]

Get the name to use for the object.

get_login_url()[source]

Override this method to override the login_url attribute.

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_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required()[source]

Override this method to override the permission_required attribute. Must return an iterable.

get_queryset()[source]

Filter the content objects by the current region

Raises:

Http404 – HTTP status 404 if the content is not found

Returns:

The rendered template response

Return type:

ContentQuerySet | (EventQuerySet | PageQuerySet)

get_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_slug_field()[source]

Get the name of a slug field to be used to look up by slug.

get_template_names()[source]

Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.

handle_no_permission()[source]
has_change_permission() bool[source]

Whether the user has the permission to change objects

Returns:

Whether the user can change objects

Return type:

bool

has_permission() bool[source]

Override django.contrib.auth.mixins.PermissionRequiredMixin.has_permission()

Returns:

Whether the current user can access this view

Return type:

bool

has_publish_permission() bool[source]

Whether the user has the permission to publish objects

Returns:

Whether the user can publish objects

Return type:

bool

has_view_permission() bool[source]

Whether the user has the permission to change objects

Returns:

Whether the user can change objects

Return type:

bool

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace'][source]
http_method_not_allowed(request, *args, **kwargs)[source]
language: Language | None = None[source]

The current language

login_url = None[source]
model: ModelBase | None = None[source]

The current content model (see SingleObjectMixin)

property model_name: str[source]

The name of this model

Returns:

The name of this model

object: AbstractContentModel | None = None[source]

The current content object (see SingleObjectMixin)

options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

permission_denied_message = ''[source]
permission_required = None[source]
property pk_url_kwarg: str[source]

The name of the URLConf keyword argument that contains the primary key. By default, pk_url_kwarg is ‘pk’. See django.views.generic.detail.SingleObjectMixin.pk_url_kwarg.

Returns:

The name of URL kwarg of the id

post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect[source]

Restore a previous revision of a page translation

Parameters:
  • request (HttpRequest) – The current request

  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Raises:

PermissionDenied – If user does not have the permission to edit the specific page

Returns:

The rendered template response

Return type:

HttpResponseRedirect

query_pk_and_slug = False[source]
queryset = None[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

response_class[source]

alias of TemplateResponse

restore_version(restored_version: Any) None[source]

Restore the given version

Parameters:

restored_version (Any) – The version which should be restored

Return type:

None

selected_version: AbstractContentTranslation | None = None[source]

The currently selected translation version

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

slug_field = 'slug'[source]
slug_url_kwarg = 'slug'[source]
template_engine = None[source]
template_name: str = 'content_versions.html'[source]

The template to render (see TemplateResponseMixin)

translations: list[AbstractContentTranslation] = [][source]

All translations of the content object in the current language

property versions_url: str[source]

The url to the form in the current language

Returns:

The edit url

view_is_async = False[source]

Delete Views

This module contains deletion views for our models that don’t need custom handling.

class integreat_cms.cms.views.delete_views.CustomDeleteView(*args, **kwargs)[source]

Bases: CustomModelDeleteMixin, DeleteView

View for deleting an object retrieved with self.get_object()

__init__(*args, **kwargs)[source]
classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

content_type = None[source]
context_object_name = None[source]
delete(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]

Call the delete() method on the fetched object and then redirect to the success URL.

Parameters:
  • request (HttpRequest) – The current request

  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Raises:

django.db.IntegrityError – If the object has many to many relationships that prevent deletion

Returns:

A redirection to the success_url

Return type:

HttpResponse

dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
form_class[source]

alias of Form

form_invalid(form)[source]

If the form is invalid, render the invalid form.

form_valid(form)[source]

If the form is valid, redirect to the supplied URL.

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

Insert the form into the context dict.

get_context_object_name(obj)[source]

Get the name to use for the object.

get_form(form_class=None)[source]

Return an instance of the form to be used in this view.

get_form_class()[source]

Return the form class to use.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

get_initial()[source]

Return the initial data to use for forms on this view.

get_login_url()[source]

Override this method to override the login_url attribute.

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_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required() tuple[str, ...][source]

Override this method to override the permission_required attribute.

Returns:

The permissions that are required for views inheriting from this Mixin

Return type:

tuple[str, …]

get_prefix()[source]

Return the prefix to use for forms.

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_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_slug_field()[source]

Get the name of a slug field to be used to look up by slug.

get_success_url() str[source]

Determine the URL to redirect to when the object is successfully deleted

Returns:

The url to redirect on success

Return type:

str

get_template_names()[source]

Return a list of template names to be used for the request. May not be called if render_to_response() is overridden. Return the following list:

  • the value of template_name on the view (if provided)

  • the contents of the template_name_field field on the object instance that the view is operating upon (if available)

  • <app_label>/<model_name><template_name_suffix>.html

handle_no_permission()[source]
has_permission()[source]

Override this method to customize the way permissions are checked.

http_method_names: list[str] = ['post'][source]

The list of HTTP method names that this view will accept. Since we’re doing confirmation dynamically, we don’t need the get-request part of this view

http_method_not_allowed(request, *args, **kwargs)[source]
initial = {}[source]
login_url = None[source]
model = None[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

permission_denied_message = ''[source]
permission_required = None[source]
pk_url_kwarg = 'pk'[source]
post(request, *args, **kwargs)[source]
prefix = None[source]
protect_manytomany: str | None = None[source]

Whether the objects should be protected from deletion if it is used in many to many relationships

query_pk_and_slug = False[source]
queryset = None[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

response_class[source]

alias of TemplateResponse

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

slug_field = 'slug'[source]
slug_url_kwarg = 'slug'[source]
success_url = None[source]
template_engine = None[source]
template_name = None[source]
template_name_field = None[source]
template_name_suffix = '_confirm_delete'[source]
view_is_async = False[source]
class integreat_cms.cms.views.delete_views.CustomModelDeleteMixin[source]

Bases: PermissionRequiredMixin

This mixin handles error messages in form views of subclasses of CustomModelForm

__init__()[source]
delete(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]

Call the delete() method on the fetched object and then redirect to the success URL.

Parameters:
  • request (HttpRequest) – The current request

  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Raises:

django.db.IntegrityError – If the object has many to many relationships that prevent deletion

Returns:

A redirection to the success_url

Return type:

HttpResponse

dispatch(request, *args, **kwargs)[source]
get_login_url()[source]

Override this method to override the login_url attribute.

get_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required() tuple[str, ...][source]

Override this method to override the permission_required attribute.

Returns:

The permissions that are required for views inheriting from this Mixin

Return type:

tuple[str, …]

get_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_success_url() str[source]

Determine the URL to redirect to when the object is successfully deleted

Returns:

The url to redirect on success

Return type:

str

handle_no_permission()[source]
has_permission()[source]

Override this method to customize the way permissions are checked.

login_url = None[source]
permission_denied_message = ''[source]
permission_required = None[source]
protect_manytomany: str | None = None[source]

Whether the objects should be protected from deletion if it is used in many to many relationships

raise_exception = False[source]
redirect_field_name = 'next'[source]

Form Views

This module contains form views for our models that don’t need custom handling.

class integreat_cms.cms.views.form_views.CustomCreateView(**kwargs)[source]

Bases: CustomModelFormMixin, BaseCreateView

A view that displays a form for creating a region object, redisplaying the form with validation errors (if there are any) and saving the object.

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

content_type = None[source]
context_object_name = None[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
fields = None[source]
form_class = None[source]
form_invalid(form: CustomModelForm) HttpResponse[source]

Renders a response, providing the invalid form as context.

Parameters:

form (CustomModelForm) – The invalid form instance

Returns:

The rendered invalid form

Return type:

HttpResponse

form_valid(form: CustomModelForm) HttpResponseRedirect[source]

Saves the form instance, sets the current object for the view, and redirects to get_success_url().

Parameters:

form (CustomModelForm) – The valid form instance

Returns:

A redirection to the success url

Return type:

HttpResponseRedirect

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

Handle GET requests: instantiate a blank version of the form.

get_context_data(**kwargs: Any) dict[str, Any][source]

Returns a dictionary representing the template context (see get_context_data()).

Parameters:

**kwargs (Any) – The given keyword arguments

Returns:

The template context

Return type:

dict[str, Any]

get_context_object_name(obj)[source]

Get the name to use for the object.

get_form(form_class=None)[source]

Return an instance of the form to be used in this view.

get_form_class()[source]

Return the form class to use in this view.

get_form_kwargs() dict[str, Any][source]

Return the keyword arguments for instantiating the form

Returns:

The form kwargs

Return type:

dict[str, Any]

get_initial()[source]

Return the initial data to use for forms on this view.

get_login_url()[source]

Override this method to override the login_url attribute.

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_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required() tuple[str][source]

Override this method to override the permission_required attribute.

Returns:

The permissions that are required for views inheriting from this Mixin

Return type:

tuple[str]

get_prefix()[source]

Return the prefix to use for forms.

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_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_slug_field()[source]

Get the name of a slug field to be used to look up by slug.

get_success_url() str[source]

Determine the URL to redirect to when the form is successfully validated

Returns:

The url to redirect on success

Return type:

str

get_template_names()[source]

Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.

handle_no_permission()[source]
has_permission()[source]

Override this method to customize the way permissions are checked.

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace'][source]
http_method_not_allowed(request, *args, **kwargs)[source]
initial = {}[source]
login_url = None[source]
property model: ModelBase[source]

Return the model class of this form mixin

Returns:

The corresponding Django model

options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

permission_denied_message = ''[source]
permission_required = None[source]
pk_url_kwarg = 'pk'[source]
post(request, *args, **kwargs)[source]

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

prefix = None[source]
put(*args, **kwargs)[source]
query_pk_and_slug = False[source]
queryset = None[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

response_class[source]

alias of TemplateResponse

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

slug_field = 'slug'[source]
slug_url_kwarg = 'slug'[source]
success_url = None[source]
template_engine = None[source]
property template_name: str[source]

Return the template name to be used for the request.

Returns:

The template to be rendered

template_name_suffix: str = '_form'[source]

The suffix to append to the auto-generated candidate template name.

view_is_async = False[source]
class integreat_cms.cms.views.form_views.CustomModelFormMixin[source]

Bases: PermissionRequiredMixin, ModelTemplateResponseMixin, ModelFormMixin, ModelConfirmationContextMixin, MediaContextMixin

This mixin handles error messages in form views of subclasses of CustomModelForm

__init__()[source]
content_type = None[source]
context_object_name = None[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
fields = None[source]
form_class = None[source]
form_invalid(form: CustomModelForm) HttpResponse[source]

Renders a response, providing the invalid form as context.

Parameters:

form (CustomModelForm) – The invalid form instance

Returns:

The rendered invalid form

Return type:

HttpResponse

form_valid(form: CustomModelForm) HttpResponseRedirect[source]

Saves the form instance, sets the current object for the view, and redirects to get_success_url().

Parameters:

form (CustomModelForm) – The valid form instance

Returns:

A redirection to the success url

Return type:

HttpResponseRedirect

get_context_data(**kwargs: Any) dict[str, Any][source]

Returns a dictionary representing the template context (see get_context_data()).

Parameters:

**kwargs (Any) – The given keyword arguments

Returns:

The template context

Return type:

dict[str, Any]

get_context_object_name(obj)[source]

Get the name to use for the object.

get_form(form_class=None)[source]

Return an instance of the form to be used in this view.

get_form_class()[source]

Return the form class to use in this view.

get_form_kwargs() dict[str, Any][source]

Return the keyword arguments for instantiating the form

Returns:

The form kwargs

Return type:

dict[str, Any]

get_initial()[source]

Return the initial data to use for forms on this view.

get_login_url()[source]

Override this method to override the login_url attribute.

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_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required() tuple[str][source]

Override this method to override the permission_required attribute.

Returns:

The permissions that are required for views inheriting from this Mixin

Return type:

tuple[str]

get_prefix()[source]

Return the prefix to use for forms.

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_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_slug_field()[source]

Get the name of a slug field to be used to look up by slug.

get_success_url() str[source]

Determine the URL to redirect to when the form is successfully validated

Returns:

The url to redirect on success

Return type:

str

get_template_names()[source]

Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.

handle_no_permission()[source]
has_permission()[source]

Override this method to customize the way permissions are checked.

initial = {}[source]
login_url = None[source]
property model: ModelBase[source]

Return the model class of this form mixin

Returns:

The corresponding Django model

permission_denied_message = ''[source]
permission_required = None[source]
pk_url_kwarg = 'pk'[source]
prefix = None[source]
query_pk_and_slug = False[source]
queryset = None[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

response_class[source]

alias of TemplateResponse

slug_field = 'slug'[source]
slug_url_kwarg = 'slug'[source]
success_url = None[source]
template_engine = None[source]
property template_name: str[source]

Return the template name to be used for the request.

Returns:

The template to be rendered

template_name_suffix: str = '_form'[source]

The suffix to append to the auto-generated candidate template name.

class integreat_cms.cms.views.form_views.CustomUpdateView(**kwargs)[source]

Bases: CustomModelFormMixin, BaseUpdateView

A view that displays a form for editing an existing region object, redisplaying the form with validation errors (if there are any) and saving changes to the object. This uses a form automatically generated from the object’s model class (unless a form class is manually specified).

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

content_type = None[source]
context_object_name = None[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
fields = None[source]
form_class = None[source]
form_invalid(form: CustomModelForm) HttpResponse[source]

Renders a response, providing the invalid form as context.

Parameters:

form (CustomModelForm) – The invalid form instance

Returns:

The rendered invalid form

Return type:

HttpResponse

form_valid(form: CustomModelForm) HttpResponseRedirect[source]

Saves the form instance, sets the current object for the view, and redirects to get_success_url().

Parameters:

form (CustomModelForm) – The valid form instance

Returns:

A redirection to the success url

Return type:

HttpResponseRedirect

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

Handle GET requests: instantiate a blank version of the form.

get_context_data(**kwargs: Any) dict[str, Any][source]

Returns a dictionary representing the template context (see get_context_data()).

Parameters:

**kwargs (Any) – The given keyword arguments

Returns:

The template context

Return type:

dict[str, Any]

get_context_object_name(obj)[source]

Get the name to use for the object.

get_form(form_class=None)[source]

Return an instance of the form to be used in this view.

get_form_class()[source]

Return the form class to use in this view.

get_form_kwargs() dict[str, Any][source]

Return the keyword arguments for instantiating the form

Returns:

The form kwargs

Return type:

dict[str, Any]

get_initial()[source]

Return the initial data to use for forms on this view.

get_login_url()[source]

Override this method to override the login_url attribute.

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_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required() tuple[str][source]

Override this method to override the permission_required attribute.

Returns:

The permissions that are required for views inheriting from this Mixin

Return type:

tuple[str]

get_prefix()[source]

Return the prefix to use for forms.

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_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_slug_field()[source]

Get the name of a slug field to be used to look up by slug.

get_success_url() str[source]

Determine the URL to redirect to when the form is successfully validated

Returns:

The url to redirect on success

Return type:

str

get_template_names()[source]

Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.

handle_no_permission()[source]
has_permission()[source]

Override this method to customize the way permissions are checked.

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace'][source]
http_method_not_allowed(request, *args, **kwargs)[source]
initial = {}[source]
login_url = None[source]
property model: ModelBase[source]

Return the model class of this form mixin

Returns:

The corresponding Django model

options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

permission_denied_message = ''[source]
permission_required = None[source]
pk_url_kwarg = 'pk'[source]
post(request, *args, **kwargs)[source]

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

prefix = None[source]
put(*args, **kwargs)[source]
query_pk_and_slug = False[source]
queryset = None[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

response_class[source]

alias of TemplateResponse

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

slug_field = 'slug'[source]
slug_url_kwarg = 'slug'[source]
success_url = None[source]
template_engine = None[source]
property template_name: str[source]

Return the template name to be used for the request.

Returns:

The template to be rendered

template_name_suffix: str = '_form'[source]

The suffix to append to the auto-generated candidate template name.

view_is_async = False[source]

List Views

This module contains list views for our models that don’t need custom handling.

class integreat_cms.cms.views.list_views.ModelListView(**kwargs)[source]

Bases: PermissionRequiredMixin, ModelTemplateResponseMixin, ModelConfirmationContextMixin, ListView

Render some list of objects, set by self.model or self.queryset.

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

allow_empty = True[source]
classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

content_type = None[source]
property context_object_name: str[source]

Designates the name of the variable to use in the context (see MultipleObjectMixin).

Returns:

The name of the objects in this list view

dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
get(request, *args, **kwargs)[source]
get_allow_empty()[source]

Return True if the view should display empty lists and False if a 404 should be raised instead.

get_context_data(**kwargs: Any) dict[str, Any][source]

Returns a dictionary representing the template context (see get_context_data()).

Parameters:

**kwargs (Any) – The given keyword arguments

Returns:

The template context

Return type:

dict[str, Any]

get_context_object_name(object_list)[source]

Get the name of the item to be used in the context.

get_login_url()[source]

Override this method to override the login_url attribute.

get_ordering()[source]

Return the field or fields to use for ordering the queryset.

get_paginate_by(queryset)[source]

Get the number of items to paginate by, or None for no pagination.

get_paginate_orphans()[source]

Return the maximum number of orphans extend the last page by when paginating.

get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]

Return an instance of the paginator for this view.

get_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_permission_required() tuple[str][source]

Override this method to override the permission_required attribute.

Returns:

The permissions that are required for views inheriting from this Mixin

Return type:

tuple[str]

get_queryset() QuerySet[source]

Get the model’s queryset (optionally filtered by the current region)

Returns:

The queryset of the current list view

Return type:

QuerySet

get_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_template_names()[source]

Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response is overridden.

handle_no_permission()[source]
has_permission()[source]

Override this method to customize the way permissions are checked.

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace'][source]
http_method_not_allowed(request, *args, **kwargs)[source]
login_url = None[source]
property model: ModelBase[source]

Return the model class of this list view.

Returns:

The corresponding Django model

options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

ordering = None[source]
page_kwarg = 'page'[source]
property paginate_by: int | None[source]

An integer specifying how many objects should be displayed per page. This either returns the current size GET parameter or the value defined in PER_PAGE. (see MultipleObjectMixin)

Returns:

The page size

paginate_orphans = 0[source]
paginate_queryset(queryset, page_size)[source]

Paginate the queryset, if needed.

paginator_class[source]

alias of Paginator

permission_denied_message = ''[source]
permission_required = None[source]
queryset = None[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

response_class[source]

alias of TemplateResponse

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

template_engine = None[source]
property template_name: str[source]

Return the template name to be used for the request.

Returns:

The template to be rendered

template_name_suffix = '_list'[source]
view_is_async = False[source]

Mixins

This module contains mixins for our views

class integreat_cms.cms.views.mixins.ContentEditLockMixin[source]

Bases: ContextMixin

A mixin that provides some variables required for the content edit lock

__init__()[source]
back_url_name: str | None = None[source]

The reverse name of the url of the associated list view

extra_context = None[source]
get_context_data(**kwargs: Any) dict[str, Any][source]

Returns a dictionary representing the template context (see get_context_data()).

Parameters:

**kwargs (Any) – The given keyword arguments

Returns:

The template context

Return type:

dict[str, Any]

class integreat_cms.cms.views.mixins.MachineTranslationContextMixin[source]

Bases: ContextMixin

This mixin provides extra context for machine translation options

__init__()[source]
extra_context = None[source]
get_context_data(**kwargs: Any) dict[str, Any][source]

Returns a dictionary representing the template context (see get_context_data()).

Parameters:

**kwargs (Any) – The given keyword arguments

Returns:

The template context

Return type:

dict[str, Any]

class integreat_cms.cms.views.mixins.ModelConfirmationContextMixin[source]

Bases: ContextMixin

A mixin that can be used to inject confirmation text into a template of a model (e.g. list or form)

__init__()[source]
extra_context = None[source]
get_context_data(**kwargs: Any) dict[str, Any][source]

Returns a dictionary representing the template context (see get_context_data()).

Parameters:

**kwargs (Any) – The given keyword arguments

Returns:

The template context

Return type:

dict[str, Any]

class integreat_cms.cms.views.mixins.ModelTemplateResponseMixin[source]

Bases: TemplateResponseMixin

A mixin that can be used to render a template of a model (e.g. list or form)

__init__()[source]
content_type = None[source]
get_template_names()[source]

Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.

render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

response_class[source]

alias of TemplateResponse

template_engine = None[source]
property template_name: str[source]

Return the template name to be used for the request.

Returns:

The template to be rendered

class integreat_cms.cms.views.mixins.RegionPermissionRequiredMixing[source]

Bases: UserPassesTestMixin

A mixin that can be used for class-based views that require that the user is has access to the current region of this request

__init__()[source]
dispatch(request, *args, **kwargs)[source]
get_login_url()[source]

Override this method to override the login_url attribute.

get_permission_denied_message()[source]

Override this method to override the permission_denied_message attribute.

get_redirect_field_name()[source]

Override this method to override the redirect_field_name attribute.

get_test_func()[source]

Override this method to use a different test_func method.

handle_no_permission()[source]
login_url = None[source]
permission_denied_message = ''[source]
raise_exception = False[source]
redirect_field_name = 'next'[source]
test_func() bool[source]

The test this account has to pass

Returns:

Whether this account has passed the test

Return type:

bool