[backport] #1303: [fix] Fix duplicate template entries in Device admin (to 1.2)#1324
[backport] #1303: [fix] Fix duplicate template entries in Device admin (to 1.2)#1324nemesifier merged 2 commits into1.2from
Conversation
Test Failure in
|
ed245e1 to
326703d
Compare
Flake8 F541 f-string missing placeholdersHello @app/openwisp-companion and @nemesifier, There is an f-string in Fix: |
(cherry picked from commit af0d99b)
Bug: The JS logic in relevant_templates.js assumed that the last `ul.sortedm2m-items` element belonged to the empty inline form used by Django admin formsets. This assumption breaks when the user does not have permission to add Config objects: in that case the ConfigInlineAdmin does not render the empty form. As a result, both selectors ended up referencing the same list and the script appended template elements twice to the same `sortedm2m` list, causing duplicate entries and issues when saving the form. Fix: Select the empty form container explicitly using `#config-empty ul.sortedm2m-items` instead of relying on the last occurrence of `ul.sortedm2m-items`. This ensures the logic works correctly regardless of whether the empty inline form is rendered. [backport 1.2] (cherry picked from commit b73e83a)
326703d to
ce0cfd7
Compare
Backport of #1303 to
1.2.