Exemplo n.º 1
0
    }
    paginator_context = functions.setup_paginator(paginator_data)

    #todo: maybe consolidate all activity in the thread
    #for the user into just one query?
    favorited = thread.has_favorite_by_user(request.user)

    is_cacheable = True
    if show_page != 1:
        is_cacheable = False
    elif show_comment_position > askbot_settings.MAX_COMMENTS_TO_SHOW:
        is_cacheable = False

    answer_form = AnswerForm(
        initial={
            'wiki': question_post.wiki and askbot_settings.WIKI_ON,
            'email_notify': thread.is_followed_by(request.user)
        })

    user_can_post_comment = (request.user.is_authenticated()
                             and request.user.can_post_comment())

    data = {
        'is_cacheable':
        False,  #is_cacheable, #temporary, until invalidation fix
        'long_time': const.LONG_TIME,  #"forever" caching
        'page_class': 'question-page',
        'active_tab': 'questions',
        'question': question_post,
        'thread': thread,
        'answer': answer_form,
Exemplo n.º 2
0
    favorited = question.has_favorite_by_user(request.user)
    if request.user.is_authenticated():
        question_vote = question.votes.select_related().filter(
            user=request.user)
    else:
        question_vote = None  #is this correct?
    if question_vote is not None and question_vote.count() > 0:
        question_vote = question_vote[0]

    data = {
        'page_class': 'question-page',
        'active_tab': 'questions',
        'question': question,
        'question_vote': question_vote,
        'question_comment_count': question.comments.count(),
        'answer': AnswerForm(question, request.user),
        'answers': page_objects.object_list,
        'user_answer_votes': user_answer_votes,
        'tags': question.tags.all(),
        'tab_id': answer_sort_method,
        'favorited': favorited,
        'similar_questions': question.get_similar_questions(),
        'language_code': translation.get_language(),
        'paginator_context': paginator_context,
        'show_post': show_post,
        'show_comment': show_comment,
        'comment_order_number': comment_order_number
    }
    return render_into_skin('question.html', data, request)

Exemplo n.º 3
0
    elif show_comment_position > askbot_settings.MAX_COMMENTS_TO_SHOW:
        is_cacheable = False

    initial = {
        'wiki': question_post.wiki and askbot_settings.WIKI_ON,
        'email_notify': thread.is_followed_by(request.user)
    }
    #maybe load draft
    if request.user.is_authenticated():
        #todo: refactor into methor on thread
        drafts = models.DraftAnswer.objects.filter(author=request.user,
                                                   thread=thread)
        if drafts.count() > 0:
            initial['text'] = drafts[0].text

    answer_form = AnswerForm(initial, user=request.user)

    user_can_post_comment = (request.user.is_authenticated()
                             and request.user.can_post_comment())

    user_already_gave_answer = False
    previous_answer = None
    if request.user.is_authenticated():
        if askbot_settings.LIMIT_ONE_ANSWER_PER_USER:
            for answer in answers:
                if answer.author == request.user:
                    user_already_gave_answer = True
                    previous_answer = answer
                    break

    data = {
Exemplo n.º 4
0
    elif show_comment_position > askbot_settings.MAX_COMMENTS_TO_SHOW:
        is_cacheable = False

    initial = {
        'wiki': question_post.wiki and askbot_settings.WIKI_ON,
        'email_notify': thread.is_followed_by(request.user)
    }
    #maybe load draft
    if request.user.is_authenticated():
        #todo: refactor into methor on thread
        drafts = models.DraftAnswer.objects.filter(author=request.user,
                                                   thread=thread)
        if drafts.count() > 0:
            initial['text'] = drafts[0].text

    answer_form = AnswerForm(initial)

    user_can_post_comment = (request.user.is_authenticated()
                             and request.user.can_post_comment())

    user_already_gave_answer = False
    previous_answer = None
    if request.user.is_authenticated():
        if askbot_settings.LIMIT_ONE_ANSWER_PER_USER:
            for answer in answers:
                if answer.author == request.user:
                    user_already_gave_answer = True
                    previous_answer = answer
                    break

    data = {