There is no form validation preventing a user from creating multiple of the same event using the multiple offerings modal. Currently, when they try, the form submits and returns a warning that the "event already exists" because it is a duplicate event. This is not intended behavior and the user should be warned beforehand.
Fixes issue #1306
Changes
Added form validation which ensures that multiple offerings of events cannot be saved if their name, date, and start times are all the same (at least one must be different)
Highlights similar events in red if you try to save with duplicate events
Refactored previous form validation code for readability
Dev Note: After careful consideration, we determined that we should prevent a user from creating two offerings of an event if they had the same name, date, start time, even when they have different end times. We cannot think of a situation when two events wouldn't be the same even with different end times.
Testing
First, prepare your local development environment and run the application
Preparation:
source setup.sh
database/reset_database.sh test
flask run
Now, you should create an event under any program and click the slider to give the event multiple offerings.
In the modal, do your best to create duplicate events and save the event page. If you cannot create multiple offerings so that when you save the event, you get a warning message saying that the "event already exists", then our PR is working.
Try creating two events that have the same fields but differ once in each of the following areas per test:
All fields same except event name
All fields same except event date
All fields same except start time
Issue Description
There is no form validation preventing a user from creating multiple of the same event using the multiple offerings modal. Currently, when they try, the form submits and returns a warning that the "event already exists" because it is a duplicate event. This is not intended behavior and the user should be warned beforehand.
Fixes issue #1306
Changes
Dev Note: After careful consideration, we determined that we should prevent a user from creating two offerings of an event if they had the same name, date, start time, even when they have different end times. We cannot think of a situation when two events wouldn't be the same even with different end times.
Testing
First, prepare your local development environment and run the application Preparation:
source setup.sh
database/reset_database.sh test
flask run
Now, you should create an event under any program and click the slider to give the event multiple offerings.
In the modal, do your best to create duplicate events and save the event page. If you cannot create multiple offerings so that when you save the event, you get a warning message saying that the "event already exists", then our PR is working. Try creating two events that have the same fields but differ once in each of the following areas per test: All fields same except event name All fields same except event date All fields same except start time
e.x.