diff --git a/core/management/commands/run_daily_tasks.py b/core/management/commands/run_daily_tasks.py index e2e5fd77..3534b0f6 100644 --- a/core/management/commands/run_daily_tasks.py +++ b/core/management/commands/run_daily_tasks.py @@ -14,8 +14,6 @@ def handle(self, *args, **kwargs): tasks.send_guest_welcome() tasks.send_departure_email() tasks.slack_embassysf_daily() - tasks.slack_ams_daily() - tasks.slack_redvic_daily() gather_tasks.events_today_reminder() if datetime.date.today().weekday() == 6: # sunday gather_tasks.weekly_upcoming_events() diff --git a/core/tasks.py b/core/tasks.py index 78bc132d..a7bc6e44 100644 --- a/core/tasks.py +++ b/core/tasks.py @@ -132,77 +132,3 @@ def slack_embassysf_daily(): logger.debug("Slack response: %s" % resp.text) -@catch_exceptions -def slack_ams_daily(): - ''' post daily arrivals and departures to slack. to enable, add an incoming - web hook to the specific channel you want this to post to. grab the webhook - url and put it in the webhook variable below.''' - if not settings.ENABLE_SLACK: - logger.info("Skipping task: slack_ams_daily") - return - - logger.info("Running task: slack_ams_daily") - webhook = "https://hooks.slack.com/services/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" - today = timezone.localtime(timezone.now()) - location = Location.objects.get(slug="amsterdam") - arriving_today = Use.objects.filter(location=location).filter(arrive=today).filter(status='confirmed') - departing_today = Use.objects.filter(location=location).filter(depart=today).filter(status='confirmed') - - payload = { - 'text': 'Arrivals and Departures for %s' % today.strftime("%B %d, %Y"), - 'attachments': [] - } - for a in arriving_today: - item = _format_attachment(a, "good") - payload['attachments'].append(item) - for d in departing_today: - item = _format_attachment(d, "danger") - payload['attachments'].append(item) - if len(arriving_today) == 0 and len(departing_today) == 0: - payload['attachments'].append({ - 'fallback': 'No arrivals or departures today', - 'text': 'No arrivals or departures today' - }) - - js = json.dumps(payload) - logger.debug(js) - resp = requests.post(webhook, data=js) - logger.debug("Slack response: %s" % resp.text) - - -@catch_exceptions -def slack_redvic_daily(): - ''' post daily arrivals and departures to slack. to enable, add an incoming - web hook to the specific channel you want this to post to. grab the webhook - url and put it in the webhook variable below.''' - if not settings.ENABLE_SLACK: - logger.info("Skipping task: slack_redvic_daily") - return - - logger.info("Running task: slack_redvic_daily") - webhook = "https://hooks.slack.com/services/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" - today = timezone.localtime(timezone.now()) - location = Location.objects.get(slug="redvic") - arriving_today = Use.objects.filter(location=location).filter(arrive=today).filter(status='confirmed') - departing_today = Use.objects.filter(location=location).filter(depart=today).filter(status='confirmed') - - payload = { - 'text': 'Arrivals and Departures for %s' % today.strftime("%B %d, %Y"), - 'attachments': [] - } - for a in arriving_today: - item = _format_attachment(a, "good") - payload['attachments'].append(item) - for d in departing_today: - item = _format_attachment(d, "danger") - payload['attachments'].append(item) - if len(arriving_today) == 0 and len(departing_today) == 0: - payload['attachments'].append({ - 'fallback': 'No arrivals or departures today', - 'text': 'No arrivals or departures today' - }) - - js = json.dumps(payload) - logger.debug(js) - resp = requests.post(webhook, data=js) - logger.debug("Slack response: %s" % resp.text)