Commit 3736d8fc authored by nekopilar's avatar nekopilar

added styling to template and image

parent 175beaf3
# Generated by Django 4.0.3 on 2022-05-19 13:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0003_reply_post'),
]
operations = [
migrations.AddField(
model_name='post',
name='post_pic',
field=models.FileField(blank=True, null=True, upload_to='uploads'),
),
]
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %} {% load static %}
{% block title %}Announcements{% endblock %} {% block title %}Forum{% endblock %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="{% static 'announcement_board/announcement_index.css' %}"> <link rel="stylesheet" href="{% static 'forum/forum_index.css' %}">
{% endblock %} {% endblock %}
{% block header %} {% block header %}
......
<!-- forum/forum_detail.html -->
{% extends 'base.html' %}
{% load static %}
{% block title %}Homepage{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'forum/forum_detail.css' %}">
{% endblock %}
{% block header %}
{{object.forum_title}}
{% endblock %}
{% block content %}
<img width=1000 height=200 src="{% static 'forum/default_forumpic.png' %}"/>
<p> by {{object.author.first_name}} {{object.author.last_name}}, {{object.pub_date | date:"d/m/o"}}</p>
<p>{{object.post_body}}</p>
<ul>
{% for reply in replies %}
<li>
<p class="post-link">
{{reply.author.first_name}}
{{reply.author.last_name}},
{{reply.pub_date | date:"d/m/o"}}:
{{reply.reply_body}}
</p> </br>
</li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
...@@ -7,12 +7,16 @@ from .models import Post, Reply ...@@ -7,12 +7,16 @@ from .models import Post, Reply
class ForumView(View): class ForumView(View):
def get(self, request): def get(self, request):
objects_set = { objects_set = {
"all_posts": [obj for obj in Post.objects.all()] "all_posts": [obj for obj in Post.objects.all().order_by('-pub_date')]
} }
return render(request, 'forum/index.html', objects_set) return render(request, 'forum/index.html', objects_set)
class ForumDetailView(DetailView): class ForumDetailView(DetailView):
model = Post model = Post
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['replies'] = Reply.objects.filter(post_id=self.kwargs['pk']).all().order_by('-pub_date')
return context
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