Fix badge for associations without intern

This commit is contained in:
Kevin Alberts 2018-09-13 14:56:33 +02:00
parent cfe4c07d84
commit faccef7405
Signed by: Kurocon
GPG key ID: BCD496FEBA0C6BC1
2 changed files with 11 additions and 1 deletions

View file

@ -31,6 +31,10 @@ class Association(models.Model):
return self.name
def get_state_display(self):
if not self.has_intern:
return "Geen intern!"
values = dict(list(Association.STATES))
values.update(dict([(x.value, x.name) for x in self.extra_states.all()]))

View file

@ -88,8 +88,14 @@ class AssociationBadgeView(View):
}
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(),
association.get_state_display(),
default_color=AssociationBadgeView.STATE_TO_COLOR.get(association.state, 'yellow'))
default_color=color)
return badge.badge_svg_text