From c3aa82b877ae50b73de6fb9cc2771371ca9bfa79 Mon Sep 17 00:00:00 2001 From: Michael Shen Date: Mon, 11 Sep 2023 21:55:00 -0400 Subject: [PATCH] cast GitHub usernames to lowercase Signed-off-by: Michael Shen --- elekto/models/meta.py | 6 +++++- elekto/utils.py | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/elekto/models/meta.py b/elekto/models/meta.py index 9c4a086..498ca3b 100644 --- a/elekto/models/meta.py +++ b/elekto/models/meta.py @@ -109,6 +109,7 @@ def build(self): self.election['key'] = self.key self.election['description'] = self.description() self.election['results'] = self.results() + self.election['election_officers'] = [election_officer.lower() for election_officer in self.election['election_offiers']] if 'exception_due' not in self.election.keys(): self.election['exception_due'] = self.election['start_datetime'] @@ -133,7 +134,9 @@ def results(self): return utils.parse_md(os.path.join(self.path, Election.RES)) def voters(self): - return utils.parse_yaml(os.path.join(self.path, Election.VOT)) + voters = utils.parse_yaml(os.path.join(self.path, Election.VOT)) + voters['eligible_voters'] = [voter.lower() for voter in voters['eligible_voters']] + return voters def showfields(self): return dict.fromkeys(self.election['show_candidate_fields'], '') @@ -148,6 +151,7 @@ def candidates(self): md = open(os.path.join(self.path, f)).read() try: c = utils.extract_candidate_info(md) + c['ID'] = c['ID'].lower() c['key'] = c['ID'] candidates.append(c) except: diff --git a/elekto/utils.py b/elekto/utils.py index cf16ba8..5df1632 100644 --- a/elekto/utils.py +++ b/elekto/utils.py @@ -38,6 +38,7 @@ def set_session(app): # if unable to fetch the user's info, set auth to False if user and user.token_expires_at and user.token_expires_at > datetime.now(): F.g.user = user + F.g.user.username = F.g.user.username.lower() F.g.auth = True # Find all the user's past and all upcoming (meta only) elections query = SESSION.query(Election).join(