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
e2232aac
Commit
e2232aac
authored
May 09, 2023
by
Julia Anishka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated views, url and created template for announcements page
parent
859a772a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
20 deletions
+36
-20
announcements.html
...ementboard/templates/announcementboard/announcements.html
+28
-0
urls.py
widget_princessgabi/announcementboard/urls.py
+1
-1
views.py
widget_princessgabi/announcementboard/views.py
+7
-19
No files found.
widget_princessgabi/announcementboard/templates/announcementboard/announcements.html
0 → 100644
View file @
e2232aac
{% extends 'base.html' %}
{% block title %} Widget's Announcement Board {% endblock %}
{% block header %}
<h1>
Welcome to Widget's Announcement Board!
</h1>
{% endblock %}
{% block content %}
<h2>
Announcements:
</h2><br>
<div>
<ul>
{% for announcement in announcements %}
<li>
<a
href=
"{{ announcement.get_absolute_url }}"
>
{{ announcement.title }} by {{ announcement.author.first_name }} {{ announcement.author.last_name }}
</a>
</li>
{% endfor %}
</ul>
</div>
<div>
<a
href=
"/announcements/announcements/add/"
>
New Announcement
</a>
</div>
<a
href=
"/dashboard/"
>
Dashboard
</a>
<a
href=
"/forum/"
>
Forum
</a>
<a
href=
"/assignments/"
>
Assignments
</a>
<a
href=
"/calendar/"
>
Calendar
</a>
{% endblock %}
\ No newline at end of file
widget_princessgabi/announcementboard/urls.py
View file @
e2232aac
...
@@ -2,5 +2,5 @@ from django.urls import path
...
@@ -2,5 +2,5 @@ from django.urls import path
from
.
import
views
from
.
import
views
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
views
.
index
,
name
=
'index
'
),
path
(
''
,
views
.
announcement_view
,
name
=
'announcements
'
),
]
]
widget_princessgabi/announcementboard/views.py
View file @
e2232aac
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
from
.models
import
Announcement
,
Reaction
from
.models
import
Announcement
,
Reaction
def
index
(
request
):
def
announcement_view
(
request
):
all_announcements
=
Announcement
.
objects
.
all
()
announcements
=
Announcement
.
objects
.
order_by
(
'-pub_datetime'
)
all_reactions
=
Reaction
.
objects
.
all
()
context
=
{
welcomeMessage
=
'Widget
\'
s Announcement Board<br><br>Announcements:<br>'
'announcements'
:
announcements
response
=
''
}
for
announcement
in
all_announcements
:
return
render
(
request
,
'announcementboard/announcements.html'
,
context
)
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