X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/0cae17bec6d31806615fae59a5b3945016285fbe..ef759fbfa694cdddd1b24027a6f8792302add9b8:/apps/newtagging/managers.py diff --git a/apps/newtagging/managers.py b/apps/newtagging/managers.py index 1dbcb2999..f802aa1cb 100644 --- a/apps/newtagging/managers.py +++ b/apps/newtagging/managers.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Custom managers for Django models registered with the tagging application. @@ -13,15 +14,15 @@ class ModelTagManager(models.Manager): def __init__(self, tag_model): super(ModelTagManager, self).__init__() self.tag_model = tag_model - + def get_query_set(self): content_type = ContentType.objects.get_for_model(self.model) return self.tag_model.objects.filter( items__content_type__pk=content_type.pk).distinct() - + def related(self, tags, *args, **kwargs): return self.tag_model.objects.related_for_model(tags, self.model, *args, **kwargs) - + def usage(self, *args, **kwargs): return self.tag_model.objects.usage_for_model(self.model, *args, **kwargs) @@ -34,11 +35,13 @@ class ModelTaggedItemManager(models.Manager): super(ModelTaggedItemManager, self).__init__() self.intermediary_table_model = tag_model.objects.intermediary_table_model - def related_to(self, obj, queryset=None, num=None): + def related_to(self, obj, queryset=None, num=None, ignore_by_tag=None): if queryset is None: - return self.intermediary_table_model.objects.get_related(obj, self.model, num=num) + return self.intermediary_table_model.objects.get_related( + obj, self.model, num=num, ignore_by_tag=ignore_by_tag) else: - return self.intermediary_table_model.objects.get_related(obj, queryset, num=num) + return self.intermediary_table_model.objects.get_related( + obj, queryset, num=num, ignore_by_tag=ignore_by_tag) def with_all(self, tags, queryset=None): if queryset is None: @@ -61,7 +64,7 @@ class TagDescriptor(object): """ def __init__(self, tag_model): self.tag_model = tag_model - + def __get__(self, instance, owner): if not instance: tag_manager = ModelTagManager(self.tag_model)