Places
This package contains all views related to places
Place Actions
This module contains view actions for objects related to places.
- integreat_cms.cms.views.places.place_actions.archive_place(request: HttpRequest, place_id: int, region_slug: str, language_slug: str) HttpResponseRedirect[source]
Archive place object
- Parameters:
- Returns:
A redirection to the
PlaceListView- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.places.place_actions.auto_complete_address(request: HttpRequest, region_slug: str) JsonResponse[source]
Autocomplete place address and coordinates
- integreat_cms.cms.views.places.place_actions.copy_place(request: HttpRequest, place_id: int, region_slug: str, language_slug: str) HttpResponseRedirect[source]
Duplicates the given event and all of its translations.
- Parameters:
- Returns:
The rendered template response
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.places.place_actions.delete_place(request: HttpRequest, place_id: int, region_slug: str, language_slug: str) HttpResponseRedirect[source]
Delete place object
- Parameters:
- Returns:
A redirection to the
PlaceListView- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.places.place_actions.get_address_from_coordinates(request: HttpRequest, region_slug: str) JsonResponse[source]
Derive address from the coordinates (map pin position)
- integreat_cms.cms.views.places.place_actions.restore_place(request: HttpRequest, place_id: int, region_slug: str, language_slug: str) HttpResponseRedirect[source]
Restore place object (set
archived=False)- Parameters:
- Returns:
A redirection to the
PlaceListView- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.places.place_actions.view_place(request: HttpRequest, place_id: int, region_slug: str, language_slug: str) HttpResponse[source]
View place object
- Parameters:
- Raises:
Http404 – If user no translation exists for the requested place and language
- Returns:
A redirection to the
PlaceListView- Return type:
HttpResponse
Place Context Mixin
- class integreat_cms.cms.views.places.place_context_mixin.PlaceContextMixin[source]
Bases:
ContextMixinThis mixin provides extra context for language tree views
- get_context_data(**kwargs: Any) dict[str, Any][source]
Returns a dictionary representing the template context (see
get_context_data()).
alias of
Place
Place Form Ajax View
- class integreat_cms.cms.views.places.place_form_ajax_view.PlaceFormAjaxView(**kwargs)[source]
Bases:
TemplateView,PlaceContextMixinView for the ajax place widget
- __init__(**kwargs)[source]
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- get(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]
Render a place form widget template
- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
The html template of a place form
- Return type:
HttpResponse
- get_context_data(**kwargs: Any) dict[str, Any][source]
Returns a dictionary representing the template context (see
get_context_data()).
- 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.
- post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]
Add a new place to the database
- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Raises:
Http404 – If no language for the given language slug was found
- Returns:
A status message, either a success or an error message
- Return type:
HttpResponse
alias of
Place
- 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
Place Form View
A view representing an instance of a place. Places can be created or updated via this view.
- class integreat_cms.cms.views.places.place_form_view.PlaceFormView(**kwargs)[source]
Bases:
TemplateView,PlaceContextMixin,MediaContextMixin,ContentEditLockMixinView for editing places
- __init__(**kwargs)[source]
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- adjust_status_of_dependent_translations(place_translation_form: PlaceTranslationForm, language: Language, region: Region) None[source]
Change the status of all dependent translations of the place according to the status of the current translation.
- Parameters:
place_translation_form (PlaceTranslationForm)
language (Language)
region (Region)
- Return type:
None
- back_url_name: str | None = 'places'[source]
The url name of the view to show if the user decides to go back (see
ContentEditLockMixin)
- check_if_place_is_locked(request: HttpRequest, place: Place | None) bool[source]
Check if the content is locked for editing.
- get(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]
Render
PlaceFormandPlaceTranslationForm- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
The rendered template response
- Return type:
HttpResponse
- get_context_data(**kwargs: Any) dict[str, Any][source]
Returns a dictionary representing the template context (see
get_context_data()).
- get_instances(language: Language, place_id: Any) tuple[Place, PlaceTranslation][source]
- Parameters:
language (Language)
place_id (Any)
- Return type:
- 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.
- instantiate_forms(request: HttpRequest, place_instance: Place, place_translation_instance: PlaceTranslation, language: Language, region: Any) tuple[PlaceForm, PlaceTranslationForm][source]
- Parameters:
request (HttpRequest)
place_instance (Place)
place_translation_instance (PlaceTranslation)
language (Language)
region (Any)
- Return type:
- is_qualified_for_save(request: HttpRequest, place_form: PlaceForm, place_translation_form: PlaceTranslationForm) bool[source]
Checks whether the current request should proceed with saving the page and translation.
- Parameters:
request (HttpRequest)
place_form (PlaceForm)
place_translation_form (PlaceTranslationForm)
- Return type:
- post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]
Submit
PlaceFormandPlaceTranslationFormand savePlaceandPlaceTranslationobjects- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
The rendered template response
- Return type:
HttpResponse
alias of
Place
- 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
- set_success_messages(is_edit: bool, request: HttpRequest, place_translation_form: PlaceTranslationForm, place_form: PlaceForm) None[source]
Show success messages after saving the place and PlaceTranslation forms.
- Parameters:
is_edit (bool)
request (HttpRequest)
place_translation_form (PlaceTranslationForm)
place_form (PlaceForm)
- Return type:
None
- show_slug_changed_message(request: HttpRequest, language: Language, region: Any, user_slug: str, place_translation_form: PlaceTranslationForm) None[source]
Shows a message to the user if the slug they provided was not unique and therefore changed.
- Parameters:
request (HttpRequest)
language (Language)
region (Any)
user_slug (str)
place_translation_form (PlaceTranslationForm)
- Return type:
None
- template_name = 'places/place_form.html'[source]
The template to render (see
TemplateResponseMixin)
- update_contact_cards(place_form: PlaceForm) None[source]
Send the post save signal of contact model to trigger contact card update
- Parameters:
place_form (PlaceForm)
- Return type:
None
- validate_place_translation(request: HttpRequest, place_translation_form: PlaceTranslationForm) bool[source]
- Parameters:
request (HttpRequest)
place_translation_form (PlaceTranslationForm)
- Return type:
Place List View
- class integreat_cms.cms.views.places.place_list_view.PlaceListView(**kwargs)[source]
Bases:
TemplateView,PlaceContextMixin,MachineTranslationContextMixin,FilterSortMixin,PaginationMixinView for listing places
- __init__(**kwargs)[source]
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- get(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]
Render place list
- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
The rendered template response
- Return type:
HttpResponse
- get_context_data(**kwargs: Any) dict[str, Any][source]
Returns a dictionary representing the template context (see
get_context_data()).
- get_filter_form() ObjectSearchForm | None[source]
- Return type:
ObjectSearchForm | None
- get_filtered_sorted_queryset(queryset: QuerySet) QuerySet[source]
Annotate sort keys that match what the user actually sees in the list:
_sort_titleand_sort_status: latest translation (any version, including auto-saves) in the language slug from the URL — this is the translation rendered byplace_list_row.html._sort_statusranks status values by workflow order (AUTO_SAVE, DRAFT, REVIEW, PUBLIC) instead of by the lexicographic order of the choice keys, which has no relation to the localized labels shown._sort_category_name: name of the category in the active backend (UI) language, mirroring howPlaceCategory.__str__renders the column.
- Parameters:
queryset (QuerySet)
- Return type:
QuerySet
- 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.
alias of
Place
- 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
- property sort_fields: list[str][source]
Extract only sortable field names from table_fields. A field is sortable if its first element is not None.
- table_fields = [('_sort_title', 'Title'), ('_sort_status', 'Publication status'), ('address', 'Street'), ('postcode', 'Postal Code'), ('city', 'City'), ('country', 'Country'), ('_sort_category_name', 'Category')][source]
- template_name = 'places/place_list.html'[source]
Template for list of non-archived and archived places
- translation_model[source]
The translation model of this list view (used to determine whether machine translations are permitted)
- Parameters:
id (BigAutoField) – Primary key: ID
title (TruncatingCharField) – Name of the place
slug (SlugField) – Link to the place. String identifier without spaces and special characters. Unique per region and language. Leave blank to generate unique parameter from title.
status (CharField) – Status
content (TextField) – Description
currently_in_translation (BooleanField) – Currently in translation. Flag to indicate a translation is being updated by an external translator
machine_translated (BooleanField) – Machine translated. Flag to indicate whether a translations is machine translated
version (PositiveIntegerField) – Revision
minor_edit (BooleanField) – Minor edit. Tick if this change does not require an update of translations in other languages.
last_updated (DateTimeField) – Modification date
published_at (DateTimeField) – Publication date
automatic_translation (BooleanField) – Automatic translation. Tick if updating this content should automatically refresh or create its translations.
meta_description (CharField) – Meta description. Describe the place in one or two short sentences. This text will be displayed in the Google search results below the title.
Relationship fields:
- Parameters:
language (
ForeignKeytoLanguage) – Language (related name:place_translations)creator (
ForeignKeytoUser) – Creator (related name:place_translations)place (
ForeignKeytoPlace) – Place (related name:translations)links (
GenericRelationtoLink) – Links (related name:place_translation)
Reverse relationships:
- Parameters:
feedback (Reverse
ForeignKeyfromPlaceFeedback) – All feedback of this place translation (related name ofplace_translation)
alias of
PlaceTranslation
Place Version View
- class integreat_cms.cms.views.places.place_version_view.PlaceVersionView(**kwargs)[source]
Bases:
PlaceContextMixin,ContentVersionViewView for browsing the place versions and restoring old place versions
- __init__(**kwargs)[source]
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- 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
- get_context_data(**kwargs: Any) dict[str, Any][source]
Returns a dictionary representing the template context (see
get_context_data()).
- 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:
- 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.
- has_change_permission() bool[source]
Whether the user has the permission to change objects
- Returns:
Whether the user can change objects
- Return type:
- has_permission() bool[source]
Override
django.contrib.auth.mixins.PermissionRequiredMixin.has_permission()- Returns:
Whether the current user can access this view
- Return type:
- has_publish_permission() bool[source]
All users who can change places also can publish these changes
- Returns:
Whether the user can publish places
- Return type:
- has_view_permission() bool[source]
Whether the user has the permission to change objects
- Returns:
Whether the user can change objects
- Return type:
- model[source]
The current content model (see
SingleObjectMixin)- Parameters:
id (BigAutoField) – Primary key: ID
created_date (DateTimeField) – Creation date
do_not_translate_title (BooleanField) – Do not translate the title. Tick if you do not want to translate the title by automatic translation.
address (CharField) – Street and house number
postcode (CharField) – Postal code
city (CharField) – City
country (CharField) – Country
latitude (FloatField) – Latitude. The latitude coordinate
longitude (FloatField) – Longitude. The longitude coordinate
place_on_map (BooleanField) – Show this place on map. Tick if you want to show this place on map
archived (BooleanField) – Archived. Whether or not the place is read-only and hidden in the API.
temporarily_closed (BooleanField) – Temporarily closed. Whether or not the place is temporarily closed. The opening hours remain and are only hidden.
appointment_url (URLField) – Appointment link. Link to an external website where an appointment for this place can be made.
opening_hours (JSONField) – Opening hours
barrier_free (BooleanField) – Barrier free. Indicate if the place is barrier free.
Relationship fields:
- Parameters:
region (
ForeignKeytoRegion) – Region (related name:places)icon (
ForeignKeytoMediaFile) – Icon. The best results are achieved with images in 16:9 aspect ratio. (related name:places)category (
ForeignKeytoPlaceCategory) – Category (related name:places)organization (
ForeignKeytoOrganization) – Organization. Specify which organization operates this place. (related name:places)
Reverse relationships:
- Parameters:
translations (Reverse
ForeignKeyfromPlaceTranslation) – All translations of this place (related name ofplace)contacts (Reverse
ForeignKeyfromContact) – All contacts of this place (related name ofplace)events (Reverse
ForeignKeyfromEvent) – All events of this place (related name ofplace)
alias of
Place
- object = None[source]
The current content object (see
SingleObjectMixin)
- 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
alias of
Place
- 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
- template_name = 'content_versions.html'[source]
The template to render (see
TemplateResponseMixin)