From 30eb75d39bd1838b48500dec6f4d3c00a39e3e40 Mon Sep 17 00:00:00 2001 From: Gagan Deep Date: Fri, 18 Sep 2020 10:48:50 +0530 Subject: [PATCH] [fix] Fixed ignore notification widget JS loading on add view #128 Ensured ignore notification widget JS written in "admin/change_form.html" is only loads for change view of a ModelAdmin Closes #128 --- .../templates/admin/change_form.html | 32 ++++++++++--------- openwisp_notifications/tests/test_admin.py | 5 +++ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/openwisp_notifications/templates/admin/change_form.html b/openwisp_notifications/templates/admin/change_form.html index c2b19f35..8295130e 100644 --- a/openwisp_notifications/templates/admin/change_form.html +++ b/openwisp_notifications/templates/admin/change_form.html @@ -11,23 +11,25 @@ {% block admin_change_form_document_ready %} {{ block.super }} - + const owNotifyObjectId = objectId.replace(/\//g,''); + + {% endif %} {% endblock %} diff --git a/openwisp_notifications/tests/test_admin.py b/openwisp_notifications/tests/test_admin.py index 4501040c..0c868f2a 100644 --- a/openwisp_notifications/tests/test_admin.py +++ b/openwisp_notifications/tests/test_admin.py @@ -282,3 +282,8 @@ def test_object_notification_setting_configured(self): reverse('admin:openwisp_users_user_change', args=(self.admin.pk,)) ) UserAdmin.Media = None + + def test_ignore_notification_widget_add_view(self): + url = reverse('admin:openwisp_users_organization_add') + response = self.client.get(url) + self.assertNotContains(response, 'owIsChangeForm')