Example #1
0
    def test_comment_from_comment_form_is_complete(self):
        form = RCommentForm(self.ct, self.user, {'text': 'Heya!'})

        tools.assert_true(form.is_valid())
        rc = form.save(commit=False)
        tools.assert_equals(self.user, rc.user)
        tools.assert_equals(self.ct.pk, rc.content_type_id)
        tools.assert_equals('Heya!', rc.text)
        tools.assert_true(rc.is_public())
Example #2
0
    def test_comment_from_comment_form_is_complete(self):
        form = RCommentForm(self.ct, self.user, {'text': 'Heya!'})

        tools.assert_true(form.is_valid())
        rc = form.save(commit=False)
        tools.assert_equals(self.user, rc.user)
        tools.assert_equals(self.ct.pk, rc.content_type_id)
        tools.assert_equals('Heya!', rc.text)
        tools.assert_true(rc.is_public())
Example #3
0
def post_comment(request, ct_id, object_pk):
    obj = _get_obj(ct_id, object_pk)

    data = None
    if request.method == 'POST':
        data = request.POST
    form = RCommentForm(obj, request.user, data)

    if form.is_valid():
        form.save()
        return HttpResponseRedirect('/')

    return TemplateResponse(request, 'comment_form.html', {'form': form, 'object': obj})
Example #4
0
def post_comment(request, ct_id, object_pk):
    obj = _get_obj(ct_id, object_pk)

    data = None
    if request.method == 'POST':
        data = request.POST
    form = RCommentForm(obj, request.user, data)

    if form.is_valid():
        form.save()
        return HttpResponseRedirect('/')

    return TemplateResponse(request, 'comment_form.html', {
        'form': form,
        'object': obj
    })