Skip to content

Commit

Permalink
cast GitHub usernames to lowercase
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Shen <[email protected]>
  • Loading branch information
mjlshen committed Sep 12, 2023
1 parent 27f236d commit c3aa82b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion elekto/models/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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'], '')
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions elekto/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c3aa82b

Please sign in to comment.