Can't delete Service Areas

Issue #396 resolved
Randle Taylor created an issue

Sometimes it may occur that a user creates a Service Event, associates it with a Service Area, and then later "deletes" the Service Event. Now, if you try to delete that same Service Area in the admin, you're unable too since the SE is only soft deleted.

Obviously we can delete manually via the Django shell, but that's not practical for most people. A couple options off the top of my head:

  1. Change the Service Area/Unit Service Area/Service Event ForeignKey on_delete chain to CASCADE instead of protect. This could be dangerous though.
  2. Add ServiceEvent's to the admin so that Service Events can be hard deleted.
  3. Add a page in the front facing UI to list all soft deleted SE's and allow users to hard delete them from there.
  4. ... something else?

@ryanbottema what do you think the best way of dealing with this is?

Comments (5)

  1. Ryan Bottema

    @randlet What about changing on_delete to SET_NULL (or more accurately, create/select a new UnitServiceArea with the same Unit and ServiceArea set to null). Would need to allow USA to accept a null SA in the db. Might also need to change the ServiceEvent form validation to explicitly catch null SAs during regular form submission, although that might already happen.

    Perhaps that's getting more complicated than just adding SE to the admin. In this case you could even just change the SA for the SEs in question without hard deleting if desired.

  2. Log in to comment