]> git.openstreetmap.org Git - osqa.git/blob - forum/context.py
Fix OSQA 100, show revision number in the powered bi osqa link, in title attribute.
[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         'APP_URL'   : settings.APP_URL,
9         'APP_KEYWORDS' : settings.APP_KEYWORDS,
10         'APP_DESCRIPTION' : settings.APP_DESCRIPTION,
11         'APP_INTRO' : settings.APP_INTRO,
12         'APP_LOGO' : settings.APP_LOGO,
13         'EMAIL_VALIDATION': 'off',
14         'FEEDBACK_SITE_URL': settings.FEEDBACK_SITE_URL,
15         'FORUM_SCRIPT_ALIAS': djsettings.FORUM_SCRIPT_ALIAS,
16         'LANGUAGE_CODE': djsettings.LANGUAGE_CODE,
17         'GOOGLE_SITEMAP_CODE':settings.GOOGLE_SITEMAP_CODE,
18         'GOOGLE_ANALYTICS_KEY':settings.GOOGLE_ANALYTICS_KEY,
19         'WIKI_ON':settings.WIKI_ON,
20         'OSQA_SKIN':djsettings.OSQA_DEFAULT_SKIN,
21         'APP_FAVICON':settings.APP_FAVICON,
22         'OSQA_VERSION': settings.OSQA_VERSION,
23         'ADMIN_MEDIA_PREFIX': djsettings.ADMIN_MEDIA_PREFIX,
24         'SVN_REVISION': settings.SVN_REVISION,
25         }
26     return {'settings':my_settings}
27
28 def auth_processor(request):
29     """
30     Returns context variables required by apps that use Django's authentication
31     system.
32
33     If there is no 'user' attribute in the request, uses AnonymousUser (from
34     django.contrib.auth).
35     """
36     if hasattr(request, 'user'):
37         user = request.user
38         if user.is_authenticated():
39             messages = user.message_set.all()
40         else:
41             messages = None
42     else:
43         from django.contrib.auth.models import AnonymousUser
44         user = AnonymousUser()
45         messages = None
46
47     from django.core.context_processors import PermWrapper
48     return {
49         'user': user,
50         'messages': messages,
51         'perms': PermWrapper(user),
52     }