trustpoint.views.base¶
Contains some global views that are not specific to a single app.
This module contains some general redirect and error views (e.g. 404) as well as specific mixins and view classes which can be used within the apps.
Module Contents¶
- class trustpoint.views.base.IndexView(**kwargs)[source]¶
Bases:
django.views.generic.base.RedirectViewView that redirects to the index home page.
- class trustpoint.views.base.ListInDetailView[source]¶
Bases:
django.views.generic.list.ListView[Any]Helper view that combines a DetailView and a ListView.
This is useful for displaying a list within a DetailView. Note that ‘model’ and ‘context_object_name’ refer to the ListView. Use ‘detail_model’ and ‘detail_context_object_name’ for the DetailView.
- get(*args, **kwargs)[source]¶
Handle GET requests.
- Parameters:
args (Any)
kwargs (Any)
- Return type:
django.http.HttpResponse
- get_queryset_for_object()[source]¶
Get the queryset for the detail object.
- Return type:
django.db.models.QuerySet[Any, Any]
- class trustpoint.views.base.SupportsGetContextData[source]¶
Bases:
ProtocolFor typing to provide super().get_context_data().
- class trustpoint.views.base.ParentSupportsGetContextData[source]¶
Bases:
SupportsGetContextData,ProtocolFor typing to provide super().get_context_data().
- class trustpoint.views.base.SortableTableMixin[source]¶
Adds utility for sorting a ListView query by URL parameters.
default_sort_param must be set in the view to specify default sorting order.
- class trustpoint.views.base.SortableTableFromListMixin[source]¶
Adds utility for sorting a ListView query by URL parameters.
default_sort_param must be set in the view to specify default sorting order. Use instead of SortableTableMixin when you have a list of dicts instead of a Django queryset.
- class trustpoint.views.base.ContextDataMixin[source]¶
Mixin to add context data from attributes prefixed with ‘context_’.
- get_context_data(**kwargs)[source]¶
Adds attributes prefixed with context_ to the context_data if it does not exist.
Note
If another succeeding class in the MRO has another get_context_data method, this method will be called after setting the attributes to the context_data.
Example
Lets consider context_page_category. Then the attribute page_category with the value of context_page_category is added to the context_data if page_category does not already exist in the context_data.
Example
- The following Mixin will add ‘page_category’: ‘pki’, and ‘page_name’: ‘endpoint_profiles’
to the context data.
- class EndpointProfilesExtraContextMixin(ContextDataMixin):
“””Mixin which adds context_data for the PKI -> Endpoint Profiles pages.”””
context_page_category = ‘pki’ context_page_name = ‘endpoint_profiles’
- Parameters:
kwargs (Any)
- Return type:
dict[str, Any]
- class trustpoint.views.base.BaseBulkDeleteView[source]¶
Bases:
django.views.generic.edit.FormMixin[django.forms.Form],django.views.generic.list.BaseListView[Any]Base view for bulk deletion of objects.
- post(*_args, **_kwargs)[source]¶
Handles POST requests to the BulkDeleteView.
- Parameters:
_args (tuple[Any])
_kwargs (dict[str, Any])
- Return type:
django.http.HttpResponse
- class trustpoint.views.base.PrimaryKeyListFromPrimaryKeyString[source]¶
Utility class to parse primary keys from a URL string.
- class trustpoint.views.base.PrimaryKeyQuerysetFromUrlMixin[source]¶
Bases:
PrimaryKeyListFromPrimaryKeyStringMixin to retrieve a queryset based on primary keys provided in the URL.
- class trustpoint.views.base.BulkDeleteView[source]¶
Bases:
django.views.generic.list.MultipleObjectTemplateResponseMixin,PrimaryKeyQuerysetFromUrlMixin,BaseBulkDeleteViewView for bulk deletion of objects.
- class trustpoint.views.base.LoggedHttpResponse(content=b'', status=None, *args, **kwargs)[source]¶
Bases:
django.http.HttpResponse,trustpoint.logger.LoggerMixinCustom HttpResponse that logs and prints error messages automatically.
- Parameters:
content (str | bytes)
status (int | None)
args (Any)
kwargs (Any)