]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/views/decorators.py
hide the navigation links in the administration if the currently authenticated user...
[osqa.git] / forum / views / decorators.py
index 758b6876294907998de3fec82cee22fabfef30b0..20eb45cbfb544c3dd76d0da8b5ef05f1c7324d81 100644 (file)
@@ -6,11 +6,22 @@ from django.core.urlresolvers import reverse
 from django.template import RequestContext\r
 from django.utils.translation import ungettext, ugettext as _\r
 from forum.modules import ui, decorate\r
+from datetime import datetime, date\r
+from forum.settings import ONLINE_USERS\r
 import logging\r
 \r
+def login_required(func, request, *args, **kwargs):\r
+    if not request.user.is_authenticated():\r
+        return HttpResponseRedirect(reverse('auth_signin'))\r
+    else:\r
+        return func(request, *args, **kwargs)\r
+\r
 def render(template=None, tab=None, tab_title='', weight=500, tabbed=True):\r
     def decorator(func):        \r
         def decorated(context, request, *args, **kwargs):\r
+            if request.user.is_authenticated():\r
+                ONLINE_USERS[request.user] = datetime.now()\r
+\r
             if isinstance(context, HttpResponse):\r
                 return context\r
 \r