M main/templates/main/dashboard.html => main/templates/main/dashboard.html +3 -2
@@ 18,8 18,9 @@
</a>
<br>
{% endif %}
-
- <a href="{% url 'image_list' %}">Images</a>
+
+ <a href="{% url 'homepage_update' %}">Homepage</a>
+ <br><a href="{% url 'image_list' %}">Images</a>
<br><a href="{% url 'post_list' %}">Posts</a>
<br><a href="{% url 'page_list' %}">Pages</a>
A main/templates/main/homepage_update.html => main/templates/main/homepage_update.html +18 -0
@@ 0,0 1,18 @@
+{% extends 'main/layout.html' %}
+
+{% block title %}Homepage content{% endblock %}
+
+{% block content %}
+<main>
+ <h1>Homepage content</h1>
+
+ <p>You can edit the content that appears on your homepage here. You can use <a href="https://daringfireball.net/projects/markdown/syntax" target="_blank" rel="noopener">Markdown</a> to format your content.</p>
+ <p>If you want your homepage to show your latest posts instead of this content, you can enable that option below.</p>
+
+ <form method="post">
+ {{ form.as_p }}
+ {% csrf_token %}
+ <input type="submit" value="Save">
+ </form>
+</main>
+{% endblock content %}
M main/urls.py => main/urls.py +1 -0
@@ 97,6 97,7 @@ urlpatterns += [
path("post/<slug:slug>/", general.post_detail_redir, name="post_detail_redir_b"),
path("blog/<slug:slug>/edit/", general.PostUpdate.as_view(), name="post_update"),
path("blog/<slug:slug>/delete/", general.PostDelete.as_view(), name="post_delete"),
+ path("dashboard/homepage/", general.HomepageUpdate.as_view(), name="homepage_update"),
]
# blog extras
M main/views/general.py => main/views/general.py +15 -1
@@ 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",