Skip to content

Commit dad83d8

Browse files
committed
Add better boolean check
1 parent 76aac36 commit dad83d8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/roster/views.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def get_context_data(self, **kwargs):
202202
context = super().get_context_data(**kwargs)
203203
context['role'] = self.role
204204
context['isSSO'] = self.request.session.get('sso', False)
205-
context['doMarketingPermission'] = settings.MAILCHIMP_MARKETING_PERMISSION
205+
context['doMarketingPermission'] = strtobool(settings.MAILCHIMP_MARKETING_PERMISSION)
206206
return context
207207

208208
def form_valid(self, form):
@@ -1710,3 +1710,17 @@ def affect_data_for_time_frame(self, time_frame):
17101710

17111711
def configure_event(self, event: Event):
17121712
event.page = 'StudentDetails'
1713+
1714+
def strtobool (val):
1715+
"""Convert a string representation of truth to true (1) or false (0).
1716+
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
1717+
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
1718+
'val' is anything else.
1719+
"""
1720+
val = val.lower()
1721+
if val in ('y', 'yes', 't', 'true', 'on', '1'):
1722+
return 1
1723+
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
1724+
return 0
1725+
else:
1726+
raise ValueError("invalid truth value %r" % (val,))

0 commit comments

Comments
 (0)