def send_test_scheduled_report(request, domain, scheduled_report_id): from corehq.apps.reports.tasks import send_report from corehq.apps.users.models import CouchUser, CommCareUser, WebUser user_id = request.couch_user._id notification = ReportNotification.get(scheduled_report_id) try: user = WebUser.get_by_user_id(user_id, domain) except CouchUser.AccountTypeError: user = CommCareUser.get_by_user_id(user_id, domain) try: send_report.delay(notification._id) except Exception, e: import logging logging.exception(e) messages.error(request, "An error occured, message unable to send")