summaryrefslogtreecommitdiff
path: root/app/gtd/views.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2023-11-18 08:59:29 -0500
committerluxagraf <sng@luxagraf.net>2023-11-18 08:59:29 -0500
commit4c8c13d44fe30bc284ed03087454dd19c1f281f8 (patch)
tree4db5aa524c10ae55b2734b5810245a156094481f /app/gtd/views.py
parent344da65e7ef3c7b5fa97909d6d8fb2dbb453be92 (diff)
gtd: added per project filtering to notes view
Diffstat (limited to 'app/gtd/views.py')
-rw-r--r--app/gtd/views.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/app/gtd/views.py b/app/gtd/views.py
index b49f106..235867d 100644
--- a/app/gtd/views.py
+++ b/app/gtd/views.py
@@ -40,7 +40,11 @@ class GTDNoteUpdateView(UpdateView):
return context
def get_success_url(self):
- return reverse('gtd:project-detail', kwargs={"pk": self.object.project.pk})
+ if self.object.project:
+ return reverse('gtd:project-detail', kwargs={"pk": self.object.project.pk})
+ else:
+ return reverse('gtd:note-list', kwargs={"pk": self.object.project.pk})
+
class GTDNoteListView(ListView):
@@ -52,12 +56,25 @@ class GTDNoteListView(ListView):
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()]
- return GTDNote.objects.filter(note_type=note_type)
- return GTDNote.objects.all()
+ try:
+ project = self.request.GET["project"]
+ print(project)
+ return GTDNote.objects.filter(note_type=note_type, project__title=project)
+ except:
+ return GTDNote.objects.filter(note_type=note_type)
+ else:
+ try:
+ project = self.request.GET["project"]
+ print(project)
+ return GTDNote.objects.filter(project__title=project)
+ except:
+ return GTDNote.objects.all()
def get_context_data(self, **kwargs):
context = super(GTDNoteListView, self).get_context_data(**kwargs)
context['note_types'] = GTDNote.NOTE_TYPE
+ context['projects'] = GTDProject.objects.all()
+ context['project'] = self.request.GET.get("project", False)
return context
@@ -151,7 +168,10 @@ class WiredNoteUpdateView(UpdateView):
return context
def get_success_url(self):
- return reverse('gtd:wiredpost-detail', kwargs={"pk": self.object.post.pk})
+ if self.object.post:
+ return reverse('gtd:wiredpost-detail', kwargs={"pk": self.object.post.pk})
+ else:
+ return reverse('gtd:wirednote-list', kwargs={"pk": self.object.project.pk})
class WiredNoteListView(ListView):