From 9e5f553863749b5bb0a83e597b2f962b0d91e442 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Tue, 10 May 2016 15:24:26 +0300 Subject: Fix for flag toggling --- servo/urls/note.py | 4 +++- servo/views/note.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/servo/urls/note.py b/servo/urls/note.py index e68bba3..5cab498 100644 --- a/servo/urls/note.py +++ b/servo/urls/note.py @@ -19,7 +19,9 @@ urlpatterns = [ name="notes-create_to_customer"), url(r'^(?P\d+)/toggle/tag/(?P\d+)/$', toggle_tag, name="notes-toggle_tag"), - url(r'^(?P\w+)?/(?P\d+)/toggle_(?P[a-z]+)/$', toggle_flag, + url(r'^(?P\w+)/(?P\d+)/toggle_(?P[a-z]+)/$', toggle_flag, + name="notes-toggle_flag"), + url(r'^all/(?P\d+)/toggle_(?P[a-z]+)/$', toggle_flag, name="notes-toggle_flag"), url(r'^(?P\d+)/reply/$', edit, name="notes-reply"), url(r'^(?P\d+)/edit/$', edit, name="notes-edit"), diff --git a/servo/views/note.py b/servo/views/note.py index 162b297..c3b0b99 100644 --- a/servo/views/note.py +++ b/servo/views/note.py @@ -287,6 +287,9 @@ def templates(request, template_id=None): def toggle_flag(request, kind, pk, flag): + """ + Toggles a flag of a note (read/unread, flagged/not, reported/not) + """ if kind == 'articles': note = get_object_or_404(Article, pk=pk) if flag == 'flagged': @@ -296,8 +299,6 @@ def toggle_flag(request, kind, pk, flag): note.toggle_read(request.user) return HttpResponse(note.get_read_title(request.user)) - return HttpResponse(getattr(note, 'get_%s_title' % flag)()) - field = 'is_%s' % flag note = get_object_or_404(Note, pk=pk) attr = getattr(note, field) -- cgit v1.2.3