Push Notifications

This package contains all views related to push notifications

Push Notification Form View

class integreat_cms.cms.views.push_notifications.push_notification_form_view.PushNotificationFormView(**kwargs)[source]

Bases: TemplateView

Class that handles HTTP POST and GET requests for editing push notifications

extra_context = {'current_menu_item': 'push_notifications_form', 'schedule_interval': 60}[source]

The context dict passed to the template (see ContextMixin)

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

Open form for creating or editing a push notification

Parameters:
  • request (HttpRequest) – Object representing the user call

  • *args (Any) – The supplied arguments

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

Returns:

The rendered template response

Return type:

HttpResponse

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

Save and show form for creating or editing a push notification. Send push notification if asked for by user.

Parameters:
  • request (HttpRequest) – Object representing the user call

  • *args (Any) – The supplied arguments

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

Raises:
Returns:

The rendered template response

Return type:

HttpResponse

template_name = 'push_notifications/push_notification_form.html'[source]

The template to render (see TemplateResponseMixin)

integreat_cms.cms.views.push_notifications.push_notification_form_view.create_from_template(request: HttpRequest, pn_form: PushNotificationForm) PushNotification | None[source]

Create a push notification from a template

Parameters:
  • request (HttpRequest) – The current request

  • pn_form (PushNotificationForm) – The push notification form

Returns:

The new created push notification object

Return type:

PushNotification | None

integreat_cms.cms.views.push_notifications.push_notification_form_view.extract_pn_details(request: HttpRequest, push_notification: PushNotification | None, sort_for_region: Region | None = None) dict[str, Any][source]

Save and show form for creating or editing a push notification. Send push notification if asked for by user.

Parameters:
  • request (HttpRequest) – Object representing the user call

  • push_notification (PushNotification | None) – The existing PushNotification or None

  • sort_for_region (Region | None) – Region for which to keep sorting order (according to language tree)

Returns:

A dict containing * all_regions, a list of all Region objects of the existing PushNotification (or the current region, if it doesn’t exist yet), * other_regions, the sublist of all_regions which the current user doesn’t have access to, * all_languages, a cumulative list of all active languages across all regions in all_regions and * disable_edit, a boolean determining whether the user should be able to edit the PushNotification given his status (superuser, staff) and the vacancy of other_regions.

Return type:

dict[str, Any]

integreat_cms.cms.views.push_notifications.push_notification_form_view.save_forms(instance: PushNotification, pn_form: PushNotificationForm, pnt_formset: Any) None[source]

Saves the forms :param instance: The push notification instance :param pn_form: The push notification form :param pnt_formset: The push notification translation formset

Parameters:
Return type:

None

integreat_cms.cms.views.push_notifications.push_notification_form_view.send_pn(request: HttpRequest, pn_form: PushNotificationForm, schedule: bool = False) bool[source]

Send (or schedule) a push notification

Parameters:
  • request (HttpRequest) – The current request

  • pn_form (PushNotificationForm) – The push notification form

  • schedule (bool) – Whether the message should be scheduled instead of sent directly

Raises:

PermissionDenied – When the user does not have the permission to send notifications

Returns:

Whether sending (or scheduling) was successful

Return type:

bool

integreat_cms.cms.views.push_notifications.push_notification_form_view.validate_forms(request: HttpRequest, details: dict, pn_form: PushNotificationForm, pnt_formset: Any) bool[source]

Validates the forms and returns True iff no errors occurred. :param request: The request :param details: The push notification details :param pn_form: The push notification form :param pnt_formset: The push notification translation formset :return: whether verification was successful

Parameters:
Return type:

bool

Push Notification List View

class integreat_cms.cms.views.push_notifications.push_notification_list_view.PushNotificationListView(**kwargs)[source]

Bases: TemplateView

Class that handles HTTP GET requests for listing push notifications

extra_context = {'current_menu_item': 'push_notifications'}[source]

The context dict passed to the template (see ContextMixin)

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

Create a list that shows existing push notifications and translations

Parameters:
  • request (HttpRequest) – Object representing the user call

  • *args (Any) – The supplied arguments

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

Returns:

The rendered template response

Return type:

HttpResponse

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

Apply the query and filter the rendered push notifications

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

template = 'push_notifications/push_notification_list.html'[source]

The template to render if templates is False

property template_name: str[source]

Select correct HTML template, depending on templates flag (see TemplateResponseMixin)

Returns:

Path to HTML template

template_templates = 'push_notifications/push_notification_template_list.html'[source]

The template to render if templates is True

templates = False[source]

If true, shows the template push notification list