@login_required
def add_remove_bookmark(request, qid):
uid = request.session.get('user')
try:
bookmark = Bookmark.objects.get(user=uid, profile=qid)
bookmark.delete()
except Bookmark.DoesNotExist:
bookmark = Bookmark.objects.create(
user=uid,
profile=OdeskProfileData.objects.get(id=qid))
bookmark.save()
return HttpResponseRedirect('/bookmarks/' + qid)
QGxvZ2luX3JlcXVpcmVkCmRlZiBhZGRfcmVtb3ZlX2Jvb2ttYXJrKHJlcXVlc3QsIHFpZCk6CiAgICB1aWQgPSByZXF1ZXN0LnNlc3Npb24uZ2V0KCd1c2VyJykKICAgIHRyeToKICAgICAgICBib29rbWFyayA9IEJvb2ttYXJrLm9iamVjdHMuZ2V0KHVzZXI9dWlkLCBwcm9maWxlPXFpZCkKICAgICAgICBib29rbWFyay5kZWxldGUoKQogICAgZXhjZXB0IEJvb2ttYXJrLkRvZXNOb3RFeGlzdDoKICAgICAgICBib29rbWFyayA9IEJvb2ttYXJrLm9iamVjdHMuY3JlYXRlKAogICAgICAgICAgICAgICAgICAgICAgICB1c2VyPXVpZCwKICAgICAgICAgICAgICAgICAgICAgICAgcHJvZmlsZT1PZGVza1Byb2ZpbGVEYXRhLm9iamVjdHMuZ2V0KGlkPXFpZCkpCiAgICAgICAgYm9va21hcmsuc2F2ZSgpCiAgICByZXR1cm4gSHR0cFJlc3BvbnNlUmVkaXJlY3QoJy9ib29rbWFya3MvJyArIHFpZCk=