mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-22 19:33:10 +00:00
clean up
This commit is contained in:
parent
aa1d7d9939
commit
43f97fd466
1 changed files with 27 additions and 5 deletions
|
@ -1225,19 +1225,41 @@ class BerryDetailSerializer(serializers.ModelSerializer):
|
||||||
flavor_objects = BerryFlavor.objects.filter(berry=obj)
|
flavor_objects = BerryFlavor.objects.filter(berry=obj)
|
||||||
|
|
||||||
flavors = OrderedDict()
|
flavors = OrderedDict()
|
||||||
|
flavors['spicy'] = OrderedDict()
|
||||||
|
flavors['dry'] = OrderedDict()
|
||||||
|
flavors['sweet'] = OrderedDict()
|
||||||
|
flavors['bitter'] = OrderedDict()
|
||||||
|
flavors['sour'] = OrderedDict()
|
||||||
|
|
||||||
for flavor_obj in flavor_objects:
|
for flavor_obj in flavor_objects:
|
||||||
|
|
||||||
contest_type_obj = ContestType.objects.get(pk=flavor_obj.contest_type.id)
|
contest_type_obj = ContestType.objects.get(pk=flavor_obj.contest_type.id)
|
||||||
contest_type = ContestTypeDetailSerializer(contest_type_obj, context=self.context).data
|
contest_type = ContestTypeDetailSerializer(contest_type_obj, context=self.context).data
|
||||||
flavor = BerryFlavorSerializer(flavor_obj, context=self.context).data
|
flavor = BerryFlavorSerializer(flavor_obj, context=self.context).data
|
||||||
|
name = contest_type['name']
|
||||||
|
|
||||||
for contest_type_name in contest_type['names']:
|
if name == 'cool':
|
||||||
if contest_type_name['language']['name'] == 'en':
|
flavors['spicy']['strength'] = flavor['flavor']
|
||||||
|
flavors['spicy']['contest_type'] = flavor['contest_type']
|
||||||
|
elif name == 'beauty':
|
||||||
|
flavors['dry']['strength'] = flavor['flavor']
|
||||||
|
flavors['dry']['contest_type'] = flavor['contest_type']
|
||||||
|
elif name == 'cute':
|
||||||
|
flavors['sweet']['strength'] = flavor['flavor']
|
||||||
|
flavors['sweet']['contest_type'] = flavor['contest_type']
|
||||||
|
elif name == 'smart':
|
||||||
|
flavors['bitter']['strength'] = flavor['flavor']
|
||||||
|
flavors['bitter']['contest_type'] = flavor['contest_type']
|
||||||
|
elif name == 'tough':
|
||||||
|
flavors['sour']['strength'] = flavor['flavor']
|
||||||
|
flavors['sour']['contest_type'] = flavor['contest_type']
|
||||||
|
|
||||||
dict = flavors[contest_type['names'][0]['flavor'].lower()] = OrderedDict()
|
# for contest_type_name in contest_type['names']:
|
||||||
dict['strength'] = flavor['flavor']
|
# if contest_type_name['language']['name'] == 'en':
|
||||||
dict['contest_type'] = flavor['contest_type']
|
|
||||||
|
# dict = flavors[contest_type['names'][0]['flavor'].lower()] = OrderedDict()
|
||||||
|
# dict['strength'] = flavor['flavor']
|
||||||
|
# dict['contest_type'] = flavor['contest_type']
|
||||||
|
|
||||||
return flavors
|
return flavors
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue