Commit d73659ee authored by Eury See's avatar Eury See

Edited the links to the pages' buttons and fixed minor details.

parent e8f4b864
......@@ -20,16 +20,16 @@
<p1>Forum posts:</p1>
{% for post in posts %}
<li><a href="{% url 'Forum:forumpost-details' pk=post.pk %}">{{post.title}} by {{post.author}}</a></li>
<li><a href="{% url 'Forum:forumpost-details' pk=post.pk %}">{{ post.title }} by {{ post.author }}</a></li>
{% endfor %}
<br>
<form method="post">
{% csrf_token %}
{{form.as_p}}
<button type="submit">New Post</button>
</form>
<button type="submit">
<a href="{% url 'Forum:forumpost-add' %}">New Post</a>
</button>
<br>
<br>
<a href="http://127.0.0.1:8000/Dashboard/dashboard">Dashboard</a>
<br>
<a href="http://127.0.0.1:8000/Announcements/announcements">Announcements</a>
......
......@@ -20,7 +20,7 @@
<br>
{{ object.body }}
<p>Post Replies:</p>
<h2>Post Replies:</h2>
{% for reply in replies %}
by {{ reply.author }}
{{ reply.pub_datetime }}
......@@ -29,12 +29,13 @@
No replies yet.
{% endfor %}
<form method="post">
{% csrf_token %}
<br><button type="submit">
Edit Post
</button>
</form>
<br>
<br>
<button type="submit">
<a href="{% url 'Forum:forumpost-edit' pk=forumpost.pk %}">Edit Post</a>
</button>
</form>
</div>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import (
index, forum, ForumDetailView, AddForumPostView, EditForumPostView)
index, forum, ForumDetailView, AddForumPostView,
EditForumPostView, ForumListView)
from . import views
urlpatterns = [
path("", views.index, name="index"),
path('forum/', forum, name='forum'),
path('forum/', ForumListView.as_view(), name='forum'),
path('forum/forumposts/<int:pk>/details/', ForumDetailView.as_view(), name='forumpost-details'),
path('forum/forumposts/add/', AddForumPostView.as_view(), name='forumpost-add'),
path('forum/forumposts/<pk>/edit/', EditForumPostView.as_view(), name = 'forumpost-edit'),
......
......@@ -4,6 +4,7 @@ from django.views import View
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView
from django.views.generic.edit import UpdateView
from django.views.generic.list import ListView
from .models import ForumPost, Reply
......@@ -24,6 +25,12 @@ def forum(request):
context = {'posts': posts}
return render(request, 'forum.html', context)
class ForumListView(ListView):
model = ForumPost
template_name = 'forum.html'
context_object_name = 'posts'
ordering = ['-pub_datetime'] # sort by newest to oldest
class ForumDetailView(DetailView):
model = ForumPost
template_name = 'forumpost-details.html'
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment