Feedback
This package contains all views related to feedback
Admin Feedback Actions
This module contains action methods for feedback items (archive, restore, …)
- integreat_cms.cms.views.feedback.admin_feedback_actions.archive_admin_feedback(request: HttpRequest) HttpResponseRedirect[source]
Archive a list of feedback items
- Parameters:
request (HttpRequest) – Object representing the user call
- Returns:
A redirection to the admin feedback list
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.feedback.admin_feedback_actions.delete_admin_feedback(request: HttpRequest) HttpResponseRedirect[source]
Delete a list of feedback items
- Parameters:
request (HttpRequest) – Object representing the user call
- Returns:
A redirection to the admin feedback list
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.feedback.admin_feedback_actions.mark_admin_feedback_as_read(request: HttpRequest) HttpResponseRedirect[source]
Set read flag for a list of feedback items
- Parameters:
request (HttpRequest) – Object representing the user call
- Returns:
A redirection to the admin feedback list
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.feedback.admin_feedback_actions.mark_admin_feedback_as_unread(request: HttpRequest) HttpResponseRedirect[source]
Unset read flag for a list of feedback items
- Parameters:
request (HttpRequest) – Object representing the user call
- Returns:
A redirection to the admin feedback list
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.feedback.admin_feedback_actions.restore_admin_feedback(request: HttpRequest) HttpResponseRedirect[source]
Restore a list of feedback items
- Parameters:
request (HttpRequest) – Object representing the user call
- Returns:
A redirection to the admin feedback list
- Return type:
HttpResponseRedirect
Admin Feedback List View
- class integreat_cms.cms.views.feedback.admin_feedback_list_view.AdminFeedbackListView(**kwargs)[source]
Bases:
TemplateViewView to list all admin feedback (technical feedback)
- __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 admin feedback list
- 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
- 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.
- 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
- template_name = 'feedback/admin_feedback_list.html'[source]
The template to render (see
TemplateResponseMixin)
Feedback Resource
- class integreat_cms.cms.views.feedback.feedback_resource.FeedbackResource(**kwargs)[source]
Bases:
ModelResourceThis is the Resource class that connects to the django-import-export library
- WIDGETS_MAP = {'AutoField': <class 'import_export.widgets.IntegerWidget'>, 'BigAutoField': <class 'import_export.widgets.IntegerWidget'>, 'BigIntegerField': <class 'import_export.widgets.IntegerWidget'>, 'BooleanField': <class 'import_export.widgets.BooleanWidget'>, 'CharField': <class 'import_export.widgets.CharWidget'>, 'DateField': <class 'import_export.widgets.DateWidget'>, 'DateTimeField': <class 'import_export.widgets.DateTimeWidget'>, 'DecimalField': <class 'import_export.widgets.DecimalWidget'>, 'DurationField': <class 'import_export.widgets.DurationWidget'>, 'FloatField': <class 'import_export.widgets.FloatWidget'>, 'ForeignKey': 'get_fk_widget', 'IntegerField': <class 'import_export.widgets.IntegerWidget'>, 'JSONField': <class 'import_export.widgets.JSONWidget'>, 'ManyToManyField': 'get_m2m_widget', 'NullBooleanField': <class 'import_export.widgets.BooleanWidget'>, 'OneToOneField': 'get_fk_widget', 'PositiveBigIntegerField': <class 'import_export.widgets.IntegerWidget'>, 'PositiveIntegerField': <class 'import_export.widgets.IntegerWidget'>, 'PositiveSmallIntegerField': <class 'import_export.widgets.IntegerWidget'>, 'SmallAutoField': <class 'import_export.widgets.IntegerWidget'>, 'SmallIntegerField': <class 'import_export.widgets.IntegerWidget'>, 'TimeField': <class 'import_export.widgets.TimeWidget'>}[source]
- __init__(**kwargs)[source]
- kwargs:
An optional dict of kwargs. Subclasses can use kwargs to pass dynamic values to enhance import / exports.
- after_delete_instance(instance, row, **kwargs)[source]
Override to add additional logic. Does nothing by default.
- Parameters:
instance – A new or existing model instance.
row – A
dictcontaining key / value data for the row to be imported.**kwargs – See
import_row()
- after_export(queryset, dataset, **kwargs)[source]
Override to add additional logic. Does nothing by default.
- Parameters:
queryset – The queryset for export.
dataset – A
tablib.Dataset.**kwargs – Metadata which may be associated with the export.
- after_import(dataset, result, **kwargs)[source]
Reset the SQL sequences after new objects are imported
- after_import_row(row, row_result, **kwargs)[source]
Override to add additional logic. Does nothing by default.
- Parameters:
row – A
dictcontaining key / value data for the row to be imported.row_result – A
RowResultinstance. References the persistedinstanceas an attribute.**kwargs – See
import_row()
- after_init_instance(instance, new, row, **kwargs)[source]
Override to add additional logic. Does nothing by default.
- Parameters:
instance – A new or existing model instance.
new – a boolean flag indicating whether instance is new or existing.
row – A
dictcontaining key / value data for the row to be imported.**kwargs – See
import_row()
- after_save_instance(instance, row, **kwargs)[source]
Override to add additional logic. Does nothing by default.
- Parameters:
instance – A new or existing model instance.
row – A
dictcontaining key / value data for the row to be imported.**kwargs – See
import_row()
- before_delete_instance(instance, row, **kwargs)[source]
Override to add additional logic. Does nothing by default.
- Parameters:
instance – A new or existing model instance.
row – A
dictcontaining key / value data for the row to be imported.**kwargs – See
import_row()
- before_export(queryset, **kwargs)[source]
Override to add additional logic. Does nothing by default.
- Parameters:
queryset – The queryset for export.
**kwargs – Metadata which may be associated with the export.
- before_import(dataset, **kwargs)[source]
Override to add additional logic. Does nothing by default.
- Parameters:
dataset – A
tablib.Dataset.**kwargs – See
import_row()
- before_import_row(row, **kwargs)[source]
Override to add additional logic. Does nothing by default.
- Parameters:
row – A
dictcontaining key / value data for the row to be imported.**kwargs – See
import_row()
- before_save_instance(instance, row, **kwargs)[source]
Override to add additional logic. Does nothing by default.
- Parameters:
instance – A new or existing model instance.
row – A
dictcontaining key / value data for the row to be imported.**kwargs – See
import_row()
- bulk_create(using_transactions, dry_run, raise_errors, batch_size=None, result=None)[source]
Creates objects by calling
bulk_create.
- bulk_delete(using_transactions, dry_run, raise_errors, result=None)[source]
Deletes objects by filtering on a list of instances to be deleted, then calling
delete()on the entire queryset.
- bulk_update(using_transactions, dry_run, raise_errors, batch_size=None, result=None)[source]
Updates objects by calling
bulk_update.
- delete_instance(instance, row, **kwargs)[source]
Calls
instance.delete()as long asdry_runis not set. Ifuse_bulkthen instances are appended to a list for bulk import.- Parameters:
instance – A new or existing model instance.
row – A
dictcontaining key / value data for the row to be imported.**kwargs – See
import_row()
- do_instance_save(instance, is_create)[source]
A method specifically to provide a single overridable hook for the instance save operation. For example, this can be overridden to implement update_or_create().
- Parameters:
instance – The model instance to be saved.
is_create – A boolean flag to indicate whether this is a new object to be created, or an existing object to be updated.
- export(queryset=None, **kwargs)[source]
Exports a resource.
- Parameters:
queryset – The queryset for export (optional).
- Returns:
A
tablib.Dataset.
- classmethod field_from_django_field(field_name, django_field, readonly)[source]
Returns a Resource Field instance for the given Django model field.
- fields = {'category': <import_export.fields.Field: Category>, 'comment': <import_export.fields.Field: Comment>, 'created_date': <import_export.fields.Field: Date>, 'language_name': <import_export.fields.Field: Language>, 'rating': <import_export.fields.Field: Rating>, 'read_by_username': <import_export.fields.Field: Read by>, 'referring_to': <import_export.fields.Field: Feedback on>}[source]
- filter_export(queryset, **kwargs)[source]
Override to filter an export queryset.
- Parameters:
queryset – The queryset for export.
**kwargs – Metadata which may be associated with the export.
- Returns:
The filtered queryset.
- for_delete(row, instance)[source]
Returns
Trueifrowimporting should delete instance.Default implementation returns
False. Override this method to handle deletion.- Parameters:
row – A
dictcontaining key / value data for the row to be imported.instance – A new or existing model instance.
- get_bulk_update_fields()[source]
Returns the fields to be included in calls to bulk_update().
import_id_fieldsare removed because id fields cannot be supplied to bulk_update().
- classmethod get_diff_class()[source]
Returns the class used to display the diff for an imported instance.
- classmethod get_error_result_class()[source]
Returns the class used to store an error resulting from an import.
- get_or_init_instance(instance_loader, row)[source]
Either fetches an already existing instance or initializes a new one.
- get_queryset()[source]
Returns a queryset of all objects for this model. Override this if you want to limit the returned queryset.
- classmethod get_row_result_class()[source]
Returns the class used to store the result of a row import.
- import_data_inner(dataset, dry_run, raise_errors, using_transactions, collect_failed_rows, **kwargs)[source]
- import_field(field, instance, row, is_m2m=False, **kwargs)[source]
Handles persistence of the field data.
- Parameters:
field – A
import_export.fields.Fieldinstance.instance – A new or existing model instance.
row – A
dictcontaining key / value data for the row to be imported.is_m2m – A boolean value indicating whether or not this is a many-to-many field.
**kwargs – See
import_row()
- import_instance(instance, row, **kwargs)[source]
Traverses every field in this Resource and calls
import_field(). Ifimport_field()results in aValueErrorbeing raised for one of more fields, those errors are captured and reraised as a single, multi-field ValidationError.- Parameters:
instance – A new or existing model instance.
row – A
dictcontaining key / value data for the row to be imported.**kwargs – See
import_row()
- save_m2m(instance, row, **kwargs)[source]
Saves m2m fields.
Model instance need to have a primary key value before a many-to-many relationship can be used.
- Parameters:
instance – A new or existing model instance.
row – A
dictcontaining key / value data for the row to be imported.**kwargs – See
import_row()
- skip_row(instance, original, row, import_validation_errors=None)[source]
Returns
Trueifrowimporting should be skipped.Default implementation returns
Falseunless skip_unchanged == True and skip_diff == False.If skip_diff is True, then no comparisons can be made because
originalwill be None.When left unspecified, skip_diff and skip_unchanged both default to
False, and rows are never skipped.By default, rows are not skipped if validation errors have been detected during import. You can change this behavior and choose to ignore validation errors by overriding this method.
Override this method to handle skipping rows meeting certain conditions.
Use
superif you want to preserve default handling while overridingclass YourResource(ModelResource): def skip_row(self, instance, original, row, import_validation_errors=None): # Add code here return super().skip_row(instance, original, row, import_validation_errors=import_validation_errors)
- Parameters:
instance – A new or updated model instance.
original – The original persisted model instance.
row – A
dictcontaining key / value data for the row to be imported.import_validation_errors – A
dictcontaining key / value data for any identified validation errors.
- validate_instance(instance, import_validation_errors=None, validate_unique=True)[source]
Takes any validation errors that were raised by
import_instance(), and combines them with validation errors raised by the instance’sfull_clean()method. The combined errors are then re-raised as single, multi-field ValidationError.If the
clean_model_instancesoption is False, the instances’sfull_clean()method is not called, and only the errors raised byimport_instance()are re-raised.
- classmethod widget_from_django_field(f, default=<class 'import_export.widgets.Widget'>)[source]
Returns the widget that would likely be associated with each Django type.
Includes mapping of Postgres Array field. In the case that psycopg2 is not installed, we consume the error and process the field regardless.
Region Feedback Actions
This module contains action methods for feedback items (archive, restore, …)
- integreat_cms.cms.views.feedback.region_feedback_actions.archive_region_feedback(request: HttpRequest, region_slug: str) HttpResponseRedirect[source]
Archive a list of feedback items
- Parameters:
request (HttpRequest) – Object representing the user call
region_slug (str) – The slug of the current region
- Returns:
A redirection to the region feedback list
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.feedback.region_feedback_actions.delete_region_feedback(request: HttpRequest, region_slug: str) HttpResponseRedirect[source]
Delete a list of feedback items
- Parameters:
request (HttpRequest) – Object representing the user call
region_slug (str) – The slug of the current region
- Returns:
A redirection to the region feedback list
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.feedback.region_feedback_actions.export_region_feedback(request: HttpRequest, region_slug: str, file_format: str) HttpResponse[source]
Export a list of feedback items
- integreat_cms.cms.views.feedback.region_feedback_actions.forward_region_feedback(request: HttpRequest, region_slug: str) HttpResponse[source]
Turn a list of feedback items into technical feedback to forward to Integreat staff
- Parameters:
request (HttpRequest) – Object representing the user call
region_slug (str) – The slug of the current region
- Returns:
A redirection to the region feedback list
- Return type:
HttpResponse
- integreat_cms.cms.views.feedback.region_feedback_actions.mark_region_feedback_as_read(request: HttpRequest, region_slug: str) HttpResponseRedirect[source]
Set read flag for a list of feedback items
- Parameters:
request (HttpRequest) – Object representing the user call
region_slug (str) – The slug of the current region
- Returns:
A redirection to the region feedback list
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.feedback.region_feedback_actions.mark_region_feedback_as_unread(request: HttpRequest, region_slug: str) HttpResponseRedirect[source]
Unset read flag for a list of feedback items
- Parameters:
request (HttpRequest) – Object representing the user call
region_slug (str) – The slug of the current region
- Returns:
A redirection to the region feedback list
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.feedback.region_feedback_actions.restore_region_feedback(request: HttpRequest, region_slug: str) HttpResponseRedirect[source]
Restore a list of feedback items
- Parameters:
request (HttpRequest) – Object representing the user call
region_slug (str) – The slug of the current region
- Returns:
A redirection to the region feedback list
- Return type:
HttpResponseRedirect
Region Feedback List View
- class integreat_cms.cms.views.feedback.region_feedback_list_view.RegionFeedbackListView(**kwargs)[source]
Bases:
TemplateViewView to list all region feedback (content feedback)
- __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 region feedback list
- 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
- 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.
- 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
- template_name = 'feedback/region_feedback_list.html'[source]
The template to render (see
TemplateResponseMixin)