-
-
Notifications
You must be signed in to change notification settings - Fork 230
[fix] Allowed deleting device with "deactivating" config status #949 #962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c345299
[fix] Allowed deleting device with "deactivating" config status #949
pandafy 82ff62d
[fix] Show warning message on deleting multiple active devices
pandafy 4b6ecd2
[tests] Added tests
pandafy 1dcd4e2
[tests] Fixed tests for Django < 4.2
pandafy 5d68fd2
[chores] Fixed coverage reporting
pandafy 5f52b96
[qa] Formatted by prettier
pandafy 2652cbb
[skip ci][docs] Added note for deleting the device
pandafy da6552f
Merge branch 'master' into issues/949-delete-offline-devices
nemesifier 13d3f68
Merge branch 'master' into issues/949-delete-offline-devices
nemesifier 62aacd5
[req-changes] Improved button text and fixed font size
pandafy 4892967
[chores] Improved intermediate page text
nemesifier 6e5fd68
[chores] Improved wording of delete_confirmation.html template
nemesifier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
openwisp_controller/config/static/config/css/device-delete-confirmation.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #deactivating-warning .warning p { | ||
| margin-top: 0px; | ||
| } | ||
| #main ul.messagelist li.warning ul li { | ||
| display: list-item; | ||
| padding: 0px; | ||
| background: inherit; | ||
| } |
12 changes: 12 additions & 0 deletions
12
openwisp_controller/config/static/config/js/device-delete-confirmation.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| "use strict"; | ||
|
|
||
| (function ($) { | ||
| $(document).ready(function () { | ||
| $("#warning-ack").click(function (event) { | ||
| event.preventDefault(); | ||
| $("#deactivating-warning").slideUp("fast"); | ||
| $("#delete-confirm-container").slideDown("fast"); | ||
| $('input[name="force_delete"]').val("true"); | ||
| }); | ||
| }); | ||
| })(django.jQuery); |
62 changes: 62 additions & 0 deletions
62
openwisp_controller/config/templates/admin/config/device/delete_confirmation.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| {% extends "admin/delete_confirmation.html" %} | ||
| {% load i18n static %} | ||
|
|
||
| {% block extrastyle %} | ||
| {{ block.super }} | ||
| <link rel="stylesheet" type="text/css" href="{% static 'config/css/device-delete-confirmation.css' %}" /> | ||
| {% endblock extrastyle %} | ||
|
|
||
| {% block content %} | ||
| {% if perms_lacking %} | ||
| <p>{% blocktranslate with escaped_object=object %}Deleting the {{ object_name }} '{{ escaped_object }}' would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktranslate %}</p> | ||
| <ul> | ||
| {% for obj in perms_lacking %} | ||
| <li>{{ obj }}</li> | ||
| {% endfor %} | ||
| </ul> | ||
| {% elif protected %} | ||
| <p>{% blocktranslate with escaped_object=object %}Deleting the {{ object_name }} '{{ escaped_object }}' would require deleting the following protected related objects:{% endblocktranslate %}</p> | ||
| <ul> | ||
| {% for obj in protected %} | ||
| <li>{{ obj }}</li> | ||
| {% endfor %} | ||
| </ul> | ||
| {% else %} | ||
| {% if deactivating_warning %} | ||
| <div id="deactivating-warning"> | ||
| <ul class="messagelist"> | ||
| <li class="warning"> | ||
| <p>{% translate 'The device is still in the deactivating state, meaning its configuration is still present on the device. If you wish to remove the configuration from the device, please wait until the config status changes to "deactivated". Proceeding will delete the device from OpenWISP without ensuring its configuration has been removed.' %}</p> | ||
| <form> | ||
| <input type="submit" class="button danger-btn" id="warning-ack" | ||
| value="{% translate 'I understand the risks, delete the device' %}"> | ||
| <a class="button cancel-link">{% translate 'No, take me back' %}</a> | ||
| </form> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| {% endif %} | ||
| <div id="delete-confirm-container" {% if deactivating_warning %}style="display:none;"{% endif %}> | ||
| <p>{% blocktranslate with escaped_object=object %}Are you sure you want to delete the {{ object_name }} | ||
| "{{ escaped_object }}"? All of the following related items will be deleted:{% endblocktranslate %}</p> | ||
| {% include "admin/includes/object_delete_summary.html" %} | ||
| <h2>{% translate "Objects" %}</h2> | ||
| <ul id="deleted-objects">{{ deleted_objects|unordered_list }}</ul> | ||
| <form method="post">{% csrf_token %} | ||
| <div> | ||
| <input type="hidden" name="post" value="yes"> | ||
| {% if is_popup %}<input type="hidden" name="{{ is_popup_var }}" value="1">{% endif %} | ||
| {% if to_field %}<input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}">{% endif %} | ||
| <input type="submit" value="{% translate 'Yes, I’m sure' %}"> | ||
| {% if deactivating_warning %}<input type="hidden" name="force_delete" value="false">{% endif %} | ||
| <a href="#" class="button cancel-link">{% translate "No, take me back" %}</a> | ||
| </div> | ||
| </form> | ||
| </div> | ||
| {% endif %} | ||
| {% endblock %} | ||
|
|
||
| {% block footer %} | ||
| {{ block.super }} | ||
| <script type="text/javascript" src="{% static 'config/js/device-delete-confirmation.js' %}"></script> | ||
| {% endblock %} |
88 changes: 64 additions & 24 deletions
88
openwisp_controller/config/templates/admin/config/device/delete_selected_confirmation.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,76 @@ | ||
| {% extends "admin/delete_selected_confirmation.html" %} | ||
| {% load i18n l10n admin_urls static %} | ||
|
|
||
| {% block extrastyle %} | ||
| {{ block.super }} | ||
| <link rel="stylesheet" type="text/css" href="{% static 'config/css/device-delete-confirmation.css' %}" /> | ||
| {% endblock extrastyle %} | ||
|
|
||
| {% block content %} | ||
| {% if perms_lacking %} | ||
| {% if perms_lacking|first == 'active_devices' %} | ||
| <p>{% blocktranslate %}You have selected the following active device{{ model_count | pluralize }} to delete:{% endblocktranslate %}</p> | ||
| <ul>{{ deletable_objects|first|unordered_list }}</ul> | ||
| <p>{% blocktrans %}It is required to flag the device as deactivated before deleting the device. If the device has configuration, then wait till the configuration status changes to "deactivated" before deleting the device.{% endblocktrans %}</p> | ||
| {% else %} | ||
| <p>{% blocktranslate %}Deleting the selected {{ objects_name }} would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktranslate %}</p> | ||
| <ul>{{ perms_lacking|unordered_list }}</ul> | ||
| {% endif %} | ||
| <p>{% blocktranslate %}Deleting the selected {{ objects_name }} would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktranslate %}</p> | ||
| <ul>{{ perms_lacking|unordered_list }}</ul> | ||
| {% elif protected %} | ||
| <p>{% blocktranslate %}Deleting the selected {{ objects_name }} would require deleting the following protected related objects:{% endblocktranslate %}</p> | ||
| <ul>{{ protected|unordered_list }}</ul> | ||
| {% else %} | ||
| <p>{% blocktranslate %}Are you sure you want to delete the selected {{ objects_name }}? All of the following objects and their related items will be deleted:{% endblocktranslate %}</p> | ||
| {% include "admin/includes/object_delete_summary.html" %} | ||
| <h2>{% translate "Objects" %}</h2> | ||
| {% for deletable_object in deletable_objects %} | ||
| <ul>{{ deletable_object|unordered_list }}</ul> | ||
| {% endfor %} | ||
| <form method="post">{% csrf_token %} | ||
| <div> | ||
| {% for obj in queryset %} | ||
| <input type="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk|unlocalize }}"> | ||
| {% endfor %} | ||
| <input type="hidden" name="action" value="delete_selected"> | ||
| <input type="hidden" name="post" value="yes"> | ||
| <input type="submit" value="{% translate 'Yes, I’m sure' %}"> | ||
| <a href="#" class="button cancel-link">{% translate "No, take me back" %}</a> | ||
| {% if active_devices %} | ||
| <div id="deactivating-warning"> | ||
| <ul class="messagelist"> | ||
| <li class="warning"> | ||
| <p> | ||
| {% blocktranslate count counter=active_devices|length %} | ||
| The following device you selected for deletion is not deactivated | ||
| (either it is active or its configuration status is still "deactivating"): | ||
| {% plural %} | ||
| The following devices you selected for deletion are not deactivated | ||
| (either they are active or their configuration status is still "deactivating"): | ||
| {% endblocktranslate %} | ||
| </p> | ||
| <ul>{{ active_devices|unordered_list }}</ul> | ||
| <p> | ||
| {% blocktranslate count counter=active_devices|length %} | ||
| If you wish to remove the configuration from the device, please wait until its | ||
| configuration status changes to "deactivated". Proceeding will delete the device | ||
| from OpenWISP without ensuring its configuration has been removed. | ||
| {% plural %} | ||
| If you wish to remove the configurations from the devices, please wait until their | ||
| configuration status change to "deactivated." Proceeding will delete the devices | ||
| from OpenWISP without ensuring their configurations have been removed. | ||
| {% endblocktranslate %} | ||
| </p> | ||
| <form> | ||
| <input type="submit" class="button danger-btn" id="warning-ack" | ||
| value="{% trans "I understand the risks, delete the device" %}"> | ||
| <a class="button cancel-link">No, take me back</a> | ||
| </form> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| {% endif %} | ||
| <div id="delete-confirm-container" {% if active_devices %}style="display:none;"{% endif %}> | ||
| <p>{% blocktranslate %}Are you sure you want to delete the selected {{ objects_name }}? All of the following objects and their related items will be deleted:{% endblocktranslate %}</p> | ||
| {% include "admin/includes/object_delete_summary.html" %} | ||
| <h2>{% translate "Objects" %}</h2> | ||
| {% for deletable_object in deletable_objects %} | ||
| <ul>{{ deletable_object|unordered_list }}</ul> | ||
| {% endfor %} | ||
| <form method="post">{% csrf_token %} | ||
| <div> | ||
| {% for obj in queryset %} | ||
| <input type="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk|unlocalize }}"> | ||
| {% endfor %} | ||
| <input type="hidden" name="action" value="delete_selected"> | ||
| <input type="hidden" name="post" value="yes"> | ||
| <input type="submit" value="{% translate 'Yes, I’m sure' %}"> | ||
| <a href="#" class="button cancel-link">{% translate "No, take me back" %}</a> | ||
| </div> | ||
| </form> | ||
| </div> | ||
| </form> | ||
| {% endif %} | ||
| {% endblock %} | ||
|
|
||
| {% block footer %} | ||
| {{ block.super }} | ||
| <script type="text/javascript" src="{% static 'config/js/device-delete-confirmation.js' %}"></script> | ||
| {% endblock %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would write something like: "you can still force the deletion from OpenWISP by hitting the delete button in the device detail page after having deactivated the device or by using the bulk delete action from the device list page".