diff --git a/api_v2/serializers/search.py b/api_v2/serializers/search.py index aaef3745..70486f3f 100644 --- a/api_v2/serializers/search.py +++ b/api_v2/serializers/search.py @@ -71,24 +71,14 @@ def get_document(self, obj): def get_route(self, obj): """Route is a way to build the link to the object.""" + route_lookup = { - "Condition":"conditions", - "Item":"items", - "Creature":"creatures", - "Spell":"spells", "CharacterClass":"classes", - "Monster":"monsters", - "MagicItem":"magicitems", - "Section":"sections", - "Background":"backgrounds", - "Subrace":"subraces", - "Feat":"feats", - "Race":"races", - "Plane":"planes", "CharClass":"classes", - "Environment":"environments" } - - route = f"{obj.schema_version}/{route_lookup[obj.object_model]}/" + if obj.object_model in route_lookup.keys(): + route = f"{obj.schema_version}/{route_lookup[obj.object_model]}/" + else: + route = f"{obj.schema_version}/{obj.object_model.lower()}s/" return route