예제 #1
0
파일: views.py 프로젝트: nzee/Django-Ghalib
def question_detail(request, question_id, **kwargs):

    group, bridge = group_and_bridge(kwargs)

    questions = Question.objects.all()

    if group:
        questions = group.content_objects(questions)
    else:
        questions = questions.filter(group_content_type=None)

    question = get_object_or_404(questions, pk=question_id)
    responses = question.responses.order_by("-score", "created", "id")

    if question.user == request.user:
        is_me = True
    else:
        is_me = False

    if request.method == "POST":
        add_response_form = AddResponseForm(request.POST)

        if add_response_form.is_valid():
            response = add_response_form.save(commit=False)
            response.question = question
            response.user = request.user
            response.save()
            return HttpResponseRedirect(response.get_absolute_url())
    else:
        if not is_me or request.user.is_staff:
            add_response_form = AddResponseForm()
        else:
            add_response_form = None

    ctx = group_context(group, bridge)
    ctx.update({
        "group":
        group,
        "can_mark_accepted":
        workflow.can_mark_accepted(request.user, question),
        "question":
        question,
        "responses":
        responses,
        "add_response_form":
        add_response_form,
    })

    ctx = RequestContext(request, ctx)
    return render_to_response("aiteo/question_detail.html", ctx)
예제 #2
0
파일: views.py 프로젝트: nzee/Django-Ghalib
def question_detail(request, question_id, **kwargs):
    
    group, bridge = group_and_bridge(kwargs)
    
    questions = Question.objects.all()
    
    if group:
        questions = group.content_objects(questions)
    else:
        questions = questions.filter(group_content_type=None)
    
    question = get_object_or_404(questions, pk=question_id)
    responses = question.responses.order_by("-score", "created", "id")
    
    if question.user == request.user:
        is_me = True
    else:
        is_me = False
    
    if request.method == "POST":
        add_response_form = AddResponseForm(request.POST)
        
        if add_response_form.is_valid():
            response = add_response_form.save(commit=False)
            response.question = question
            response.user = request.user
            response.save()
            return HttpResponseRedirect(response.get_absolute_url())
    else:
        if not is_me or request.user.is_staff:
            add_response_form = AddResponseForm()
        else:
            add_response_form = None
    
    ctx = group_context(group, bridge)
    ctx.update({
        "group": group,
        "can_mark_accepted": workflow.can_mark_accepted(request.user, question),
        "question": question,
        "responses": responses,
        "add_response_form": add_response_form,
    })
    
    ctx = RequestContext(request, ctx)
    return render_to_response("aiteo/question_detail.html", ctx)
예제 #3
0
파일: views.py 프로젝트: budong/graduate
def question_list(request, **kwargs):
    
    group, bridge = group_and_bridge(kwargs)
    
    questions = Question.objects.all().order_by("-score", "created", "id")
    
    if group:
        questions = group.content_objects(questions)
    else:
        questions = questions.filter(group_content_type=None)
    
    ctx = group_context(group, bridge)
    ctx.update({
        "group": group,
        "questions": questions,
    })
   # take care of ctx 
    ctx = RequestContext(request, ctx)
    return render_to_response("aiteo/question_list.html", ctx)
예제 #4
0
def question_list(request, **kwargs):
    
    group, bridge = group_and_bridge(kwargs)
    
    questions = Question.objects.all().order_by("-score", "created", "id")
    
    if group:
        questions = group.content_objects(questions)
    else:
        questions = questions.filter(group_content_type=None)
    
    ctx = group_context(group, bridge)
    ctx.update({
        "group": group,
        "questions": questions,
    })
   # take care of ctx 
    ctx = RequestContext(request, ctx)
    return render_to_response("aiteo/question_list.html", ctx)
예제 #5
0
파일: views.py 프로젝트: nzee/Django-Ghalib
def question_create(request, **kwargs):
    
    group, bridge = group_and_bridge(kwargs)
    
    if request.method == "POST":
        form = AskQuestionForm(request.POST)
        if form.is_valid():
            question = form.save(commit=False)
            question.user = request.user
            question.save()
            return HttpResponseRedirect(question.get_absolute_url())
    else:
        form = AskQuestionForm()
    
    ctx = group_context(group, bridge)
    ctx.update({
        "group": group,
        "form": form,
    })
    
    ctx = RequestContext(request, ctx)
    return render_to_response("aiteo/question_create.html", ctx)
예제 #6
0
파일: views.py 프로젝트: nzee/Django-Ghalib
def question_create(request, **kwargs):

    group, bridge = group_and_bridge(kwargs)

    if request.method == "POST":
        form = AskQuestionForm(request.POST)
        if form.is_valid():
            question = form.save(commit=False)
            question.user = request.user
            question.save()
            return HttpResponseRedirect(question.get_absolute_url())
    else:
        form = AskQuestionForm()

    ctx = group_context(group, bridge)
    ctx.update({
        "group": group,
        "form": form,
    })

    ctx = RequestContext(request, ctx)
    return render_to_response("aiteo/question_create.html", ctx)