Push Notifications
This package contains both data models related to push notifications:
PushNotification
and
PushNotificationTranslation
.
Push Notification
The model for the push notification
- class integreat_cms.cms.models.push_notifications.push_notification.PushNotification(*args, **kwargs)[source]
Bases:
AbstractBaseModel
Data model representing a push notification
- Parameters:
id (BigAutoField) – Primary key: ID
channel (CharField) – Channel
draft (BooleanField) – Draft. Whether or not the News is a draft (drafts cannot be sent)
sent_date (DateTimeField) –
Sent date. The date and time when the News was sent.
None
if the push notification is not yet sentcreated_date (DateTimeField) – Creation date
scheduled_send_date (DateTimeField) – Scheduled send date. The scheduled date for this News to be sent
mode (CharField) –
Mode. Sets behavior for dealing with not existing News translations
Manage choices in
push_notifications
is_template (BooleanField) –
News template
Distinct functionalities for templates
template_name (CharField) – News template name. Provide a distinct name for the template
Relationship fields:
- Parameters:
regions (
ManyToManyField
toRegion
) – Regions (related name:push_notifications
)
Reverse relationships:
- Parameters:
translations (Reverse
ForeignKey
fromPushNotificationTranslation
) – All translations of this push notification (related name ofpush_notification
)
- exception DoesNotExist[source]
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned[source]
Bases:
MultipleObjectsReturned
- property backend_translation: PushNotificationTranslation | None[source]
This function returns the translation of this push notification in the current backend language.
- Returns:
The backend translation of a push notification
- property best_translation: PushNotificationTranslation[source]
This function returns the translation of this push notification in the current backend language and if it doesn’t exist, it provides a fallback to the translation in the region’s default language.
- Returns:
The “best” translation of a push notification for displaying in the backend
- property default_language: Language[source]
This property returns the default language of this push notification :return: The default language of the first region
- property default_translation: PushNotificationTranslation[source]
This function returns the translation of this push notification in the region’s default language. Since a push notification can only be created by creating a translation in the default language, this is guaranteed to return a push notification translation.
- Returns:
The default translation of a push notification
- get_repr() str [source]
This overwrites the default Django
__repr__()
method which would return<PushNotification: PushNotification object (id)>
. It is used for logging.- Returns:
The canonical string representation of the push notification
- Return type:
- is_overdue[source]
This property returns whether the notification is overdue based on the retain time setting and scheduled_send_date. This method only works for scheduled notifications.
- Returns:
True if the message is overdue, False otherwise
- is_template[source]
Type:
BooleanField
News template
Distinct functionalities for templates
- languages[source]
This property returns a QuerySet of all
Language
objects, to which a push notification translation exists.- Returns:
QuerySet of all
Language
a push notification is translated into
- mode[source]
Type:
CharField
Mode. Sets behavior for dealing with not existing News translations
Choices:
ONLY_AVAILABLE
USE_MAIN_LANGUAGE
Manage choices in
push_notifications
- scheduled_send_date_local[source]
Convert the scheduled send date to local time
- Returns:
The scheduled send date in local time
- sent_date[source]
Type:
DateTimeField
Sent date. The date and time when the News was sent.
None
if the push notification is not yet sent
Push Notification Translation
- class integreat_cms.cms.models.push_notifications.push_notification_translation.PushNotificationTranslation(*args, **kwargs)[source]
Bases:
AbstractBaseModel
Data model representing a push notification translation
- Parameters:
id (BigAutoField) – Primary key: ID
title (CharField) – Title
text (TextField) – Content
last_updated (DateTimeField) – Modification date
Relationship fields:
- Parameters:
language (
ForeignKey
toLanguage
) – Language (related name:push_notification_translations
)push_notification (
ForeignKey
toPushNotification
) – Push notification (related name:translations
)
- exception DoesNotExist[source]
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned[source]
Bases:
MultipleObjectsReturned
- get_absolute_url() str [source]
Generates the absolute url to a news object in the app
- Returns:
The link to the news
- Return type:
- get_repr() str [source]
This overwrites the default Django
__repr__()
method which would return<PushNotificationTranslation: PushNotificationTranslation object (id)>
. It is used for logging.- Returns:
The canonical string representation of the event
- Return type:
- get_text() str [source]
Get the text of the notification. Construct a fallback text if possible.
- Returns:
A text for the push notification
- Return type:
- get_title() str [source]
Get the title of the notification translation.
- Returns:
A title for the push notification
- Return type:
- classmethod search(region: Region, language_slug: str, query: str) QuerySet[PushNotificationTranslation] [source]
Searches for all push notifications which match the given query in their title. :param region: The current region :param language_slug: The language slug :param query: The query string used for filtering the push notifications :return: A query for all matching objects
- Parameters:
- Return type:
QuerySet[PushNotificationTranslation]