django-cleanup icon indicating copy to clipboard operation
django-cleanup copied to clipboard

Select models and fields via settings

Open stevelacey opened this issue 1 month ago • 0 comments

Select models and fields via settings, allowing for more granular filtering of what is or isn't included in cleanup.

CLEANUP = {
    # "core.achievement": {"frame", "image", "obscure_image"},
    "core.achievementupload": {"achievement_csv"},
    "core.bitstreamversion": {"asset_file"},
    "core.cerberusversion": {"asset_file"},
    "core.feedpost": {"image"},
    # "core.machine": {"backglass_art", "logo", "template_file"},
    "core.recording": {"file"},
    "core.scoredetectorversion": {"asset_file"},
    "core.scoreimage": {"image"},
    # "core.session": {"log_file"},
    "core.slideshowimage": {"image"},
    # "core.spike2firmwareversion": {"asset_file"},
    "core.userprofile": {"profile_picture"},
}

Note I didn't do anything different for select_mode given it got confusing fast, maybe it's easier to consider this as a layer on top of whatever app config has been selected, it's essentially select mode but more granular.

Mostly I've based the setting syntax off of what FIELDS stores anyway, given it's quite similar to how other packages like cacheops are configured.

Might be nice to fnmatch the model same as cacheops so you can do "core.*" but I didn't bother at this point.

This resolves https://github.com/un1t/django-cleanup/issues/113.

stevelacey avatar Jan 21 '25 10:01 stevelacey