예제 #1
0
def bookmark_post(request): 
    if not request.is_ajax():
        return HttpResponse("you cant access here")
    post_id=request.POST['id']
    ret = {"success": 0}
    try:
        bookmark = BookMark.objects.get(post__pk=post_id)
    except BookMark.DoesNotExist:
        BookMark.objects.create(user=request.user,post=Posting.objects.get(pk=post_id))
        #success if new bookmark is created
        ret['success']=1
    else:
        BookMark.delete(bookmark)
    return HttpResponse(simplejson.dumps(ret), content_type="application/json")
예제 #2
0
def unbookmark(request):
    bm_id=request.POST.get("bookmark_id",None)
    if bm_id:
        bookmark = BookMark.objects.get(post__pk=bm_id)
        BookMark.delete(bookmark)
    return redirect('bookmark_listView')