def test_owner_can_delete_report(self, mock_success): report = self._create_report(owner_id=self.user._id) response = self.delete_scheduled_report(user=self.user, report_id=report._id) self.assertEqual(response.status_code, 302) with self.assertRaises(ResourceNotFound): ReportNotification.get(report._id)
def test_domain_admin_can_delete_report(self, mock_success): domain_admin = self._create_user(username='******', is_admin=True) report = self._create_report(owner_id=self.user._id) response = self.delete_scheduled_report(user=domain_admin, report_id=report._id) self.assertEqual(response.status_code, 302) with self.assertRaises(ResourceNotFound): ReportNotification.get(report._id)
def send_report(notification_id): notification = ReportNotification.get(notification_id) # If the report's start date is later than today, return and do not send the email if notification.start_date and notification.start_date > datetime.today().date(): return try: notification.send() except UnsupportedScheduledReportError: pass
def send_report(notification_id): notification = ReportNotification.get(notification_id) # If the report's start date is later than today, return and do not send the email if notification.start_date and notification.start_date > datetime.today( ).date(): return try: notification.send() except UnsupportedScheduledReportError: pass
def send_delayed_report(report_id): """ Sends a scheduled report, via celery background task. """ domain = ReportNotification.get(report_id).domain if (settings.SERVER_ENVIRONMENT == 'production' and any( re.match(pattern, domain) for pattern in settings.THROTTLE_SCHED_REPORTS_PATTERNS)): # This is to prevent a few scheduled reports from clogging up # the background queue. # https://manage.dimagi.com/default.asp?270029#BugEvent.1457969 send_report_throttled.delay(report_id) else: send_report.delay(report_id)
def send_delayed_report(report_id): """ Sends a scheduled report, via celery background task. """ domain = ReportNotification.get(report_id).domain if ( settings.SERVER_ENVIRONMENT == 'production' and any(re.match(pattern, domain) for pattern in settings.THROTTLE_SCHED_REPORTS_PATTERNS) ): # This is to prevent a few scheduled reports from clogging up # the background queue. # https://manage.dimagi.com/default.asp?270029#BugEvent.1457969 send_report_throttled.delay(report_id) else: send_report.delay(report_id)