From 0b09365d0d947c012f117935d74a57fe5e125909 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Sun, 1 Aug 2021 13:30:16 -0700 Subject: [PATCH] #6797: Improve form error/django messages handling --- netbox/netbox/views/generic.py | 2 +- netbox/project-static/dist/netbox-dark.css | Bin 765368 -> 765466 bytes netbox/project-static/dist/netbox-light.css | Bin 477465 -> 477529 bytes netbox/project-static/styles/netbox.scss | 7 ++ netbox/templates/inc/messages.html | 77 ++++++++++---------- 5 files changed, 47 insertions(+), 39 deletions(-) diff --git a/netbox/netbox/views/generic.py b/netbox/netbox/views/generic.py index d5d5198e0..d8ea04536 100644 --- a/netbox/netbox/views/generic.py +++ b/netbox/netbox/views/generic.py @@ -854,7 +854,7 @@ class BulkEditView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View): return redirect(self.get_return_url(request)) except ValidationError as e: - messages.error(self.request, "{} failed validation: {}".format(obj, e)) + messages.error(self.request, "{} failed validation: {}".format(obj, ", ".join(e.messages))) except PermissionsViolation: msg = "Object update failed due to object-level permissions violation" diff --git a/netbox/project-static/dist/netbox-dark.css b/netbox/project-static/dist/netbox-dark.css index 9376db9b4006620d8714742e3f9556798bb7b9e8..ca9ac8d6a6e836b7e29dd9b6ba082eb2f4db2883 100644 GIT binary patch delta 100 zcmdmSTW{7Ky@nRX7N!>F7M2#)7Pc1l7LFFq7OpMa=T=)Or(`AOrRVGBrWO|`rl%HH z7vvXbmSpDVS*2xGq^4LGWu|A8SQ!?j=2|D^mz3n^S{Yd9CKjb<=1qQZO=J7H)!eTb E0ffXSo&W#< delta 37 tcmbPrM{mb%y@nRX7N!>F7M2#)7Pc1l7LFFq7OpMa=T>hwSi}8_5dabL4h8@K diff --git a/netbox/project-static/dist/netbox-light.css b/netbox/project-static/dist/netbox-light.css index 9fdb12a01e5c2dba35ce7f3ee0b2fbb1193a0c81..423470886cfd874c759a9904f693c47a63505273 100644 GIT binary patch delta 103 zcmbO^N%rO>*@hOz7N!>F7M2#)7Pc+y+uiMzQ?e5C((`q5Q;Ule(^HG93-XIIOEUBG ztkNuvw<&Mw6W E0L42cH2?qr delta 39 ucmcaPNp|KW*@hOz7N!>F7M2#)7Pc+y+uf&Ud$3DQU*y5Ax7{AdVgvvip$xbH diff --git a/netbox/project-static/styles/netbox.scss b/netbox/project-static/styles/netbox.scss index f08ce515a..5f395ff7c 100644 --- a/netbox/project-static/styles/netbox.scss +++ b/netbox/project-static/styles/netbox.scss @@ -1062,6 +1062,13 @@ div.card > div.card-header > div.table-controls { border-bottom: 1px solid $nav-tabs-border-color; } +#django-messages { + position: fixed; + right: $spacer; + bottom: 0; + margin: $spacer; +} + // Page-specific styles. html { // Shade the home page content background-color. diff --git a/netbox/templates/inc/messages.html b/netbox/templates/inc/messages.html index 409117efe..1cb9a6215 100644 --- a/netbox/templates/inc/messages.html +++ b/netbox/templates/inc/messages.html @@ -1,46 +1,13 @@ {% load helpers %} -
+
{# Django Messages #} - {% if messages %} - {% for message in messages %} - {% with message.level_tag|status_from_tag as status %} - {% with status|icon_from_status as icon %} - - {% endwith %} - {% endwith %} - {% endfor %} - - {% elif form and form.non_field_errors %} - {# Non-Field Form Errors #} - - {% for error in form.non_field_errors.get_json_data %} - - {% endfor %} - - {% elif form and form.errors %} - {# Form Field Errors #} - + {# Form Field Errors #} + {% if form and form.errors %} {% for field in form %} {% for error in field.errors %} -