Commit 578c4f34 authored by Joshua Son's avatar Joshua Son

'y

parent 6f2945ed
......@@ -6,13 +6,15 @@ class Announcement(models.Model):
announcement_body = models.CharField(max_length=500)
pub_date = models.DateTimeField("date published")
def __str__(self):
return self.announcement_title
class Reaction(models.Model):
announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE)
announcement = models.ForeignKey('Announcement', on_delete=models.CASCADE)
reaction_name = models.CharField(max_length=10)
tally = models.IntegerField(default=0)
def __str__(self):
return self.reaction_name
\ No newline at end of file
<p>
<h2>ANNOUNCEMENTS: </h2>
{% for announcement in announcements%}
<p><b>{{announcement.announcement_title}}</b> dated {{announcement.pub_date}}</p>
<p>{{announcement.announcement_body}}</p>
{% if announcement.reaction_list != NULL %}
<p>{% include "reaction_list.html" with reaction=announcement.reaction_list %}</p>
{% endif %}
{{ value|linebreaks }}
{% endfor %}
</p>
\ No newline at end of file
<p>
{% for reaction in reactions %}
<p>{{ reaction.reaction_name }} : {{reaction.tally}} </p>
{{ value|linebreaks }}
{% endfor %}
</p>
\ No newline at end of file
......@@ -3,5 +3,5 @@ from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index')
path('', views.show_announcements, name='show_announcements')
]
\ No newline at end of file
from django.http import HttpResponse
from django.shortcuts import render
from .models import Announcement, Reaction
# Create your views here.
def index(request):
return HttpResponse("This is the Announcement Board!")
\ No newline at end of file
def show_announcements(request):
announcement = Announcement.objects.all()
return render(request, 'announcement_board.html', {'announcements': announcement})
\ 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