From 1ed5d394c5718034dbf2aba3a32f7ab4a520e3c6 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 9 Feb 2022 11:27:08 +0100 Subject: [PATCH] fix the new version of dispatch for NewDataWipeView --- ereuse_devicehub/inventory/views.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 01bbe1db..1eae4de2 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -336,12 +336,17 @@ class NewAllocateView(NewActionView, DeviceListMix): class NewDataWipeView(NewActionView, DeviceListMix): methods = ['POST'] - _form = DataWipeForm + form_class = DataWipeForm def dispatch_request(self): - dispatch = super().dispatch_request() - if dispatch: - return dispatch + self.form = self.form_class() + + if self.form.validate_on_submit(): + instance = self.form.save() + messages.success('Action "{}" created successfully!'.format(instance.type)) + + next_url = self.get_next_url() + return flask.redirect(next_url) lot_id = self.form.lot.data self.get_context(lot_id)