Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - cast GitHub usernames to lowercase #99

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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