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}
def unlike_book(request, slug): book = get_object_or_404(Book, slug=slug) if likes(request.user, book): set_sets(request.user, book, []) if request.is_ajax(): return JSONResponse({"success": True, "msg": "ok", "like": False}) else: return redirect(book)
def unlike_book(request, slug): if not request.user.is_authenticated(): return HttpResponseForbidden('Login required.') book = get_object_or_404(Book, slug=slug) if likes(request.user, book): set_sets(request.user, book, []) if request.is_ajax(): return JsonResponse({"success": True, "msg": "ok", "like": False}) else: return redirect(book)
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}
def unlike(self, user): from social.utils import likes, set_sets if likes(user, self): set_sets(user, self, [])
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])