bgneal@513: """ bgneal@513: Celery tasks for the core application. bgneal@513: bgneal@513: """ bgneal@750: from __future__ import absolute_import bgneal@750: bgneal@892: import django.core.mail bgneal@750: from celery import shared_task bgneal@513: bgneal@519: import core.whos_online bgneal@519: bgneal@513: bgneal@750: @shared_task bgneal@892: def send_mail(**kwargs): bgneal@516: """ bgneal@516: A task to send mail via Django. bgneal@516: bgneal@892: kwargs must be a dict of keyword arguments for an EmailMessage. bgneal@892: bgneal@516: """ bgneal@892: msg = django.core.mail.EmailMessage(**kwargs) bgneal@892: msg.send() bgneal@516: bgneal@516: bgneal@750: @shared_task bgneal@516: def cleanup(): bgneal@516: """ bgneal@516: A task to perform site-wide cleanup actions. bgneal@516: bgneal@516: """ bgneal@518: # These imports, when placed at the top of the module, caused all kinds of bgneal@518: # import problems when running on the production server (Python 2.5 and bgneal@518: # mod_wsgi). Moving them here worked around that problem. bgneal@518: bgneal@681: from django.contrib.sessions.management.commands import clearsessions bgneal@681: from forums.management.commands import forum_cleanup bgneal@518: bgneal@681: # Cleanup old sessions bgneal@516: bgneal@681: command = clearsessions.Command() bgneal@516: command.execute() bgneal@516: bgneal@516: # Execute our forum cleanup command to delete old last visit records. bgneal@516: bgneal@681: command = forum_cleanup.Command() bgneal@516: command.execute() bgneal@519: bgneal@519: bgneal@750: @shared_task bgneal@519: def max_users(): bgneal@519: """ bgneal@519: Run the periodic task to calculate the who's online max users/visitors bgneal@519: statistics. bgneal@519: bgneal@519: """ bgneal@519: core.whos_online.max_users()