def get_object(self, bits): if len(bits) > 1: raise ObjectDoesNotExist if bits: self.tags = get_tags_by_slug(bits[0]) return get_tagged(bits[0], published(cls.objects.all()), tags=self.tags) return None
def get_tagged(slug, queryset = None, tags = None): tags = tags or get_tags_by_slug(slug) if queryset is None: queryset = GeneralPost.objects.all() queryset = published(queryset) # Magic starts here. # I am mangling with queryset's model # attribute to make 'tagging' belive # that it is operates on GeneralPost type. general_queryset = queryset.all() general_queryset.model = GeneralPost tagged_queryset = TaggedItem.objects.get_by_model(general_queryset, tags) tagged_queryset.model = queryset.model # End of magic. return tagged_queryset, tags
def get_tagged(slug, queryset=None, tags=None): tags = tags or get_tags_by_slug(slug) if queryset is None: queryset = GeneralPost.objects.all() queryset = published(queryset) # Magic starts here. # I am mangling with queryset's model # attribute to make 'tagging' belive # that it is operates on GeneralPost type. general_queryset = queryset.all() general_queryset.model = GeneralPost tagged_queryset = TaggedItem.objects.get_by_model(general_queryset, tags) tagged_queryset.model = queryset.model # End of magic. return tagged_queryset, tags
def post_list(request, **kwargs): kwargs['queryset'] = published(kwargs['queryset']) return object_list(request, **kwargs)
def items(self, obj): if obj: items = obj[0][:RSS_LENGTH] else: items = published(cls.objects.all())[:RSS_LENGTH] return [obj.upcast() for obj in items]