Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
16 changes: 16 additions & 0 deletions hknweb/events/migrations/0013_alter_icalview_options.py
Comment thread
PBales1 marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.2.5 on 2023-11-29 07:09

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("events", "0012_icalview"),
]

operations = [
migrations.AlterModelOptions(
name="icalview",
options={"verbose_name": "iCal view"},
),
]
30 changes: 13 additions & 17 deletions hknweb/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,30 +236,26 @@ def generate_password() -> str:

return password

email_information = []
# Process user data into useable structs
user_data = []
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"] in existing_usernames:
continue

# Generate a password
password = generate_password()

# Construct user object
user = User.objects.create_user(
user_data.append(User(
username=row["username"],
first_name=row["First name"],
last_name=row["Last name"],
email=row["Berkeley email"],
password=password,
)
user.save()

# Add user to the candidates group
password=generate_password(),
Comment thread
oliver-ni marked this conversation as resolved.
Outdated
))

users = User.objects.bulk_create(user_data) # Bulk process accounts into database

# Save each user, add to candidate group set, and add information for emails
email_information = []
for user in users:
group.user_set.add(user)
Comment thread
PBales1 marked this conversation as resolved.
Outdated

# Add information for sending emails
email_information.append((user, password))
email_information.append((user, user.password))
Comment thread
PBales1 marked this conversation as resolved.
Outdated

self.email_information = email_information

Expand Down