workflows.views¶
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).
Classes¶
Return a flattened, searchable catalog of {{ ctx.* }} variables for a running instance. |
|
Return email templates grouped for the wizard. |
|
API endpoint returning all events. |
|
Return all issuing CAs as JSON. |
|
Return all domains as JSON. |
|
Return all devices as JSON. |
|
Return JSON for a single WorkflowDefinition (for editing in wizard). |
|
Show all workflow definitions. |
|
Accepts a JSON file exported from this system and stages a one-time wizard prefill. |
|
Returns and CLEARS a one-time wizard prefill from the session. |
|
Download a single workflow definition as a JSON file. |
|
Toggle published flag via POST (publish/unpublish). |
|
UI wizard to create or edit a linear workflow. |
|
POST-only: deletes the WorkflowDefinition. |
|
Show detailed info for a pending workflow instance, including step summary. |
|
Endpoint to signal (approve/reject) a workflow instance via POST. |
|
List EnrollmentRequests (main pending requests page). |
|
Show WorkflowInstances that belong to a single EnrollmentRequest. |
|
POST endpoint to abort multiple EnrollmentRequests. |
|
Approve or reject all workflow instances belonging to a single EnrollmentRequest. |
|
Bulk approve or reject enrollment requests. |
Module Contents¶
- class workflows.views.ContextCatalogView(**kwargs)[source]¶
Bases:
django.views.ViewReturn a flattened, searchable catalog of {{ ctx.* }} variables for a running instance.
- get(_request, instance_id, *_args, **_kwargs)[source]¶
Return JSON catalog of available template paths for {{ ctx.* }}.
- Parameters:
_request (django.http.HttpRequest) – The HTTP request.
instance_id (uuid.UUID) – Workflow instance UUID.
_args (Any)
_kwargs (Any)
- Returns:
JsonResponse with ‘usage’ and ‘vars’ (each var has key, label, sample).
- Return type:
django.http.JsonResponse
- class workflows.views.MailTemplateListView(**kwargs)[source]¶
Bases:
django.views.ViewReturn email templates grouped for the wizard.
- get(_request, *_args, **_kwargs)[source]¶
Return JSON grouping available mail templates.
- Parameters:
_request (django.http.HttpRequest) – The HTTP request.
*_args (Any) – Unused positional args.
**_kwargs (Any) – Unused keyword args.
- Returns:
A JsonResponse containing grouped mail templates.
- Return type:
django.http.JsonResponse
- class workflows.views.EventsListView(**kwargs)[source]¶
Bases:
django.views.ViewAPI endpoint returning all events.
- get(_request, *_args, **_kwargs)[source]¶
Return JSON with all available events.
- Parameters:
_request (django.http.HttpRequest) – The HTTP request.
*_args (Any) – Unused positional args.
**_kwargs (Any) – Unused keyword args.
- Returns:
A JsonResponse containing events keyed by event ID.
- Return type:
django.http.JsonResponse
- class workflows.views.CAListView(**kwargs)[source]¶
Bases:
django.views.ViewReturn all issuing CAs as JSON.
- get(_request, *_args, **_kwargs)[source]¶
Return a list of active issuing CAs.
- Parameters:
_request (django.http.HttpRequest) – The HTTP request.
*_args (Any) – Unused positional args.
**_kwargs (Any) – Unused keyword args.
- Returns:
A JsonResponse with CA IDs and names.
- Return type:
django.http.JsonResponse
- class workflows.views.DomainListView(**kwargs)[source]¶
Bases:
django.views.ViewReturn all domains as JSON.
- get(_request, *_args, **_kwargs)[source]¶
Return a list of active domains.
- Parameters:
_request (django.http.HttpRequest) – The HTTP request.
*_args (Any) – Unused positional args.
**_kwargs (Any) – Unused keyword args.
- Returns:
A JsonResponse with domain IDs and names.
- Return type:
django.http.JsonResponse
- class workflows.views.DeviceListView(**kwargs)[source]¶
Bases:
django.views.ViewReturn all devices as JSON.
- get(_request, *_args, **_kwargs)[source]¶
Return a list of devices.
- Parameters:
_request (django.http.HttpRequest) – The HTTP request.
*_args (Any) – Unused positional args.
**_kwargs (Any) – Unused keyword args.
- Returns:
A JsonResponse with device IDs and names.
- Return type:
django.http.JsonResponse
- class workflows.views.DefinitionDetailView(**kwargs)[source]¶
Bases:
django.views.ViewReturn JSON for a single WorkflowDefinition (for editing in wizard).
- get(_request, pk, *_args, **_kwargs)[source]¶
Return details of a single WorkflowDefinition.
- Parameters:
_request (django.http.HttpRequest) – The HTTP request.
pk (uuid.UUID) – The workflow definition UUID.
*_args (Any) – Unused positional args.
**_kwargs (Any) – Unused keyword args.
- Returns:
A JsonResponse with workflow definition metadata.
- Return type:
django.http.JsonResponse
- class workflows.views.WorkflowDefinitionListView[source]¶
Bases:
django.views.generic.ListView[workflows.models.WorkflowDefinition]Show all workflow definitions.
- class workflows.views.WorkflowDefinitionImportView(**kwargs)[source]¶
Bases:
django.views.ViewAccepts 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).
- post(request, *_args, **_kwargs)[source]¶
Handle upload of a workflow export and stage wizard prefill.
- Parameters:
request (django.http.HttpRequest) – The HTTP request containing the uploaded JSON file.
_args (Any)
_kwargs (Any)
- Returns:
HttpResponse redirecting back to the definition table or wizard.
- Return type:
django.http.HttpResponse
- _validate_and_transform_export(data)[source]¶
Returns (errors, prefill) where prefill is.
{ name, events: [{handler, protocol, operation}], steps: [{type, params}], scopes:{} }
- Parameters:
data (dict[str, Any])
- Return type:
tuple[list[str], dict[str, Any] | None]
- static _validate_export_schema(schema, errs)[source]¶
- Parameters:
schema (Any)
errs (list[str])
- Return type:
None
- static _extract_export_events_and_steps(definition, errs)[source]¶
- Parameters:
definition (dict[str, Any])
errs (list[str])
- Return type:
tuple[list[Any], list[Any]]
- class workflows.views.WizardPrefillView(**kwargs)[source]¶
Bases:
django.views.ViewReturns and CLEARS a one-time wizard prefill from the session.
- class workflows.views.WorkflowDefinitionExportView(**kwargs)[source]¶
Bases:
django.views.ViewDownload 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”
}
- class workflows.views.WorkflowDefinitionPublishView(**kwargs)[source]¶
Bases:
django.views.ViewToggle published flag via POST (publish/unpublish).
- class workflows.views.WorkflowWizardView(**kwargs)[source]¶
Bases:
django.views.ViewUI wizard to create or edit a linear workflow.
- get(request)[source]¶
Render the workflow definition wizard page.
- Parameters:
request (django.http.HttpRequest)
- Return type:
django.http.HttpResponse
- post(request)[source]¶
Validate and save a workflow definition submitted from the wizard.
- Parameters:
request (django.http.HttpRequest)
- Return type:
django.http.JsonResponse
- static _parse_payload_for_save(data)[source]¶
- Parameters:
data (dict[str, Any])
- Return type:
tuple[str, list[dict[str, str]], list[dict[str, Any]], list[dict[str, Any]]]
- class workflows.views.WorkflowDefinitionDeleteView(**kwargs)[source]¶
Bases:
django.views.ViewPOST-only: deletes the WorkflowDefinition.
- class workflows.views.WorkflowInstanceDetailView(**kwargs)[source]¶
Bases:
trustpoint.page_context.PageContextMixin,django.views.ViewShow detailed info for a pending workflow instance, including step summary.
- class workflows.views.SignalInstanceView(**kwargs)[source]¶
Bases:
django.views.ViewEndpoint to signal (approve/reject) a workflow instance via POST.
- class workflows.views.EnrollmentRequestListView[source]¶
Bases:
django.views.generic.ListView[workflows.models.EnrollmentRequest]List EnrollmentRequests (main pending requests page).
- get_queryset()[source]¶
Return EnrollmentRequests annotated with workflow instance counts, filtered.
- Return type:
django.db.models.query.QuerySet[workflows.models.EnrollmentRequest]
- class workflows.views.EnrollmentRequestDetailView[source]¶
Bases:
django.views.generic.ListView[workflows.models.WorkflowInstance]Show WorkflowInstances that belong to a single EnrollmentRequest.
- get_queryset()[source]¶
Return WorkflowInstances for the requested EnrollmentRequest.
- Return type:
django.db.models.query.QuerySet[workflows.models.WorkflowInstance]
- class workflows.views.BulkAbortEnrollmentRequestsView(**kwargs)[source]¶
Bases:
django.views.ViewPOST endpoint to abort multiple EnrollmentRequests.
- post(request, *_args, **_kwargs)[source]¶
Handles the POST request for bulk abortion of enrollment requests.
- Parameters:
request (django.http.HttpRequest) – The django request object.
_args (Any) – Positional arguments are discarded.
kwargs – Keyword arguments are passed to get_context_data.
_kwargs (Any)
- Returns:
The HttpResponseRedirect.
- Return type:
django.http.HttpResponseRedirect
- class workflows.views.SignalEnrollmentRequestView(**kwargs)[source]¶
Bases:
django.views.ViewApprove or reject all workflow instances belonging to a single EnrollmentRequest.
- post(request, er_id, *_args, **_kwargs)[source]¶
Handle approval or rejection of all workflow instances in an enrollment request.
- Parameters:
request (django.http.HttpRequest) – The HTTP request containing the action.
er_id (uuid.UUID) – The id of the enrollment request.
_args (Any)
_kwargs (Any)
- Returns:
HttpResponse redirecting back to the request table.
- Return type:
django.http.HttpResponseRedirect
- class workflows.views.BulkSignalEnrollmentRequestsView(**kwargs)[source]¶
Bases:
django.views.ViewBulk approve or reject enrollment requests.
- post(request, *_args, **_kwargs)[source]¶
Handle bulk approval or rejection of enrollment requests.
- Parameters:
request (django.http.HttpRequest) – The HTTP request containing the list of selected enrollment requests.
_args (Any)
_kwargs (Any)
- Returns:
HttpResponse redirecting back to the request table.
- Return type:
django.http.HttpResponseRedirect