From: jordan Date: Wed, 7 Dec 2011 21:51:23 +0000 (+0000) Subject: adding support for focusing answers when linking to them X-Git-Tag: live~109 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/4066b758e1b919f2d5e4f8ff4e6abea65fec6777 adding support for focusing answers when linking to them git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1208 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/skins/default/media/style/style.css b/forum/skins/default/media/style/style.css index 58bc23a..883c891 100644 --- a/forum/skins/default/media/style/style.css +++ b/forum/skins/default/media/style/style.css @@ -795,6 +795,10 @@ div.question-body p, div.answer-body p { color: #6B2B28; } +.focusedAnswer { + background: #FFFFCC; +} + .tagsList { list-style-type: none; margin: 0; diff --git a/forum/skins/default/templates/question.html b/forum/skins/default/templates/question.html index aff082b..2172da9 100644 --- a/forum/skins/default/templates/question.html +++ b/forum/skins/default/templates/question.html @@ -153,7 +153,7 @@ {% for answer in answers.paginator.page %} -
+
diff --git a/forum/views/readers.py b/forum/views/readers.py index 99233e8..3de8c41 100644 --- a/forum/views/readers.py +++ b/forum/views/readers.py @@ -324,8 +324,8 @@ def answer_redirect(request, answer): if page == 0: page = 1 - return HttpResponsePermanentRedirect("%s?%s=%s#%s" % ( - answer.question.get_absolute_url(), _('page'), page, answer.id)) + return HttpResponseRedirect("%s?%s=%s&focusedAnswerId=%s#%s" % ( + answer.question.get_absolute_url(), _('page'), page, answer.id, answer.id)) @decorators.render("question.html", 'questions') def question(request, id, slug='', answer=None): @@ -375,6 +375,10 @@ def question(request, id, slug='', answer=None): subscription = False else: subscription = False + try: + focused_answer_id = int(request.GET.get("focusedAnswerId", None)) + except TypeError, ValueError: + focused_answer_id = None return pagination.paginated(request, ('answers', AnswerPaginatorContext()), { "question" : question, @@ -383,6 +387,7 @@ def question(request, id, slug='', answer=None): "similar_questions" : question.get_related_questions(), "subscription": subscription, "embed_youtube_videos" : settings.EMBED_YOUTUBE_VIDEOS, + "focused_answer_id" : focused_answer_id })