diff options
author | luxagraf <sng@luxagraf.net> | 2023-07-19 13:16:51 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2023-07-19 13:16:51 -0500 |
commit | b57ea2a45e541f7048df141949325637f5088d5f (patch) | |
tree | 42dda183288bc52e396d1946845436ffad15aff9 /app | |
parent | cadb4a09bfa9457171f03848dd054c987fda3322 (diff) |
posts: prettied up the table
Diffstat (limited to 'app')
-rw-r--r-- | app/posts/templates/posts/post_list.html | 84 | ||||
-rw-r--r-- | app/posts/urls.py | 13 | ||||
-rw-r--r-- | app/posts/views.py | 44 |
3 files changed, 141 insertions, 0 deletions
diff --git a/app/posts/templates/posts/post_list.html b/app/posts/templates/posts/post_list.html new file mode 100644 index 0000000..4c54f62 --- /dev/null +++ b/app/posts/templates/posts/post_list.html @@ -0,0 +1,84 @@ +{% extends 'base.html' %} +{%block extrahead%} +<link href="/media/sortable.min.css" rel="stylesheet" /> +{%endblock%} +{% block primary %} +<div class="results"> +<table class="sortable" id="result_list"> +<thead> +<tr> + +<th scope="col" class="action-checkbox-column"> + + <div class="text"><span><input type="checkbox" id="action-toggle"></span></div> + <div class="clear"></div> +</th> +<th scope="col" class="sortable column-title"> + + <div class="text"><span>Title</span></div> + <div class="clear"></div> +</th> +<th scope="col" class="column-admin_url"> + + <div class="text"><span>URL</span></div> + <div class="clear"></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"><a href="">Post type</a></div> + <div class="clear"></div> +</th> +<th scope="col" class="sortable column-update_frequency"> + + + + <div class="text"><a href="?o=6.4">Update frequency</a></div> + <div class="clear"></div> +</th> +<th scope="col" class="sortable column-needs_update"> + <div class="text">Needs update</div> + <div class="clear"></div> +</th> +<th scope="col" class="column-days_overdue"> + <div class="text"><span>Days overdue</span></div> + <div class="clear"></div> +</th> +</tr> +</thead> +<tbody> + + +{% for object in object_list %} +<tr> + <td class="action-checkbox"> + <input type="checkbox" name="_selected_action" value="349" class="action-select"> + </td> + <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}} + </a> + </td> + <td class="field-date_last_pub nowrap">{{object.date_last_pub}}</td> + <td class="field-post_type">{{object.post_type}}</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 %} + + +</tbody> +</table> +</div> +{% endblock %} + {% block js %} +<script src="/media/sortable.min.js"></script> + {% endblock%} diff --git a/app/posts/urls.py b/app/posts/urls.py new file mode 100644 index 0000000..ea96e92 --- /dev/null +++ b/app/posts/urls.py @@ -0,0 +1,13 @@ +from django.urls import path, re_path + +from . import views + +app_name = "posts" + +urlpatterns = [ + path( + r'', + views.PostListView.as_view(), + name="list" + ), +] diff --git a/app/posts/views.py b/app/posts/views.py new file mode 100644 index 0000000..2048f28 --- /dev/null +++ b/app/posts/views.py @@ -0,0 +1,44 @@ +from django.views.generic import UpdateView, DetailView, ListView +from django.utils.decorators import method_decorator +from django.contrib.auth.decorators import login_required + +from .models import Post + + +class PostListView(ListView): + model = Post + + @method_decorator(login_required) + def dispatch(self, *args, **kwargs): + return super(PostListView, self).dispatch(*args, **kwargs) + + def get_queryset(self): + return Post.objects.filter(user=self.request.user).order_by("-needs_update") + + +''' + +class UpdateViewWithUser(UpdateView): + + def get_form_kwargs(self, **kwargs): + kwargs = super().get_form_kwargs(**kwargs) + kwargs.update({'user': self.request.user}) + return kwargs + + +class ProfileView(UpdateViewWithUser): + model = UserProfile + form_class = ProfileForm + template_name = "accounts/change-settings.html" + + def get_object(self): + return self.request.user.profile + + +class SettingsListView(DetailView): + model = UserProfile + template_name = "accounts/profile.html" + + def get_object(self): + return self.request.user.profile +''' |