Exemple #1
0
 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
Exemple #2
0
 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
Exemple #3
0
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
Exemple #4
0
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
Exemple #5
0
def post_list(request, **kwargs):
    kwargs['queryset'] = published(kwargs['queryset'])
    return object_list(request, **kwargs)
Exemple #6
0
 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]
Exemple #7
0
def post_list(request, **kwargs):
    kwargs['queryset'] = published(kwargs['queryset'])
    return object_list(request, **kwargs)
Exemple #8
0
 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]