import logging
from urllib import urlencode
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
import logging
from urllib import urlencode
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.utils.encoding import smart_unicode
from django.utils.translation import ungettext, ugettext as _
from django.utils.encoding import smart_unicode
from django.utils.translation import ungettext, ugettext as _
-from django.http import HttpResponse, HttpResponseRedirect, Http404
+from django.http import (HttpResponse, HttpResponseRedirect, Http404,
+ HttpResponseBadRequest)
from forum.models import *
from forum.utils.decorators import ajax_login_required
from forum.actions import *
from forum.models import *
from forum.utils.decorators import ajax_login_required
from forum.actions import *
@decorate.withfn(command)
def vote_post(request, id, vote_type):
@decorate.withfn(command)
def vote_post(request, id, vote_type):
raise AnonymousNotAllowedException(_('accept answers'))
node = get_object_or_404(Node, id=id)
raise AnonymousNotAllowedException(_('accept answers'))
node = get_object_or_404(Node, id=id)
# Redirect URL should include additional get parameters that might have been attached
redirect_url = answer.parent.get_absolute_url() + "?accepted_answer=true&%s" % smart_unicode(urlencode(request.GET))
# Redirect URL should include additional get parameters that might have been attached
redirect_url = answer.parent.get_absolute_url() + "?accepted_answer=true&%s" % smart_unicode(urlencode(request.GET))
tag_output = ''
for tag in possible_tags:
tag_output += "%s|%s|%s\n" % (tag.id, tag.name, tag.used_count)
tag_output = ''
for tag in possible_tags:
tag_output += "%s|%s|%s\n" % (tag.id, tag.name, tag.used_count)
for user in possible_users:
output += ("%s|%s|%s\n" % (user.id, user.decorated_name, user.reputation))
for user in possible_users:
output += ("%s|%s|%s\n" % (user.id, user.decorated_name, user.reputation))
def related_questions(request):
if request.POST and request.POST.get('title', None):
def related_questions(request):
if request.POST and request.POST.get('title', None):
if can_rank and isinstance(can_rank, basestring):
questions = questions.order_by(can_rank)
if can_rank and isinstance(can_rank, basestring):
questions = questions.order_by(can_rank)
[dict(title=q.title, url=q.get_absolute_url(), score=q.score, summary=q.summary)
[dict(title=q.title, url=q.get_absolute_url(), score=q.score, summary=q.summary)
AwardPointsAction(user=request.user, node=answer, extra=extra).save(data=dict(value=points, affected=awarded_user))
return { 'message' : _("You have awarded %(awarded_user)s with %(points)d points") % {'awarded_user' : awarded_user, 'points' : points} }
AwardPointsAction(user=request.user, node=answer, extra=extra).save(data=dict(value=points, affected=awarded_user))
return { 'message' : _("You have awarded %(awarded_user)s with %(points)d points") % {'awarded_user' : awarded_user, 'points' : points} }