workflows.views =============== .. py:module:: workflows.views .. autoapi-nested-parse:: Workflow views for TrustPoint. This module provides Django class-based views for: - Listing and retrieving workflow definitions, domains, devices, and CAs. - Managing workflows via a wizard and delete endpoint. - Displaying pending approvals and workflow instance details. - Signaling workflow instances (approve/reject). Module Contents --------------- .. py:class:: ContextCatalogView(**kwargs) Bases: :py:obj:`django.views.View` Return a flattened, searchable catalog of {{ ctx.* }} variables for a running instance. .. py:method:: get(_request, instance_id, *_args, **_kwargs) Return JSON catalog of available template paths for {{ ctx.* }}. :param _request: The HTTP request. :param instance_id: Workflow instance UUID. :returns: JsonResponse with 'usage' and 'vars' (each var has key, label, sample). .. py:class:: MailTemplateListView(**kwargs) Bases: :py:obj:`django.views.View` Return email templates grouped for the wizard. .. py:method:: get(_request, *_args, **_kwargs) Return JSON grouping available mail templates. :param _request: The HTTP request. :param \*_args: Unused positional args. :param \*\*_kwargs: Unused keyword args. :returns: A JsonResponse containing grouped mail templates. .. py:class:: EventsListView(**kwargs) Bases: :py:obj:`django.views.View` API endpoint returning all events. .. py:method:: get(_request, *_args, **_kwargs) Return JSON with all available events. :param _request: The HTTP request. :param \*_args: Unused positional args. :param \*\*_kwargs: Unused keyword args. :returns: A JsonResponse containing events keyed by event ID. .. py:class:: CAListView(**kwargs) Bases: :py:obj:`django.views.View` Return all issuing CAs as JSON. .. py:method:: get(_request, *_args, **_kwargs) Return a list of active issuing CAs. :param _request: The HTTP request. :param \*_args: Unused positional args. :param \*\*_kwargs: Unused keyword args. :returns: A JsonResponse with CA IDs and names. .. py:class:: DomainListView(**kwargs) Bases: :py:obj:`django.views.View` Return all domains as JSON. .. py:method:: get(_request, *_args, **_kwargs) Return a list of active domains. :param _request: The HTTP request. :param \*_args: Unused positional args. :param \*\*_kwargs: Unused keyword args. :returns: A JsonResponse with domain IDs and names. .. py:class:: DeviceListView(**kwargs) Bases: :py:obj:`django.views.View` Return all devices as JSON. .. py:method:: get(_request, *_args, **_kwargs) Return a list of devices. :param _request: The HTTP request. :param \*_args: Unused positional args. :param \*\*_kwargs: Unused keyword args. :returns: A JsonResponse with device IDs and names. .. py:class:: DefinitionDetailView(**kwargs) Bases: :py:obj:`django.views.View` Return JSON for a single WorkflowDefinition (for editing in wizard). .. py:method:: get(_request, pk, *_args, **_kwargs) Return details of a single WorkflowDefinition. :param _request: The HTTP request. :param pk: The workflow definition UUID. :param \*_args: Unused positional args. :param \*\*_kwargs: Unused keyword args. :returns: A JsonResponse with workflow definition metadata. .. py:class:: WorkflowDefinitionListView Bases: :py:obj:`django.views.generic.ListView`\ [\ :py:obj:`workflows.models.WorkflowDefinition`\ ] Show all workflow definitions. .. py:attribute:: model .. py:attribute:: template_name :value: 'workflows/definition_table.html' .. py:attribute:: context_object_name :value: 'definitions' .. py:method:: get_context_data(**kwargs) Add page metadata to context. .. py:class:: WorkflowDefinitionImportView(**kwargs) Bases: :py:obj:`django.views.View` Accepts a JSON file exported from this system and stages a one-time wizard prefill. UX: - On success → message.success + redirect to wizard (the wizard loads and clears prefill). - On error → message.error + redirect back to the definition list (keeps user in UI). .. py:attribute:: MAX_ERRORS_TO_SHOW :value: 6 .. py:method:: post(request, *_args, **_kwargs) Handle upload of a workflow export and stage wizard prefill. :param request: The HTTP request containing the uploaded JSON file. :returns: HttpResponse redirecting back to the definition table or wizard. .. py:class:: WizardPrefillView(**kwargs) Bases: :py:obj:`django.views.View` Returns and CLEARS a one-time wizard prefill from the session. .. py:method:: get(request, *_args, **_kwargs) Return and clear any staged wizard prefill from the session. .. py:class:: WorkflowDefinitionExportView(**kwargs) Bases: :py:obj:`django.views.View` Download a single workflow definition as a JSON file. { "schema": "trustpoint.workflow/1", "name": "...", "version": 1, "published": true/false, "definition": {...}, "scopes": [{"ca_id":..., "domain_id":..., "device_id":...}, ...], "exported_at": "ISO-8601" } .. py:method:: get(_request, pk, *_args, **_kwargs) Return a JSON file export for the given workflow definition. .. py:class:: WorkflowDefinitionPublishView(**kwargs) Bases: :py:obj:`django.views.View` Toggle published flag via POST (publish/unpublish). .. py:method:: post(request, pk, *_args, **_kwargs) Publish or pause a workflow definition based on the submitted action. .. py:class:: WorkflowWizardView(**kwargs) Bases: :py:obj:`django.views.View` UI wizard to create or edit a linear workflow. .. py:attribute:: template_name :value: 'workflows/definition_wizard.html' .. py:method:: get(request) Render the workflow definition wizard page. .. py:method:: post(request) Validate and save a workflow definition submitted from the wizard. .. py:class:: WorkflowDefinitionDeleteView(**kwargs) Bases: :py:obj:`django.views.View` POST-only: deletes the WorkflowDefinition. .. py:method:: post(request, pk, *_args, **_kwargs) Delete a workflow definition by ID. .. py:class:: WorkflowInstanceDetailView(**kwargs) Bases: :py:obj:`trustpoint.page_context.PageContextMixin`, :py:obj:`django.views.View` Show detailed info for a pending workflow instance, including step summary. .. py:attribute:: template_name :value: 'workflows/instance_detail.html' .. py:method:: get(request, instance_id, *_args, **_kwargs) Render the detail view for a single workflow instance. .. py:class:: SignalInstanceView(**kwargs) Bases: :py:obj:`django.views.View` Endpoint to signal (approve/reject) a workflow instance via POST. .. py:method:: post(request, instance_id, *_args, **_kwargs) Handle approval or rejection of a single workflow instance. .. py:class:: EnrollmentRequestListView Bases: :py:obj:`django.views.generic.ListView`\ [\ :py:obj:`workflows.models.EnrollmentRequest`\ ] List EnrollmentRequests (main pending requests page). .. py:attribute:: model .. py:attribute:: template_name :value: 'workflows/enrollment_request_table.html' .. py:attribute:: context_object_name :value: 'requests' .. py:attribute:: paginate_by :value: 25 .. py:method:: get_queryset() Return EnrollmentRequests annotated with workflow instance counts, filtered. .. py:method:: get_context_data(**kwargs) Add page metadata and filter to context. .. py:class:: EnrollmentRequestDetailView Bases: :py:obj:`django.views.generic.ListView`\ [\ :py:obj:`workflows.models.WorkflowInstance`\ ] Show WorkflowInstances that belong to a single EnrollmentRequest. .. py:attribute:: model .. py:attribute:: template_name :value: 'workflows/enrollment_request_detail.html' .. py:attribute:: context_object_name :value: 'instances' .. py:attribute:: paginate_by :value: 50 .. py:method:: get_queryset() Return WorkflowInstances for the requested EnrollmentRequest. .. py:method:: get_context_data(**kwargs) Expose the parent EnrollmentRequest and page metadata. .. py:class:: BulkAbortEnrollmentRequestsView(**kwargs) Bases: :py:obj:`django.views.View` POST endpoint to abort multiple EnrollmentRequests. .. py:method:: post(request, *_args, **_kwargs) Handles the POST request for bulk abortion of enrollment requests. :param request: The django request object. :param _args: Positional arguments are discarded. :param kwargs: Keyword arguments are passed to get_context_data. :returns: The HttpResponseRedirect. .. py:class:: SignalEnrollmentRequestView(**kwargs) Bases: :py:obj:`django.views.View` Approve or reject all workflow instances belonging to a single EnrollmentRequest. .. py:method:: post(request, er_id, *_args, **_kwargs) Handle approval or rejection of all workflow instances in an enrollment request. :param request: The HTTP request containing the action. :param er_id: The id of the enrollment request. :returns: HttpResponse redirecting back to the request table. .. py:class:: BulkSignalEnrollmentRequestsView(**kwargs) Bases: :py:obj:`django.views.View` Bulk approve or reject enrollment requests. .. py:method:: post(request, *_args, **_kwargs) Handle bulk approval or rejection of enrollment requests. :param request: The HTTP request containing the list of selected enrollment requests. :returns: HttpResponse redirecting back to the request table.