Events
Forms for creating or saving event objects and their corresponding event translation objects and recurrence rule objects
Event Filter Form
Form for submitting filter requests
- class integreat_cms.cms.forms.events.event_filter_form.EventFilterForm(**kwargs: Any)[source]
Bases:
CustomFilterForm
Form to filter the event list
Form fields:
all_day
: All Day (TypedMultipleChoiceField
)recurring
: Recurring (TypedMultipleChoiceField
)date_from
: Date From (DateField
)date_to
: Date To (DateField
)events_time_range
: Events Time Range (MultipleChoiceField
)poi_id
: Poi Id (IntegerField
)query
: Query (CharField
)
- Parameters:
kwargs (Any)
- __init__(**kwargs: Any) None [source]
Initialize the custom filter form
- Parameters:
**kwargs (Any) – The supplied keyword arguments
- 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_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.
- apply(events: EventQuerySet, region: Region, language_slug: str) tuple[EventQuerySet, None, None] [source]
Filter the events according to the given filter data
- Parameters:
events (EventQuerySet) – The list of events
region (Region) – The current region
language_slug (str) – The slug of the current language
- Returns:
The filtered list of events, the poi used for filtering, and the search query
- Return type:
tuple[EventQuerySet, None, None]
- clean()[source]
Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.
- property filters_visible: bool[source]
This function determines whether the filter form is visible by default.
- Returns:
Whether any filters (other than search) were changed
- 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.
- property is_enabled: bool[source]
This function determines whether the filters are applied.
- Returns:
Whether filtering should be performed
- 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.
Event Form
- class integreat_cms.cms.forms.events.event_form.EventForm(**kwargs: Any)[source]
Bases:
CustomModelForm
Form for creating and modifying event objects
Form fields:
start
: Start (DateTimeField
)end
: End (DateTimeField
)icon
: Icon (ModelChoiceField
)location
: Location (ModelChoiceField
)external_calendar
: External calendar (ModelChoiceField
)external_event_id
: The ID of this event in the external calendar (CharField
)is_all_day
: All-day (BooleanField
)is_recurring
: Recurring (BooleanField
)has_not_location
: Event does not have a physical location (BooleanField
)start_date
: start date (DateField
)end_date
: end date (DateField
)start_time
: start time (TimeField
)end_time
: end time (TimeField
)
- Parameters:
kwargs (Any)
- __init__(**kwargs: Any) None [source]
Initialize event form
- Parameters:
**kwargs (Any) – The supplied keyword arguments
- 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 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
Event Translation Form
- class integreat_cms.cms.forms.events.event_translation_form.EventTranslationForm(**kwargs: Any)[source]
Bases:
MachineTranslationForm
Form for creating and modifying event translation objects
Form fields:
title
: Title of the event (CharField
)status
: Status (TypedChoiceField
)content
: Description (CharField
)minor_edit
: Minor edit (BooleanField
)automatic_translation
: Automatic translation (BooleanField
)machine_translated
: Machine translated (BooleanField
)slug
: Event link (SlugField
)mt_translations_to_create
: Create new translations: (ModelMultipleChoiceField
)mt_translations_to_update
: Update existing translations: (ModelMultipleChoiceField
)
- Parameters:
kwargs (Any)
- __init__(**kwargs: Any) None [source]
Initialize MT translation form. If request and language kwargs are missing, MTs are disabled.
- Parameters:
**kwargs (Any) – The supplied keyword arguments
- 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 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.
- add_success_message(request: HttpRequest) None [source]
This adds a success message for a translation form. Requires the attributes “title”, “status” and “foreign_object” on the form instance.
- Parameters:
request (HttpRequest) – The current request submitting the translation form
- Return type:
None
- clean() dict[str, Any] [source]
Validate form fields which depend on each other, see
django.forms.Form.clean()
- clean_content() str [source]
Validate the content field (see Overriding the clean() method) and applies changes to any element to match the guidelines.
- Raises:
ValidationError – When a heading 1 (
<h1>
) is used in the text content- Returns:
The valid content
- Return type:
- clean_slug() str [source]
Validate the slug field (see Overriding the clean() method)
- Returns:
A unique slug based on the input value
- 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.
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.
- mt_form_is_enabled() NS_NodeQuerySet [source]
Helper method to decide if this form should be shown, or if it should be hidden for the current language due to a lack of MT-compatible child language nodes
- Returns:
Whether this form is enabled
- Return type:
NS_NodeQuerySet
- 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, foreign_form_changed: bool = False)[source]
Create machine translations and save them to the database
- Parameters:
- Returns:
The saved content translation object
- Return type:
External Calendar Form
- class integreat_cms.cms.forms.events.external_calendar_form.ExternalCalendarForm(user: User | None, *args: Any, **kwargs: Any)[source]
Bases:
CustomModelForm
Form for adding a new external calendar
Form fields:
name
: Calendar name (CharField
)url
: URL (URLField
)import_filter_category
: The category that events need to have to get imported (Leave blank to import all events) (CharField
)
- Parameters:
user (User | None)
args (Any)
kwargs (Any)
- __init__(user: User | None, *args: Any, **kwargs: Any) None [source]
Initialize placeholder model 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]
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.
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
Recurrence Rule Form
- class integreat_cms.cms.forms.events.recurrence_rule_form.RecurrenceRuleForm(**kwargs: Any)[source]
Bases:
CustomModelForm
Form for creating and modifying event recurrence rule objects
Form fields:
frequency
: Frequency (TypedChoiceField
)interval
: Repeat every … time(s) (IntegerField
)weekdays_for_weekly
: Weekdays (SimpleArrayField
)weekday_for_monthly
: Weekday (TypedChoiceField
)week_for_monthly
: Week (TypedChoiceField
)recurrence_end_date
: Recurrence end date (DateField
)has_recurrence_end_date
: Recurrence ends (BooleanField
)
- Parameters:
kwargs (Any)
- __init__(**kwargs: Any) None [source]
Initialize recurrence rule form
- Parameters:
**kwargs (Any) – The supplied keyword arguments
- 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 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.
- has_changed() bool [source]
This function provides a workaround for the
weekdays_for_weekly
field to be correctly recognized as changed.- Returns:
Whether or not the recurrence rule 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