]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/views/users.py
fixes osqa-54: The user was not being informed that they were trying to submit a...
[osqa.git] / forum / views / users.py
index 227cdf603f140aabb0a6aa0385b68b7c4b3094c3..543d5c79b47589330b7474113729372e1ac53aed 100644 (file)
@@ -16,6 +16,7 @@ from django.core.urlresolvers import reverse
 from forum.forms import *\r
 from forum.utils.html import sanitize_html\r
 from forum.authentication import user_updated\r
+from datetime import date\r
 import decorators\r
 \r
 import time\r
@@ -115,7 +116,7 @@ def edit_user(request, id):
             user.website = sanitize_html(form.cleaned_data['website'])\r
             user.location = sanitize_html(form.cleaned_data['city'])\r
             user.date_of_birth = sanitize_html(form.cleaned_data['birthday'])\r
-            if len(user.date_of_birth) == 0:\r
+            if user.date_of_birth == "None":\r
                 user.date_of_birth = '1900-01-01'\r
             user.about = sanitize_html(form.cleaned_data['about'])\r
 \r
@@ -134,10 +135,13 @@ def edit_user(request, id):
 \r
 \r
 \r
-def user_view(template, tab_name, tab_description, page_title):\r
+def user_view(template, tab_name, tab_description, page_title, private=False):\r
     def decorator(fn):\r
         def decorated(request, id, slug=None):\r
-            context = fn(request, get_object_or_404(User, id=id))\r
+            user = get_object_or_404(User, id=id)\r
+            if private and not user == request.user:\r
+                return HttpResponseForbidden()\r
+            context = fn(request, user)\r
             context.update({\r
                 "tab_name" : tab_name,\r
                 "tab_description" : tab_description,\r
@@ -192,7 +196,7 @@ def user_recent(request, user):
     return {"view_user" : user, "activities" : activities}\r
 \r
 \r
-@user_view('users/votes.html', 'votes', _('user vote record'), _('profile - votes'))\r
+@user_view('users/votes.html', 'votes', _('user vote record'), _('profile - votes'), True)\r
 def user_votes(request, user):\r
     votes = user.votes.exclude(node__deleted=True).order_by('-voted_at')[:USERS_PAGE_SIZE]\r
 \r
@@ -210,13 +214,13 @@ def user_reputation(request, user):
 \r
     return {"view_user": user, "reputation": reputation, "graph_data": graph_data}\r
 \r
-@user_view('users/questions.html', 'favorites', _('favorite questions'),  _('profile - favorite questions'))\r
+@user_view('users/questions.html', 'favorites', _('favorite questions'),  _('profile - favorite questions'), True)\r
 def user_favorites(request, user):\r
     questions = user.favorite_questions.filter(deleted=False)\r
 \r
     return {"questions" : questions, "view_user" : user}\r
 \r
-@user_view('users/subscriptions.html', 'subscriptions', _('subscription settings'), _('profile - subscriptions'))\r
+@user_view('users/subscriptions.html', 'subscriptions', _('subscription settings'), _('profile - subscriptions'), True)\r
 def user_subscriptions(request, user):\r
     if request.method == 'POST':\r
         form = SubscriptionSettingsForm(request.POST)\r