serialization of single groups

This commit is contained in:
Laura Klünder 2017-07-11 18:53:43 +02:00
parent 9b15e06733
commit 8edb845deb

View file

@ -140,7 +140,10 @@ class SpecificLocation(Location, models.Model):
if detailed:
groups = {}
for group in self.groups.all():
groups.setdefault(group.category.name, []).append(group.pk)
groups.setdefault(group.category, []).append(group.pk)
groups = {category.name: (items[0] if items else None) if category.single else items
for category, items in groups.items()
if getattr(category, 'allow_'+self.__class__._meta.default_related_name)}
result['groups'] = groups
return result