Skip to content
Open
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
15 changes: 14 additions & 1 deletion hknweb/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,19 @@ def email_to_username(email: str) -> str:
"username", flat=True
)
)

# Get existing emails
emails = []
for row in rows:
email = row["Berkeley email"]
if email:
emails.append(email)

existing_emails = set(
User.objects.filter(email__in=emails).values_list(
"email", flat=True
)
)

# Setup account provisioning utils
# Get candidate group to add users to
Expand All @@ -241,7 +254,7 @@ def generate_password() -> str:
email_information = []
for row in rows:
# If username is None or already exists, skip provisioning
if (row["username"] is None) or (row["username"] in existing_usernames):
if (row["username"] is None) or (row["username"].lower() in existing_usernames) or (row["Berkeley email"] in existing_emails):
continue

# Generate a password
Expand Down