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: TemplateView

View to list all admin feedback (technical feedback)

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

archived = False[source]

Whether or not to show archived feedback

classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

content_type = None[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
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_context_data(**kwargs)[source]
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.

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace'][source]
http_method_not_allowed(request, *args, **kwargs)[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

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

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

template = 'feedback/admin_feedback_list.html'[source]

The template to render (see TemplateResponseMixin)

template_archived = 'feedback/admin_feedback_list_archived.html'[source]
template_engine = None[source]
property template_name: str[source]

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

Returns:

Path to HTML template

view_is_async = False[source]

Feedback Resource

class integreat_cms.cms.views.feedback.feedback_resource.FeedbackResource(**kwargs)[source]

Bases: ModelResource

This is the Resource class that connects to the django-import-export library

DEFAULT_RESOURCE_FIELD[source]

alias of Field

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', '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, dry_run)[source]

Override to add additional logic. Does nothing by default.

after_export(queryset, data, *args, **kwargs)[source]

Override to add additional logic. Does nothing by default.

after_import(dataset, result, using_transactions, dry_run, **kwargs)[source]

Reset the SQL sequences after new objects are imported

after_import_instance(instance, new, row_number=None, **kwargs)[source]

Override to add additional logic. Does nothing by default.

after_import_row(row, row_result, row_number=None, **kwargs)[source]

Override to add additional logic. Does nothing by default.

Parameters:
  • row – A dict of the import row.

  • row_result – A RowResult instance. References the persisted instance as an attribute.

  • row_number – The row number from the dataset.

after_save_instance(instance, using_transactions, dry_run)[source]

Override to add additional logic. Does nothing by default.

before_delete_instance(instance, dry_run)[source]

Override to add additional logic. Does nothing by default.

before_export(queryset, *args, **kwargs)[source]

Override to add additional logic. Does nothing by default.

before_import(dataset, using_transactions, dry_run, **kwargs)[source]

Override to add additional logic. Does nothing by default.

before_import_row(row, row_number=None, **kwargs)[source]

Override to add additional logic. Does nothing by default.

before_save_instance(instance, using_transactions, dry_run)[source]

Override to add additional logic. Does nothing by default.

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, using_transactions=True, dry_run=False)[source]

Calls instance.delete() as long as dry_run is not set. If use_bulk then instances are appended to a list for bulk import.

export(*args, queryset=None, **kwargs)[source]

Exports a resource. :returns: Dataset object.

export_field(field, obj)[source]
export_resource(obj)[source]
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, *args, **kwargs)[source]

Override to filter an export queryset.

for_delete(row, instance)[source]

Returns True if row importing should delete instance.

Default implementation returns False. Override this method to handle deletion.

get_bulk_update_fields()[source]

Returns the fields to be included in calls to bulk_update(). import_id_fields are removed because id fields cannot be supplied to bulk_update().

get_chunk_size()[source]
classmethod get_db_connection_name()[source]
classmethod get_diff_class()[source]

Returns the class used to display the diff for an imported instance.

get_diff_headers()[source]

Diff representation headers.

classmethod get_display_name()[source]
classmethod get_error_result_class()[source]

Returns the class used to store an error resulting from an import.

get_export_fields()[source]
get_export_headers()[source]
get_export_order()[source]
get_field_name(field)[source]

Returns the field name for a given field.

get_fields(**kwargs)[source]

Returns fields sorted according to export_order.

classmethod get_fk_widget(field)[source]

Prepare widget for fk and o2o fields

get_import_fields()[source]
get_import_id_fields()[source]
get_instance(*args: Any, **kwargs: Any) Any[source]

See import_export.resources.Resource.get_instance()

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

Any

classmethod get_m2m_widget(field)[source]

Prepare widget for m2m field

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_result_class()[source]

Returns the class used to store the result of an import.

classmethod get_row_result_class()[source]

Returns the class used to store the result of a row import.

get_use_transactions()[source]
get_user_visible_fields()[source]
get_user_visible_headers()[source]
handle_import_error(result, error, raise_errors=False)[source]
import_data(*args: Any, **kwargs: Any) Any[source]

See import_export.resources.Resource.import_data()

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

Any

import_data_inner(dataset, dry_run, raise_errors, using_transactions, collect_failed_rows, rollback_on_validation_errors=None, **kwargs)[source]
import_field(field, obj, data, is_m2m=False, **kwargs)[source]

Calls import_export.fields.Field.save() if Field.attribute is specified, and Field.column_name is found in data.

import_obj(obj, data, dry_run, **kwargs)[source]

Traverses every field in this Resource and calls import_field(). If import_field() results in a ValueError being raised for one of more fields, those errors are captured and reraised as a single, multi-field ValidationError.

import_row(*args: Any, **kwargs: Any) Any[source]

See import_export.resources.Resource.import_row()

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

Any

init_instance(row=None)[source]

Initializes a new Django model.

iter_queryset(queryset)[source]
save_instance(*args: Any, **kwargs: Any) Any[source]

See import_export.resources.Resource.save_instance()

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

Any

save_m2m(obj, data, using_transactions, dry_run)[source]

Saves m2m fields.

Model instance need to have a primary key value before a many-to-many relationship can be used.

skip_row(instance, original, row, import_validation_errors=None)[source]

Returns True if row importing should be skipped.

Default implementation returns False unless skip_unchanged == True and skip_diff == False.

If skip_diff is True, then no comparisons can be made because original will 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 super if you want to preserve default handling while overriding

class 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)
validate_instance(instance, import_validation_errors=None, validate_unique=True)[source]

Takes any validation errors that were raised by import_obj(), and combines them with validation errors raised by the instance’s full_clean() method. The combined errors are then re-raised as single, multi-field ValidationError.

If the clean_model_instances option is False, the instances’s full_clean() method is not called, and only the errors raised by import_obj() 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.

classmethod widget_kwargs_for_field(field_name)[source]

Returns widget kwargs for given field_name.

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

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

  • region_slug (str) – The slug of the current region

  • file_format (str) – The export format

Returns:

Response with file

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: TemplateView

View to list all region feedback (content feedback)

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

archived = False[source]

Whether or not to show archived feedback

classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

content_type = None[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
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_context_data(**kwargs)[source]
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.

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace'][source]
http_method_not_allowed(request, *args, **kwargs)[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

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

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

template = 'feedback/region_feedback_list.html'[source]

The template to render (see TemplateResponseMixin)

template_archived = 'feedback/region_feedback_list_archived.html'[source]
template_engine = None[source]
property template_name: str[source]

Select correct HTML template, depending on archived flag (see TemplateResponseMixin) :return: Path to HTML template

view_is_async = False[source]