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_validationto add pre-delete business rules. - Override
get_warnings_for_object(fromWarningConfirmationMixin) to gate single and bulkdestroy(andactivate/deactivatewhenDeactivateActionViewSetMixinis mixed in) behind a 409 confirmation with the same rule for both; overrideget_warningsinstead 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}
| Name | Type | Required | Description |
|---|---|---|---|
| cls | yes | ||
| kwargs | yes |
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
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| queryset | yes |
Source
server/vueda/core/viewsets/__init__.py:951
destroy
Delete one or more objects.
Signature
destroy(self, request, kwargs)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| request | yes | ||
| kwargs | yes |
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
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| objs | yes |
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
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| request | yes | ||
| instance | yes |
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
| Name | Type | Required | Description |
|---|---|---|---|
| cls | yes |
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
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes |
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
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes |
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
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| request | yes | ||
| pk | yes |
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
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| request | yes | ||
| args | yes | ||
| kwargs | yes |
Source
server/vueda/core/viewsets/__init__.py:892
detail_args
Source
server/vueda/core/viewsets/__init__.py:869