groups_api package

Subpackages

Submodules

groups_api.serializers module

class groups_api.serializers.GroupCreateSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

Serializer used for group creation.

class Meta[source]

Bases: object

fields = ('id', 'name')
model

alias of Group

create(validated_data: dict[str, str]) Group[source]

We have a bit of extra checking around this in order to provide descriptive messages when something goes wrong, but this method is essentially just:

return ExampleModel.objects.create(**validated_data)

If there are many to many fields present on the instance then they cannot be set until the model is instantiated, in which case the implementation is like so:

example_relationship = validated_data.pop(‘example_relationship’) instance = ExampleModel.objects.create(**validated_data) instance.example_relationship = example_relationship return instance

The default implementation also does not handle nested relationships. If you want to support writable nested relationships you’ll need to write an explicit .create() method.

class groups_api.serializers.GroupRetrieveSerializer(*args, **kwargs)[source]

Bases: GroupSerializer

Serializer used for group listing.

class Meta[source]

Bases: object

fields = ('id', 'name', 'users', 'datasets')
model

alias of Group

get_datasets(group: Group) list[dict][source]
to_representation(instance: Group) dict[source]

Object instance -> Dict of primitive datatypes.

class groups_api.serializers.GroupSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

class Meta[source]

Bases: object

fields = ('id', 'name')
model

alias of Group

groups_api.urls module

groups_api.views module

class groups_api.views.GroupsViewSet(**kwargs)[source]

Bases: CreateModelMixin, UpdateModelMixin, ReadOnlyModelViewSet

Groups view set.

authentication_classes = [<class 'utils.authentication.SessionAuthenticationWithoutCSRF'>, <class 'utils.authentication.GPFOAuth2Authentication'>]
basename = None
description = None
detail = None
filter_backends = (<class 'rest_framework.filters.SearchFilter'>,)
get_queryset() QuerySet[source]

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

get_serializer_class() Type[GroupSerializer][source]

Return the class to use for the serializer. Defaults to using self.serializer_class.

You may want to override this if you need to provide different serializations depending on the incoming request.

(Eg. admins get full serialization, others get basic serialization)

lookup_field = 'name'
name = None
permission_classes = (<class 'rest_framework.permissions.IsAdminUser'>,)
search_fields = ('name',)
serializer_class

alias of GroupSerializer

suffix = None

Module contents