diff --git a/app/logic/events.py b/app/logic/events.py index 08284719b..ad2931d4e 100644 --- a/app/logic/events.py +++ b/app/logic/events.py @@ -119,8 +119,9 @@ def attemptSaveMultipleOfferings(eventData, attachmentFiles = None): seriesId = calculateNewSeriesId() # Create separate event data for each event in the series, inheriting from the original eventData - - seriesData = sorted(eventData.get('seriesData'), key=lambda x: datetime.strptime(f"{x['eventDate']} {x['startTime']}",'%Y-%m-%d %H:%M')) + print("seriesData received:", eventData.get('seriesData')) + seriesData = sorted(eventData.get('seriesData'), key=lambda x: datetime.strptime(x['eventDate'].split(' ')[0] + ' ' + x['startTime'], '%Y-%m-%d %H:%M')) + # sorts the events in the series by date and time so that the events are created in order and the naming convention of Week 1, Week 2, etc. is consistent with the order of the events. isRepeating = bool(eventData.get('isRepeating')) with mainDB.atomic() as transaction: for index, event in enumerate(seriesData): diff --git a/app/static/js/createEvents.js b/app/static/js/createEvents.js index 8693dc6cc..8e0609633 100644 --- a/app/static/js/createEvents.js +++ b/app/static/js/createEvents.js @@ -405,8 +405,7 @@ function loadOfferingsToModal() { function loadRepeatingOfferingToModal(offering){ var seriesTable = $("#generatedEventsTable"); - var eventDate = new Date(offering.date || offering.eventDate).toLocaleDateString(); - + var eventDate = formatDate(offering.date || offering.eventDate); seriesTable.append( "" + @@ -686,6 +685,9 @@ $("#cancelEvent").on('click', function (event) { if ($(this).is(':checked')) { $("#repeatingEventsNamePicker").val($("#inputEventName").val()); $("#repeatingEventsLocationPicker").val($("#inputEventLocation-main").val()); + $("#repeatingEventsStartDate").val($("#startDatePicker-mainOnly").val()); + $("#repeatingEventsStartTime").val($("#startTime-main").val()); + $("#repeatingEventsEndTime").val($("#endTime-main").val()); $('.addMultipleOfferingEvent').hide(); $("#repeatingEventsDiv").removeClass('d-none'); $("#multipleOfferingSlots").children().remove(); @@ -748,10 +750,14 @@ $("#cancelEvent").on('click', function (event) { /*cloning the div with ID multipleOfferingEvent and cloning, changing the ID of each clone going up by 1. This also changes the ID of the deleteMultipleOffering so that when the trash icon is clicked, that specific row will be deleted*/ $(".addMultipleOfferingEvent").click(function () { - // Get the current value from the main location input + // Get the current value from the main location input and the date input let mainLocation = $("#inputEventLocation-main").val(); - createOfferingModalRow({ eventLocation: mainLocation }); - }); + let existingRows = $("#multipleOfferingSlots .eventOffering").length; + let mainDate = existingRows === 0 ? $("#startDatePicker-mainOnly").val() : null; + let mainTime = $("#startTime-main").val(); + let endTime = $("#endTime-main").val(); + createOfferingModalRow({ eventLocation: mainLocation, eventDate: mainDate, startTime: mainTime, endTime: endTime }); +}); var minDate = new Date('10/25/1999') $("#startDatePicker-main").datepicker("option", "minDate", minDate) @@ -877,9 +883,4 @@ $("#cancelEvent").on('click', function (event) { }); setCharacterLimit($("#inputCharacters"), "#remainingCharacters"); - }); - - - - - + }); \ No newline at end of file diff --git a/tests/code/test_bonner.py b/tests/code/test_bonner.py index bd84806fd..da691c69c 100644 --- a/tests/code/test_bonner.py +++ b/tests/code/test_bonner.py @@ -113,7 +113,7 @@ def test_addBonnerCohortToRsvpLog(): BonnerCohort.create(user="neillz", year=currentYear) BonnerCohort.create(user="khatts", year=currentYear) - testDate = datetime.strptime("2025-01-19 05:00","%Y-%m-%d %H:%M") + testDate = datetime.strptime("01/19/2025 05:00","%m/%d/%Y %H:%M") # Create a test event associated with a Bonner Scholars program programEvent = Program.create(id = 15, diff --git a/tests/code/test_event_list.py b/tests/code/test_event_list.py index 30601b135..fbe955150 100644 --- a/tests/code/test_event_list.py +++ b/tests/code/test_event_list.py @@ -77,7 +77,7 @@ def test_getVolunteerOpportunities(training_events): @pytest.mark.integration def test_getUpcomingVolunteerOpportunitiesCount(): with mainDB.atomic() as transaction: - testDate = datetime.strptime("2021-08-01 05:00","%Y-%m-%d %H:%M") + testDate = datetime.strptime("08/01/2021 05:00","%m/%d/%Y %H:%M") currentTestTerm = Term.get_by_id(5) # In case any events are put in term 5 in testData, put them into the past. diff --git a/tests/code/test_events.py b/tests/code/test_events.py index ed153bfbe..687fed4fe 100644 --- a/tests/code/test_events.py +++ b/tests/code/test_events.py @@ -772,7 +772,7 @@ def test_deleteEvent(): @pytest.mark.integration def test_upcomingEvents(): with mainDB.atomic() as transaction: - testDate = datetime.strptime("2021-08-01 05:00","%Y-%m-%d %H:%M") + testDate = datetime.strptime("08/01/2021 05:00","%m/%d/%Y %H:%M") dayBeforeTestDate = testDate - timedelta(days=1) # Create a user to run the tests with @@ -1329,7 +1329,7 @@ def test_inviteCohortsToEvent(): with app.app_context(): g.current_user = "heggens" - testDate = datetime.strptime("2025-08-01 05:00","%Y-%m-%d %H:%M") + testDate = datetime.strptime("08/01/2025 05:00","%m/%d/%Y %H:%M") programEvent = Program.create(id = 13, programName = "Bonner Scholars", isBonnerScholars = True, @@ -1362,7 +1362,7 @@ def test_updateEventCohorts(): with app.app_context(): g.current_user = "heggens" - testDate = datetime.strptime("2025-10-01 05:00","%Y-%m-%d %H:%M") + testDate = datetime.strptime("10/01/2025 05:00","%m/%d/%Y %H:%M") programEvent = Program.create(id = 13, programName = "Bonner Scholars", isBonnerScholars = True,