Commit 32e443b6 authored by Cherish Magpayo's avatar Cherish Magpayo

Updated views for announcement page

parent 291cfb3d
from django.http import HttpResponse from django.http import HttpResponse
from announcements.models import Announcement
# Create your views here. # Create your views here.
def index(request): def index(request):
return HttpResponse("This is the Announcement Board!") announcement_objects = Announcement.objects.all()
\ No newline at end of file response = "ANNOUNCEMENTS:<br>"
for announcement in announcement_objects:
like = announcement.reaction_set.get(reaction_name="LIKE").tally
love = announcement.reaction_set.get(reaction_name="LOVE").tally
angry = announcement.reaction_set.get(reaction_name="ANGRY").tally
response = (response + f"{announcement.announcement_title} by"
+ f"{announcement.author.first_name} {announcement.author.last_name}"
+ f"dated {announcement.pub_date.date()}:<br> {announcement.announcement_body} <br>"
+ f"Like: {like} <br> Love: {love} <br> Angry: {angry}<br><br>")
return HttpResponse(response)
\ 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