use only can_describe=True locations to describe routes

This commit is contained in:
Laura Klünder 2017-11-27 23:38:55 +01:00
parent e5f53aa399
commit 1ac5d554f2
2 changed files with 8 additions and 8 deletions

View file

@ -85,14 +85,14 @@ class Location(LocationSlug, AccessRestrictionMixin, TitledMixin, models.Model):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.titles = self.titles.copy() 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) result = super().serialize(detailed=detailed, **kwargs)
if not detailed: if not detailed:
result = OrderedDict(( if describe_only and not self.can_describe:
(name, result[name]) for name in ('id', 'type', 'slug', 'title', 'subtitle', 'point', 'bounds', fields = ('id', 'on_top_of')
'locations') else:
if name in result 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 return result
def _serialize(self, **kwargs): def _serialize(self, **kwargs):

View file

@ -67,10 +67,10 @@ class RouteItem:
result['waytype'] = self.waytype.serialize(detailed=False) result['waytype'] = self.waytype.serialize(detailed=False)
if not self.last_item or self.space.pk != self.last_item.space.pk: 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: 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 return result