Commit 6ee33d60 authored by Ross Batacan's avatar Ross Batacan

Modified announcements/views.py to display author name under announcements

parent e577fc0f
......@@ -7,7 +7,7 @@ from dashboard.models import WidgetUser
class Announcement(models.Model):
announcement_title = models.CharField(max_length=50, unique=True, null=True, )
announcement_body = models.CharField(max_length=250, unique=True, null=True, )
announcement_author = models.ForeignKey(WidgetUser,on_delete=models.CASCADE, null=True)
announcement_author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, null=True)
announcement_pub_datetime = models.DateTimeField(null=True, )
def __str__(self):
......
......@@ -8,13 +8,16 @@ from .models import Announcement, Reaction
def announcements(request):
announcement = Announcement.objects.all()
response = "<h2>Widget's Announcement Board</h2>"
response = "<h3>Widget's Announcement Board</h3>"
for every in announcement:
datetime = every.announcement_pub_datetime.strftime("%a, %b %d, %Y %I:%M %p")
response += "<h3>{}</h3>".format(every.announcement_title) +\
"<p>By --insert foreign name-- published {}</p>".format(datetime)
response += "<p>{}".format(every.announcement_title) +\
" By {}".format(every.announcement_author.first_name) +\
" {}".format(every.announcement_author.last_name) +\
" published {}".format(datetime) +\
"<br>{}".format(every.announcement_body)
like_on_post = 0
love_on_post = 0
......@@ -29,9 +32,9 @@ def announcements(request):
elif every.reaction_name == "Angry":
angry_on_post = every.reaction_tally
response += "<p>like: {}".format(like_on_post) +\
response += "<br>like: {}".format(like_on_post) +\
"<br>love: {}".format(love_on_post) +\
"<br>angry: {}</p>".format(angry_on_post)
"<br>angry: {}<br>".format(angry_on_post)
return HttpResponse(response)
......
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