From 4ebb312e59833721fda647e5c4cb11eee78d7e6b Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 3 Feb 2022 11:27:16 +0100 Subject: [PATCH 01/10] first step for datawipe form --- ereuse_devicehub/inventory/forms.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 83efbd89..198d762c 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -529,3 +529,22 @@ class AllocateForm(NewActionForm): is_valid = False return is_valid + + +class DataWipeForm(NewActionForm): + url = URL(required= False, ) + success = Boolean(required=False, default=False) + software = StringField() + date = DateField(u'endTime', + required=False, + id_document = StringField(u'documentId', + file_name = StringField(u'filename', + validate=validate.Length(max=100)) + file_hash = StringField(u'hash', + default='', + validate=validate.Length(max=64)) + + def validate(self, extra_validators=None): + is_valid = super().validate(extra_validators) + + return is_valid From 8b467b95c3571691841ac55d684a17112c642254 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 7 Feb 2022 14:01:38 +0100 Subject: [PATCH 02/10] template for data wipe --- ereuse_devicehub/static/js/main_inventory.js | 25 +++++++- .../templates/inventory/data_wipe.html | 63 +++++++++++++++++++ .../templates/inventory/device_list.html | 4 +- 3 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 ereuse_devicehub/templates/inventory/data_wipe.html diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index 05833fe5..1eb680fd 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -1,8 +1,12 @@ $(document).ready(function() { - var show_action_form = $("#allocateModal").data('show-action-form'); - if (show_action_form != "None") { + var show_allocate_form = $("#allocateModal").data('show-action-form'); + var show_datawipe_form = $("#datawipeModal").data('show-action-form'); + if (show_allocate_form != "None") { $("#allocateModal .btn-primary").show(); - newAllocate(show_action_form); + newAllocate(show_allocate_form); + } else if (show_datawipe_form != "None") { + $("#datawipeModal .btn-primary").show(); + newDataWipe(show_datawipe_form); } else { $(".deviceSelect").on("change", deviceSelect); } @@ -26,6 +30,9 @@ function deviceSelect() { $("#allocateModal .pol").show(); $("#allocateModal .btn-primary").hide(); + + $("#datawipeModal .pol").show(); + $("#datawipeModal .btn-primary").hide(); } else { $("#addingLotModal .pol").hide(); $("#addingLotModal .btn-primary").show(); @@ -39,6 +46,9 @@ function deviceSelect() { $("#allocateModal .pol").hide(); $("#allocateModal .btn-primary").show(); + $("#datawipeModal .pol").hide(); + $("#datawipeModal .btn-primary").show(); + $("#addingTagModal .pol").hide(); } } @@ -69,11 +79,20 @@ function newAllocate(action) { $("#activeAllocateModal").click(); } +function newDataWipe(action) { + $("#datawipeModal #type").val(action); + $("#datawipeModal #title-action").html(action); + get_device_list(); + deviceSelect(); + $("#activeDatawipeModal").click(); +} + function get_device_list() { var devices = $(".deviceSelect").filter(':checked'); /* Insert the correct count of devices in actions form */ var devices_count = devices.length; + $("#datawipeModal .devices-count").html(devices_count); $("#allocateModal .devices-count").html(devices_count); $("#actionModal .devices-count").html(devices_count); diff --git a/ereuse_devicehub/templates/inventory/data_wipe.html b/ereuse_devicehub/templates/inventory/data_wipe.html new file mode 100644 index 00000000..8ce124ad --- /dev/null +++ b/ereuse_devicehub/templates/inventory/data_wipe.html @@ -0,0 +1,63 @@ + diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index 97291791..a165e387 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -80,6 +80,7 @@ +