From cf0f93063a8a6c712c22b83eb5297cc9a0bb85e8 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Wed, 26 Jul 2023 14:32:40 -0500 Subject: notes: added buttons for each status of note --- app/notes/models.py | 2 +- app/notes/templates/notes/note_list.html | 9 +++++++-- app/notes/urls.py | 2 +- app/notes/views.py | 15 ++++++++------- templates/base.html | 1 - 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/notes/models.py b/app/notes/models.py index 6fa3cca..ffd0a25 100644 --- a/app/notes/models.py +++ b/app/notes/models.py @@ -24,7 +24,7 @@ class Note(models.Model): status = models.IntegerField(choices=STATUS, default=0) class Meta: - ordering = ('date_created',) + ordering = ('date_created', 'status') def __str__(self): return self.title diff --git a/app/notes/templates/notes/note_list.html b/app/notes/templates/notes/note_list.html index 2c74335..094fbea 100644 --- a/app/notes/templates/notes/note_list.html +++ b/app/notes/templates/notes/note_list.html @@ -1,13 +1,18 @@ {% extends 'base.html' %} {% block primary %}
-
- New Note +
{% for object in object_list %} {% endfor%}
diff --git a/app/notes/urls.py b/app/notes/urls.py index ecf7c5c..5571f46 100644 --- a/app/notes/urls.py +++ b/app/notes/urls.py @@ -19,7 +19,7 @@ urlpatterns = [ path( r'', views.NoteListView.as_view(), - name="todo" + name="status" ), path( r'/edit', diff --git a/app/notes/views.py b/app/notes/views.py index 0b31bcd..7dd9c04 100644 --- a/app/notes/views.py +++ b/app/notes/views.py @@ -45,11 +45,12 @@ class NoteListView(LoginRequiredMixin, ListView): def get_queryset(self): if self.kwargs['status']: - if self.kwargs['status'] == "todo": - status = "Call In" - else: - status = self.kwargs['status'] status_reverse = dict((v, k) for k, v in Note.STATUS) - qs = Note.objects.filter(user=self.request.user).filter(status=status_reverse[status]) - qs = Note.objects.filter(user=self.request.user) - return qs + status = status_reverse[self.kwargs['status'].title()] + return Note.objects.filter(user=self.request.user, status=status) + return Note.objects.filter(user=self.request.user) + + def get_context_data(self, **kwargs): + context = super(NoteListView, self).get_context_data(**kwargs) + context['note_statuses'] = Note.STATUS + return context diff --git a/templates/base.html b/templates/base.html index c980b1b..0d85eae 100644 --- a/templates/base.html +++ b/templates/base.html @@ -20,7 +20,6 @@ W