Commit 2972cd28 authored by Alliyah Marcelo's avatar Alliyah Marcelo

Final commit.

parent 991f5c63
......@@ -10,7 +10,7 @@ class ForumPost(models.Model):
on_delete=models.CASCADE,
related_name='forumpost_author'
)
pub_datetime = models.DateTimeField()
pub_datetime = models.DateTimeField(auto_now=True)
def __str__(self):
return '{} by {} posted {}: {}'.format(
......
......@@ -8,18 +8,19 @@
{% block content %}
<p>
Forum Posts:<br>
{% for post in posts %}
{% for post in posts|slice:"::-1" %}
<a href="{{ post.get_absolute_url }}">
{{ post.title }} by {{ post.author }}
{{ post.title }} by {{ post.author.first_name }} {{ post.author.last_name }}
</a><br>
{% endfor %}
</p>
{% endblock %}
{% block footing %}
<a href="{% url 'forum:forumpost-create' %}">
<button class="btn add">New Post</button>
</a><br>
</a><br><br>
<a href="/dashboard/" class="link">Dashboard</a><br>
<a href="/announcements/" class="link">Announcements</a><br>
......
......@@ -11,11 +11,18 @@
{% block content %}
<p>
by {{ object.author }}<br>
{{ object.pub_datetime }}<br>
by {{ object.author.first_name }} {{ object.author.last_name }}<br>
{{ object.pub_datetime|date:"m/d/Y" }}, {{ object.pub_datetime|time:"g:iA" }}<br>
{{ object.body }}<br>
</p>
{% endblock %}
POST REPLIES:<br>
{% for reply in replys %}
{% if reply.forumpost == object %}
by {{ reply.author.first_name }} {{ reply.author.last_name }}<br>
{{ reply.pub_datetime|date:"m/d/Y" }}, {{ reply.pub_datetime|time:"g:iA" }}<br>
{{ reply.body }}<br><br>
{% endif %}
{% endfor %}
{% block footing %}
<a href="{% url 'forum:forumpost-update' object.pk %}">
......
......@@ -4,7 +4,7 @@ from .views import (forum, ForumPostDetailView,
ForumPostCreateView, ForumPostUpdateView)
urlpatterns = [
path('forum/', forum, name='forum'),
path('', forum, name='forum'),
path('forumposts/<int:pk>/details/',
ForumPostDetailView.as_view(),
name='forumpost-details'),
......
......@@ -2,7 +2,7 @@ from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import ForumPost
from .models import ForumPost, Reply
def forum(request):
......@@ -14,6 +14,11 @@ class ForumPostDetailView(DetailView):
model = ForumPost
template_name = 'forum/forumpost-details.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['replys'] = Reply.objects.all()
return context
class ForumPostCreateView(CreateView):
model = ForumPost
......
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