Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_aguandhischipmunks
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Adrian Lance Damalerio
midterm_aguandhischipmunks
Commits
3b5393e1
Commit
3b5393e1
authored
Mar 06, 2023
by
Agu Syquia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated views.py
Finalized the for loops and HttpResponse
parent
6f6a1ca6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
2 deletions
+33
-2
views.py
widget_aguandhischipmunks/announcement_board/views.py
+33
-2
No files found.
widget_aguandhischipmunks/announcement_board/views.py
View file @
3b5393e1
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
.models
import
Announcement
,
Reaction
# Create your views here.
def
announcement_boardIndex
(
request
):
announcements
=
Announcement
.
objects
.
all
()
reactions
=
Reaction
.
objects
.
all
()
announcement_board_output
=
"Widget’s Announcement Board <br><br> Announcements: <br>"
for
announcement
in
announcements
:
datetime
=
announcement
.
pub_datetime
.
strftime
(
"
%
m/
%
d/
%
Y,
%
I:
%
M
%
p"
)
announcement_board_output
+=
(
announcement
.
title
+
" by "
+
announcement
.
author
.
first_name
+
" "
+
announcement
.
author
.
last_name
+
" published "
+
datetime
+
": <br>"
+
announcement
.
body
+
"<br>"
)
like_tally
=
0
love_tally
=
0
angry_tally
=
0
for
reaction
in
reactions
:
if
reaction
.
announcement
.
title
==
announcement
.
title
:
if
reaction
.
name
==
"Like"
:
like_tally
=
reaction
.
tally
elif
reaction
.
name
==
"Love"
:
love_tally
=
reaction
.
tally
elif
reaction
.
name
==
"Angry"
:
angry_tally
=
reaction
.
tally
announcement_board_output
=
(
announcement_board_output
+
"Like: "
+
str
(
like_tally
)
+
"<br>Love: "
+
str
(
love_tally
)
+
"<br>Angry: "
+
str
(
angry_tally
)
+
"<br><br>"
)
return
HttpResponse
(
announcement_board_output
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment