annotate core/tasks.py @ 686:216f06267e2d

For Django 1.5: Remove all references to django.contrib.markup. This amounted to deleting some old templates, removing the app from INSTALLED_APPS, and doing some cleanup in core.markup.
author Brian Neal <bgneal@gmail.com>
date Sat, 24 Aug 2013 20:08:12 -0500
parents 53a56d19568c
children aeafbf3ecebf
rev   line source
bgneal@513 1 """
bgneal@513 2 Celery tasks for the core application.
bgneal@513 3
bgneal@513 4 """
bgneal@513 5 from celery.task import task
bgneal@513 6 import django.core.mail
bgneal@513 7
bgneal@519 8 import core.whos_online
bgneal@519 9
bgneal@513 10
bgneal@513 11 @task
bgneal@513 12 def add(x, y):
bgneal@516 13 """
bgneal@516 14 It is useful to have a test task laying around. This is it.
bgneal@516 15
bgneal@516 16 """
bgneal@513 17 return x + y
bgneal@513 18
bgneal@516 19
bgneal@513 20 @task
bgneal@513 21 def send_mail(subject, message, from_email, recipient_list, **kwargs):
bgneal@516 22 """
bgneal@516 23 A task to send mail via Django.
bgneal@516 24
bgneal@516 25 """
bgneal@513 26 django.core.mail.send_mail(subject, message, from_email, recipient_list,
bgneal@513 27 **kwargs)
bgneal@516 28
bgneal@516 29
bgneal@516 30 @task
bgneal@516 31 def cleanup():
bgneal@516 32 """
bgneal@516 33 A task to perform site-wide cleanup actions.
bgneal@516 34
bgneal@516 35 """
bgneal@518 36 # These imports, when placed at the top of the module, caused all kinds of
bgneal@518 37 # import problems when running on the production server (Python 2.5 and
bgneal@518 38 # mod_wsgi). Moving them here worked around that problem.
bgneal@518 39
bgneal@681 40 from django.contrib.sessions.management.commands import clearsessions
bgneal@681 41 from forums.management.commands import forum_cleanup
bgneal@518 42
bgneal@681 43 # Cleanup old sessions
bgneal@516 44
bgneal@681 45 command = clearsessions.Command()
bgneal@516 46 command.execute()
bgneal@516 47
bgneal@516 48 # Execute our forum cleanup command to delete old last visit records.
bgneal@516 49
bgneal@681 50 command = forum_cleanup.Command()
bgneal@516 51 command.execute()
bgneal@519 52
bgneal@519 53
bgneal@519 54 @task
bgneal@519 55 def max_users():
bgneal@519 56 """
bgneal@519 57 Run the periodic task to calculate the who's online max users/visitors
bgneal@519 58 statistics.
bgneal@519 59
bgneal@519 60 """
bgneal@519 61 core.whos_online.max_users()