From 9fb69bbf64d263d9b3c3a8083c7a3abb30de71a5 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 27 Jan 2021 16:07:46 -0700 Subject: [PATCH] Add a notes template, slightly alter query --- .gitignore | 1 + stickynotes/templates/notes.html | 18 ++++++++++++++++++ stickynotes/views.py | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 stickynotes/templates/notes.html diff --git a/.gitignore b/.gitignore index cf1b9d7..e844511 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__ *.egg-info *.sqlite +stickynotes.cfg diff --git a/stickynotes/templates/notes.html b/stickynotes/templates/notes.html new file mode 100644 index 0000000..0863f18 --- /dev/null +++ b/stickynotes/templates/notes.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} + {% block content %} +
+ {% for note in notes %} +
+
+
+ {% if note.title %} +
{{note.title}}
+ {% else %} +
{{note.url}}
+ {% endif %} +
+
+
+ {% endfor %} +
+ {% endblock %} diff --git a/stickynotes/views.py b/stickynotes/views.py index f5a41b3..e10f369 100644 --- a/stickynotes/views.py +++ b/stickynotes/views.py @@ -132,7 +132,7 @@ def view(note_url): :param note_url: The note to show """ - note = StickyNote.query.filter(StickyNote.url == note_url).scalar() + note = StickyNote.query.filter(StickyNote.url == note_url).first() if not note: flash('That note does not exist', 'danger') return redirect('/')