Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_Alipins
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
Angelico Ruiz T. Teaño
widget_Alipins
Commits
a59f4b66
Commit
a59f4b66
authored
May 09, 2022
by
Carlo Joseph Echon
🐟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed Announcement URLs and Views for the templates
parent
b45e3782
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
20 deletions
+22
-20
urls.py
widget_alipins/announcements/urls.py
+3
-1
views.py
widget_alipins/announcements/views.py
+19
-19
db.sqlite3
widget_alipins/db.sqlite3
+0
-0
No files found.
widget_alipins/announcements/urls.py
View file @
a59f4b66
...
...
@@ -2,6 +2,8 @@ from django.urls import path
from
.
import
views
app_name
=
"announcements"
urlpatterns
=
[
path
(
''
,
views
.
index
,
name
=
"indexAnnouncements"
)
path
(
''
,
views
.
index
,
name
=
"indexAnnouncements"
),
path
(
'<int:announcement_id>/details'
,
views
.
details
,
name
=
"details"
)
]
\ No newline at end of file
widget_alipins/announcements/views.py
View file @
a59f4b66
from
django.http
import
HttpResponse
from
multiprocessing
import
context
from
django.http
import
HttpResponse
,
Http404
from
.models
import
Announcement
,
Reaction
from
django.shortcuts
import
render
# Create your views here.
def
index
(
request
):
display_output
=
"<u><b>ANNOUNCEMENTS</u></b>: <br>"
announcement_list
=
Announcement
.
objects
.
order_by
(
"pub_date"
)
context
=
{
"announcement_list"
:
announcement_list
,
}
for
object
in
Announcement
.
objects
.
all
():
display_output
+=
'''
<b>{title} by {first_name} {last_name}</b> dated {date}:<br>
{body}<br>
Like: {like_tally}<br>
Love: {love_tally}<br>
Angry: {angry_tally}<br>
<br>
'''
.
format
(
title
=
object
.
announcement_title
,
first_name
=
object
.
author
.
first_name
,
last_name
=
object
.
author
.
last_name
,
date
=
str
(
object
.
pub_date
),
body
=
object
.
announcement_body
,
like_tally
=
Reaction
.
objects
.
filter
(
announcement_id
=
object
.
id
)
.
filter
(
reaction_name
=
"Like"
)
.
first
()
.
tally
,
love_tally
=
Reaction
.
objects
.
filter
(
announcement_id
=
object
.
id
)
.
filter
(
reaction_name
=
"Love"
)
.
first
()
.
tally
,
angry_tally
=
Reaction
.
objects
.
filter
(
announcement_id
=
object
.
id
)
.
filter
(
reaction_name
=
"Angry"
)
.
first
()
.
tally
)
return
render
(
request
,
"announcements/index.html"
,
context
)
return
HttpResponse
(
display_output
)
def
details
(
request
,
announcement_id
):
try
:
announcement
=
Announcement
.
objects
.
get
(
pk
=
announcement_id
)
reaction_list
=
Reaction
.
objects
.
order_by
(
"reaction_name"
)
except
Announcement
.
DoesNotExist
:
raise
Http404
(
"Announcement does not exist!"
)
output
=
{
"announcement"
:
announcement
,
"reaction_list"
:
reaction_list
,
}
return
render
(
request
,
"announcements/detail.html"
,
output
)
widget_alipins/db.sqlite3
View file @
a59f4b66
No preview for this file type
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