diff options
author | luxagraf <sng@luxagraf.net> | 2023-07-26 14:32:40 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2023-07-26 14:32:40 -0500 |
commit | cf0f93063a8a6c712c22b83eb5297cc9a0bb85e8 (patch) | |
tree | a8fd27e812ab772eaa2a8b96e8d0cf3e83e31538 | |
parent | bbf7c09dc6efcbc7610fd79fa791f25168f72806 (diff) |
notes: added buttons for each status of note
-rw-r--r-- | app/notes/models.py | 2 | ||||
-rw-r--r-- | app/notes/templates/notes/note_list.html | 9 | ||||
-rw-r--r-- | app/notes/urls.py | 2 | ||||
-rw-r--r-- | app/notes/views.py | 15 | ||||
-rw-r--r-- | 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 %} <main class="post-detail"> - <div class="post-header"> - <a href="/notes/create" class="btn">New Note</a> + <div class="post-header"><ul class="flex header-list"> + {% for status in note_statuses %} + <li><a class="btn" href="/notes/{{status.1|lower}}">{{status.1}}</a></li> + {% endfor %} + <li class="right"><a href="/notes/create" class="btn">New Note</a></li> + </ul> </div> <div class="note-list">{% for object in object_list %}<article> <h2>{%if object.url%}<a href="{{object.url}}">{{object.title}}</a>{%else%}{{object.title}}{%endif%}<span class="note-edit"><a href="{{object.get_absolute_url}}">edit</a></span></h2> <p>{{object.body_markdown}}</p> <p class="small">For: <a href="/post/{{object.post.pk}}/notes">{{object.post}}</a></p> + <p class="small">Status: <a href="/post/{{object.post.pk}}/notes">{{object.get_status_display}}</a></p> </article> {% endfor%}</div> </main> 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'<str:status>', views.NoteListView.as_view(), - name="todo" + name="status" ), path( r'<pk>/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 @@ <a class="logo-link" href="/" title="Home">W</span></a> </div> <nav> - <a class="nav-item" href="/notes/todo" title="See what needs to be called in">Call in</a> <a class="nav-item" href="/notes" title="View Guides">Notes</a> <a class="nav-item" href="/posts" title="View Guides">Guides</a> <a class="nav-item" href="/posts/todo" title="View Guides">todo</a> |