Skip to content

Commit

Permalink
Merge pull request #273 from pinwheeeel/develop
Browse files Browse the repository at this point in the history
Semi-automatic implemenation of #250
  • Loading branch information
pinwheeeel authored Sep 4, 2024
2 parents a76986a + c2bfb4e commit 479d255
Show file tree
Hide file tree
Showing 5 changed files with 464 additions and 6 deletions.
16 changes: 11 additions & 5 deletions core/management/commands/add_clubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def add_arguments(self, parser):
parser.add_argument(
"sheets_link",
type=str,
help="Link to Google Sheets (must be published as CSV)",
help= "Link to Google Sheets (must be published as CSV). " \
"Follow this guide (https://support.google.com/docs/answer/183965) to publish the spreadsheet, " \
"set the dropbox to 'Comma-separated-values (.csv)' and copy the link underneath (https://web.archive.org/web/20240902165418/https://cdn.discordapp.com/attachments/1280208592712241285/1280209073949638717/publish_to_web.png?ex=66d73f1c&is=66d5ed9c&hm=616b70187f8f3a54885b050e5f80c606d275318382333e5819364e020ba421bb&)",
)

def handle(self, *args, **options):
Expand All @@ -29,7 +31,7 @@ def handle(self, *args, **options):
if not ("output=csv" in sheets_url or sheets_url.endswith(".csv")):
print(sheets_url.endswith("?output=csv"))
raise AssertionError(
"Make sure make a copy of the club spreadsheet and use the link provided when publishing as CSV (https://support.google.com/docs/answer/183965)"
"Make sure to make a copy of the club spreadsheet and use the link provided when publishing as .csv file (https://support.google.com/docs/answer/183965)"
)

csv_reader = csv.reader(StringIO(requests.get(sheets_url).text))
Expand All @@ -54,10 +56,12 @@ def handle(self, *args, **options):
for row in csv_reader:
organization_is_not_approved = row[1] != "TRUE"
has_duplicate_owner = len(row[0]) == 0

if organization_is_not_approved or has_duplicate_owner:
self.stdout.write(
self.style.ERROR(
f"Skipping {row[0]} because it is not approved or has a duplicate owner"
f"Skipping row in spreadsheet because the club has multiple owners\n" if has_duplicate_owner else \
f"Skipping {row[0]} because it is not approved\n"
)
)
continue
Expand Down Expand Up @@ -88,7 +92,7 @@ def handle(self, *args, **options):

skip_entry = False
self.stdout.write(
"\tIf you have the correct email, please enter it here:"
"\tIf you have the correct email, please enter it here (type 'skip' to skip this entry):"
)
while True:
try:
Expand All @@ -109,7 +113,9 @@ def handle(self, *args, **options):
self.stdout.write("\tPlease re-enter email:")

if skip_entry:
self.stdout.write(f"\tSkipped creation of {organization_name}")
self.stdout.write(
self.style.SUCCESS(f"\tSkipped creation of {organization_name}\n")
)
continue
self.stdout.write(
self.style.SUCCESS(f"\tFound a match for {owner_name}'s email")
Expand Down
Loading

0 comments on commit 479d255

Please sign in to comment.