[snowy] Clicking a notebook name now takes you to a list of all notes
- From: Jeff Schroeder <jschroeder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [snowy] Clicking a notebook name now takes you to a list of all notes
- Date: Tue, 18 Jan 2011 05:21:14 +0000 (UTC)
commit f3bcf275130447afc914ffb8a36ae0d02f4a7ca4
Author: Jeff Schroeder <jeffschroeder computer org>
Date: Thu Dec 23 08:44:45 2010 -0800
Clicking a notebook name now takes you to a list of all notes
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=613884
notes/templates/notes/note_list_snippet.html | 3 +++
notes/templates/notes/notebook_list_snippet.html | 4 ++--
notes/urls.py | 1 +
notes/views.py | 12 ++++++++++++
4 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/notes/templates/notes/note_list_snippet.html b/notes/templates/notes/note_list_snippet.html
index f397292..dad9d01 100644
--- a/notes/templates/notes/note_list_snippet.html
+++ b/notes/templates/notes/note_list_snippet.html
@@ -1,4 +1,7 @@
{% load i18n %}{% load humanize %}{% load pagination_tags %}
+{% if notebook %}
+<h1>{% trans "All notes for" %} {{ notebook.get_name_for_display }}</h1>
+{% endif %}
<table class="object_list" cellspacing="0" cellpadding="0">
<thead>
<tr>
diff --git a/notes/templates/notes/notebook_list_snippet.html b/notes/templates/notes/notebook_list_snippet.html
index 4cbbbe1..22dbca7 100644
--- a/notes/templates/notes/notebook_list_snippet.html
+++ b/notes/templates/notes/notebook_list_snippet.html
@@ -1,7 +1,7 @@
{% comment %}In the spirit of D.R.Y.{% endcomment %}
{% for n in all_notebooks %}
{# This grossness goes away with django 1.2's smarter if tags #}
- {% if n.is_public %}<li class="notebook-item"><a href="#">{{ n.get_name_for_display }}</a></li>
- {% else %}{% ifequal request.user n.author %}<li class="notebook-item"><a href="#">{{ n.get_name_for_display }}</a></li>{% endifequal %}
+ {% if n.is_public %}<li class="notebook-item"><a href="{% url notebook_detail n.author n.pk n.get_name_for_display|slugify %}">{{ n.get_name_for_display }}</a></li>
+ {% else %}{% ifequal request.user n.author %}<li class="notebook-item"><a href="{% url notebook_detail n.author n.pk n.get_name_for_display|slugify %}">{{ n.get_name_for_display }}</a></li>{% endifequal %}
{% endif %}
{% endfor %}
diff --git a/notes/urls.py b/notes/urls.py
index 6bc35cc..75bca01 100644
--- a/notes/urls.py
+++ b/notes/urls.py
@@ -23,4 +23,5 @@ urlpatterns = patterns('',
url(r'^list/$', 'snowy.notes.views.note_list', name='note_list'),
url(r'^(?P<note_id>\d+)/$', 'snowy.notes.views.note_detail', name='note_detail_no_slug'),
url(r'^(?P<note_id>\d+)/(?P<slug>[^/]+)/$', 'snowy.notes.views.note_detail', name='note_detail'),
+ url(r'^notebooks/(?P<notebook_id>\d+)/(?P<slug>[^/]+)/$', 'snowy.notes.views.notebook_detail', name='notebook_detail'),
)
diff --git a/notes/views.py b/notes/views.py
index cff7f78..46f4cce 100644
--- a/notes/views.py
+++ b/notes/views.py
@@ -56,6 +56,18 @@ def note_list(request, username,
'author': author},
context_instance=RequestContext(request))
+def notebook_detail(request, username, notebook_id, slug,
+ template_name='notes/note_list.html'):
+ author = get_object_or_404(User, username=username)
+ notebook = get_object_or_404(NoteTag, pk=notebook_id)
+ notes = Note.objects.user_viewable(request.user, author).filter(tags__in=[notebook]).order_by("-modified")
+ return render_to_response(template_name,
+ {'notes': notes,
+ 'author': author,
+ 'username': username,
+ 'notebook': notebook},
+ context_instance=RequestContext(request))
+
def note_detail(request, username, note_id, slug='',
template_name='notes/note_detail.html'):
author = get_object_or_404(User, username=username)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]