diff options
author | luxagraf <sng@luxagraf.net> | 2023-07-27 08:48:30 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2023-07-27 08:48:30 -0500 |
commit | 3e31c2bb0e5984d344a1c5d7144fb956b395f062 (patch) | |
tree | 9b93bed5b6c7a6b580dce5a37679cd9158271d8a /app | |
parent | 65b1bb075774478bc717de81f0737f96cf32e497 (diff) |
posts: added new view and new posts template
Diffstat (limited to 'app')
-rw-r--r-- | app/posts/templates/posts/post_list.html | 74 | ||||
-rw-r--r-- | app/posts/templates/posts/post_table.html | 80 | ||||
-rw-r--r-- | app/posts/views.py | 6 |
3 files changed, 89 insertions, 71 deletions
diff --git a/app/posts/templates/posts/post_list.html b/app/posts/templates/posts/post_list.html index 2fa18a0..316a11b 100644 --- a/app/posts/templates/posts/post_list.html +++ b/app/posts/templates/posts/post_list.html @@ -4,75 +4,11 @@ {%endblock%} {% block primary %} <main class="content"> -<div class="results"> -<table class="sortable" id="result_list"> -<thead> -<tr> -<th scope="col" class="sortable column-title"> - <div class="text"><span>Title</span></div> -</th> -<th scope="col" class="column-admin_url"> - <div class="text"><span>URL</span></div> -</th> -<th scope="col" class="sortable column-date_last_pub sorted ascending"> -Date last pub - </th> -<th scope="col" class="sortable column-post_type"> - <div class="text">Post type</div> -</th> -<th scope="col" class="sortable column-update_frequency"> - <div class="text">Update frequency</div> -</th> -<th scope="col" class="sortable column-needs_update"> - <div class="text">Needs update</div> -</th> -<th scope="col" class="column-days_overdue"> - <div class="text"><span>Days overdue</span></div> -</th> -</tr> -</thead> -<tbody>{% for object in object_list %} -<tr> - <td class="field-title"> - <a href="/post/{{object.id}}/notes">{{object.title}}</a> - </td> - <td class="field-admin_url"> - <a target="_blank" href="{{object.url}}"> - {{object.url|truncatechars:55}} - </a> - </td> - <td class="field-date_last_pub nowrap">{{object.date_last_pub}}</td> - <td class="field-post_type"><span class="hide">{{object.post_type}}</span>{{object.get_post_type_display}}</td> - <td class="field-update_frequency">{{object.update_frequency}}</td> - <td class="field-needs_update">{% if object.needs_update %} - <span class="hide">1</span><img src="/static/admin/img/icon-yes.svg" alt="True">{%else%} - <span class="hide">0</span><img src="/static/admin/img/icon-no.svg" alt="False">{%endif%} - </td> - <td class="field-days_overdue">{{object.days_overdue}}</td></tr> -</tr> -{% endfor %} -{% if reviews %}{% for object in reviews %} -<tr> - <td class="field-title"> - <a href="/post/{{object.id}}/notes">{{object.title}}</a> - </td> - <td class="field-admin_url"> - <a target="_blank" href="{{object.url}}"> - {{object.url|truncatechars:55}} - </a> - </td> - <td class="field-date_last_pub nowrap">{{object.date_last_pub}}</td> - <td class="field-post_type"><span class="hide">{{object.post_type}}</span>{{object.get_post_type_display}}</td> - <td class="field-update_frequency">{{object.update_frequency}}</td> - <td class="field-needs_update">{% if object.needs_update %} - <span class="hide">1</span><img src="/static/admin/img/icon-yes.svg" alt="True">{%else%} - <span class="hide">0</span><img src="/static/admin/img/icon-no.svg" alt="False">{%endif%} - </td> - <td class="field-days_overdue">{{object.days_overdue}}</td></tr> -</tr>{% endfor %}{% endif %} -</tbody> -</table> -</div> + <ul>{% for object in object_list %} + <li> + <a href="/post/{{object.id}}/notes">{{object.title}}</a> + </li>{% endfor %} + </ul> </main> {% endblock %} {% block js %} diff --git a/app/posts/templates/posts/post_table.html b/app/posts/templates/posts/post_table.html new file mode 100644 index 0000000..2fa18a0 --- /dev/null +++ b/app/posts/templates/posts/post_table.html @@ -0,0 +1,80 @@ +{% extends 'base.html' %} +{%block extrahead%} +<link href="/media/sortable.min.css" rel="stylesheet" /> +{%endblock%} +{% block primary %} +<main class="content"> +<div class="results"> +<table class="sortable" id="result_list"> +<thead> +<tr> +<th scope="col" class="sortable column-title"> + <div class="text"><span>Title</span></div> +</th> +<th scope="col" class="column-admin_url"> + <div class="text"><span>URL</span></div> +</th> +<th scope="col" class="sortable column-date_last_pub sorted ascending"> +Date last pub + </th> +<th scope="col" class="sortable column-post_type"> + <div class="text">Post type</div> +</th> +<th scope="col" class="sortable column-update_frequency"> + <div class="text">Update frequency</div> +</th> +<th scope="col" class="sortable column-needs_update"> + <div class="text">Needs update</div> +</th> +<th scope="col" class="column-days_overdue"> + <div class="text"><span>Days overdue</span></div> +</th> +</tr> +</thead> +<tbody>{% for object in object_list %} +<tr> + <td class="field-title"> + <a href="/post/{{object.id}}/notes">{{object.title}}</a> + </td> + <td class="field-admin_url"> + <a target="_blank" href="{{object.url}}"> + {{object.url|truncatechars:55}} + </a> + </td> + <td class="field-date_last_pub nowrap">{{object.date_last_pub}}</td> + <td class="field-post_type"><span class="hide">{{object.post_type}}</span>{{object.get_post_type_display}}</td> + <td class="field-update_frequency">{{object.update_frequency}}</td> + <td class="field-needs_update">{% if object.needs_update %} + <span class="hide">1</span><img src="/static/admin/img/icon-yes.svg" alt="True">{%else%} + <span class="hide">0</span><img src="/static/admin/img/icon-no.svg" alt="False">{%endif%} + </td> + <td class="field-days_overdue">{{object.days_overdue}}</td></tr> +</tr> +{% endfor %} +{% if reviews %}{% for object in reviews %} +<tr> + <td class="field-title"> + <a href="/post/{{object.id}}/notes">{{object.title}}</a> + </td> + <td class="field-admin_url"> + <a target="_blank" href="{{object.url}}"> + {{object.url|truncatechars:55}} + </a> + </td> + <td class="field-date_last_pub nowrap">{{object.date_last_pub}}</td> + <td class="field-post_type"><span class="hide">{{object.post_type}}</span>{{object.get_post_type_display}}</td> + <td class="field-update_frequency">{{object.update_frequency}}</td> + <td class="field-needs_update">{% if object.needs_update %} + <span class="hide">1</span><img src="/static/admin/img/icon-yes.svg" alt="True">{%else%} + <span class="hide">0</span><img src="/static/admin/img/icon-no.svg" alt="False">{%endif%} + </td> + <td class="field-days_overdue">{{object.days_overdue}}</td></tr> +</tr>{% endfor %}{% endif %} +</tbody> +</table> +</div> +</main> +{% endblock %} +{% block js %} +<script src="/media/sortable.min.js"></script> +{% endblock%} diff --git a/app/posts/views.py b/app/posts/views.py index f406d29..402b473 100644 --- a/app/posts/views.py +++ b/app/posts/views.py @@ -8,20 +8,21 @@ from notes.models import Note class PostListView(LoginRequiredMixin, ListView): model = Post + template_name = 'posts/post_table.html' def get_queryset(self): return Post.objects.filter(user=self.request.user).order_by("-needs_update") class PostNewView(LoginRequiredMixin, ListView): - template_name = 'notes/notes_detail.html' + template_name = 'posts/post_list.html' def get_queryset(self): return Post.objects.filter(user=self.request.user).filter(is_live=0) class PostTodoView(LoginRequiredMixin, ListView): - template_name = 'posts/post_list.html' + template_name = 'posts/post_table.html' def get_queryset(self): qs = Post.objects.filter(user=self.request.user) @@ -34,5 +35,6 @@ class PostTodoView(LoginRequiredMixin, ListView): context['reviews'] = Note.objects.filter(plan=1) return context + class PostNotesView(LoginRequiredMixin, DetailView): model = Post |