From ad18b6e36e780cdcf66591cc6bd8a3574f85f8b4 Mon Sep 17 00:00:00 2001 From: bledsoef Date: Fri, 22 Nov 2024 19:49:28 -0500 Subject: [PATCH 1/3] just about removed all occurences of endDate --- app/controllers/admin/routes.py | 1 - app/logic/emailHandler.py | 2 -- app/logic/events.py | 11 ++----- app/models/event.py | 3 +- app/templates/events/createEvent.html | 1 - app/templates/events/eventNav.html | 4 +-- database/prod-backup.sql | 1 - database/test_data.py | 22 ++------------ tests/code/test_emailHandler.py | 8 ++--- tests/code/test_event_list.py | 15 ++-------- tests/code/test_events.py | 43 ++++----------------------- tests/code/test_minor.py | 2 -- tests/code/test_participants.py | 3 -- tests/code/test_scripts.py | 2 -- tests/code/test_transcripts.py | 4 --- tests/code/test_users.py | 1 - 16 files changed, 21 insertions(+), 102 deletions(-) diff --git a/app/controllers/admin/routes.py b/app/controllers/admin/routes.py index a7d52183f..00feacaf6 100644 --- a/app/controllers/admin/routes.py +++ b/app/controllers/admin/routes.py @@ -226,7 +226,6 @@ def renewEvent(eventId): 'timeEnd': formData['timeEnd'], 'location': formData['location'], 'startDate': f'{formData["startDate"][-4:]}-{formData["startDate"][0:-5]}', - 'endDate': f'{formData["endDate"][-4:]}-{formData["endDate"][0:-5]}', 'isRecurring': bool(priorEvent['recurringId']), 'isMultipleOffering': bool(priorEvent['multipleOfferingId']), }) diff --git a/app/logic/emailHandler.py b/app/logic/emailHandler.py index 7a6ffedb4..093685b82 100644 --- a/app/logic/emailHandler.py +++ b/app/logic/emailHandler.py @@ -258,7 +258,6 @@ def retrievePlaceholderList(eventId): ["Recipient Name", "{recipient_name}"], ["Event Name", event.name], ["Start Date", (event.startDate).strftime('%m/%d/%Y')], - ["End Date", (event.endDate).strftime('%m/%d/%Y')], ["Start Time", (event.timeStart).strftime('%I:%M')], ["End Time", (event.timeEnd).strftime('%I:%M')], ["Location", event.location], @@ -274,7 +273,6 @@ def replaceStaticPlaceholders(eventId, email_body): new_body = email_body.format(event_name=event.name, location=event.location, start_date=(event.startDate).strftime('%m/%d/%Y'), - end_date=(event.endDate).strftime('%m/%d/%Y'), start_time=(event.timeStart).strftime('%I:%M'), end_time=(event.timeEnd).strftime('%I:%M'), event_link="{event_link}", diff --git a/app/logic/events.py b/app/logic/events.py index 8e0ad643c..03d543802 100644 --- a/app/logic/events.py +++ b/app/logic/events.py @@ -222,7 +222,6 @@ def saveEventToDb(newEventData, renewedEvent = False): "isService": newEventData['isService'], "startDate": eventInstance['date'], "rsvpLimit": newEventData['rsvpLimit'], - "endDate": eventInstance['date'], "contactEmail": newEventData['contactEmail'], "contactName": newEventData['contactName'] } @@ -269,7 +268,7 @@ def getUpcomingStudentLedCount(term, currentTime): .join(Event, on=(Program.id == Event.program_id)) .where(Program.isStudentLed, Event.term == term, Event.deletionDate == None, - (Event.endDate > currentTime) | ((Event.endDate == currentTime) & (Event.timeEnd >= currentTime)), + (Event.startDate > currentTime) | ((Event.startDate == currentTime) & (Event.timeEnd >= currentTime)), Event.isCanceled == False) .group_by(Program.id)) @@ -413,7 +412,7 @@ def validateNewEventData(data): if 'on' in [data['isFoodProvided'], data['isRsvpRequired'], data['isTraining'], data['isEngagement'], data['isService'], data['isRecurring'], data['isMultipleOffering']]: return (False, "Raw form data passed to validate method. Preprocess first.") - if data['isRecurring'] and data['endDate'] < data['startDate']: + if data['isRecurring'] and data['endDate'] < data['startDate']: return (False, "Event start date is after event end date.") if data['timeEnd'] <= data['timeStart']: @@ -532,10 +531,6 @@ def preprocessEventData(eventData): elif not isinstance(eventData[eventDate], date): # The date is not a date object eventData[eventDate] = '' - # If we aren't recurring, all of our events are single-day or mutliple offerings, which also have the same start and end date - if not eventData['isRecurring']: - eventData['endDate'] = eventData['startDate'] - # Process multipleOfferingData if 'multipleOfferingData' not in eventData: eventData['multipleOfferingData'] = json.dumps([]) @@ -641,7 +636,7 @@ def getCountdownToEvent(event, *, currentDatetime=None): currentMorning = currentDatetime.replace(hour=0, minute=0) eventStart = datetime.combine(event.startDate, event.timeStart) - eventEnd = datetime.combine(event.endDate, event.timeEnd) + eventEnd = datetime.combine(event.startDate, event.timeEnd) if eventEnd < currentDatetime: return "Already passed" diff --git a/app/models/event.py b/app/models/event.py index b17716d05..0da7b0cf1 100644 --- a/app/models/event.py +++ b/app/models/event.py @@ -18,7 +18,6 @@ class Event(baseModel): isAllVolunteerTraining = BooleanField(default=False) rsvpLimit = IntegerField(null=True) startDate = DateField() - endDate = DateField(null=True) recurringId = IntegerField(null=True) multipleOfferingId = IntegerField(null=True) contactEmail = CharField(null=True) @@ -47,7 +46,7 @@ def isPastStart(self): @property def isPastEnd(self): - return datetime.now() >= datetime.combine(self.endDate, self.timeEnd) + return datetime.now() >= datetime.combine(self.startDate, self.timeEnd) @property def isRecurring(self): diff --git a/app/templates/events/createEvent.html b/app/templates/events/createEvent.html index 1acb1be90..f3ae10dce 100644 --- a/app/templates/events/createEvent.html +++ b/app/templates/events/createEvent.html @@ -85,7 +85,6 @@

{{page_title}}

diff --git a/app/templates/events/eventNav.html b/app/templates/events/eventNav.html index cf47c1ff3..d77420e68 100644 --- a/app/templates/events/eventNav.html +++ b/app/templates/events/eventNav.html @@ -21,9 +21,9 @@ {% set isInProg = not event.isPastEnd and event.isPastStart %} {% set display = "" if eventPast or event.isCanceled or isInProg else "d-none"%} {% set alertClass = ("alert-success" if isInProg else ( "alert-danger" if eventPast else "alert-warning")) %} - {% set event_year = event.endDate.strftime("%Y") | int %} + {% set event_year = event.startDate.strftime("%Y") | int %} {% set currentYear = g.currentDateTime.year | int %} - {% set formatted_date = event.endDate.strftime("%B %d %Y") if currentYear > event_year else event.endDate.strftime("%B %d") %} + {% set formatted_date = event.startDate.strftime("%B %d %Y") if currentYear > event_year else event.startDate.strftime("%B %d") %}