Add public notes access

This commit is contained in:
Gregory Soutade 2016-06-14 11:28:37 +02:00
parent 72c3a97ffa
commit b4e7d60760
5 changed files with 21 additions and 8 deletions

View File

@ -13,12 +13,15 @@
</head> </head>
<body onload="startup();"> <body onload="startup();">
<!-- Header --> <!-- Header -->
<div class="settings">{% if authenticated %}<a href="/user/edit">Settings</a> <a href="/disconnect">Disconnect</a><br/> <div class="settings"><a href="/public_notes">Public notes</a> {% if authenticated %}<a href="/user/edit">Settings</a> <a href="/disconnect">Disconnect</a><br/>
{% endif %} {% endif %}
<form action="/search" method="post">{% csrf_token %}<input name="text"/><input type="submit" value="Search"/></form></div> <form action="/search" method="post">{% csrf_token %}<input name="text"/><input type="submit" value="Search"/></form></div>
<!-- Left panel --> <!-- Left panel -->
<div id="left_panel"> <div id="left_panel">
<a id="home_icon" href="/" alt="Home"><img src="{{ STATIC_URL }}images/home.png"/></a><br/><br/> <a id="home_icon" href="/" alt="Home"><img src="{{ STATIC_URL }}images/home.png"/></a><br/><br/>
{% if authenticated %}
<a href="/note/add">Add a note</a>
{% endif %}
{% block left %} {% endblock %} {% block left %} {% endblock %}
</div> </div>
<div id="main_panel"> <div id="main_panel">

View File

@ -6,9 +6,6 @@
</script> </script>
{% endblock %} {% endblock %}
{% block left %} {% block left %}
{% if authenticated %}
<a href="/note/add">Add a note</a>
{% endif %}
<div id="categories"> <div id="categories">
{% for meta_note in notes_by_category %} {% for meta_note in notes_by_category %}
<div class="category" category_id="{{ meta_note.category_id }}"> <div class="category" category_id="{{ meta_note.category_id }}">
@ -46,10 +43,6 @@
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
{% else %}
{% if notes_by_category|length == 0 %}
<b>Any note</b>
{% endif %}
{% endif %} {% endif %}
</div> </div>
{% endblock %} {% endblock %}

View File

@ -27,6 +27,8 @@
<tr><td>Password</td><td><input id="password" type="password" name="password"/></td></tr> <tr><td>Password</td><td><input id="password" type="password" name="password"/></td></tr>
<tr><td/><td><input type="submit" value="Connect"/></td></tr> <tr><td/><td><input type="submit" value="Connect"/></td></tr>
<tr><td/><td><a href="/user/add">Create an account</a><br/>({{ nb_people_registered }} people(s) registered)</td></tr> <tr><td/><td><a href="/user/add">Create an account</a><br/>({{ nb_people_registered }} people(s) registered)</td></tr>
<tr><td></td><td></td></tr>
<tr><td></td><td><a href="/public_notes">Public notes</a></td></tr>
</table> </table>
</form> </form>
</div> </div>

View File

@ -29,6 +29,7 @@ urlpatterns = patterns('',
url(r'^note/add$', 'denote.views.add_note', name='add_note'), url(r'^note/add$', 'denote.views.add_note', name='add_note'),
url(r'^note/(\d+)$', 'denote.views.note', name='note'), url(r'^note/(\d+)$', 'denote.views.note', name='note'),
url(r'^note/(\d+)/(\d+)$', 'denote.views.public_note', name='public_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'^category/edit/(\d)$','denote.views.edit_category', name='edit_category'),
url(r'^preferences$', 'denote.views.preferences', name='preferences'), url(r'^preferences$', 'denote.views.preferences', name='preferences'),
url(r'^search$', 'denote.views.search', name='search'), url(r'^search$', 'denote.views.search', name='search'),

View File

@ -238,6 +238,20 @@ def public_note(request, user_id, note_id):
return render(request, 'public_note.html', context) 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 @login_required
def edit_category(request, category_id): def edit_category(request, category_id):
user = request.user user = request.user