annotate wiki/tasks.py @ 693:ad69236e8501

For issue #52, update many 3rd party Javascript libraries. Updated to jquery 1.10.2, jquery ui 1.10.3. This broke a lot of stuff. - Found a newer version of the jquery cycle all plugin (3.0.3). - Updated JPlayer to 2.4.0. - Updated to MarkItUp 1.1.14. This also required me to add multiline attributes set to true on various buttons in the markdown set. - As per a stackoverflow post, added some code to get multiline titles in a jQuery UI dialog. They removed that functionality but allow you to put it back. Tweaked the MarkItUp preview CSS to show blockquotes in italic. Did not update TinyMCE at this time. I'm not using the JQuery version and this version appears to work ok for now. What I should do is make a repo for MarkItUp and do a vendor branch thing so I don't have to futz around diffing directories to figure out if I'll lose changes when I update.
author Brian Neal <bgneal@gmail.com>
date Wed, 04 Sep 2013 19:55:20 -0500
parents a4300639c6e7
children aeafbf3ecebf
rev   line source
bgneal@627 1 """
bgneal@627 2 Celery tasks for the wiki app.
bgneal@627 3
bgneal@627 4 """
bgneal@627 5 import datetime
bgneal@627 6 import logging
bgneal@627 7 import time
bgneal@627 8
bgneal@627 9 from celery.task import task
bgneal@627 10 from django.conf import settings
bgneal@627 11 import redis
bgneal@627 12
bgneal@627 13 from core.services import get_redis_connection
bgneal@627 14
bgneal@627 15
bgneal@627 16 logger = logging.getLogger(__name__)
bgneal@627 17
bgneal@627 18
bgneal@627 19 @task
bgneal@627 20 def expire_cookies():
bgneal@627 21 """
bgneal@627 22 Periodically run this task to remove expired cookies from the Redis set
bgneal@627 23 that is shared between this Django application & the MoinMoin wiki for
bgneal@627 24 authentication.
bgneal@627 25
bgneal@627 26 """
bgneal@627 27 now = datetime.datetime.utcnow()
bgneal@627 28 cutoff = now - datetime.timedelta(seconds=settings.WIKI_COOKIE_AGE)
bgneal@627 29 min_score = time.mktime(cutoff.utctimetuple())
bgneal@627 30
bgneal@627 31 conn = get_redis_connection()
bgneal@627 32
bgneal@627 33 set_name = settings.WIKI_REDIS_SET
bgneal@627 34 try:
bgneal@627 35 count = conn.zcard(set_name)
bgneal@627 36 except redis.RedisError:
bgneal@627 37 logger.error("Error getting zcard")
bgneal@627 38 return
bgneal@627 39
bgneal@627 40 try:
bgneal@627 41 removed = conn.zremrangebyscore(set_name, 0.0, min_score)
bgneal@627 42 except redis.RedisError:
bgneal@627 43 logger.error("Error removing by score")
bgneal@627 44 return
bgneal@627 45
bgneal@627 46 total = count - removed
bgneal@627 47 logger.info("Expire wiki cookies: removed %d, total is now %d",
bgneal@627 48 removed, total)