[fix] Added delete_confirmation_template attr in DeviceAdmin#1239
Conversation
📝 WalkthroughWalkthroughA custom delete confirmation template is specified for the DeviceAdmin class by adding a Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| delete_selected_confirmation_template = ( | ||
| "admin/config/device/delete_selected_confirmation.html" | ||
| ) | ||
| delete_confirmation_template = "admin/config/device/delete_confirmation.html" |
There was a problem hiding this comment.
@asmodehn if this is missing, you run into issues? Could you provide an example? Just double checking.
There was a problem hiding this comment.
If I write a custom_config app with Admin classes that inherit from the config app, during the deletion (and without adding my own deletion template in the custom_config app), the template that django displays is the default "admin/delete_confirmation.html"
So in openwisp usecase, it means the "warning" part was skipped, so the deletion workflow ended up to be different
Note: this behavior is different than with other templates (as they are defined as attributes)
That behavior is explicited there :
https://github.com/django/django/blob/main/django/contrib/admin/options.py#L1769
Without that attribute, django assumes a default template name for this app, or replace it with its own default template.
|
Thanks for the explanation @asmodehn 🙏 |
Checklist
Description of Changes
This add delete_confirmation_template attr to the Device Admin class, just like other templates.
Without it, selenium deletion tests will fail on apps deriving from config, that are not named
config.