Beispiel #1
0
def bookmark_create(request, topic_id):
    if not request.is_ajax():
        return Http404()

    topic = get_object_or_404(Topic, pk=topic_id)
    form = BookmarkForm(user=request.user, topic=topic, data=request.POST)

    if form.is_valid():
        form.save()
        return json_response()

    return Http404()
Beispiel #2
0
def bookmark_create(request, topic_id):
    if not request.is_ajax():
        return Http404()

    topic = get_object_or_404(Topic, pk=topic_id)
    form = BookmarkForm(user=request.user, topic=topic, data=request.POST)

    if form.is_valid():
        form.save()
        return json_response()

    return Http404()
Beispiel #3
0
def bookmark_create(request, topic_id):
    if not request.is_ajax():
        return Http404()

    topic = get_object_or_404(Topic, pk=topic_id)
    form = BookmarkForm(data=request.POST)

    if not form.is_valid():
        return Http404()

    comment_number = form.cleaned_data['comment_number']

    # Bookmark is created/updated on topic view.
    CommentBookmark.objects.filter(user=request.user, topic=topic)\
        .update(comment_number=comment_number)

    return json_response()
Beispiel #4
0
def bookmark_create(request, topic_id):
    if not request.is_ajax():
        return Http404()

    topic = get_object_or_404(Topic, pk=topic_id)
    form = BookmarkForm(data=request.POST)

    if not form.is_valid():
        return Http404()

    comment_number = form.cleaned_data['comment_number']

    # Bookmark is created/updated on topic view.
    CommentBookmark.objects.filter(user=request.user, topic=topic)\
        .update(comment_number=comment_number)

    return json_response()
 def test_form(self):
     form_data = {'comment_number': 999, }
     form = BookmarkForm(data=form_data)
     self.assertEqual(form.is_valid(), True)