Beispiel #1
0
def thread(request, cslug, tslug, template='snapboard/thread.html'):
    thread = get_object_or_404(smodels.Thread.objects.filter(category__slug=cslug), slug=tslug)
    form = PostForm(request.POST or None, request=request)
    if form.is_valid():
        post = form.save(thread)
        return HttpResponseRedirect(post.get_url())
    
    ctx = {
        'is_fav': thread.is_fav(request.user),
        'posts': thread.get_posts(),
        'thread': thread,
        'form': form,
        'category': thread.category
    }
    return render_and_cache(template, ctx, request)
Beispiel #2
0
def thread(request, cslug, tslug, template='snapboard/thread.html'):
    thread = get_object_or_404(
        smodels.Thread.objects.filter(category__slug=cslug), slug=tslug)
    form = PostForm(request.POST or None, request=request)
    if form.is_valid():
        post = form.save(thread)
        return HttpResponseRedirect(post.get_url())

    ctx = {
        'is_fav': thread.is_fav(request.user),
        'posts': thread.get_posts(),
        'thread': thread,
        'form': form,
        'category': thread.category
    }
    return render_and_cache(template, ctx, request)
Beispiel #3
0
def thread_list(request, template='snapboard/thread_list.html'):
    # TODO: Keep sticky posts from clogging up the list.
    threads = smodels.Thread.objects.get_user_query_set(request.user).order_by('-date')
    return render_and_cache(template, {'threads': threads}, request)
Beispiel #4
0
def category(request, slug, template='snapboard/category.html'):
    category = get_object_or_404(smodels.Category, slug=slug)
    threads = category.thread_set.get_user_query_set(request.user)
    ctx = {'category': category, 'threads': threads}
    return render_and_cache(template, ctx, request)
Beispiel #5
0
def category_list(request, template='snapboard/category_list.html'):
    ctx = {'categories': smodels.Category.objects.all()}    
    return render_and_cache(template, ctx, request)
Beispiel #6
0
def thread_list(request, template='snapboard/thread_list.html'):
    # TODO: Keep sticky posts from clogging up the list.
    threads = smodels.Thread.objects.get_user_query_set(
        request.user).order_by('-date')
    return render_and_cache(template, {'threads': threads}, request)
Beispiel #7
0
def category(request, slug, template='snapboard/category.html'):
    category = get_object_or_404(smodels.Category, slug=slug)
    threads = category.thread_set.get_user_query_set(request.user)
    ctx = {'category': category, 'threads': threads}
    return render_and_cache(template, ctx, request)
Beispiel #8
0
def category_list(request, template='snapboard/category_list.html'):
    ctx = {'categories': smodels.Category.objects.all()}
    return render_and_cache(template, ctx, request)