bgneal@513: """ bgneal@513: Celery tasks for the core application. bgneal@513: bgneal@513: """ bgneal@513: from celery.task import task bgneal@513: import django.core.mail bgneal@516: from django.core.management.commands.cleanup import Command as CleanupCommand bgneal@516: from forums.management.commands.forum_cleanup import Command as ForumCleanup bgneal@513: bgneal@513: bgneal@513: @task bgneal@513: def add(x, y): bgneal@516: """ bgneal@516: It is useful to have a test task laying around. This is it. bgneal@516: bgneal@516: """ bgneal@513: return x + y bgneal@513: bgneal@516: bgneal@513: @task bgneal@513: def send_mail(subject, message, from_email, recipient_list, **kwargs): bgneal@516: """ bgneal@516: A task to send mail via Django. bgneal@516: bgneal@516: """ bgneal@513: django.core.mail.send_mail(subject, message, from_email, recipient_list, bgneal@513: **kwargs) bgneal@516: bgneal@516: bgneal@516: @task bgneal@516: def cleanup(): bgneal@516: """ bgneal@516: A task to perform site-wide cleanup actions. bgneal@516: bgneal@516: """ bgneal@516: # Execute Django's cleanup command (deletes old sessions). bgneal@516: bgneal@516: command = CleanupCommand() bgneal@516: command.execute() bgneal@516: bgneal@516: # Execute our forum cleanup command to delete old last visit records. bgneal@516: bgneal@516: command = ForumCleanup() bgneal@516: command.execute()