Exemplo n.º 1
0
def form(request, id):
    """
    Should be called asynchronously.
    Returns the rendered comment form to reply to the comment with the given id.
    """
    comment = get_object_or_404(Comment, id=id)
    return render(request, 'comments/addform.html', {
        'object': comment,
    })
Exemplo n.º 2
0
def register(request):
    name = request.POST['username']
    password = request.POST['password']
    next = request.POST.get('next', '/')
    if request.POST.get('honeypot'):
        return redirect(next)
    if User.objects.filter(username=name).count():
        return render(request, 'registration/login.html', {
            'next': next,
            'collision': True,
            'form': AuthenticationForm(request),
        })
    user = User.objects.create_user(name, '', password)
    user.save()
    user = authenticate(username=name, password=password)
    login(request, user)
    return redirect(next)
Exemplo n.º 3
0
def new(request):
    """
    This is a special hook to bridge the gap between django's comment
    posting and asynchronous comment posting, and it's damn sexy. Django
    comment posting will be able to redirect somewhere. It puts the new
    comment id in request.GET['c']. If you redirect here, then this will
    render the comment and return the new HTML. Then you javascript
    can handle the rest.

    Note that if comments are disabled during the submission, this will 404.
    That's not necessarily a bad thing, though.
    """
    comment = get_object_or_404(Comment, id=request.GET['c'])
    return render(request, 'comments/comment.html', {
        'depth': 0,
        'allow_add': comment.ancestor().enable_comments,
        'comment': comment,
    })
Exemplo n.º 4
0
def render(request, name, context=None, processors=()):
    from overviewer.utilities.views import render
    from overviewer.comments import context_processor
    processors += (context_processor,)
    return render(request, name, context, processors)
Exemplo n.º 5
0
def continue_thread(request, id):
    return render(request, 'comments/continue.html', {
        'object': get_object_or_404(Comment, id=id),
    })