From b2f7894ed55eabf89089e318111f6dd06d480792 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Sat, 18 Nov 2023 09:08:52 -0500 Subject: gtd: added per post filtering to wirednotes --- app/gtd/templates/gtd/wirednote_list.html | 6 ++++++ app/gtd/views.py | 23 +++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'app/gtd') diff --git a/app/gtd/templates/gtd/wirednote_list.html b/app/gtd/templates/gtd/wirednote_list.html index 73c93bb..fb2a214 100644 --- a/app/gtd/templates/gtd/wirednote_list.html +++ b/app/gtd/templates/gtd/wirednote_list.html @@ -7,6 +7,11 @@ {% endfor %}
  • New Note
  • + +
    {% for object in object_list %}

    {%if object.url%}{{object.title}}{%else%}{{object.title}}{%endif%}edit

    @@ -21,4 +26,5 @@ {% endblock %} {% block js %} + {% endblock%} diff --git a/app/gtd/views.py b/app/gtd/views.py index 235867d..db014b1 100644 --- a/app/gtd/views.py +++ b/app/gtd/views.py @@ -52,23 +52,18 @@ class GTDNoteListView(ListView): template_name = "gtd/note_list.html" def get_queryset(self): + project = self.request.GET.get("project", False) if self.kwargs['note_type']: print(self.kwargs['note_type']) note_type_reverse = dict((v, k) for k, v in GTDNote.NOTE_TYPE) note_type = note_type_reverse[self.kwargs['note_type'].title()] - try: - project = self.request.GET["project"] - print(project) + if project: return GTDNote.objects.filter(note_type=note_type, project__title=project) - except: - return GTDNote.objects.filter(note_type=note_type) + return GTDNote.objects.filter(note_type=note_type) else: - try: - project = self.request.GET["project"] - print(project) + if project: return GTDNote.objects.filter(project__title=project) - except: - return GTDNote.objects.all() + return GTDNote.objects.all() def get_context_data(self, **kwargs): context = super(GTDNoteListView, self).get_context_data(**kwargs) @@ -179,15 +174,23 @@ class WiredNoteListView(ListView): template_name = "gtd/wirednote_list.html" def get_queryset(self): + wiredpost = self.request.GET.get("post", False) if self.kwargs['status']: status_reverse = dict((v, k) for k, v in WiredNote.STATUS) status = status_reverse[self.kwargs['status'].title()] + if wiredpost: + return WiredNote.objects.filter(status=status, post__title=wiredpost) return WiredNote.objects.filter(status=status) + else: + if wiredpost: + return WiredNote.objects.filter(post__title=wiredpost) return WiredNote.objects.all() def get_context_data(self, **kwargs): context = super(WiredNoteListView, self).get_context_data(**kwargs) context['note_statuses'] = WiredNote.STATUS + context['posts'] = WiredPost.objects.all() + context['post'] = self.request.GET.get("post", False) return context -- cgit v1.2.3-70-g09d2