Ejemplo n.º 1
0
def like_book(request, slug):
    if not request.user.is_authenticated():
        return HttpResponseForbidden('Login required.')
    book = get_object_or_404(Book, slug=slug)
    if not likes(request.user, book):
        tag = get_set(request.user, '')
        set_sets(request.user, book, [tag])

    if request.is_ajax():
        return JsonResponse({"success": True, "msg": "ok", "like": True})
    else:
        return redirect(book)
Ejemplo n.º 2
0
 def save(self, request):
     tags = [get_set(self._user, tag_name.strip())
                 for tag_name in self.cleaned_data['tags'].split(',')]
     set_sets(self._user, self._obj, tags)
     return {"like": True}
Ejemplo n.º 3
0
 def like(self, user):
     from social.utils import likes, get_set, set_sets
     if not likes(user, self):
         tag = get_set(user, '')
         set_sets(user, self, [tag])