def note_detail(request, username, note_id, slug='',
                template_name='notes/note_detail.html'):
    author = get_object_or_404(User, username=username)
    note = get_object_or_404(Note, pk=note_id, author=author)

    if request.user != author and note.permissions == 0:
        return HttpResponseForbidden()

    if note.slug != slug:
        return HttpResponseRedirect(note.get_absolute_url())

    body = note_to_html(note, author)

    try:
        # Get the notebook name, if any
        notebook = note.tags.get(is_notebook=True)
        if notebook:
            notebook = notebook.get_name_for_display()
    except ObjectDoesNotExist:
        notebook = []

    return render_to_response(template_name,
                              {'title': note.title,  'note': note,
                               'notebook': notebook, 'body': body,
                               'request': request, 'author': author},
                              context_instance=RequestContext(request))
Beispiel #2
0
def note_detail(request,
                username,
                note_id,
                slug='',
                template_name='notes/note_detail.html'):
    author = get_object_or_404(User, username=username)
    note = get_object_or_404(Note, pk=note_id, author=author)

    if request.user != author and note.permissions == 0:
        return HttpResponseForbidden()

    if note.slug != slug:
        return HttpResponseRedirect(note.get_absolute_url())

    body = note_to_html(note, author)

    try:
        # Get the notebook name, if any
        notebook = note.tags.get(is_notebook=True)
        if notebook:
            notebook = notebook.get_name_for_display()
    except ObjectDoesNotExist:
        notebook = []

    return render_to_response(template_name, {
        'title': note.title,
        'note': note,
        'notebook': notebook,
        'body': body,
        'request': request,
        'author': author
    },
                              context_instance=RequestContext(request))
Beispiel #3
0
def note_detail(request, username, note_id, slug='',
                template_name='notes/note_detail.html'):
    author = get_object_or_404(User, username=username)
    note = get_object_or_404(Note, pk=note_id, author=author)

    if request.user != author and note.permissions == 0:
        return HttpResponseForbidden()

    if note.slug != slug:
        return HttpResponseRedirect(note.get_absolute_url())

    body = note_to_html(note, author)

    return render_to_response(template_name,
                              {'title': note.title,
                               'note': note, 'body': body,
                               'request': request, 'author': author},
                              context_instance=RequestContext(request))