render colors in right order
This commit is contained in:
parent
0afdc0793d
commit
27287b8a00
3 changed files with 11 additions and 4 deletions
|
@ -125,12 +125,17 @@ class Location(LocationSlug, AccessRestrictionMixin, TitledMixin, models.Model):
|
|||
return None
|
||||
|
||||
def get_color(self, instance=None):
|
||||
# dont filter in the query here so prefetch_related works
|
||||
result = self.get_color_sorted(instance)
|
||||
return None if result is None else result[1]
|
||||
|
||||
def get_color_sorted(self, instance=None):
|
||||
# dont filter in the query here so prefetch_related works
|
||||
if instance is None:
|
||||
instance = self
|
||||
for group in instance.groups.all():
|
||||
if group.color and getattr(group.category, 'allow_'+self.__class__._meta.default_related_name):
|
||||
return group.color
|
||||
return (0, group.category.priority, group.priority), group.color
|
||||
return None
|
||||
|
||||
def get_icon(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue