]> git.openstreetmap.org Git - osqa.git/blob - forum/context.py
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@244 0cfe37f9-358a-4d5e-be75-b63607...
[osqa.git] / forum / context.py
1 from forum import settings
2 from django.conf import settings as djsettings
3
4 def application_settings(context):
5     my_settings = {
6         'APP_TITLE' : settings.APP_TITLE,
7         'APP_SHORT_NAME' : settings.APP_SHORT_NAME,
8         'SHOW_WELCOME_BOX' : settings.SHOW_WELCOME_BOX,
9         'APP_URL'   : settings.APP_URL,
10         'APP_KEYWORDS' : settings.APP_KEYWORDS,
11         'APP_DESCRIPTION' : settings.APP_DESCRIPTION,
12         'APP_INTRO' : settings.APP_INTRO,
13         'APP_LOGO' : settings.APP_LOGO,
14         'EMAIL_VALIDATION': 'off',
15         'FEEDBACK_SITE_URL': settings.FEEDBACK_SITE_URL,
16         'FORUM_SCRIPT_ALIAS': djsettings.FORUM_SCRIPT_ALIAS,
17         'LANGUAGE_CODE': djsettings.LANGUAGE_CODE,
18         'GOOGLE_SITEMAP_CODE':settings.GOOGLE_SITEMAP_CODE,
19         'GOOGLE_ANALYTICS_KEY':settings.GOOGLE_ANALYTICS_KEY,
20         'WIKI_ON':settings.WIKI_ON,
21         'OSQA_SKIN':djsettings.OSQA_DEFAULT_SKIN,
22         'APP_FAVICON':settings.APP_FAVICON,
23         'OSQA_VERSION': settings.OSQA_VERSION,
24         'ADMIN_MEDIA_PREFIX': djsettings.ADMIN_MEDIA_PREFIX,
25         'SVN_REVISION': settings.SVN_REVISION,
26         }
27     return {'settings':my_settings}
28
29 def auth_processor(request):
30     """
31     Returns context variables required by apps that use Django's authentication
32     system.
33
34     If there is no 'user' attribute in the request, uses AnonymousUser (from
35     django.contrib.auth).
36     """
37     if hasattr(request, 'user'):
38         user = request.user
39         if user.is_authenticated():
40             messages = user.message_set.all()
41         else:
42             messages = None
43     else:
44         from django.contrib.auth.models import AnonymousUser
45         user = AnonymousUser()
46         messages = None
47
48     from django.core.context_processors import PermWrapper
49     return {
50         'user': user,
51         'messages': messages,
52         'perms': PermWrapper(user),
53     }