DemocracyClub / yournextrepresentative

👥 A website for crowd-sourcing structured election candidate data
https://candidates.democracyclub.org.uk
GNU Affero General Public License v3.0
21 stars 27 forks source link

DRY up safe to delete logic #782

Open symroe opened 5 years ago

symroe commented 5 years ago

There are a few places we do a "safe to delete check" or a "save delete". This basically uses django.contrib.admin.utils.NestedObjects to check if a delete will cause a CASCADE delete and then optionally deletes the model.

Known places we do this:

All these can more or less be converted to use the same couple of functions.

chris48s commented 5 years ago

also elections.models.Election.safe_delete