diff options
author | Filipp Lepalaan <filipp@mac.com> | 2016-03-21 20:37:11 +0200 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2016-03-21 20:37:11 +0200 |
commit | ec867584ef2078492d70b555ca419ea9e01dca8e (patch) | |
tree | 104c93fa71c67b18ad8e4221f8f1f9325178e04e /servo/views | |
parent | 1b6e5ee722f76f594e3d95dfa8d77ac2b9f2173a (diff) | |
download | Servo-ec867584ef2078492d70b555ca419ea9e01dca8e.tar.gz Servo-ec867584ef2078492d70b555ca419ea9e01dca8e.tar.bz2 Servo-ec867584ef2078492d70b555ca419ea9e01dca8e.zip |
Fixed article flag marking
Diffstat (limited to 'servo/views')
-rw-r--r-- | servo/views/note.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/servo/views/note.py b/servo/views/note.py index 416e845..162b297 100644 --- a/servo/views/note.py +++ b/servo/views/note.py @@ -59,8 +59,7 @@ def prep_list_view(request, kind): all_notes = Note.objects.all().order_by("-created_at") if kind == "articles": - all_notes = Article.objects.all() - #all_notes = all_notes.filter(order=None).order_by("is_read", "-created_at") + all_notes = Article.objects.all().order_by('-date_created') if kind == "inbox": all_notes = all_notes.filter(order=None).order_by("is_read", "-created_at") if kind == "sent": @@ -287,7 +286,18 @@ def templates(request, template_id=None): return render(request, 'notes/templates.html', {'templates': templates}) -def toggle_flag(request, pk, flag): +def toggle_flag(request, kind, pk, flag): + if kind == 'articles': + note = get_object_or_404(Article, pk=pk) + if flag == 'flagged': + note.toggle_flagged(request.user) + return HttpResponse(note.get_flagged_title(request.user)) + if flag == 'read': + 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) @@ -318,12 +328,15 @@ def list_notes(request, kind="inbox"): def view_note(request, kind, pk): + data = prep_list_view(request, kind) + if kind == 'articles': note = get_object_or_404(Article, pk=pk) + data['read_title'] = note.get_read_title(request.user) + data['flagged_title'] = note.get_flagged_title(request.user) else: note = get_object_or_404(Note, pk=pk) - data = prep_list_view(request, kind) data['title'] = note.get_title() data['note'] = note |