]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/views/readers.py
use latest jQuery version
[osqa.git] / forum / views / readers.py
index a16712e2164805193ca44d45adf4245adcc27b36..3de8c4148c4f4ebaf3fc2e9e509d8ccd3da839dd 100644 (file)
@@ -126,8 +126,14 @@ def tag(request, tag):
                          mark_safe(_(u'Questions Tagged With %(tag)s') % {'tag': tag}),
                          False)
 
                          mark_safe(_(u'Questions Tagged With %(tag)s') % {'tag': tag}),
                          False)
 
+    # If the return data type is not a dict just return it
+    if not isinstance(question_context, dict):
+        return question_context
+
+    question_context = dict(question_context)
+
     # Create the combined context
     # Create the combined context
-    context = dict(question_context, **tag_context)
+    context = dict(question_context.items() + tag_context.items())
 
     return context
 
 
     return context
 
@@ -166,7 +172,8 @@ def question_list(request, initial,
                   feed_url=None,
                   paginator_context=None,
                   feed_sort=('-added_at',),
                   feed_url=None,
                   paginator_context=None,
                   feed_sort=('-added_at',),
-                  feed_req_params_exclude=(_('page'), _('pagesize'), _('sort'))):
+                  feed_req_params_exclude=(_('page'), _('pagesize'), _('sort')),
+                  extra_context={}):
 
     questions = initial.filter_state(deleted=False)
 
 
     questions = initial.filter_state(deleted=False)
 
@@ -206,6 +213,7 @@ def question_list(request, initial,
         'tab' : 'questions',
         'feed_url': feed_url,
     }
         'tab' : 'questions',
         'feed_url': feed_url,
     }
+    context.update(extra_context)
 
     return pagination.paginated(request,
                                ('questions', paginator_context or QuestionListPaginatorContext()), context)
 
     return pagination.paginated(request,
                                ('questions', paginator_context or QuestionListPaginatorContext()), context)
@@ -316,8 +324,8 @@ def answer_redirect(request, answer):
     if page == 0:
         page = 1
 
     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):
 
 @decorators.render("question.html", 'questions')
 def question(request, id, slug='', answer=None):
@@ -367,6 +375,10 @@ def question(request, id, slug='', answer=None):
             subscription = False
     else:
         subscription = False
             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,
 
     return pagination.paginated(request, ('answers', AnswerPaginatorContext()), {
     "question" : question,
@@ -375,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,
     "similar_questions" : question.get_related_questions(),
     "subscription": subscription,
     "embed_youtube_videos" : settings.EMBED_YOUTUBE_VIDEOS,
+    "focused_answer_id" : focused_answer_id
     })
 
 
     })