From b4e7d6076046d15e34d90aa181f65d0a72a27599 Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Tue, 14 Jun 2016 11:28:37 +0200 Subject: [PATCH] Add public notes access --- denote/templates/base.html | 5 ++++- denote/templates/base_user.html | 7 ------- denote/templates/login.html | 2 ++ denote/urls.py | 1 + denote/views.py | 14 ++++++++++++++ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/denote/templates/base.html b/denote/templates/base.html index ac2c197..a593f20 100644 --- a/denote/templates/base.html +++ b/denote/templates/base.html @@ -13,12 +13,15 @@ -
{% if authenticated %}Settings Disconnect
+
Public notes {% if authenticated %}Settings Disconnect
{% endif %}
{% csrf_token %}


+ {% if authenticated %} + Add a note + {% endif %} {% block left %} {% endblock %}
diff --git a/denote/templates/base_user.html b/denote/templates/base_user.html index 7a7f4fd..fcab4ef 100644 --- a/denote/templates/base_user.html +++ b/denote/templates/base_user.html @@ -6,9 +6,6 @@ {% endblock %} {% block left %} - {% if authenticated %} - Add a note - {% endif %}
{% for meta_note in notes_by_category %}
@@ -46,10 +43,6 @@ {% endfor %}
- {% else %} - {% if notes_by_category|length == 0 %} - Any note - {% endif %} {% endif %}
{% endblock %} diff --git a/denote/templates/login.html b/denote/templates/login.html index 96fb400..2591969 100644 --- a/denote/templates/login.html +++ b/denote/templates/login.html @@ -27,6 +27,8 @@ Password Create an account
({{ nb_people_registered }} people(s) registered) + + Public notes
diff --git a/denote/urls.py b/denote/urls.py index 65595b4..6ec851c 100644 --- a/denote/urls.py +++ b/denote/urls.py @@ -29,6 +29,7 @@ urlpatterns = patterns('', url(r'^note/add$', 'denote.views.add_note', name='add_note'), url(r'^note/(\d+)$', 'denote.views.note', name='note'), url(r'^note/(\d+)/(\d+)$', 'denote.views.public_note', name='public_note'), + url(r'^public_notes$', 'denote.views.public_notes', name='public_notes'), url(r'^category/edit/(\d)$','denote.views.edit_category', name='edit_category'), url(r'^preferences$', 'denote.views.preferences', name='preferences'), url(r'^search$', 'denote.views.search', name='search'), diff --git a/denote/views.py b/denote/views.py index 2fd340a..8c1a8dd 100644 --- a/denote/views.py +++ b/denote/views.py @@ -238,6 +238,20 @@ def public_note(request, user_id, note_id): return render(request, 'public_note.html', context) +def public_notes(request): + user = request.user + + if user.is_authenticated(): + public_notes = Note.objects.filter(visibility__gte=Note.REGISTERED).order_by('-modified_date') + else: + public_notes = Note.objects.filter(visibility__gte=Note.PUBLIC).order_by('-modified_date') + + context = _prepare_note_context(user) + context['notes'] = public_notes[:50] + context['public_notes'] = public_notes[:50] + + return render(request, 'public_notes.html', context) + @login_required def edit_category(request, category_id): user = request.user