2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

Add option to recursively delete part categories (#3435)

* Add option to recursively delete part categories

Fixes #3384

* - Added test (broken ATM)
- Refactored parameters to booleanish

* Fix styling issues reported by flake8

* Working on unit testing

* Added on_commit debugging callback

* Separate the recursive part of the deletion into another method
to make sure that the delete operation is performed in a single transaction

* Trying transactions with @transactions.atomic

* Fix flake8 reported issues

* Removed unused debug callback

* Fixed tests for category recursive deletion

* Fix flake reported issues

* Fix flake reported issues
Again

* Remove unrelated formatting changes

* Fixed a part of review comments
This commit is contained in:
Miklós Márton
2022-11-08 01:57:00 +01:00
committed by GitHub
parent adcb975853
commit f6cfc12343
6 changed files with 218 additions and 26 deletions

View File

@ -333,15 +333,33 @@ function deletePartCategory(pk, options={}) {
var html = `
<div class='alert alert-block alert-danger'>
{% trans "Are you sure you want to delete this part category?" %}
<ul>
<li>{% trans "Any child categories will be moved to the parent of this category" %}</li>
<li>{% trans "Any parts in this category will be moved to the parent of this category" %}</li>
</ul>
</div>`;
var subChoices = [
{
value: 0,
display_name: '{% trans "Move to parent category" %}',
},
{
value: 1,
display_name: '{% trans "Delete" %}',
}
];
constructForm(url, {
title: '{% trans "Delete Part Category" %}',
method: 'DELETE',
fields: {
'delete_parts': {
label: '{% trans "Action for parts in this category" %}',
choices: subChoices,
type: 'choice'
},
'delete_child_categories': {
label: '{% trans "Action for child categories" %}',
choices: subChoices,
type: 'choice'
},
},
preFormContent: html,
onSuccess: function(response) {
handleFormSuccess(response, options);