Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_princessgabi
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
Ysabella Panghulan
midterm_princessgabi
Commits
859a772a
Commit
859a772a
authored
Mar 06, 2023
by
Julia Anishka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created views for announcement board
parent
4a69aebf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
views.py
widget_princessgabi/announcementboard/views.py
+22
-2
No files found.
widget_princessgabi/announcementboard/views.py
View file @
859a772a
from
django.
shortcuts
import
render
from
django.
http
import
HttpResponse
# Create your views here.
from
.models
import
Announcement
,
Reaction
def
index
(
request
):
all_announcements
=
Announcement
.
objects
.
all
()
all_reactions
=
Reaction
.
objects
.
all
()
welcomeMessage
=
'Widget
\'
s Announcement Board<br><br>Announcements:<br>'
response
=
''
for
announcement
in
all_announcements
:
reactions
=
''
reactions_list
=
{
'Like'
:
0
,
'Love'
:
0
,
'Angry'
:
0
}
for
reaction
in
all_reactions
:
if
reaction
.
announcement
.
title
==
announcement
.
title
:
reactions_list
[
reaction
.
name
]
=
reaction
.
tally
keys
=
list
(
reactions_list
.
keys
())
for
key
in
keys
:
reactions
+=
key
+
': '
+
str
(
reactions_list
[
key
])
+
'<br>'
datetime
=
announcement
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y,
%
I:
%
M
%
p'
)
author
=
announcement
.
author
.
first_name
+
' '
+
announcement
.
author
.
last_name
response
+=
announcement
.
title
+
' by '
+
author
+
' published '
+
datetime
response
+=
':'
+
'<br>'
+
announcement
.
body
+
'<br>'
+
reactions
+
'<br>'
return
HttpResponse
(
welcomeMessage
+
response
)
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