From e78a474290b4c24d621da3a270f8afdb9ddf608c Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Tue, 14 Apr 2020 20:45:24 +0100 Subject: [PATCH] Modify audit exclusions to properly prevent data loss --- assets/forms.py | 6 +-- assets/templates/asset_audit.html | 29 +++-------- .../templates/partials/cable_form_body.html | 50 ------------------- 3 files changed, 11 insertions(+), 74 deletions(-) delete mode 100644 assets/templates/partials/cable_form_body.html diff --git a/assets/forms.py b/assets/forms.py index 7912c81f..0304e6a0 100644 --- a/assets/forms.py +++ b/assets/forms.py @@ -21,11 +21,11 @@ class AssetForm(forms.ModelForm): self.fields['date_acquired'].widget.format = '%Y-%m-%d' -# Needed to prevent assets losing parent data on audit class AssetAuditForm(AssetForm): class Meta(AssetForm.Meta): - # TODO Inherit exlcusions from superclass - exclude = ['asset_id_prefix', 'asset_id_number', 'last_audited_at', 'last_audited_by', 'parent'] + # Prevents assets losing existing data that isn't included in the audit form + exclude = ['asset_id_prefix', 'asset_id_number', 'last_audited_at', 'last_audited_by', + 'parent', 'purchased_from', 'purchase_price', 'comments'] class AssetSearchForm(forms.Form): diff --git a/assets/templates/asset_audit.html b/assets/templates/asset_audit.html index caaee4d7..2ed26c88 100644 --- a/assets/templates/asset_audit.html +++ b/assets/templates/asset_audit.html @@ -69,7 +69,12 @@ Today Unknown - + +
+ +
+ {% render_field form.date_sold|add_class:'form-control' value=object.date_sold %} +
@@ -89,15 +94,9 @@
- +
- {% render_field form.plug|add_class:'form-control'%} -
-
-
- -
- {% render_field form.socket|add_class:'form-control'%} + {% render_field form.cable_type|add_class:'form-control' %}
@@ -127,18 +126,6 @@ 2.5{{ form.csa.help_text }}
-
- -
- {% render_field form.circuits|add_class:'form-control' value=object.circuits %} -
-
-
- -
- {% render_field form.cores|add_class:'form-control' value=object.cores %} -
-
{% if not request.is_ajax %}
diff --git a/assets/templates/partials/cable_form_body.html b/assets/templates/partials/cable_form_body.html deleted file mode 100644 index ffe5ed77..00000000 --- a/assets/templates/partials/cable_form_body.html +++ /dev/null @@ -1,50 +0,0 @@ -{% load widget_tweaks %} -
-
- -
- {% render_field form.plug|add_class:'form-control'%} -
-
-
- -
- {% render_field form.socket|add_class:'form-control'%} -
-
-
- -
-
- {% render_field form.length|add_class:'form-control' %} - {{ form.length.help_text }} -
-
-
- 5m - 10m - 20m -
-
-
- -
-
- {% render_field form.csa|add_class:'form-control' value=object.csa %} - {{ form.csa.help_text }} -
-
-
-
- -
- {% render_field form.circuits|add_class:'form-control' value=object.circuits %} -
-
-
- -
- {% render_field form.cores|add_class:'form-control' value=object.cores %} -
-
-