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
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
\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
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
\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