Skip to content

VuedaViewSet

Overview

Full CRUD ViewSet for VUEDA models. Extends DRF's ModelViewSet with:

  • Flex-fields expansion (FlexFieldsMixin)
  • Query-parameter validation against filter and serializer fields (NoExtraFieldsForViewSetMixin)
  • Row-level and workflow-aware list filtering (ListRowLevelViewSetMixin)
  • Bulk delete with dry-run support
  • Override destroy_validation to add pre-delete business rules.
  • Override get_warnings_for_object (from WarningConfirmationMixin) to gate single and bulk destroy (and activate/deactivate when DeactivateActionViewSetMixin is mixed in) behind a 409 confirmation with the same rule for both; override get_warnings instead if bulk needs its own logic.

init_subclass {#init_subclass}

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

Signature {#init_subclass-signature}

__init_subclass__(cls, kwargs)

Parameters {#init_subclass-parameters}

NameTypeRequiredDescription
clsyes
kwargsyes

Source {#init_subclass-source}

server/vueda/core/viewsets/__init__.py:934

apply_object_permission_filter

Keep only objects the current request can access at object-permission level.

Signature

apply_object_permission_filter(self, queryset)

Parameters

NameTypeRequiredDescription
selfyes
querysetyes

Source

server/vueda/core/viewsets/__init__.py:951

destroy

Delete one or more objects.

Signature

destroy(self, request, kwargs)

Parameters

NameTypeRequiredDescription
selfyes
requestyes
kwargsyes

Source

server/vueda/core/viewsets/__init__.py:964

destroy_validation

Override to validate objects before deletion. Raise VuedaValidationError to prevent deletion. Called for both single-object and bulk-delete requests.

Signature

destroy_validation(self, objs)

Parameters

NameTypeRequiredDescription
selfyes
objsyes

Source

server/vueda/core/viewsets/__init__.py:944

get_allowed_extra_actions

Override this function to change if a user is allowed to do a certain action.

Signature

get_allowed_extra_actions(self, request, instance)

Parameters

NameTypeRequiredDescription
selfyes
requestyes
instanceyes

Source

server/vueda/core/viewsets/__init__.py:1001

get_extra_actions

Drop the history endpoint for a model that records no history.

Every consumer of the extra actions reads this: the router that builds the routes, the permitted-action list the client renders, and the model-info metadata. Gating here means an opted-out model has no history route, no control, and no schema entry, rather than a route that answers with an error.

Signature

get_extra_actions(cls)

Parameters

NameTypeRequiredDescription
clsyes

Source

server/vueda/core/viewsets/__init__.py:901

get_object

Override this function to convert the pk kwarg to a list if the model has a composite primary key.

Signature

get_object(self)

Parameters

NameTypeRequiredDescription
selfyes

Source

server/vueda/core/viewsets/__init__.py:1011

get_queryset

Annotate formatted_name and, for list/retrieve, apply the select_related/ prefetch_related plan :func:build_prefetch_plan derives from what the request's ?e= actually expanded, so an expanded response's query count does not grow with the number of rows returned. See :func:build_prefetch_plan for why ?f=/?om= play no part in this.

A plan entry whose lookup this queryset already prefetches (typically a relation the viewset's own queryset/get_queryset() hand-optimized before this plan existed) is dropped rather than applied a second time; see :func:filter_new_prefetch_lookups for why that matters for prefetch_related specifically.

Signature

get_queryset(self)

Parameters

NameTypeRequiredDescription
selfyes

Source

server/vueda/core/viewsets/__init__.py:1030

history_list

Return this object's history as the user actions behind it.

A page is a page of actions. One action that wrote several rows stays whole, because the grouping and the visibility filter both run in the database before the paginator sees anything.

Signature

history_list(self, request, pk)

Parameters

NameTypeRequiredDescription
selfyes
requestyes
pkyes

Source

server/vueda/core/viewsets/__init__.py:918

initial

Runs anything that needs to occur prior to calling the method handler.

Signature

initial(self, request, args, kwargs)

Parameters

NameTypeRequiredDescription
selfyes
requestyes
argsyes
kwargsyes

Source

server/vueda/core/viewsets/__init__.py:892

detail_args

Source

server/vueda/core/viewsets/__init__.py:869

Documents matching: server v3.0.0a1.post1client v3.0.0-alpha.2