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).

Module Contents

class workflows.views.ContextCatalogView(**kwargs)[source]

Bases: django.views.View

Return 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.View

Return 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.View

API 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.View

Return 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.View

Return 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.View

Return 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.View

Return 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.

model[source]
template_name = 'workflows/definition_table.html'[source]
context_object_name = 'definitions'[source]
get_context_data(**kwargs)[source]

Add page metadata to context.

Parameters:

kwargs (Any)

Return type:

dict[str, Any]

class workflows.views.WorkflowDefinitionImportView(**kwargs)[source]

Bases: 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).

MAX_ERRORS_TO_SHOW = 6[source]
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

class workflows.views.WizardPrefillView(**kwargs)[source]

Bases: django.views.View

Returns and CLEARS a one-time wizard prefill from the session.

get(request, *_args, **_kwargs)[source]

Return and clear any staged wizard prefill from the session.

Parameters:
  • request (django.http.HttpRequest)

  • _args (Any)

  • _kwargs (Any)

Return type:

django.http.JsonResponse

class workflows.views.WorkflowDefinitionExportView(**kwargs)[source]

Bases: 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”

}

get(_request, pk, *_args, **_kwargs)[source]

Return a JSON file export for the given workflow definition.

Parameters:
  • _request (django.http.HttpRequest)

  • pk (uuid.UUID)

  • _args (Any)

  • _kwargs (Any)

Return type:

django.http.HttpResponse

class workflows.views.WorkflowDefinitionPublishView(**kwargs)[source]

Bases: django.views.View

Toggle published flag via POST (publish/unpublish).

post(request, pk, *_args, **_kwargs)[source]

Publish or pause a workflow definition based on the submitted action.

Parameters:
  • request (django.http.HttpRequest)

  • pk (uuid.UUID)

  • _args (Any)

  • _kwargs (Any)

Return type:

django.http.HttpResponseRedirect

class workflows.views.WorkflowWizardView(**kwargs)[source]

Bases: django.views.View

UI wizard to create or edit a linear workflow.

template_name = 'workflows/definition_wizard.html'[source]
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

class workflows.views.WorkflowDefinitionDeleteView(**kwargs)[source]

Bases: django.views.View

POST-only: deletes the WorkflowDefinition.

post(request, pk, *_args, **_kwargs)[source]

Delete a workflow definition by ID.

Parameters:
  • request (django.http.HttpRequest)

  • pk (uuid.UUID)

  • _args (Any)

  • _kwargs (Any)

Return type:

django.http.HttpResponseRedirect

class workflows.views.WorkflowInstanceDetailView(**kwargs)[source]

Bases: trustpoint.page_context.PageContextMixin, django.views.View

Show detailed info for a pending workflow instance, including step summary.

template_name = 'workflows/instance_detail.html'[source]
get(request, instance_id, *_args, **_kwargs)[source]

Render the detail view for a single workflow instance.

Parameters:
  • request (django.http.HttpRequest)

  • instance_id (uuid.UUID)

  • _args (Any)

  • _kwargs (Any)

Return type:

django.http.HttpResponse

class workflows.views.SignalInstanceView(**kwargs)[source]

Bases: django.views.View

Endpoint to signal (approve/reject) a workflow instance via POST.

post(request, instance_id, *_args, **_kwargs)[source]

Handle approval or rejection of a single workflow instance.

Parameters:
  • request (django.http.HttpRequest)

  • instance_id (uuid.UUID)

  • _args (Any)

  • _kwargs (Any)

Return type:

django.http.HttpResponseRedirect

class workflows.views.EnrollmentRequestListView[source]

Bases: django.views.generic.ListView[workflows.models.EnrollmentRequest]

List EnrollmentRequests (main pending requests page).

model[source]
template_name = 'workflows/enrollment_request_table.html'[source]
context_object_name = 'requests'[source]
paginate_by = 25[source]
get_queryset()[source]

Return EnrollmentRequests annotated with workflow instance counts, filtered.

Return type:

django.db.models.query.QuerySet[workflows.models.EnrollmentRequest]

get_context_data(**kwargs)[source]

Add page metadata and filter to context.

Parameters:

kwargs (Any)

Return type:

dict[str, Any]

class workflows.views.EnrollmentRequestDetailView[source]

Bases: django.views.generic.ListView[workflows.models.WorkflowInstance]

Show WorkflowInstances that belong to a single EnrollmentRequest.

model[source]
template_name = 'workflows/enrollment_request_detail.html'[source]
context_object_name = 'instances'[source]
paginate_by = 50[source]
get_queryset()[source]

Return WorkflowInstances for the requested EnrollmentRequest.

Return type:

django.db.models.query.QuerySet[workflows.models.WorkflowInstance]

get_context_data(**kwargs)[source]

Expose the parent EnrollmentRequest and page metadata.

Parameters:

kwargs (Any)

Return type:

dict[str, Any]

class workflows.views.BulkAbortEnrollmentRequestsView(**kwargs)[source]

Bases: django.views.View

POST 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.View

Approve 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.View

Bulk 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