def remove_external_provider(request, id):
association = get_object_or_404(AuthKeyUserAssociation, id=id)
if not association.user == request.user:
def remove_external_provider(request, id):
association = get_object_or_404(AuthKeyUserAssociation, id=id)
if not association.user == request.user:
- raise HttpResponseForbidden()
+ return HttpResponseForbidden()
request.user.message_set.create(message=_("You removed the association with %s") % association.provider)
association.delete()
return HttpResponseRedirect(reverse('user_authsettings'))
request.user.message_set.create(message=_("You removed the association with %s") % association.provider)
association.delete()
return HttpResponseRedirect(reverse('user_authsettings'))
-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
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
context.update({\r
"tab_name" : tab_name,\r
"tab_description" : tab_description,\r
return {"view_user" : user, "activities" : activities}\r
\r
\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
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
\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
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
def user_subscriptions(request, user):\r
if request.method == 'POST':\r
form = SubscriptionSettingsForm(request.POST)\r