diff options
Diffstat (limited to 'app/gtd/views.py')
-rw-r--r-- | app/gtd/views.py | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/app/gtd/views.py b/app/gtd/views.py index 2fb419e..8aa2c30 100644 --- a/app/gtd/views.py +++ b/app/gtd/views.py @@ -1,10 +1,10 @@ from django.views.generic import UpdateView, DetailView, ListView from django.views.generic.edit import CreateView, DeleteView, UpdateView from django.contrib.auth.mixins import LoginRequiredMixin -from django.urls import reverse +from django.urls import reverse, reverse_lazy from django.db.models import Q -from .models import GTDNote, GTDProject, WiredNote, WiredPost +from .models import GTDNote, GTDProject, GTDOutcome, WiredNote, WiredPost from .forms import GTDNoteCreateForm, GTDNoteEditForm, GTDProjectCreateForm, GTDProjectUpdateForm, WiredNoteCreateForm, WiredNoteEditForm, WiredPostUpdateForm class GTDNoteCreateView(CreateView): @@ -97,10 +97,20 @@ class GTDProjectListView(ListView): model = GTDProject template_name = "gtd/project_list.html" - def get_context_data(self, **kwargs): + def get_queryset(self): + print("hello world") + print(self.kwargs['project_type']) + if self.kwargs['project_type']: + project_type_reverse = dict((v, k) for k, v in GTDProject.PROJECT_TYPE) + project_type = project_type_reverse[self.kwargs['project_type'].title()] + return GTDProject.objects.filter(project_type=project_type) context = super(GTDProjectListView, self).get_context_data(**kwargs) return context + def get_context_data(self, **kwargs): + context = super(GTDProjectListView, self).get_context_data(**kwargs) + context['project_types'] = GTDProject.PROJECT_TYPE + return context class GTDProjectDeleteView(DeleteView): # specify the model you want to use @@ -120,6 +130,7 @@ class GTDNoteTODOView(ListView): class WiredNoteCreateView(CreateView): model = WiredNote form_class = WiredNoteCreateForm + template_name = "gtd/wirednote_form.html" def get_form_kwargs(self): kwargs = super(WiredNoteCreateView, self).get_form_kwargs() @@ -139,6 +150,7 @@ class WiredNoteCreateView(CreateView): class WiredNoteUpdateView(UpdateView): model = WiredNote form_class = WiredNoteEditForm + template_name = "gtd/wirednote_form.html" def get_form_kwargs(self): kwargs = super(WiredNoteUpdateView, self).get_form_kwargs() @@ -150,11 +162,12 @@ class WiredNoteUpdateView(UpdateView): return context def get_success_url(self): - return reverse('gtd:post-detail', kwargs={"pk": self.object.post.pk}) + return reverse('gtd:wiredpost-detail', kwargs={"pk": self.object.post.pk}) class WiredNoteListView(ListView): model = WiredNote + template_name = "gtd/wirednote_list.html" def get_queryset(self): if self.kwargs['status']: @@ -178,14 +191,14 @@ class WiredNoteDeleteView(DeleteView): class WiredPostListView(ListView): model = WiredPost - template_name = 'gtd/post_table.html' + template_name = 'gtd/wiredpost_table.html' def get_queryset(self): return WiredPost.objects.all().order_by("-needs_update") class WiredPostNewView(ListView): - template_name = 'gtd/post_list.html' + template_name = 'gtd/wiredpost_list.html' def get_queryset(self): return WiredPost.objects.filter(is_live=0) @@ -197,7 +210,7 @@ class WiredPostNewView(ListView): class WiredPostTodoView(ListView): - template_name = 'gtd/post_table.html' + template_name = 'gtd/wiredpost_table.html' def get_queryset(self): qs = WiredPost.objects.filter(Q(needs_update=True) | Q(is_live=0)).exclude(post_status=1) @@ -212,6 +225,7 @@ class WiredPostTodoView(ListView): class WiredPostNotesView(DetailView): model = WiredPost + template_name = "gtd/wiredpost_detail.html" def get_context_data(self, **kwargs): context = super(WiredPostNotesView, self).get_context_data(**kwargs) @@ -222,6 +236,7 @@ class WiredPostNotesView(DetailView): class WiredPostUpdateView(UpdateView): model = WiredPost form_class = WiredPostUpdateForm + template_name = "gtd/wiredpost_form.html" def get_form_kwargs(self): kwargs = super(WiredPostUpdateView, self).get_form_kwargs() @@ -239,3 +254,33 @@ class GTDNoteDeleteView(DeleteView): model = GTDNote success_url ="/gtd/notes" template_name = "gtd/confirm_delete.html" + + +class GTDOutcomeCreateView(CreateView): + model = GTDOutcome + template_name = "gtd/outcome_form.html" + fields = ['title', 'body_markdown', 'date_goal', 'date_ended'] + success_url = reverse_lazy("gtd:outcome-list") + + +class GTDOutcomeUpdateView(UpdateView): + model = GTDOutcome + template_name = "gtd/outcome_form.html" + fields = ['title', 'body_markdown', 'date_goal', 'date_ended'] + success_url = reverse_lazy("gtd:outcome-list") + + def get_context_data(self, **kwargs): + context = super(GTDOutcomeUpdateView, self).get_context_data(**kwargs) + context['is_update'] = True + return context + +class GTDOutcomeListView(ListView): + model = GTDOutcome + template_name = "gtd/outcome_list.html" + + +class GTDOutcomeDeleteView(DeleteView): + # specify the model you want to use + model = GTDOutcome + success_url ="/gtd/outcomes" + template_name = "gtd/confirm_delete.html" |