]> git.openstreetmap.org Git - osqa.git/blob - forum/context.py
Adds the hability to create custom css. Fixes a small issue with admin area forms.
[osqa.git] / forum / context.py
1 from forum import settings
2
3 def application_settings(context):
4     return {'settings': settings}
5
6 def auth_processor(request):
7     """
8     Returns context variables required by apps that use Django's authentication
9     system.
10
11     If there is no 'user' attribute in the request, uses AnonymousUser (from
12     django.contrib.auth).
13     """
14     if hasattr(request, 'user'):
15         user = request.user
16         if user.is_authenticated():
17             messages = user.message_set.all()
18         else:
19             messages = None
20     else:
21         from django.contrib.auth.models import AnonymousUser
22         user = AnonymousUser()
23         messages = None
24
25     from django.core.context_processors import PermWrapper
26     return {
27         'user': user,
28         'messages': messages,
29         'perms': PermWrapper(user),
30     }