MCPcopy Index your code
hub / github.com/PokeAPI/pokeapi / CharacteristicDetailSerializer

Class CharacteristicDetailSerializer

pokemon_v2/serializers.py:463–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461
462
463class CharacteristicDetailSerializer(serializers.ModelSerializer):
464 descriptions = CharacteristicDescriptionSerializer(
465 many=True, read_only=True, source="characteristicdescription"
466 )
467 highest_stat = StatSummarySerializer(source="stat")
468 gene_modulo = serializers.IntegerField(source="gene_mod_5")
469 possible_values = serializers.SerializerMethodField("get_values")
470
471 class Meta:
472 model = Characteristic
473 fields = (
474 "id",
475 "gene_modulo",
476 "possible_values",
477 "highest_stat",
478 "descriptions",
479 )
480
481 @extend_schema_field(
482 field={
483 "type": "array",
484 "items": {
485 "type": "integer",
486 "format": "int32",
487 },
488 "examples": [[0, 5, 10, 15, 20, 25, 30]],
489 }
490 )
491 def get_values(self, obj):
492 mod = obj.gene_mod_5
493 values = []
494 while mod <= 31:
495 values.append(mod)
496 mod += 5
497
498 return values
499
500
501#########################

Callers

nothing calls this directly

Tested by

no test coverage detected