diff options
author | Adolfo Fitoria <fitoria@fitoria-laptop.(none)> | 2009-08-06 11:09:00 -0600 |
---|---|---|
committer | Adolfo Fitoria <fitoria@fitoria-laptop.(none)> | 2009-08-06 11:09:00 -0600 |
commit | 0b39716196977f9a368cfded6a1d05244ca724d0 (patch) | |
tree | fd1a31f04a866cab270a7c4ea846206782009823 /context.py | |
parent | 02409029d958cced911b3b18e025cf495656cb04 (diff) | |
parent | 8d5ef067c8c4e7de276d559af67417f5324f9171 (diff) | |
download | askbot-0b39716196977f9a368cfded6a1d05244ca724d0.tar.gz askbot-0b39716196977f9a368cfded6a1d05244ca724d0.tar.bz2 askbot-0b39716196977f9a368cfded6a1d05244ca724d0.zip |
Merge branch 'master' of git://github.com/evgenyfadeev/CNPROG into evgenyfadeev/master
Conflicts:
forum/auth.py
forum/models.py
forum/views.py
Diffstat (limited to 'context.py')
-rw-r--r-- | context.py | 35 |
1 files changed, 33 insertions, 2 deletions
@@ -1,9 +1,40 @@ from django.conf import settings def application_settings(context): - return { + my_settings = { 'APP_TITLE' : settings.APP_TITLE, 'APP_URL' : settings.APP_URL, 'APP_KEYWORDS' : settings.APP_KEYWORDS, 'APP_DESCRIPTION' : settings.APP_DESCRIPTION, - 'APP_INTRO' : settings.APP_INTRO + 'APP_INTRO' : settings.APP_INTRO, + 'EMAIL_VALIDATION': settings.EMAIL_VALIDATION, + 'LANGUAGE_CODE': settings.LANGUAGE_CODE, + 'GOOGLE_SITEMAP_CODE':settings.GOOGLE_SITEMAP_CODE, + 'GOOGLE_ANALYTICS_KEY':settings.GOOGLE_ANALYTICS_KEY, } + 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), + } |