Fix badge for associations without intern
This commit is contained in:
parent
cfe4c07d84
commit
faccef7405
|
@ -31,6 +31,10 @@ class Association(models.Model):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def get_state_display(self):
|
def get_state_display(self):
|
||||||
|
|
||||||
|
if not self.has_intern:
|
||||||
|
return "Geen intern!"
|
||||||
|
|
||||||
values = dict(list(Association.STATES))
|
values = dict(list(Association.STATES))
|
||||||
values.update(dict([(x.value, x.name) for x in self.extra_states.all()]))
|
values.update(dict([(x.value, x.name) for x in self.extra_states.all()]))
|
||||||
|
|
||||||
|
|
|
@ -88,8 +88,14 @@ class AssociationBadgeView(View):
|
||||||
}
|
}
|
||||||
|
|
||||||
def generate_badge(self, association):
|
def generate_badge(self, association):
|
||||||
|
|
||||||
|
color = AssociationBadgeView.STATE_TO_COLOR.get(association.state, 'yellow')
|
||||||
|
|
||||||
|
if not association.has_intern:
|
||||||
|
color = 'lightgrey'
|
||||||
|
|
||||||
badge = anybadge.Badge(lxml.html.fromstring(association.short_name).text_content(),
|
badge = anybadge.Badge(lxml.html.fromstring(association.short_name).text_content(),
|
||||||
association.get_state_display(),
|
association.get_state_display(),
|
||||||
default_color=AssociationBadgeView.STATE_TO_COLOR.get(association.state, 'yellow'))
|
default_color=color)
|
||||||
|
|
||||||
return badge.badge_svg_text
|
return badge.badge_svg_text
|
||||||
|
|
Loading…
Reference in a new issue