mirror of
https://github.com/getredash/redash.git
synced 2025-12-19 17:37:19 -05:00
Close #930: remove alerts for archived queries
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Are you sure you want to archive this query?
|
||||
<br/> All dashboard widgets created with its visualizations will be deleted.
|
||||
<br/> All alerts and dashboard widgets created with its visualizations will be deleted.
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
|
||||
|
||||
@@ -641,6 +641,9 @@ class Query(ModelTimestampsMixin, BaseModel, BelongsToOrgMixin):
|
||||
for w in vis.widgets:
|
||||
w.delete_instance()
|
||||
|
||||
for alert in self.alerts:
|
||||
alert.delete_instance(recursive=True)
|
||||
|
||||
self.save()
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -276,6 +276,16 @@ class QueryArchiveTest(BaseTestCase):
|
||||
|
||||
self.assertEqual(None, query.schedule)
|
||||
|
||||
def test_deletes_alerts(self):
|
||||
subscription = self.factory.create_alert_subscription()
|
||||
query = subscription.alert.query
|
||||
|
||||
query.archive()
|
||||
|
||||
self.assertRaises(models.Alert.DoesNotExist, models.Alert.get_by_id, subscription.alert.id)
|
||||
self.assertRaises(models.AlertSubscription.DoesNotExist, models.AlertSubscription.get_by_id, subscription.id)
|
||||
|
||||
|
||||
class DataSourceTest(BaseTestCase):
|
||||
def test_get_schema(self):
|
||||
return_value = [{'name': 'table', 'columns': []}]
|
||||
|
||||
Reference in New Issue
Block a user