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

add_clubs improvements #277

Merged
merged 3 commits into from
Sep 28, 2024
Merged
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
10 changes: 5 additions & 5 deletions core/management/commands/add_clubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import csv
from io import StringIO
import re

import requests
from django.core.management.base import BaseCommand
Expand Down Expand Up @@ -87,6 +88,7 @@ def handle(self, *args, **options):
continue

self.success(f"New organization: {row[0]}")
row = [token.strip() for token in row]
(
organization_name,
_,
Expand Down Expand Up @@ -132,10 +134,8 @@ def handle(self, *args, **options):
} # this singular comma gave me a run for my money. i have lost my family, my wealth, my sanity, and my soul from the inclusion of this character.
# fmt: on

slug="".join(
c.casefold() if c.isalnum() else "-"
for c in organization_name
).lower()
# remove all non-alphanumeric or whitespace characters (a-z, A-Z, 0-9, space) and then replace spaces with dashes
slug = re.sub(r"[^a-zA-Z0-9\s]", "", organization_name.strip().casefold()).replace(" ", "-")

if not Organization.objects.filter(slug=slug).exists():
slug = self.get_corrected_slug_or_not(organization_name, slug)
Expand Down Expand Up @@ -166,7 +166,7 @@ def handle(self, *args, **options):

def get_user_by_email(self, name: str, email: str) -> User | Status:
try:
return User.objects.get(email=email)
return User.objects.get(email__iexact=email)
except User.DoesNotExist:
self.error(
f"\t{name}'s email ({email}) not found! Are you sure they registered a metro account with this email?"
Expand Down
Loading