annotate wiki/signals.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 63603e931503
children
rev   line source
bgneal@626 1 """Signal handlers for wiki integration.
bgneal@626 2
bgneal@629 3 We are interested in hearing about users logging in and out, so we can create
bgneal@629 4 and destroy an external cookie to allow access to the wiki.
bgneal@629 5
bgneal@626 6 """
bgneal@626 7 import logging
bgneal@626 8
bgneal@626 9 from django.contrib.auth.signals import user_logged_in, user_logged_out
bgneal@626 10
bgneal@629 11 from wiki.constants import SESSION_SET_MEMBER
bgneal@626 12
bgneal@626 13 logger = logging.getLogger(__name__)
bgneal@626 14
bgneal@626 15
bgneal@626 16 def login_callback(sender, request, user, **kwargs):
bgneal@626 17 """Signal callback function for a user logging in.
bgneal@626 18
bgneal@626 19 Sets a flag for the middleware to create an external cookie.
bgneal@626 20
bgneal@626 21 """
bgneal@626 22 logger.info('User login: %s', user.username)
bgneal@626 23
bgneal@629 24 request.wiki_set_cookie = True
bgneal@626 25
bgneal@626 26
bgneal@626 27 def logout_callback(sender, request, user, **kwargs):
bgneal@626 28 """Signal callback function for a user logging in.
bgneal@626 29
bgneal@626 30 Sets a flag for the middleware to delete the external cookie.
bgneal@626 31
bgneal@627 32 Since the user is about to logout, her session will be wiped out after
bgneal@627 33 this function returns. This forces us to set an attribute on the request
bgneal@627 34 object so that the response middleware can delete the wiki's cookie.
bgneal@627 35
bgneal@626 36 """
bgneal@630 37 if user:
bgneal@630 38 logger.info('User logout: %s', user.username)
bgneal@626 39
bgneal@630 40 # Remember what Redis set member to delete by adding an attribute to the
bgneal@630 41 # request object:
bgneal@630 42 request.wiki_delete_cookie = request.session.get(SESSION_SET_MEMBER)
bgneal@626 43
bgneal@626 44
bgneal@626 45 user_logged_in.connect(login_callback, dispatch_uid='wiki.signals.login')
bgneal@626 46 user_logged_out.connect(logout_callback, dispatch_uid='wiki.signals.logout')