From 5060043253b6444fc9b3d8917474632f7a3325c6 Mon Sep 17 00:00:00 2001 From: Jordan Robinson Date: Sun, 14 Sep 2025 21:39:25 +0100 Subject: [PATCH] add new homepage content update page --- main/templates/main/dashboard.html | 5 +++-- main/templates/main/homepage_update.html | 18 ++++++++++++++++++ main/urls.py | 1 + main/views/general.py | 16 +++++++++++++++- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 main/templates/main/homepage_update.html diff --git a/main/templates/main/dashboard.html b/main/templates/main/dashboard.html index 499e589e5dedf418e202de4f1d47acabdf744583..1608e897a60d3f6dbc4c9da0d5bd4f25e97db1d3 100644 --- a/main/templates/main/dashboard.html +++ b/main/templates/main/dashboard.html @@ -18,8 +18,9 @@
{% endif %} - - Images + + Homepage +
Images
Posts
Pages diff --git a/main/templates/main/homepage_update.html b/main/templates/main/homepage_update.html new file mode 100644 index 0000000000000000000000000000000000000000..681511ab3b240278e3556b6ad20e2afff80d9de8 --- /dev/null +++ b/main/templates/main/homepage_update.html @@ -0,0 +1,18 @@ +{% extends 'main/layout.html' %} + +{% block title %}Homepage content{% endblock %} + +{% block content %} +
+

Homepage content

+ +

You can edit the content that appears on your homepage here. You can use Markdown to format your content.

+

If you want your homepage to show your latest posts instead of this content, you can enable that option below.

+ +
+ {{ form.as_p }} + {% csrf_token %} + +
+
+{% endblock content %} diff --git a/main/urls.py b/main/urls.py index 387d27acbc87356fff54dbd3d0cd706a4f096cef..0f6cfaf8d99f61dde625a028867a1e94fb3eeef6 100644 --- a/main/urls.py +++ b/main/urls.py @@ -97,6 +97,7 @@ urlpatterns += [ path("post//", general.post_detail_redir, name="post_detail_redir_b"), path("blog//edit/", general.PostUpdate.as_view(), name="post_update"), path("blog//delete/", general.PostDelete.as_view(), name="post_delete"), + path("dashboard/homepage/", general.HomepageUpdate.as_view(), name="homepage_update"), ] # blog extras diff --git a/main/views/general.py b/main/views/general.py index 2505368b26172d3be57dc1b685af2c8563d10f2f..dc78d1f4164851fd8fc36f9ef8ea1be6a540a4dd 100644 --- a/main/views/general.py +++ b/main/views/general.py @@ -235,6 +235,21 @@ class UserCreateStepTwo(CreateView): return redirect("index") return super().dispatch(request, *args, **kwargs) +class HomepageUpdate(LoginRequiredMixin, SuccessMessageMixin, UpdateView): + model = models.User + fields = [ + "blog_index_content", + "show_posts_on_homepage", + ] + template_name = "main/homepage_update.html" + success_message = "homepage updated" + success_url = reverse_lazy("dashboard") + + def get_object(self): + return self.request.user + + def form_valid(self, form): + return super().form_valid(form) class UserUpdate(LoginRequiredMixin, SuccessMessageMixin, UpdateView): model = models.User @@ -244,7 +259,6 @@ class UserUpdate(LoginRequiredMixin, SuccessMessageMixin, UpdateView): "blog_title", "posts_page_title", "blog_byline", - "blog_index_content", "subscribe_note", "footer_note", "theme_zialucia",