]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/views/users.py
take another approach to the settings import from modules
[osqa.git] / forum / views / users.py
index 6686a265d5f15c27e842aee008aa6ad12404cbfb..6eb9baaed1d74da13ee2cf8d4b0d9d89bc03c83a 100644 (file)
@@ -255,8 +255,14 @@ def suspend(request, id):
 \r
 def user_view(template, tab_name, tab_title, tab_description, private=False, tabbed=True, render_to=None, weight=500):\r
     def decorator(fn):\r
-        def params(request, id, slug=None):\r
-            user = get_object_or_404(User, id=id)\r
+        def params(request, id=None, slug=None):\r
+            # Get the user object by id if the id parameter has been passed\r
+            if id is not None:\r
+                user = get_object_or_404(User, id=id)\r
+            # ...or by slug if the slug has been given\r
+            elif slug is not None:\r
+                user = get_object_or_404(User, username=slug)\r
+\r
             if private and not (user == request.user or request.user.is_superuser):\r
                 raise ReturnImediatelyException(HttpResponseUnauthorized(request))\r
 \r