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