get_color() only allow groups that are allowed for this model

This commit is contained in:
Laura Klünder 2017-07-11 19:02:33 +02:00
parent 268fb2f683
commit 2fa482d9fd

View file

@ -124,7 +124,7 @@ class Location(LocationSlug, TitledMixin, models.Model):
if instance is None:
instance = self
for group in instance.groups.all():
if group.color:
if group.color and getattr(group.category, 'allow_'+self.__class__._meta.default_related_name):
return group.color
return None