X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/ca88510e4dd14206f623cababfda1e8a9daf70d4..d806c871a8829172d645cea7d0cf5896cf5a37d4:/forum/views/users.py?ds=inline diff --git a/forum/views/users.py b/forum/views/users.py index 6818974..7202d39 100644 --- a/forum/views/users.py +++ b/forum/views/users.py @@ -15,7 +15,7 @@ from django.utils import simplejson from django.core.urlresolvers import reverse from forum.forms import * from forum.utils.html import sanitize_html -from datetime import date +from datetime import datetime, date import decorators from forum.actions import EditProfileAction, FavoriteAction, BonusRepAction @@ -96,9 +96,9 @@ def edit_user(request, id): user.real_name = sanitize_html(form.cleaned_data['realname']) user.website = sanitize_html(form.cleaned_data['website']) user.location = sanitize_html(form.cleaned_data['city']) - user.date_of_birth = sanitize_html(form.cleaned_data['birthday']) + user.date_of_birth = form.cleaned_data['birthday'] if user.date_of_birth == "None": - user.date_of_birth = '1900-01-01' + user.date_of_birth = datetime(1900, 1, 1, 0, 0) user.about = sanitize_html(form.cleaned_data['about']) user.save() @@ -174,8 +174,8 @@ def user_view(template, tab_name, tab_description, page_title, private=False): @user_view('users/stats.html', 'stats', _('user profile'), _('user overview')) def user_stats(request, user): - questions = Question.objects.filter(author=user, deleted=None).order_by('-added_at') - answers = Answer.objects.filter(author=user, deleted=None).order_by('-added_at') + questions = Question.objects.filter_state(deleted=False).filter(author=user).order_by('-added_at') + answers = Answer.objects.filter_state(deleted=False).filter(author=user).order_by('-added_at') up_votes = user.vote_up_count down_votes = user.vote_down_count @@ -211,7 +211,7 @@ def user_recent(request, user): @user_view('users/votes.html', 'votes', _('user vote record'), _('votes'), True) def user_votes(request, user): - votes = user.votes.filter(node__deleted=None, node__node_type__in=("question", "answer")).order_by('-voted_at')[:USERS_PAGE_SIZE] + votes = user.votes.exclude(node__state_string__contains="(deleted").filter(node__node_type__in=("question", "answer")).order_by('-voted_at')[:USERS_PAGE_SIZE] return {"view_user" : user, "votes" : votes} @@ -227,11 +227,13 @@ def user_reputation(request, user): for i in range(len(values)) ]) - return {"view_user": user, "reputation": reversed(rep), "graph_data": graph_data} + rep = user.reputes.filter(action__canceled=False).order_by('-date')[0:20] + + return {"view_user": user, "reputation": rep, "graph_data": graph_data} @user_view('users/questions.html', 'favorites', _('favorite questions'), _('favorite questions')) def user_favorites(request, user): - favorites = FavoriteAction.objects.filter(user=user) + favorites = FavoriteAction.objects.filter(canceled=False, user=user) return {"favorites" : favorites, "view_user" : user}