cri_api.serializers.user module

class cri_api.serializers.user.CRIMembershipSerializer(*args, **kwargs)[source]

Bases: rest_framework.serializers.ModelSerializer

class Meta[source]

Bases: object

extra_kwargs = {'url': {'lookup_field': 'id'}}
fields = ('id', 'group', 'begin_at', 'end_at', 'graduation_year', 'is_current')
model

alias of cri_models.models.crigroup.CRIMembership

create(validated_data)[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 cri_api.serializers.user.CRIPhotoKindSerializer(*args, **kwargs)[source]

Bases: rest_framework.serializers.ModelSerializer

class Meta[source]

Bases: object

fields = ['name', 'priority']
model

alias of cri_models.models.criuser.CRIPhotoKind

class cri_api.serializers.user.CRIPhotoSerializer(*args, **kwargs)[source]

Bases: rest_framework.serializers.ModelSerializer

class Meta[source]

Bases: object

fields = ['uuid', 'user', 'kind', 'image', 'image_thumb', 'image_square', 'priority']
model

alias of cri_models.models.criuser.CRIPhoto

create(validated_data)[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 cri_api.serializers.user.CRIUserCreateSerializer(*args, **kwargs)[source]

Bases: rest_framework.serializers.ModelSerializer

class Meta[source]

Bases: object

fields = ('login', 'uid', 'primary_group', 'first_name', 'last_name', 'legal_first_name', 'legal_last_name', 'email', 'phone', 'birthdate', 'memberships', 'kerberos_principals', 'nickname', 'callsign')
model

alias of cri_models.models.criuser.CRIUser

create(validated_data)[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.

validate(attrs)[source]
class cri_api.serializers.user.CRIUserSearchSerializer(*args, **kwargs)[source]

Bases: rest_framework.serializers.Serializer

class cri_api.serializers.user.CRIUserSerializer(*args, **kwargs)[source]

Bases: rest_framework_serializer_field_permissions.serializers.FieldPermissionSerializerMixin, cri_api.serializers.user.ProfileSerializer

class cri_api.serializers.user.NestedCRIMembershipCreateSerializer(*args, **kwargs)[source]

Bases: rest_framework.serializers.ModelSerializer

class Meta[source]

Bases: object

fields = ('group', 'begin_at', 'end_at', 'graduation_year')
model

alias of cri_models.models.crigroup.CRIMembership

class cri_api.serializers.user.NestedKerberosPrincipalSerializer(*args, **kwargs)[source]

Bases: rest_framework.serializers.ModelSerializer

class Meta[source]

Bases: object

fields = ('principal', 'is_primary', 'out_of_date')
model

alias of cri_models.models.criuser.KerberosPrincipal

class cri_api.serializers.user.ProfileSerializer(*args, **kwargs)[source]

Bases: rest_framework.serializers.HyperlinkedModelSerializer

class Meta[source]

Bases: object

extra_kwargs = {'uid': {'required': False}, 'url': {'lookup_field': 'username', 'lookup_url_kwarg': 'login'}}
fields = ('url', 'login', 'uid', 'primary_group', 'first_name', 'last_name', 'legal_first_name', 'legal_last_name', 'email', 'mail_aliases', 'phone', 'birthdate', 'groups_history', 'current_groups', 'old_accounts', 'new_account', 'nickname', 'callsign', 'sshkeys')
model

alias of cri_models.models.criuser.CRIUser

class cri_api.serializers.user.SSHPublicKeySerializer(*args, **kwargs)[source]

Bases: rest_framework_serializer_field_permissions.serializers.FieldPermissionSerializerMixin, cri_api.serializers.base.FieldExclusionSerializerMixin, rest_framework_nested.serializers.NestedHyperlinkedModelSerializer

class Meta[source]

Bases: object

extra_kwargs = {'url': {'lookup_field': 'id'}}
fields = ('id', 'title', 'key', 'key_type', 'key_length')
model

alias of cri_models.models.criuser.SSHPublicKey

create(validated_data)[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.

to_representation(instance)[source]

Object instance -> Dict of primitive datatypes.