From 54ec38f7e1e85a3350a0e9b81bc73815dfbd1e65 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Sun, 16 Feb 2020 15:37:09 +0000 Subject: [PATCH] Various UX Improvements Also rearranged asset detail/edit to be more space efficient --- assets/forms.py | 6 ++++++ assets/templates/asset_audit.html | 9 +++++++++ assets/templates/asset_update.html | 12 ++++++------ assets/templates/partials/asset_buttons.html | 1 + assets/templates/partials/asset_list_table_body.html | 6 +++--- assets/templates/partials/audit_details.html | 2 +- assets/views.py | 2 ++ 7 files changed, 28 insertions(+), 10 deletions(-) diff --git a/assets/forms.py b/assets/forms.py index dafd978b..d4d90931 100644 --- a/assets/forms.py +++ b/assets/forms.py @@ -20,6 +20,12 @@ 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'] + class AssetSearchForm(forms.Form): query = forms.CharField(required=False) category = forms.ModelMultipleChoiceField(models.AssetCategory.objects.all(), required=False) diff --git a/assets/templates/asset_audit.html b/assets/templates/asset_audit.html index 21612fef..9d8f071a 100644 --- a/assets/templates/asset_audit.html +++ b/assets/templates/asset_audit.html @@ -54,6 +54,15 @@ +
+ +
+
+ £ + {% render_field form.salvage_value|add_class:'form-control' value=object.salvage_value %} +
+
+

diff --git a/assets/templates/asset_update.html b/assets/templates/asset_update.html index 7bd9af5f..cd781de5 100644 --- a/assets/templates/asset_update.html +++ b/assets/templates/asset_update.html @@ -23,15 +23,15 @@
- {% if perms.assets.asset_finance %} -
- {% include 'partials/purchasedetails_form.html' %} -
- {%endif%} - + {% if perms.assets.asset_finance %} +
+ {% include 'partials/purchasedetails_form.html' %} +
+ {%endif%}
{% include 'partials/parent_form.html' %}
diff --git a/assets/templates/partials/asset_buttons.html b/assets/templates/partials/asset_buttons.html index 3c99225f..e9a4e43e 100644 --- a/assets/templates/partials/asset_buttons.html +++ b/assets/templates/partials/asset_buttons.html @@ -13,6 +13,7 @@ {% endif %} {% if create or edit or duplicate %} diff --git a/assets/templates/partials/asset_list_table_body.html b/assets/templates/partials/asset_list_table_body.html index 0d38fcd4..2677c187 100644 --- a/assets/templates/partials/asset_list_table_body.html +++ b/assets/templates/partials/asset_list_table_body.html @@ -7,10 +7,10 @@ {{ item.category }} {{ item.status }} - {% if audit %} - Audit - {% else %}
+ {% if audit %} + Audit + {% else %} View {% if perms.assets.change_asset %} Edit diff --git a/assets/templates/partials/audit_details.html b/assets/templates/partials/audit_details.html index 6c67ad56..8edc2d80 100644 --- a/assets/templates/partials/audit_details.html +++ b/assets/templates/partials/audit_details.html @@ -1,4 +1,4 @@ -
+
Audit Details
diff --git a/assets/views.py b/assets/views.py index 97d828f4..8bef66d2 100644 --- a/assets/views.py +++ b/assets/views.py @@ -193,8 +193,10 @@ class AssetAuditList(AssetList): self.form = forms.AssetSearchForm(data={}) return self.model.objects.filter(Q(last_audited_at__isnull=True)) + class AssetAudit(AssetEdit): template_name = 'asset_audit.html' + form_class = forms.AssetAuditForm def get_success_url(self): # TODO For some reason this doesn't stick when done in form_valid??