simpler describe_location

This commit is contained in:
Laura Klünder 2017-12-18 01:57:36 +01:00
parent 032dcebcd0
commit ee83d56a5c
2 changed files with 2 additions and 7 deletions

View file

@ -85,10 +85,7 @@ class Location(LocationSlug, AccessRestrictionMixin, TitledMixin, models.Model):
def serialize(self, detailed=True, describe_only=False, **kwargs):
result = super().serialize(detailed=detailed, **kwargs)
if not detailed:
if describe_only and not self.can_describe:
fields = ('id', 'on_top_of')
else:
fields = ('id', 'type', 'slug', 'title', 'subtitle', 'point', 'bounds', 'locations', 'on_top_of')
fields = ('id', 'type', 'slug', 'title', 'subtitle', 'point', 'bounds', 'locations', 'on_top_of')
result = OrderedDict(((name, result[name]) for name in fields if name in result))
return result

View file

@ -12,9 +12,7 @@ def describe_location(location, locations):
final_location = locations.get(location.pk)
if final_location is not None:
location = final_location
else:
location.can_describe = False
return location.serialize(include_type=True, detailed=False, describe_only=True, simple_geometry=True)
return location.serialize(include_type=True, detailed=False, simple_geometry=True)
class Route: