From 0cf194935edb17d2c9288e4c4e5344a1775bcb5d Mon Sep 17 00:00:00 2001 From: hernani Date: Tue, 25 May 2010 10:29:24 +0000 Subject: [PATCH] Fixing some encoding/decoding errors, including the akismate module, and fixed the 500 on empty search. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@324 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/skins/default/templates/ask.html | 2 +- forum/skins/default/templates/search.html | 25 +++++++++++++++++++++++ forum/views/decorators.py | 2 +- forum_modules/akismet/startup.py | 7 ++++--- 4 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 forum/skins/default/templates/search.html diff --git a/forum/skins/default/templates/ask.html b/forum/skins/default/templates/ask.html index 8745331..5c12c86 100644 --- a/forum/skins/default/templates/ask.html +++ b/forum/skins/default/templates/ask.html @@ -68,7 +68,7 @@
-
+ {% if not request.user.is_authenticated %}

{% trans "login to post question info" %}

diff --git a/forum/skins/default/templates/search.html b/forum/skins/default/templates/search.html new file mode 100644 index 0000000..e413abd --- /dev/null +++ b/forum/skins/default/templates/search.html @@ -0,0 +1,25 @@ +{% extends "base_content.html" %} + +{% load i18n %} + +{% block content %} +
+ {% blocktrans with settings.APP_SHORT_NAME as app_name %} + Search in {{ app_name }} + {% endblocktrans %} +
+
+ +
+ + +
+
+ + + +
+ +
+{% endblock %} \ No newline at end of file diff --git a/forum/views/decorators.py b/forum/views/decorators.py index f9929ff..37413d2 100644 --- a/forum/views/decorators.py +++ b/forum/views/decorators.py @@ -81,7 +81,7 @@ def command(func): if isinstance(e, CommandException): response = { 'success': False, - 'error_message': str(e) + 'error_message': e.message } else: logging.error("%s: %s" % (func.__name__, str(e))) diff --git a/forum_modules/akismet/startup.py b/forum_modules/akismet/startup.py index 0688746..1e9e731 100644 --- a/forum_modules/akismet/startup.py +++ b/forum_modules/akismet/startup.py @@ -1,6 +1,7 @@ from django.utils.translation import ugettext as _ from django.http import HttpResponse, HttpResponseRedirect from django.utils import simplejson +from django.utils.encoding import smart_str from django.shortcuts import render_to_response from forum.modules.decorators import decorate from forum import views @@ -15,8 +16,8 @@ import settings def check_spam(param, comment_type): def wrapper(origin, request, *args, **kwargs): if (request.POST and request.POST.get(param, None) and WORDPRESS_API_KEY) and (not request.user.is_authenticated() - or not (request.user.is_staff and request.user.is_superuser and request.user.reputation >= REP_FOR_NO_SPAM_CHECK)): - comment = request.POST[param] + or not (request.user.is_staff or request.user.is_superuser or request.user.reputation >= REP_FOR_NO_SPAM_CHECK)): + comment = smart_str(request.POST[param]) data = { "user_ip":request.META["REMOTE_ADDR"], @@ -27,7 +28,7 @@ def check_spam(param, comment_type): if request.user.is_authenticated(): data.update({ - "comment_author":request.user.username, + "comment_author":smart_str(request.user.username), "comment_author_email":request.user.email, "comment_author_url":request.user.website, }) -- 2.39.5