Push Notifications
Forms for creating and modifying push notification and push notification translation objects
Push Notification Form
- class integreat_cms.cms.forms.push_notifications.push_notification_form.PushNotificationForm(regions: QuerySet | None = None, selected_regions: list[Region] | None = None, disabled: bool = False, template: bool = False, **kwargs: Any)[source]
Bases:
CustomModelForm
Form for creating and modifying push notification objects
Form fields:
channel
: Channel (TypedChoiceField
)regions
: Regions (ModelMultipleChoiceField
)mode
: Mode (TypedChoiceField
)scheduled_send_date
: Scheduled send date (DateTimeField
)is_template
: News template (BooleanField
)template_name
: News template name (CharField
)schedule_send
: Schedule sending (BooleanField
)scheduled_send_date_day
: Scheduled send day (DateField
)scheduled_send_date_time
: Scheduled send time (TimeField
)
- Parameters:
- __init__(regions: QuerySet | None = None, selected_regions: list[Region] | None = None, disabled: bool = False, template: bool = False, **kwargs: Any) None [source]
Initialize push notification form
- add_error(field, error)[source]
Update the content of self._errors.
The field argument is the name of the field to which the errors should be added. If it’s None, treat the errors as NON_FIELD_ERRORS.
The error argument can be a single error, a list of errors, or a dictionary that maps field names to lists of errors. An “error” can be either a simple string or an instance of ValidationError with its message attribute set and a “list or dictionary” can be an actual list or dict or an instance of ValidationError with its error_list or error_dict attribute set.
If error is a dictionary, the field argument must be None and errors will be added to the fields that correspond to the keys of the dictionary.
- add_error_messages(request: HttpRequest) None [source]
This function accepts the current request and adds the form’s error messages to the message queue of
django.contrib.messages
.- Parameters:
request (HttpRequest) – The current request submitting the form
- Return type:
None
- add_initial_prefix(field_name)[source]
Add an ‘initial’ prefix for checking dynamic initial values.
- add_prefix(field_name)[source]
Return the field name with a prefix appended, if this Form has a prefix set.
Subclasses may wish to override.
- clean() dict[str, Any] [source]
Validate form fields which depend on each other, see
django.forms.Form.clean()
- get_error_messages() list[dict[str, str]] [source]
Return all error messages of this form and append labels to field-errors
- get_initial_for_field(field, field_name)[source]
Return initial data for field on form. Use initial data from the form or the field, in that order. Evaluate callable values.
Return a list of all the BoundField objects that are hidden fields. Useful for manual form layout in templates.
- is_multipart()[source]
Return True if the form needs to be multipart-encoded, i.e. it has FileInput, or False otherwise.
- non_field_errors()[source]
Return an ErrorList of errors that aren’t associated with a particular field – i.e., from Form.clean(). Return an empty ErrorList if there are none.
- order_fields(field_order)[source]
Rearrange the fields according to field_order.
field_order is a list of field names specifying the order. Append fields not included in the list in the default order for backward compatibility with subclasses not overriding field_order. If field_order is None, keep all fields in the order defined in the class. Ignore unknown fields in field_order to allow disabling fields in form subclasses without redefining ordering.
- save(commit: bool = True) Any [source]
This method extends the default
save()
-method of the baseModelForm
to provide debug logging- Parameters:
commit (bool) – Whether or not the changes should be written to the database
- Returns:
The saved object returned by The save() method
- Return type:
Any
Push Notification Translation Form
- class integreat_cms.cms.forms.push_notifications.push_notification_translation_form.PushNotificationTranslationForm(**kwargs: Any)[source]
Bases:
CustomModelForm
Form for creating and modifying push notification translation objects
Form fields:
title
: Title (CharField
)text
: Content (CharField
)language
: Language (ModelChoiceField
)
- Parameters:
kwargs (Any)
- __init__(**kwargs: Any) None [source]
Initialize placeholder model form
- Parameters:
**kwargs (Any) – The supplied keyword arguments
- Raises:
TypeError – If form is instantiated directly without an inheriting subclass
- Return type:
None
- add_error(field, error)[source]
Update the content of self._errors.
The field argument is the name of the field to which the errors should be added. If it’s None, treat the errors as NON_FIELD_ERRORS.
The error argument can be a single error, a list of errors, or a dictionary that maps field names to lists of errors. An “error” can be either a simple string or an instance of ValidationError with its message attribute set and a “list or dictionary” can be an actual list or dict or an instance of ValidationError with its error_list or error_dict attribute set.
If error is a dictionary, the field argument must be None and errors will be added to the fields that correspond to the keys of the dictionary.
- add_error_messages(request: HttpRequest) None [source]
This function overwrites
add_error_messages()
to add the language of the current translation to the error messages- Parameters:
request (HttpRequest) – The current request submitting the form
- Return type:
None
- add_initial_prefix(field_name)[source]
Add an ‘initial’ prefix for checking dynamic initial values.
- add_prefix(field_name)[source]
Return the field name with a prefix appended, if this Form has a prefix set.
Subclasses may wish to override.
- clean() dict[str, Any] [source]
This method extends the default
clean()
-method of the baseModelForm
to provide debug logging- Returns:
The cleaned data (see Overriding the clean() method)
- Return type:
- get_error_messages() list[dict[str, str]] [source]
Return all error messages of this form and append labels to field-errors
- get_initial_for_field(field, field_name)[source]
Return initial data for field on form. Use initial data from the form or the field, in that order. Evaluate callable values.
- has_changed() bool [source]
Return
True
if submitted data differs from initial data. If the main language should be used as fallback for missing translations, this always returnTrue
.- Returns:
Whether the form has changed
- Return type:
Return a list of all the BoundField objects that are hidden fields. Useful for manual form layout in templates.
- is_multipart()[source]
Return True if the form needs to be multipart-encoded, i.e. it has FileInput, or False otherwise.
- non_field_errors()[source]
Return an ErrorList of errors that aren’t associated with a particular field – i.e., from Form.clean(). Return an empty ErrorList if there are none.
- order_fields(field_order)[source]
Rearrange the fields according to field_order.
field_order is a list of field names specifying the order. Append fields not included in the list in the default order for backward compatibility with subclasses not overriding field_order. If field_order is None, keep all fields in the order defined in the class. Ignore unknown fields in field_order to allow disabling fields in form subclasses without redefining ordering.
- save(commit: bool = True) Any [source]
This method extends the default
save()
-method of the baseModelForm
to provide debug logging- Parameters:
commit (bool) – Whether or not the changes should be written to the database
- Returns:
The saved object returned by The save() method
- Return type:
Any