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

Remove all occurences of endDate #1362

Draft
wants to merge 1 commit into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion app/controllers/admin/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
})
Expand Down
2 changes: 0 additions & 2 deletions app/logic/emailHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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}",
Expand Down
11 changes: 3 additions & 8 deletions app/logic/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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']:
Expand Down Expand Up @@ -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([])
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions app/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion app/templates/events/createEvent.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ <h1 id="pageTitle">{{page_title}}</h1>
<div class='input-group date endDate' id="endDate-{{pageLocation}}" data-page-location="{{pageLocation}}">
<input autocomplete="off" type='text' class="form-control datePicker endDatePicker"
id='endDatePicker-{{pageLocation}}'
value="{{eventData.endDate.strftime('%Y-%m-%d') if eventData.endDate and eventData.endDate.strftime else eventData.endDate}}"
name="endDate" placeholder="Pick an end date" data-page-location="{{pageLocation}}">
<div class="input-group-text" id="calendarIconEnd-{{pageLocation}}">
<span><i class="bi bi-calendar-plus-fill"></i></span>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/events/eventNav.html
Original file line number Diff line number Diff line change
Expand Up @@ -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") %}

<div class = "{{alertClass}} {{display}} mb-2 pb-2 pt-2" role="alert">
{% if eventPast and event.isCanceled %}
Expand Down
1 change: 0 additions & 1 deletion database/prod-backup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ CREATE TABLE `event` (
`isService` tinyint(1) NOT NULL,
`isAllVolunteerTraining` tinyint(1) NOT NULL,
`startDate` date NOT NULL,
`endDate` date DEFAULT NULL,
`recurringId` int DEFAULT NULL,
`contactEmail` varchar(255) DEFAULT NULL,
`contactName` varchar(255) DEFAULT NULL,
Expand Down
22 changes: 3 additions & 19 deletions database/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Seabury Center",
"startDate": datetime.strptime("2021 10 12","%Y %m %d"),
"endDate": datetime.strptime("2022 6 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 1
Expand All @@ -582,7 +581,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Berea Community School",
"startDate": datetime.strptime("2021 11 12","%Y %m %d"),
"endDate": datetime.strptime("2022 6 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 1
Expand All @@ -598,7 +596,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Alumni Patio",
"startDate": datetime.strptime("2021 12 12","%Y %m %d"),
"endDate": datetime.strptime("2022 6 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 3
Expand All @@ -613,7 +610,6 @@
"timeEnd": datetime.strptime("9:00 am", "%I:%M %p"),
"location": "Stephenson Building",
"startDate": datetime.strptime("2021 6 25","%Y %m %d"),
"endDate": datetime.strptime("2021 6 25","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 2
Expand All @@ -628,7 +624,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Woodspen",
"startDate": datetime.strptime("2021 6 18","%Y %m %d"),
"endDate": datetime.strptime("2022 6 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 2
Expand All @@ -643,7 +638,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Woods-Penniman",
"startDate": datetime.strptime("2021 08 12","%Y %m %d"),
"endDate": datetime.strptime("2021 9 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 3
Expand All @@ -658,7 +652,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Berea Community Park",
"startDate": datetime.strptime("2021 12 12","%Y %m %d"),
"endDate": datetime.strptime("2022 6 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 1
Expand All @@ -673,7 +666,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Stephenson Building",
"startDate": datetime.strptime("2021 12 12","%Y %m %d"),
"endDate": datetime.strptime("2022 6 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 2
Expand All @@ -688,7 +680,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Berea Farm",
"startDate": datetime.strptime("2021 12 12","%Y %m %d"),
"endDate": datetime.strptime("2022 6 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 2
Expand All @@ -704,7 +695,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Stephenson Building",
"startDate": datetime.strptime("2021 1 12","%Y %m %d"),
"endDate": datetime.strptime("2021 6 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 3
Expand All @@ -719,7 +709,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Stephenson Building",
"startDate": datetime.strptime("2021 6 12","%Y %m %d"),
"endDate": datetime.strptime("2021 7 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 9
Expand All @@ -734,7 +723,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Boone Tavern",
"startDate": datetime.strptime("2021 6 12","%Y %m %d"),
"endDate": datetime.strptime("2021 7 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 3
Expand All @@ -749,7 +737,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Berea Community Park",
"startDate": datetime.strptime("2021 6 12","%Y %m %d"),
"endDate": datetime.strptime("2021 7 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 9
Expand All @@ -765,7 +752,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Woods-Penniman",
"startDate": datetime.strptime("2021 6 12","%Y %m %d"),
"endDate": datetime.strptime("2021 7 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 9
Expand All @@ -780,7 +766,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Alumni Building",
"startDate": datetime.strptime("2021 6 12","%Y %m %d"),
"endDate": datetime.strptime("2021 7 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 9
Expand All @@ -796,7 +781,6 @@
"timeEnd": datetime.strptime("9:00 pm", "%I:%M %p"),
"location": "Alumni Building",
"startDate": datetime.strptime("2021 6 12","%Y %m %d"),
"endDate": datetime.strptime("2021 7 12","%Y %m %d"),
"contactEmail": "testEmail",
"contactName": "testName",
"program": 9
Expand Down Expand Up @@ -1350,22 +1334,22 @@
{
#'id': 1,
'subject': 'Test Email',
'body': 'Hello {recipient_name}, This is a test event named {event_name} located in {location}. Other info: {start_date}-{end_date} and this {start_time}-{end_time}.',
'body': 'Hello {recipient_name}, This is a test event named {event_name} located in {location}. Other info: {start_date} and this {start_time}-{end_time}.',
'action': 'sent',
'purpose': 'Test',
'replyToAddress': '[email protected]'
},
{
#'id': 2,
'subject': 'Test Email 2',
'body': 'Hello {recipient_name}, This is another test event named {event_name} located in {location}. Other info: {start_date}-{end_date} and this {start_time}-{end_time}. The link is {event_link}',
'body': 'Hello {recipient_name}, This is another test event named {event_name} located in {location}. Other info: {start_date} and this {start_time}-{end_time}. The link is {event_link}',
'action': 'sent',
'purpose': 'Test2',
'replyToAddress': '[email protected]'
},
{
'subject': 'Event Reminder',
'body': 'Hello! This is a reminder that you have an event coming up tomorrow, {start_date}. The event is {event_name} and it will be taking place at {location} from {start_time}-{end_time}. The link is {event_link}. The event is scheduled to happen {relative_time} from now.',
'body': 'Hello! This is a reminder that you have an event coming up tomorrow, {start_date}. The event is {event_name} and it will be taking place at {location} on {start_time}. The link is {event_link}. The event is scheduled to happen {relative_time} from now.',
'action': 'sent',
'purpose': 'Reminder',
'replyToAddress': '[email protected]'
Expand Down
8 changes: 4 additions & 4 deletions tests/code/test_emailHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

@pytest.mark.integration
def test_replaceStaticPlaceholders():
body = EmailHandler.replaceStaticPlaceholders(1, "location= {location}, start_date= {start_date}, end_date= {end_date}, start_time= {start_time}, end_time= {end_time}")
assert body == "location= Seabury Center, start_date= 10/12/2021, end_date= 06/12/2022, start_time= 06:00, end_time= 09:00"
body = EmailHandler.replaceStaticPlaceholders(1, "location= {location}, start_date= {start_date}, start_time= {start_time}, end_time= {end_time}")
assert body == "location= Seabury Center, start_date= 10/12/2021, start_time= 06:00, end_time= 09:00"

body = EmailHandler.replaceStaticPlaceholders(2, "location= {location}, start_date= {start_date}, end_date= {end_date}, start_time= {start_time}, end_time= {end_time}")
assert body == "location= Berea Community School, start_date= 11/12/2021, end_date= 06/12/2022, start_time= 06:00, end_time= 09:00"
body = EmailHandler.replaceStaticPlaceholders(2, "location= {location}, start_date= {start_date}, start_time= {start_time}, end_time= {end_time}")
assert body == "location= Berea Community School, start_date= 11/12/2021, start_time= 06:00, end_time= 09:00"

@pytest.mark.integration
def test_getSenderInfo():
Expand Down
Loading
Loading