Mercurial > public > sg101
annotate core/tasks.py @ 884:4dd7e1b5efe8
New NSSR Latin surf logo.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 23 Jan 2015 18:56:02 -0600 |
parents | aeafbf3ecebf |
children | 79a71b9d0a2a |
rev | line source |
---|---|
bgneal@513 | 1 """ |
bgneal@513 | 2 Celery tasks for the core application. |
bgneal@513 | 3 |
bgneal@513 | 4 """ |
bgneal@750 | 5 from __future__ import absolute_import |
bgneal@750 | 6 |
bgneal@750 | 7 from celery import shared_task |
bgneal@513 | 8 import django.core.mail |
bgneal@513 | 9 |
bgneal@519 | 10 import core.whos_online |
bgneal@519 | 11 |
bgneal@513 | 12 |
bgneal@750 | 13 @shared_task |
bgneal@513 | 14 def send_mail(subject, message, from_email, recipient_list, **kwargs): |
bgneal@516 | 15 """ |
bgneal@516 | 16 A task to send mail via Django. |
bgneal@516 | 17 |
bgneal@516 | 18 """ |
bgneal@513 | 19 django.core.mail.send_mail(subject, message, from_email, recipient_list, |
bgneal@513 | 20 **kwargs) |
bgneal@516 | 21 |
bgneal@516 | 22 |
bgneal@750 | 23 @shared_task |
bgneal@516 | 24 def cleanup(): |
bgneal@516 | 25 """ |
bgneal@516 | 26 A task to perform site-wide cleanup actions. |
bgneal@516 | 27 |
bgneal@516 | 28 """ |
bgneal@518 | 29 # These imports, when placed at the top of the module, caused all kinds of |
bgneal@518 | 30 # import problems when running on the production server (Python 2.5 and |
bgneal@518 | 31 # mod_wsgi). Moving them here worked around that problem. |
bgneal@518 | 32 |
bgneal@681 | 33 from django.contrib.sessions.management.commands import clearsessions |
bgneal@681 | 34 from forums.management.commands import forum_cleanup |
bgneal@518 | 35 |
bgneal@681 | 36 # Cleanup old sessions |
bgneal@516 | 37 |
bgneal@681 | 38 command = clearsessions.Command() |
bgneal@516 | 39 command.execute() |
bgneal@516 | 40 |
bgneal@516 | 41 # Execute our forum cleanup command to delete old last visit records. |
bgneal@516 | 42 |
bgneal@681 | 43 command = forum_cleanup.Command() |
bgneal@516 | 44 command.execute() |
bgneal@519 | 45 |
bgneal@519 | 46 |
bgneal@750 | 47 @shared_task |
bgneal@519 | 48 def max_users(): |
bgneal@519 | 49 """ |
bgneal@519 | 50 Run the periodic task to calculate the who's online max users/visitors |
bgneal@519 | 51 statistics. |
bgneal@519 | 52 |
bgneal@519 | 53 """ |
bgneal@519 | 54 core.whos_online.max_users() |