Пример #1
0
def edit_question(request, id):
    question = get_object_or_404(Question, id=int(id))    
    if not question.user == request.user:
        return HttpResponse('<h1>Permiso denegado</h1>')

    if request.method == 'POST':
        form = AskForm(request.POST)
        if form.is_valid():            
            question.question = request.POST['question']
            question.description = request.POST['description']
            question.tags = request.POST['tags']
            question.save()
            return HttpResponseRedirect('/foro/questions/%s' % question.id)
    else:
        form = AskForm(instance=question)
    return render_to_response('askbotmini/ask_question.html', 
                              RequestContext(request, locals()))
Пример #2
0
def ask_question(request):
    if request.method == 'POST':
        form = AskForm(request.POST)
        if form.is_valid():
            obj = Question()
            obj.question = request.POST['question']
            obj.description = request.POST['description']
            obj.user = request.user
            obj.views = 0
            obj.date_created = datetime.datetime.now()
            obj.tags = request.POST['tags']
            obj.save()
            if form.cleaned_data['notify']:
                thread.start_new_thread(notify_all, (obj,))
            return HttpResponseRedirect('/foro/?tab=latest')
    else:
        form = AskForm()
    return render_to_response('askbotmini/ask_question.html', 
                              RequestContext(request, locals()))