add cell property to location serialization

This commit is contained in:
Laura Klünder 2018-12-10 19:24:19 +01:00
parent 0ef08ad61b
commit 1528e66758

View file

@ -85,7 +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:
fields = ('id', 'type', 'slug', 'title', 'subtitle', 'point', 'bounds', 'locations', 'on_top_of')
fields = ('id', 'type', 'slug', 'title', 'subtitle', 'point', 'bounds', 'locations', 'cell', 'on_top_of')
result = OrderedDict(((name, result[name]) for name in fields if name in result))
return result
@ -137,6 +137,9 @@ class SpecificLocation(Location, models.Model):
def _serialize(self, detailed=True, **kwargs):
result = super()._serialize(detailed=detailed, **kwargs)
grid_cell = self.grid_cell
if grid_cell is not None:
result['cell'] = grid_cell or None
if detailed:
groups = {}
for group in self.groups.all():