]> git.openstreetmap.org Git - osqa.git/blob - forum/context.py
Minor tweaks to default user sidebar content wording and block display order.
[osqa.git] / forum / context.py
1 from forum import settings
2 from django.conf import settings as djsettings
3 def application_settings(context):
4     my_settings = {
5         'APP_TITLE' : settings.APP_TITLE,
6         'APP_SHORT_NAME' : settings.APP_SHORT_NAME,
7         'APP_URL'   : settings.APP_URL,
8         'APP_KEYWORDS' : settings.APP_KEYWORDS,
9         'APP_DESCRIPTION' : settings.APP_DESCRIPTION,
10         'APP_INTRO' : settings.APP_INTRO,
11         'APP_LOGO' : settings.APP_LOGO,
12         'EMAIL_VALIDATION': 'off',
13         'FEEDBACK_SITE_URL': settings.FEEDBACK_SITE_URL,
14         'FORUM_SCRIPT_ALIAS': djsettings.FORUM_SCRIPT_ALIAS,
15         'LANGUAGE_CODE': djsettings.LANGUAGE_CODE,
16         'GOOGLE_SITEMAP_CODE':settings.GOOGLE_SITEMAP_CODE,
17         'GOOGLE_ANALYTICS_KEY':settings.GOOGLE_ANALYTICS_KEY,
18         'WIKI_ON':settings.WIKI_ON,
19         'OSQA_SKIN':djsettings.OSQA_DEFAULT_SKIN,
20         'APP_FAVICON':settings.APP_FAVICON,
21         }
22     return {'settings':my_settings}
23
24 def auth_processor(request):
25     """
26     Returns context variables required by apps that use Django's authentication
27     system.
28
29     If there is no 'user' attribute in the request, uses AnonymousUser (from
30     django.contrib.auth).
31     """
32     if hasattr(request, 'user'):
33         user = request.user
34         if user.is_authenticated():
35             messages = user.message_set.all()
36         else:
37             messages = None
38     else:
39         from django.contrib.auth.models import AnonymousUser
40         user = AnonymousUser()
41         messages = None
42
43     from django.core.context_processors import PermWrapper
44     return {
45         'user': user,
46         'messages': messages,
47         'perms': PermWrapper(user),
48     }