X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/3badd77f743883992829a1174eef7c8d5e851766..5b9ee3437b7fa98820eba7286abd524c3ede76e9:/apps/social/utils.py?ds=inline diff --git a/apps/social/utils.py b/apps/social/utils.py index 96f0ca0c7..c6a93537b 100755 --- a/apps/social/utils.py +++ b/apps/social/utils.py @@ -1,7 +1,12 @@ +# -*- coding: utf-8 -*- +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# from django.db.models import Q -from catalogue.models import Tag +from catalogue.models import Book, Tag from catalogue import utils from catalogue.tasks import touch_tag +from social.models import Cite def likes(user, work): @@ -32,4 +37,9 @@ def set_sets(user, work, sets): touch_tag(shelf) # delete empty tags - Tag.objects.filter(category='set', user=user, book_count=0).delete() + Tag.objects.filter(category='set', user=user, items=None).delete() + + +def cites_for_tags(tags): + """Returns a QuerySet with all Cites for books with given tags.""" + return Cite.objects.filter(book__in=Book.tagged.with_all(tags))