Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_jupert
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
Joseph Izon
widget_jupert
Commits
32e443b6
Commit
32e443b6
authored
Apr 06, 2022
by
Cherish Magpayo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated views for announcement page
parent
291cfb3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
views.py
widget_jupert/announcements/views.py
+16
-1
No files found.
widget_jupert/announcements/views.py
View file @
32e443b6
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
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