simpler describe_location
This commit is contained in:
parent
032dcebcd0
commit
ee83d56a5c
2 changed files with 2 additions and 7 deletions
|
@ -85,10 +85,7 @@ class Location(LocationSlug, AccessRestrictionMixin, TitledMixin, models.Model):
|
||||||
def serialize(self, detailed=True, describe_only=False, **kwargs):
|
def serialize(self, detailed=True, describe_only=False, **kwargs):
|
||||||
result = super().serialize(detailed=detailed, **kwargs)
|
result = super().serialize(detailed=detailed, **kwargs)
|
||||||
if not detailed:
|
if not detailed:
|
||||||
if describe_only and not self.can_describe:
|
fields = ('id', 'type', 'slug', 'title', 'subtitle', 'point', 'bounds', 'locations', 'on_top_of')
|
||||||
fields = ('id', 'on_top_of')
|
|
||||||
else:
|
|
||||||
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))
|
result = OrderedDict(((name, result[name]) for name in fields if name in result))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,7 @@ def describe_location(location, locations):
|
||||||
final_location = locations.get(location.pk)
|
final_location = locations.get(location.pk)
|
||||||
if final_location is not None:
|
if final_location is not None:
|
||||||
location = final_location
|
location = final_location
|
||||||
else:
|
return location.serialize(include_type=True, detailed=False, simple_geometry=True)
|
||||||
location.can_describe = False
|
|
||||||
return location.serialize(include_type=True, detailed=False, describe_only=True, simple_geometry=True)
|
|
||||||
|
|
||||||
|
|
||||||
class Route:
|
class Route:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue