diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-06-13 01:40:01 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-06-13 01:40:01 -0400 |
commit | 9e9f6b0a71fca40b7a118acb4db37e45609fb5b8 (patch) | |
tree | 9a9ab81940a08bfa53c485eb33dc1eda07133ff2 /askbot/context.py | |
parent | 3b6143c0ebe0fbfbcc05bd61d9c34906d55f69a7 (diff) | |
download | askbot-9e9f6b0a71fca40b7a118acb4db37e45609fb5b8.tar.gz askbot-9e9f6b0a71fca40b7a118acb4db37e45609fb5b8.tar.bz2 askbot-9e9f6b0a71fca40b7a118acb4db37e45609fb5b8.zip |
renamed main django app from forum to askbot
Diffstat (limited to 'askbot/context.py')
-rw-r--r-- | askbot/context.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/askbot/context.py b/askbot/context.py new file mode 100644 index 00000000..3d246dd2 --- /dev/null +++ b/askbot/context.py @@ -0,0 +1,34 @@ +from django.conf import settings +from askbot.conf import settings as askbot_settings +def application_settings(context): + my_settings = askbot_settings.as_dict() + my_settings['LANGUAGE_CODE'] = settings.LANGUAGE_CODE + my_settings['FORUM_SCRIPT_ALIAS'] = settings.FORUM_SCRIPT_ALIAS + #print '\n'.join(sorted(my_settings.keys())) + return {'settings':my_settings} + +def auth_processor(request): + """ + Returns context variables required by apps that use Django's authentication + system. + + If there is no 'user' attribute in the request, uses AnonymousUser (from + django.contrib.auth). + """ + if hasattr(request, 'user'): + user = request.user + if user.is_authenticated(): + messages = user.message_set.all() + else: + messages = None + else: + from django.contrib.auth.models import AnonymousUser + user = AnonymousUser() + messages = None + + from django.core.context_processors import PermWrapper + return { + 'user': user, + 'messages': messages, + 'perms': PermWrapper(user), + } |