From: hernani Date: Thu, 21 Oct 2010 14:29:28 +0000 (+0000) Subject: Small tweaks. X-Git-Tag: live~523 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/f6b59a872054fb7e4c171cbdffb5470d55c9025e Small tweaks. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@611 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/views/readers.py b/forum/views/readers.py index b61e3e9..38c3c9f 100644 --- a/forum/views/readers.py +++ b/forum/views/readers.py @@ -243,7 +243,7 @@ def update_question_view_times(request, question): request.session['last_seen_in_question'][question.id] = datetime.datetime.now() -def match_question_slug(slug): +def match_question_slug(id, slug): slug_words = slug.split('-') qs = Question.objects.filter(title__istartswith=slug_words[0]) @@ -287,7 +287,7 @@ def question(request, id, slug='', answer=None): question = Question.objects.get(id=id) except: if slug: - question = match_question_slug(slug) + question = match_question_slug(id, slug) if question is not None: return HttpResponseRedirect(question.get_absolute_url()) diff --git a/forum_modules/pgfulltext/pg_fts_install.sql b/forum_modules/pgfulltext/pg_fts_install.sql index e08e22b..c046870 100644 --- a/forum_modules/pgfulltext/pg_fts_install.sql +++ b/forum_modules/pgfulltext/pg_fts_install.sql @@ -116,5 +116,14 @@ begin end $$ LANGUAGE plpgsql; -ALTER table forum_rootnode_doc DISABLE TRIGGER ALL; -UPDATE forum_noderevision SET id = id WHERE TRUE; +CREATE OR REPLACE FUNCTION public.rebuild_index() RETURNS VOID as $$ + DECLARE + r integer; + BEGIN + FOR r IN SELECT active_revision_id FROM forum_node WHERE node_type = 'question' LOOP + UPDATE forum_noderevision SET id = id WHERE id = r; + END LOOP; + END +$$ LANGUAGE 'plpgsql'; + +SELECT rebuild_index(); diff --git a/forum_modules/pgfulltext/startup.py b/forum_modules/pgfulltext/startup.py index cbb4138..d45019f 100644 --- a/forum_modules/pgfulltext/startup.py +++ b/forum_modules/pgfulltext/startup.py @@ -3,7 +3,7 @@ from forum.models import KeyValue from django.db import connection, transaction import settings -VERSION = 10 +VERSION = 11 if int(settings.PG_FTSTRIGGERS_VERSION) < VERSION: f = open(os.path.join(os.path.dirname(__file__), 'pg_fts_install.sql'), 'r')