Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widgets_FEKK
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
Kyla Martin
widgets_FEKK
Commits
ef6517e9
Commit
ef6517e9
authored
May 15, 2022
by
Kyla Martin
❓
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Announcements templates, link in urls
parent
9d067069
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
99 additions
and
15 deletions
+99
-15
styles.css
WidgetFEKK/Announcements/static/Announcements/styles.css
+41
-0
details.html
...etFEKK/Announcements/templates/announcements/details.html
+27
-0
index.html
WidgetFEKK/Announcements/templates/announcements/index.html
+21
-0
views.py
WidgetFEKK/Announcements/views.py
+8
-15
urls.py
WidgetFEKK/WidgetFEKK/urls.py
+2
-0
db.sqlite3
WidgetFEKK/db.sqlite3
+0
-0
No files found.
WidgetFEKK/Announcements/static/Announcements/styles.css
0 → 100644
View file @
ef6517e9
@import
url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap')
;
body
{
font-family
:
'Roboto'
;
padding
:
4rem
12rem
;
}
h1
{
font-size
:
2.5rem
;
text-align
:
center
;
}
#title
{
margin
:
20px
0
10px
0
;
}
#subtitle
{
margin
:
auto
;
text-align
:
center
;
}
.reactions
{
background-color
:
gainsboro
;
padding
:
5px
;
width
:
fit-content
;
border-radius
:
5px
;
}
li
{
color
:
black
;
}
a
{
color
:
black
;
text-decoration
:
none
;
}
a
:hover
{
color
:
red
;
}
\ No newline at end of file
WidgetFEKK/Announcements/templates/announcements/details.html
0 → 100644
View file @
ef6517e9
{% extends "base.html" %}
{% load static %}
{% block styles %}
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'Announcements/index.css' %}"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'Announcements/styles.css' %}"
>
{% endblock %}
{% block title %}
{{ announcement.announcement_title }}
{% endblock %}
{% block content %}
<article>
<div
id=
"back"
><a
href=
"/announcements"
>
Back to all announcements
</a></div>
<h1
id=
"title"
>
{{ announcement.announcement_title}}
</h1>
<h4
id=
"subtitle"
>
by {{ announcement.author.first_name}} {{ announcement.author.last_name }}, {{ announcement.pub_date|date:"d/m/Y" }}
</h4>
<p
class=
"body"
>
{{ announcement.announcement_body }}
</p>
<p
class=
"reactions"
>
{% for reactions in reaction_sorted %}
<strong>
{{ reactions.reaction_name }}
</strong>
: {{ reactions.tally }}
{% endfor %}
</p>
</article>
{% endblock %}
\ No newline at end of file
WidgetFEKK/Announcements/templates/announcements/index.html
0 → 100644
View file @
ef6517e9
{% extends "base.html" %}
{% load static %}
{% block styles %}
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'Announcements/styles.css' %}"
>
{% endblock %}
{% block title %}Widget's Announcement Board{% endblock %}
{% block content %}
<main>
<h1>
Announcement Board
</h1>
<h3>
Important Announcements:
</h3>
<ul
class=
"announcements"
></ul>
{% for announcement in announcement_sorted %}
<li>
<a
href=
"/announcements/{{ announcement.pk }}/details"
><strong>
{{ announcement.announcement_title }}
</strong>
by
<strong>
{{ announcement.author.first_name }} {{ announcement.author.last_name }}
</strong>
dated
<strong>
{{ announcement.pub_date|date:"d/m/Y" }}
</strong></a>
</li>
{% endfor %}
</ul>
</main>
{% endblock %}
\ No newline at end of file
WidgetFEKK/Announcements/views.py
View file @
ef6517e9
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.http
import
Http
404
,
Http
Response
from
.models
import
Announcement
,
Reaction
def
date_month_year
(
timestamp
):
return
timestamp
.
strftime
(
"
%
d/
%
m/
%
Y"
)
def
index
(
request
):
content
=
"ANNOUNCEMENTS:<br>"
return
render
(
request
,
'announcements/index.html'
,
{
'announcement_sorted'
:
Announcement
.
objects
.
order_by
(
'-pub_date'
)})
announcements
=
Announcement
.
objects
.
all
()
for
announcements
in
announcements
:
content
+=
f
'{announcements.announcement_title} by {announcements.author.last_name}, {announcements.author.first_name} dated {date_month_year(announcements.pub_date)}: <br>'
content
+=
f
'{announcements.announcement_body} <br>'
reactions
=
announcements
.
reaction_set
.
all
()
for
reactions
in
reactions
:
content
+=
f
'{reactions.reaction_name}: {reactions.tally} <br>'
content
+=
'<br>'
return
HttpResponse
(
content
)
\ No newline at end of file
def
details
(
request
,
announcement_id
):
try
:
announcement
=
Announcement
.
objects
.
get
(
pk
=
announcement_id
)
except
Announcement
.
DoesNotExist
:
raise
Http404
(
'Announcement does not exist'
)
return
render
(
request
,
'announcements/details.html'
,
{
'announcement'
:
announcement
,
'reaction_sorted'
:
announcement
.
reaction_set
.
order_by
(
'tally'
)})
\ No newline at end of file
WidgetFEKK/WidgetFEKK/urls.py
View file @
ef6517e9
...
...
@@ -15,11 +15,13 @@ Including another URLconf
"""
from
django.contrib
import
admin
from
django.urls
import
path
,
include
import
Announcements.views
as
Announcements_views
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'forum/'
,
include
(
'Forum.urls'
,
namespace
=
'Forum'
)),
path
(
'homepage/'
,
include
(
'Homepage.urls'
,
namespace
=
"Homepage"
)),
path
(
'announcements/'
,
include
(
'Announcements.urls'
,
namespace
=
"Announcements"
)),
path
(
'announcements/<int:announcement_id>/details'
,
Announcements_views
.
details
,
name
=
'announcement_details'
),
path
(
'assignments/'
,
include
(
'Assignments.urls'
,
namespace
=
"Assignments"
)),
]
WidgetFEKK/db.sqlite3
View file @
ef6517e9
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