From b5b90c50f6ac5ccd79ab173e262f3e5e47b7d061 Mon Sep 17 00:00:00 2001 From: pedro Date: Wed, 25 Sep 2024 22:32:26 -0300 Subject: [PATCH 1/3] placeholder form: route to unassigned devices An empty form can be filled, and if you press multiple times save, it saves multiple devices/placeholders edit device goes to unassigned devices, so probably is the same for new device --- device/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/views.py b/device/views.py index 8d4c024..60412de 100644 --- a/device/views.py +++ b/device/views.py @@ -21,7 +21,7 @@ class NewDeviceView(DashboardView, FormView): template_name = "new_device.html" title = _("New Device") breadcrumb = "Device / New Device" - success_url = reverse_lazy('device:add') + success_url = reverse_lazy('dashboard:unassigned_devices') form_class = DeviceFormSet def form_valid(self, form): From 5b84d815903238fb2db4cae221390d32345633ec Mon Sep 17 00:00:00 2001 From: pedro Date: Wed, 25 Sep 2024 22:48:03 -0300 Subject: [PATCH 2/3] new_device: UX: clarify add component details --- device/templates/new_device.html | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/device/templates/new_device.html b/device/templates/new_device.html index bdb2911..5f76e69 100644 --- a/device/templates/new_device.html +++ b/device/templates/new_device.html @@ -40,15 +40,6 @@ {% endif %} {{ form.management_form }}
-
{% bootstrap_field form.0.type %} @@ -64,6 +55,17 @@ {% bootstrap_field form.0.customer_id %}
+
+
+ {% trans 'Component details' %} +
+ +
{% for f in form %}
From e3b0d70f042d74732703c41c80b9cb0cada8e88a Mon Sep 17 00:00:00 2001 From: pedro Date: Wed, 25 Sep 2024 23:10:41 -0300 Subject: [PATCH 3/3] fix typo: customer_id -> custom_id --- device/forms.py | 6 +++--- device/templates/new_device.html | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/device/forms.py b/device/forms.py index b6c1d21..21c9a9a 100644 --- a/device/forms.py +++ b/device/forms.py @@ -23,7 +23,7 @@ DEVICE_TYPES = [ class DeviceForm(forms.Form): type = forms.ChoiceField(choices = DEVICE_TYPES, required=False) amount = forms.IntegerField(required=False, initial=1) - customer_id = forms.CharField(required=False) + custom_id = forms.CharField(required=False) name = forms.CharField(required=False) value = forms.CharField(required=False) @@ -49,8 +49,8 @@ class BaseDeviceFormSet(forms.BaseFormSet): row["amount"] = d["amount"] if d.get("name"): row[d["name"]] = d.get("value", '') - if d.get("customer_id"): - row['CUSTOMER_ID']= d["customer_id"] + if d.get("custom_id"): + row['CUSTOM_ID']= d["custom_id"] doc = create_doc(row) if not commit: diff --git a/device/templates/new_device.html b/device/templates/new_device.html index 5f76e69..320790d 100644 --- a/device/templates/new_device.html +++ b/device/templates/new_device.html @@ -52,7 +52,7 @@
- {% bootstrap_field form.0.customer_id %} + {% bootstrap_field form.0.custom_id %}