You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/07/30 07:35:45 UTC

[GitHub] [incubator-superset] JasonD28 commented on a change in pull request #10476: feat: add test email functionality to SQL-based email alerts

JasonD28 commented on a change in pull request #10476:
URL: https://github.com/apache/incubator-superset/pull/10476#discussion_r462624105



##########
File path: superset/views/alerts.py
##########
@@ -95,5 +105,47 @@ class AlertModelView(SupersetModelView):  # pylint: disable=too-many-ancestors
             "Superset nags you again."
         ),
     }
+
+    add_form_extra_fields = {
+        "test_alert": BooleanField(
+            "Send Test Alert",
+            default=False,
+            description="If enabled, a test alert will be sent on the creation / update of active alerts. "
+            "All alerts after will be sent only if the SQL statement defined above returns True.",
+        ),
+        "test_email_recipients": StringField(
+            "Test Email Recipients",
+            default=None,
+            description="List of recipients to send test email to. "
+            "If empty, an email will be sent to the original recipients.",
+        ),
+    }
+    edit_form_extra_fields = add_form_extra_fields
     edit_columns = add_columns
     related_views = [AlertLogModelView]
+
+    def process_form(self, form: Form, is_created: bool) -> None:
+        test_email_recipients = None
+        if form.test_email_recipients.data:
+            test_email_recipients = get_email_address_str(
+                form.test_email_recipients.data
+            )
+
+        self._extra_data["test_alert"] = form.test_alert.data
+        self._extra_data["test_email_recipients"] = test_email_recipients  # type: ignore

Review comment:
       mypy was complaining: `Incompatible types in assignment (expression has type "Optional[str]", target has type "Optional[bool]")`
   All other type definitions matched




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org