You shouldn't be able to delete a program that has one or more events, or events with one or more participants.
Description
Event Timeline
@Niharika Maybe you could clarify the expected behaviour? I'm just going off of memory. Are there also situations where you shouldn't be able to delete an Event?
@MusikAnimal Yeah, programs with >= 1 events should not be deletable. Similarly events with >= 1 participants should not be deleteable.
If there are events/participants, the deletion buttons will now be grayed out. Attempting to click on it will show an alert with "This event cannot be deleted because it has one or more participants", etc. Admins can still delete any program/event.
This validation is currently only done in the frontend... because unfortunately in the model layer there's no concept of who's logged in. So it's possible for someone to hack their way into deleting their own program/event, but I don't think we need to worry about that right now. Maybe should create a ticket, though.
Commit: https://github.com/wikimedia/grantmetrics/commit/18a37f8dbee8da0b654c1be3604d0eaf3dde93a7
I couldn't get this to work on ToolForge. I'm trying to delete an event which has participants and it lets me delete it. I'm on Safari. No console errors.
Indeed! Use your admin powers wisely :)
It's easy to change it so that admins aren't exempt from this restriction, but I figure if you did need to delete something, it might be a pain to have to first go through and delete each individual participant/event. You already get a confirmation popup, so hopefully there won't be any accidents.
Aha, makes sense. Shouldn't be a problem. This will definitely make it easy to deal with spam, if we have to. Thanks!