use only can_describe=True locations to describe routes
This commit is contained in:
parent
e5f53aa399
commit
1ac5d554f2
2 changed files with 8 additions and 8 deletions
|
@ -85,14 +85,14 @@ class Location(LocationSlug, AccessRestrictionMixin, TitledMixin, models.Model):
|
|||
super().__init__(*args, **kwargs)
|
||||
self.titles = self.titles.copy()
|
||||
|
||||
def serialize(self, detailed=True, **kwargs):
|
||||
def serialize(self, detailed=True, describe_only=False, **kwargs):
|
||||
result = super().serialize(detailed=detailed, **kwargs)
|
||||
if not detailed:
|
||||
result = OrderedDict((
|
||||
(name, result[name]) for name in ('id', 'type', 'slug', 'title', 'subtitle', 'point', 'bounds',
|
||||
'locations')
|
||||
if name in result
|
||||
))
|
||||
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')
|
||||
result = OrderedDict(((name, result[name]) for name in fields if name in result))
|
||||
return result
|
||||
|
||||
def _serialize(self, **kwargs):
|
||||
|
|
|
@ -67,10 +67,10 @@ class RouteItem:
|
|||
result['waytype'] = self.waytype.serialize(detailed=False)
|
||||
|
||||
if not self.last_item or self.space.pk != self.last_item.space.pk:
|
||||
result['space'] = self.space.serialize(detailed=False)
|
||||
result['space'] = self.space.serialize(detailed=False, describe_only=True)
|
||||
|
||||
if not self.last_item or self.level.pk != self.last_item.level.pk:
|
||||
result['level'] = self.level.serialize(detailed=False)
|
||||
result['level'] = self.level.serialize(detailed=False, describe_only=True)
|
||||
return result
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue