Skip to content

Commit

Permalink
Merge pull request #278 from pinwheeeel/develop
Browse files Browse the repository at this point in the history
add_clubs improvements
  • Loading branch information
pinwheeeel authored Sep 29, 2024
2 parents 3168203 + 3c88619 commit 2d70f7c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/management/commands/add_clubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def handle(self, *args, **options):
expected_header == next(csv_reader)
), "Google Sheets layout changed since the last time the script was updated, please consult the backend team."

skipped_orgs = []
for row in csv_reader:
organization_is_not_approved = row[1] != "TRUE"
has_duplicate_owner = len(row[0]) == 0
Expand All @@ -87,7 +88,7 @@ def handle(self, *args, **options):
self.error(f"Skipping {row[0]} because it is not approved\n")
continue

self.success(f"New organization: {row[0]}")
self.success(f"\nNew organization: {row[0]}")
row = [token.strip() for token in row]
(
organization_name,
Expand All @@ -104,6 +105,7 @@ def handle(self, *args, **options):

club_owner = self.get_user_by_email(owner_name, owner_email)
if club_owner == "skipped": # prevent a repeat of the same error message
skipped_orgs.append(organization_name)
continue

supervisor_user = self.get_user_by_email(staff_name, staff_email)
Expand All @@ -119,6 +121,7 @@ def handle(self, *args, **options):
self.error(
f"Skipping {organization_name} as {user_statuses} is not found\n"
)
skipped_orgs.append(organization_name)
continue

try:
Expand Down Expand Up @@ -161,6 +164,11 @@ def handle(self, *args, **options):
except IntegrityError as IE:
self.error(IE.__traceback__)
self.stdout.write()

self.warn(
f"Skipped {len(skipped_orgs)} organizations: \n\t{'\n\t'.join(skipped_orgs)}"
)
self.success("Done!")

type Status = "skipped" # noqa: F821

Expand Down

0 comments on commit 2d70f7c

Please sign in to comment.