From 00c88367c6918ca6afb3463f9ac823d17dae984b Mon Sep 17 00:00:00 2001 From: Jacob Sayles Date: Tue, 18 Apr 2017 11:37:35 -0700 Subject: [PATCH] removed celery --- docs/mailing_lists.rst | 1 - nadine/__init__.py | 4 -- nadine/celery.py | 22 -------- scripts/checkCelery.sh | 6 -- staff/tasks.py | 123 ----------------------------------------- 5 files changed, 156 deletions(-) delete mode 100644 nadine/celery.py delete mode 100755 scripts/checkCelery.sh delete mode 100644 staff/tasks.py diff --git a/docs/mailing_lists.rst b/docs/mailing_lists.rst index f0d9ac536..170efe551 100644 --- a/docs/mailing_lists.rst +++ b/docs/mailing_lists.rst @@ -6,7 +6,6 @@ In the interest of shipping more quickly, we have made certain assumptions about * the reply-to address for mail from a list is the original sender, not the entire list * attachments are neither saved nor sent to the list, but a removal note is appended to the message * incoming messages are parsed for a single text message and a single html message (not multiple MIME messages) -* you can set the frequency of mail fetching by changing the value in CELERYBEAT_SCHEDULE in your settings.py or local_settings.py * loops and bounces are silently dropped * any email sent to a list which is not in a subscriber's user or membership record is moderated * the sender of a message receives a copy of the message like any other subscriber diff --git a/nadine/__init__.py b/nadine/__init__.py index b64e43e83..c3961685a 100755 --- a/nadine/__init__.py +++ b/nadine/__init__.py @@ -1,5 +1 @@ from __future__ import absolute_import - -# This will make sure the app is always imported when -# Django starts so that shared_task will use this app. -from .celery import app as celery_app diff --git a/nadine/celery.py b/nadine/celery.py deleted file mode 100644 index 09dc148f8..000000000 --- a/nadine/celery.py +++ /dev/null @@ -1,22 +0,0 @@ -from __future__ import absolute_import - -import os - -from celery import Celery - -from django.conf import settings - -# set the default Django settings module for the 'celery' program. -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'nadine.settings') - -app = Celery('nadine') - -# Using a string here means the worker will not have to -# pickle the object when using Windows. -app.config_from_object('django.conf:settings') -app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) - - -@app.task(bind=True) -def debug_task(self): - print('Request: {0!r}'.format(self.request)) diff --git a/scripts/checkCelery.sh b/scripts/checkCelery.sh deleted file mode 100755 index e0a892cfe..000000000 --- a/scripts/checkCelery.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -/usr/local/bin/celery inspect active > /dev/null 2> /dev/null -if [ $? -ne 0 ] ; then - echo "Celery Not Running!" | mail jacob@officenomads.com -s "Celery Error"; -fi \ No newline at end of file diff --git a/staff/tasks.py b/staff/tasks.py deleted file mode 100644 index 0d8a50416..000000000 --- a/staff/tasks.py +++ /dev/null @@ -1,123 +0,0 @@ -from __future__ import absolute_import - -from celery import shared_task -from datetime import datetime, timedelta - -from django.contrib.auth.models import User -from django.utils.timezone import localtime, now - -from nadine.models.profile import SpecialDay -from nadine.models.membership import Membership -from nadine.models.usage import CoworkingDay -from nadine.models.payment import BillingLog -from members.models import UserNotification - -from arpwatch import arp -from nadine import email -from staff import billing - - -@shared_task -def billing_task(): - """A recurring task which calculates billing""" - billing.run_billing() - -@shared_task -def first_day_checkins(): - """A recurring task which sends an email to new members""" - now = localtime(now()) - midnight = now - timedelta(seconds=now.hour * 60 * 60 + now.minute * 60 + now.second) - free_trials = CoworkingDay.objects.filter(visit_date__range=(midnight, now), payment='Trial') - for l in free_trials: - email.send_first_day_checkin(l.user) - - -@shared_task -def regular_checkins(): - """A recurring task which sends checkin emails to members""" - # Pull the memberships that started 60 days ago and send the coworking survey - # if they are still active and this was their first membership - today = localtime(now()).date() - two_months_ago = today - timedelta(days=60) - for membership in Membership.objects.filter(start_date=two_months_ago): - if OldMembership.objects.filter(user=membership.user, start_date__lt=two_months_ago).count() == 0: - if membership.user.profile.is_active(): - email.send_member_survey(membership.user) - - # Pull all the free trials from 30 days ago and send an email if they haven't been back - one_month_ago = today - timedelta(days=30) - for dropin in CoworkingDay.objects.filter(visit_date=one_month_ago, payment='Trial'): - if CoworkingDay.objects.filter(user=dropin.user).count() == 1: - if not dropin.user.profile.is_active(): - email.send_no_return_checkin(dropin.user) - - # Send an exit survey to members that have been gone a week. - one_week_ago = today - timedelta(days=7) - for membership in Membership.objects.filter(end_date=one_week_ago): - if not membership.user.profile.is_active(): - email.send_exit_survey(membership.user) - - # Announce to the team when a new user is nearing the end of their first month - #almost_a_month_ago = today - timedelta(days=21) - # for membership in Membership.objects.filter(start_date=almost_a_month_ago): - # if OldMembership.objects.filter(user=membership.user, start_date__lt=almost_a_month_ago).count() == 0: - # if membership.user.profile.is_active(): - # email.announce_member_checkin(membership.user) - - -@shared_task -def member_alert_check(): - from nadine.models.alerts import MemberAlert - MemberAlert.objects.trigger_periodic_check() - - -@shared_task -def unsubscribe_recent_dropouts_task(): - """A recurring task which checks for members who need to be unsubscribed from mailing lists""" - from interlink.models import unsubscribe_recent_dropouts - unsubscribe_recent_dropouts() - - -@shared_task -def make_backup(): - from staff.backup import BackupManager - manager = BackupManager() - manager.make_backup() - - -@shared_task -def export_active_users(): - from staff.backup import BackupManager - manager = BackupManager() - manager.export_active_users() - - -@shared_task -def anniversary_checkin(): - for u in User.helper.active_members(): - d = u.profile.duration() - if d.years and not d.months and not d.days: - email.announce_anniversary(u) - email.send_edit_profile(u) - - -@shared_task -def announce_special_days(): - today = localtime(now()).date() - for u in User.helper.active_members(): - for sd in SpecialDay.objects.filter(user=u): - if sd.month == today.month and sd.day == today.day: - email.announce_special_day(u, sd) - - -@shared_task -def send_notifications(): - here_today = User.helper.here_today() - for n in UserNotification.objects.filter(sent_date__isnull=True): - if n.notify_user in here_today: - if n.target_user in here_today: - email.send_user_notifications(n.notify_user, n.target_user) - n.sent_date = localtime(now()) - n.save() - -# Copyright 2017 Office Nomads LLC (http://www.officenomads.com/) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.