Commit 79b393ca authored by Ross Batacan's avatar Ross Batacan

Created empty templates for announcements home, edit, create, and details views

parent f81011c5
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
<!--def announcements(request):-->
<!-- announcement = Announcement.objects.all()-->
<!-- 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 += "<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-->
<!-- angry_on_post = 0-->
<!-- reactions = Reaction.objects.filter(reaction_announcement=every)-->
<!-- for every in reactions:-->
<!-- if every.reaction_name == "Like":-->
<!-- like_on_post = every.reaction_tally-->
<!-- elif every.reaction_name == "Love":-->
<!-- love_on_post = every.reaction_tally-->
<!-- elif every.reaction_name == "Angry":-->
<!-- angry_on_post = every.reaction_tally-->
<!-- response += "<br>like: {}".format(like_on_post) +\-->
<!-- "<br>love: {}".format(love_on_post) +\-->
<!-- "<br>angry: {}<br>".format(angry_on_post)-->
<!-- return HttpResponse(response)-->
{% extends 'base.html' %}
{% block title %}My Favorite Books & Authors{% endblock %}
{% block content %}
<h1>Welcome to Widget's Announcement Board!</h1>
<h3>Announcements:</h3>
{% endblock %}
...@@ -3,5 +3,6 @@ from . import views ...@@ -3,5 +3,6 @@ from . import views
urlpatterns = [ urlpatterns = [
path('', views.announcements, name="announcements") path('', views.announcements, name="announcements"),
path('')
] ]
from django.http import HttpResponse from django.shortcuts import render
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Announcement, Reaction from .models import Announcement, Reaction
# Create your views here. # Create your views here.
def home(request):
return render(request, 'announcements/announcements.html')
class AnnouncementsDetailsView(DetailView):
model = Announcement
template_name = 'announcements/announcement-details.html'
class AnnouncementsCreateView(CreateView):
model = Announcement
template_name = 'announcements/announcement-add.html'
class AnnouncementsEditView(UpdateView):
model = Announcement
template_name = 'announcements/announcement-edit.html'
# def announcements(request):
# announcement = Announcement.objects.all()
#
# 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 += "<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
# angry_on_post = 0
# reactions = Reaction.objects.filter(reaction_announcement=every)
#
# for every in reactions:
# if every.reaction_name == "Like":
# like_on_post = every.reaction_tally
# elif every.reaction_name == "Love":
# love_on_post = every.reaction_tally
# elif every.reaction_name == "Angry":
# angry_on_post = every.reaction_tally
#
# response += "<br>like: {}".format(like_on_post) +\
# "<br>love: {}".format(love_on_post) +\
# "<br>angry: {}<br>".format(angry_on_post)
#
# return HttpResponse(response)
def announcements(request):
announcement = Announcement.objects.all()
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 += "<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
angry_on_post = 0
reactions = Reaction.objects.filter(reaction_announcement=every)
for every in reactions:
if every.reaction_name == "Like":
like_on_post = every.reaction_tally
elif every.reaction_name == "Love":
love_on_post = every.reaction_tally
elif every.reaction_name == "Angry":
angry_on_post = every.reaction_tally
response += "<br>like: {}".format(like_on_post) +\
"<br>love: {}".format(love_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