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 book_shelf_tags(request, book_id): if not request.user.is_authenticated(): return None book = Book.objects.get(pk=book_id) lks = likes(request.user, book, request) def get_value(): if not lks: return '' tags = book.tags.filter(category='set', user=request.user).exclude(name='') if not tags: return '' ctx = {'tags': tags} return template.loader.render_to_string('social/shelf_tags.html', ctx) return lazy(get_value, unicode)()
def likes_book(request, book_id): return likes(request.user, Book.objects.get(pk=book_id), request)
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])