Exemple #1
0
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)
Exemple #2
0
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 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)()
Exemple #5
0
def likes_book(request, book_id):
    return likes(request.user, Book.objects.get(pk=book_id), request)
def likes_book(request, book_id):
    return likes(request.user, Book.objects.get(pk=book_id), request)
Exemple #7
0
 def unlike(self, user):
     from social.utils import likes, set_sets
     if likes(user, self):
         set_sets(user, self, [])
Exemple #8
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])