diff options
-rw-r--r-- | app/posts/templates/posts/post_detail.html | 14 | ||||
-rw-r--r-- | app/posts/views.py | 4 |
2 files changed, 13 insertions, 5 deletions
diff --git a/app/posts/templates/posts/post_detail.html b/app/posts/templates/posts/post_detail.html index 193cfa5..bf2998f 100644 --- a/app/posts/templates/posts/post_detail.html +++ b/app/posts/templates/posts/post_detail.html @@ -5,11 +5,15 @@ <h1><a href="{{object.url}}">{{object.title}}</a></h1> <p>Last Updated: {{object.date_last_pub}}</p> <p>Needs Update: {% if object.needs_update %} Yes {% if object.days_overdue %}{{object.days_overdue}} days overdue{%endif %}{%endif%}</p> - </div> - <div class="note-list">{% for object in object.note_set.all%}<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>Status: {% if object.status == 0 %}<span class="alert">{{object.get_status_display}}</span>{%else%}{{object.get_status_display}}{%endif%}</p></article> + </div>{% regroup notes by get_status_display as newlist %} + <div class="note-list">{% for obj in newlist %} + <h5>{{obj.grouper}}</h5> + {% for object in obj.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>Status: {% if object.status == 0 %}<span class="alert">{{object.get_status_display}}</span>{%else%}{{object.get_status_display}}{%endif%}</p> + </article>{%endfor%} {% endfor%}</div> </main> {% endblock %} diff --git a/app/posts/views.py b/app/posts/views.py index 250611f..6241314 100644 --- a/app/posts/views.py +++ b/app/posts/views.py @@ -54,6 +54,10 @@ class PostTodoView(LoginRequiredMixin, ListView): class PostNotesView(LoginRequiredMixin, DetailView): model = Post + def get_context_data(self, **kwargs): + context = super(PostNotesView, self).get_context_data(**kwargs) + context['notes'] = self.get_object().note_set.all().order_by("status") + return context class PostUpdateView(LoginRequiredMixin, UpdateView): model = Post |