예제 #1
0
def tag_list(request):
    if request.user.is_superuser:
        tags = Tag.objects.order_by("-id").all()
    else:
        tags = Tag.objects.filter(
            author__user__username=request.user.username).order_by("-id")

    tags = helpers.pg_records(request, tags, 5)
    return render(request, 'cadmin/tag_list.html', {'tags': tags})
예제 #2
0
def post_list(request):
    if request.user.is_superuser:
        posts = Post.objects.order_by("-id").all()
    else:
        posts = Post.objects.filter(
            author__user__username=request.user.username).order_by("-id")

    posts = helpers.pg_records(request, posts, 5)

    return render(request, 'cadmin/post_list.html', {'posts': posts})
예제 #3
0
def category_list(request):
    if request.user.is_superuser:
        categories = Category.objects.order_by("-id").all()
    else:
        categories = Category.objects.filter(
            author__user__username=request.user.username).order_by("-id")

    categories = helpers.pg_records(request, categories, 5)

    return render(request, 'cadmin/category_list.html',
                  {'categories': categories})
예제 #4
0
def post_by_tag(request, tag_slug):
    tag = get_object_or_404(Tag, slug=tag_slug)
    posts = get_list_or_404(Post.objects.order_by('-id'), tags=tag)
    posts = helpers.pg_records(request, posts, 5)
    context = {'tag': tag, 'posts': posts}
    return render(request, 'myapp/post_by_tag.html', context)
예제 #5
0
def post_by_category(request, category_slug):
    category = get_object_or_404(Category, slug=category_slug)
    posts = get_list_or_404(Post.objects.order_by('-id'), category=category)
    posts = helpers.pg_records(request, posts, 5)
    context = {'category': category, 'posts': posts}
    return render(request, 'myapp/post_by_category.html', context)
예제 #6
0
def post_list(request):
    posts = Post.objects.order_by('-id').all()
    posts = helpers.pg_records(request, posts, 5)
    return render(request, 'myapp/post_list.html', {'posts': posts})