diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-03-27 11:38:06 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-03-27 11:38:06 -0400 |
commit | 9413c12d2126d4f86f2340e458226e72c0d4ecec (patch) | |
tree | b8c6cb667db07cb0247c07a3e09c222f412d6a99 /forum/context.py | |
parent | c50f61d34bf8b5431e8557a48b81a57026b3f0da (diff) | |
parent | 5c483bace8ac3066b88f2ce7ecb8c95a34aea07d (diff) | |
download | askbot-9413c12d2126d4f86f2340e458226e72c0d4ecec.tar.gz askbot-9413c12d2126d4f86f2340e458226e72c0d4ecec.tar.bz2 askbot-9413c12d2126d4f86f2340e458226e72c0d4ecec.zip |
intermediate commit after merge
Diffstat (limited to 'forum/context.py')
-rw-r--r-- | forum/context.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/forum/context.py b/forum/context.py new file mode 100644 index 00000000..905d24dd --- /dev/null +++ b/forum/context.py @@ -0,0 +1,46 @@ +from django.conf import settings +def application_settings(context): + my_settings = { + 'APP_TITLE' : settings.APP_TITLE, + 'APP_SHORT_NAME' : settings.APP_SHORT_NAME, + 'APP_URL' : settings.APP_URL, + 'APP_KEYWORDS' : settings.APP_KEYWORDS, + 'APP_DESCRIPTION' : settings.APP_DESCRIPTION, + 'APP_INTRO' : settings.APP_INTRO, + 'EMAIL_VALIDATION': settings.EMAIL_VALIDATION, + 'FEEDBACK_SITE_URL': settings.FEEDBACK_SITE_URL, + 'FORUM_SCRIPT_ALIAS': settings.FORUM_SCRIPT_ALIAS, + 'LANGUAGE_CODE': settings.LANGUAGE_CODE, + 'GOOGLE_SITEMAP_CODE':settings.GOOGLE_SITEMAP_CODE, + 'GOOGLE_ANALYTICS_KEY':settings.GOOGLE_ANALYTICS_KEY, + 'WIKI_ON':settings.WIKI_ON, + 'RESOURCE_REVISION':settings.RESOURCE_REVISION, + 'OSQA_SKIN':settings.OSQA_DEFAULT_SKIN, + } + 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), + } |