Commit a4cbb052 authored by Nics De Vega's avatar Nics De Vega

edited url views for app announcement_board

parent 6f2412e0
from django.shortcuts import render
from django.http import HttpResponse
from .models import Announcement, Reaction
from dashboard.models import WidgetUser
def index(request):
return HttpResponse('Hello! This is the Announcement Board!')
return_string = '<body>'
for announcement in Announcement.objects.all():
announcement_heading = '{} by {} {} published {}:<br>'.format(
announcement.title,
announcement.author.first_name,
announcement.author.last_name,
announcement.pub_datetime.strftime("%m/%d/%Y, %I:%M %p")
)
announcement_body = '{}<br>'.format(announcement.body)
announcement_reactions = ''
announcement_reactions += 'Like: {}<br>'.format(Reaction.objects.get(announcement=announcement,name='Like').tally)
announcement_reactions += 'Love: {}<br>'.format(Reaction.objects.get(announcement=announcement,name='Love').tally)
announcement_reactions += 'Angry: {}<br>'.format(Reaction.objects.get(announcement=announcement,name='Angry').tally)
return_string += announcement_heading + announcement_body + announcement_reactions +'<br>'
html_string ='<html>{}</html>'.format(return_string)
return HttpResponse('Widget’s Announcement Board<br><br>Announcements:<br>'+html_string)
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