diff options
author | luxagraf <sng@luxagraf.net> | 2023-07-19 13:43:28 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2023-07-19 13:43:28 -0500 |
commit | 258a1fd1b46de9c81f75929d8401c7e8132157c6 (patch) | |
tree | ebed648856a2e85cc679219699c07e11577ff4d7 | |
parent | b57ea2a45e541f7048df141949325637f5088d5f (diff) |
posts: added notes list
-rw-r--r-- | app/posts/templates/posts/post_detail.html | 11 | ||||
-rw-r--r-- | app/posts/urls.py | 5 | ||||
-rw-r--r-- | app/posts/views.py | 4 | ||||
-rw-r--r-- | config/base_urls.py | 2 |
4 files changed, 22 insertions, 0 deletions
diff --git a/app/posts/templates/posts/post_detail.html b/app/posts/templates/posts/post_detail.html new file mode 100644 index 0000000..c616361 --- /dev/null +++ b/app/posts/templates/posts/post_detail.html @@ -0,0 +1,11 @@ +{% extends 'base.html' %} +{% block primary %} +<h1><a href="{{object.url}}">{{object.title}}</a></h1> + <p>Last Updated: {{object.date_last_pub}}{% if object.needs_update %}<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%} overdue: {{object.days_overdue}}</p> +<div class="note-list">{% for object in object.note_set.all%} + <h2><a href="{{object.url}}">{{object.title}}</a></h2> + <p>{{object.body_markdown}}</p> +</div>{% endfor%} +{% endblock %} + {% block js %} + {% endblock%} diff --git a/app/posts/urls.py b/app/posts/urls.py index ea96e92..2b5e850 100644 --- a/app/posts/urls.py +++ b/app/posts/urls.py @@ -10,4 +10,9 @@ urlpatterns = [ views.PostListView.as_view(), name="list" ), + path( + r'<pk>/notes', + views.PostNotesView.as_view(), + name="detail" + ), ] diff --git a/app/posts/views.py b/app/posts/views.py index 2048f28..41475d8 100644 --- a/app/posts/views.py +++ b/app/posts/views.py @@ -16,6 +16,10 @@ class PostListView(ListView): return Post.objects.filter(user=self.request.user).order_by("-needs_update") +class PostNotesView(DetailView): + model = Post + + ''' class UpdateViewWithUser(UpdateView): diff --git a/config/base_urls.py b/config/base_urls.py index 4d3a58d..ba981f6 100644 --- a/config/base_urls.py +++ b/config/base_urls.py @@ -13,6 +13,8 @@ AdminSite.site_title = "Sorting" urlpatterns = [ path(r'admin/', admin.site.urls), path(r'code/', include('deals.urls', namespace='deals')), + path(r'post/', include('posts.urls')), + re_path(r'^post/$', RedirectView.as_view(url='/posts/')), path(r'posts/', include('posts.urls', namespace='posts')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) |