Commit 2565072e authored by Joshua Son's avatar Joshua Son

Improvement: New and improved announcement page with images and style

parent 3d2d6be6
# Generated by Django 3.2.12 on 2022-05-20 11:19
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcements', '0016_alter_announcement_author'),
]
operations = [
migrations.AddField(
model_name='announcement',
name='announce_image',
field=models.ImageField(blank=True, default='faceless_9ltCukV.png', null=True, upload_to=''),
),
]
......@@ -8,7 +8,7 @@ class Announcement(models.Model):
announcement_body = models.CharField(max_length=500)
pub_date = models.DateTimeField("date published")
reaction_list = models.ForeignKey('Reaction', on_delete=models.CASCADE, related_name='+', default=1)
announce_image = models.ImageField(default="faceless_9ltCukV.png", null=True, blank=True)
def __str__(self):
return self.announcement_title
......
h1 {
color: purple;
font-weight:bold;
font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
}
p {
color: orange;
font-weight:bold;
font-family:'Courier New', Courier, monospace;
}
body {
background-color: beige;
font-family:'Courier New', Courier, monospace;
}
a {
color: orangered;
}
\ No newline at end of file
}
{% extends "announcement/base.html" %}
{% block content %}
<h1> {{ announce.announcement_title }} </h1>
<p> <em> by {{ announce.author.first_name}} {{announce.author.last_name}}, {{announce.pub_date}} </em> </p>
<p> {{announce.announcement_body}}</p>
<p> {% include "announcement/reactions_list.html" with reactions=announce.reaction_list %}</p>
<img src="{{announce.announce_image.url}}">
<h1> {{ announce.announcement_title }} </h1>
<p> <em> by {{ announce.author.first_name}} {{announce.author.last_name}}, {{announce.pub_date|date:"d/m/Y h:i:s A"}} </em> </p>
<p> {{announce.announcement_body}}</p>
<ul>
{% for react in reacts %}
<li> {{react.reaction_name}}:{{react.tally}} </li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
......@@ -5,7 +5,7 @@
{% if announce_list %}
<ul>
{% for announce in announce_list %}
<li> <a href = "{% url 'detail' announce.id %}">{{ announce.announcement_title }} by {{announce.author.first_name}} {{announce.author.last_name}} dated {{announce.pub_date}} </a></li>
<li> <a href = "{% url 'detail' announce.id %}">{{ announce.announcement_title }} by {{announce.author.first_name}} {{announce.author.last_name}} dated {{announce.pub_date|date:"d/m/Y h:i:s A"}} </a></li>
{% endfor %}
</ul>
{% else %}
......
{% extends "announcement/base.html" %}
<p>
<p>{{ reactions.reaction_name }} : {{reactions.tally}}</p>
{% if reactions.reaction_self != NULL %}
<p>{% include "announcement/reactions_list.html" with reactions=reactions.reaction_self %}</p>
{% endif %}
</p>
\ No newline at end of file
from django.http import Http404
from django.shortcuts import render
from .models import Announcement
from .models import Announcement, Reaction
# Create your views here.
......@@ -21,5 +21,6 @@ def detail(request, announcement_id):
announce = Announcement.objects.get(pk=announcement_id)
except Announcement.DoesNotExist:
raise Http404("Announcement does not exist!")
return render(request, "announcement/announcement_board.html", {"announce": announce})
\ No newline at end of file
reacts = Reaction.objects.filter(announcement_id=announce).order_by("reaction_name")
return render(request, "announcement/announcement_board.html", {"announce": announce, "reacts": reacts})
\ No newline at end of file
<p>
<i> Reply by {{post.author.first_name}} {{post.author.last_name}} dated {{reply.pub_date}}: </i>
<i> Reply by {{post.author.first_name}} {{post.author.last_name}} dated {{reply.pub_date|date:"d/m/Y h:i:s A"}}: </i>
</p>
<p>{{reply.reply_body}}</p>
......
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