Foreign app serializers

Foreign app serializers.

class WordSerializer(*args, **kwargs)

Bases: ModelSerializer

Word serializer.

class Meta

Bases: object

Serializer settings.

model

alias of Word

fields = ['id', 'foreign_word', 'native_word']

Fields (list[str]).

class ExerciseParamSerializer(*args, **kwargs)

Bases: ModelSerializer

Parameters of translate foreign word exercise the serializer.

class Meta

Bases: object

Serializer settings.

model

alias of TranslateParams

exclude = ['id', 'user']

Exclude fields (list[str]).

class ExerciseChoiceSerializer(*args, **kwargs)

Bases: ModelSerializer

Choice of translate foreign word params serializer.

class Meta

Bases: object

Serializer settings.

model

alias of TranslateParams

exclude = ['id', 'user']

Exclude fields (list[str]).

create(validated_data: dict) TranslateParams

Update or create the user glossary exercise parameters.

to_internal_value(data: Mapping) Mapping

Add user ID.

to_representation(instance: object) object

Update the representation data.

Creates exercise_params to response.

class ExerciseSerializer(*args, **kwargs)

Bases: Serializer

Foreign exercise serializer.

class WordCategorySerializer(*args, **kwargs)

Bases: ModelSerializer

Foreign word Category serializer.

alias

Field alias of pk (int).

humanly

Field alias of name (str).

class Meta

Bases: object

Serializer settings.

model

alias of WordCategory

fields = ['alias', 'humanly']

Fields (list[str]).

classmethod get_alias(obj: Model) int

Add alias as name of pk field.

class WordAssessmentSerializer(*args, **kwargs)

Bases: Serializer

Word knowledge assessment serializer.

item_id

Word ID (int).

action

Assessment action (str).

classmethod validate_item_id(value: int) int

Validate the item ID field.

Parameters:

value (int) – word ID.

Return int value:

word ID.

Return type:

int

Raises:

ValidationError – if word by ID not exists().

classmethod validate_action(value: str) str

Validate the action field.

Parameters:

value (str) – the action alias.

Return str value:

the action alias.

Return type:

str

Raises:

ValidationError – if not correct action alias.

validate(attrs: dict) dict

Check the ownership of the word being assessed.

Params dict attrs:

a dictionary of field values.

Return attrs:

a dictionary of field values.

Return type:

dict

Raises:

ValidationError – if user has not the ownership on the word being assessed.