From e904cf9ab98e7f547ed6ba4710068143d6b64090 Mon Sep 17 00:00:00 2001
From: Tanner Prestegard <tanner.prestegard@ligo.org>
Date: Wed, 6 Mar 2019 09:30:22 -0600
Subject: [PATCH] Fix for notification edit view with label queries

---
 gracedb/alerts/views.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gracedb/alerts/views.py b/gracedb/alerts/views.py
index 52ea08164..9fd84c064 100644
--- a/gracedb/alerts/views.py
+++ b/gracedb/alerts/views.py
@@ -101,6 +101,12 @@ class EditNotificationView(UpdateView):
         kw = super(EditNotificationView, self).get_form_kwargs(
             *args, **kwargs)
         kw['user'] = self.request.user
+
+        # Cases that have a label query actually have labels in the database.
+        # But we don't want to include those in the form because
+        # a) it's confusing and b) it breaks the form
+        if self.object.label_query and self.object.labels.exists():
+            kw['initial']['labels'] = None
         return kw
 
     def get_queryset(self):
-- 
GitLab