Commit 9557b2cb authored by Trisha Angel Millena's avatar Trisha Angel Millena Committed by Ysabella Panghulan

Created Details Page: Created forumpost-details.html, edited views.py, edited...

Created Details Page: Created forumpost-details.html, edited views.py, edited urls.py, edited models.py. Edited form.html.
parent 8b7f321c
......@@ -13,8 +13,8 @@ class ForumPost(models.Model):
def __str__(self):
return self.title
def get_absoluteurl(self):
return reverse('forum:forumpost-detail', kwargs={'pk': self.pk})
def get_absolute_url(self):
return reverse('forum:forumpost-details', kwargs={'pk': self.pk})
class Reply(models.Model):
body = models.CharField(max_length = 300)
......
......@@ -10,25 +10,25 @@
<h2>Forum posts:</h2>
<ul>
{% for forum in forums %}
{% for post in forumposts %}
<li>
<a href = "{{forum.get_absouluteurl}}">
{{ forum.title }} by {{ forum.author.first_name }} {{ forum.author.last_name }}
<a href = "{{ post.get_absolute_url }}">
{{ post.title }} by {{ post.author.first_name }} {{ post.author.last_name }}
</a>
</li>
{% endfor %}
</ul>
<a href="/forum/forumposts/add/"> New Button </a>
<a href="../forumposts/add/">New Post</a>
<div>
<a href = "/dashboard/">Dashboard</a>
<a href = "../dashboard/">Dashboard</a>
<a href = "/announcements/">Announcements</a>
<a href = "../announcements/">Announcement Board</a>
<a href = "/assignments/">Assignments</a>
<a href = "../assignments/">Assignments</a>
<a href = "/calendar/">Calendar</a>
<a href = "../calendar/">Calendar</a>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.title }} {% endblock %}
{% block content %}
<h1>{{ object.title }}</h1>
<h2>by {{ object.author.first_name }} {{ object.author.last_name }}</h2>
<h3>{{ object.pub_datetime|date:'m/d/Y, H:i A' }}</h2>
<p>{{ object.body }}</h2>
<h2>POST REPLIES:</h2>
<ul>
{% for reply in object.replies.all %}
<li>
<h2>by {{ reply.author.first_name }} {{ reply.author.last_name }}</h2>
<h3>by {{ reply.pub_datetime|date:'m/d/Y, H:i A' }}</h3>
<p>{{ reply.body }}</p>
</li>
{% endfor %}
</ul>
<form action = "./edit">
<input type = "submit" value = "Edit Post">
</form>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import index
from django.urls import path
from .views import forum, ForumPostDetailView
urlpatterns = [
path('', index, name = "index")
path('', forum, name = "forum"),
path("forum/forumposts/<int:pk>/details/", ForumPostDetailView.as_view(), name = "forumpost-details"),
]
app_name = "forum"
\ No newline at end of file
......@@ -3,15 +3,22 @@ from django.http import HttpResponse
from .models import ForumPost, Reply
from django.views.generic.detail import DetailView
def index(request):
forums = ForumPost.objects.all()
def forum(request):
posts = ForumPost.objects.all()
replies = Reply.objects.all()
context = {
'forums':forums,
'forumposts':posts,
'replies':replies
}
return render(request, 'forum/forum.html', context)
class ForumPostDetailView(DetailView):
model = ForumPost
template_name = 'widget_forum/forum.html'
\ No newline at end of file
template_name = 'forum/forumpost-details.html'
'''
class ForumCreateView(CreateView):
model = ForumPost
template_name = 'forum/forumpost-details.html'
fields = ['title', 'body', 'author']
'''
\ No newline at end of file
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