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
592cf44e
Commit
592cf44e
authored
May 16, 2022
by
Kyla Martin
❓
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'martin/announcements' into 'master'
Martin/announcements See merge request
!14
parents
5c3b03e1
340ca903
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
15 deletions
+103
-15
header.png
WidgetFEKK/Announcements/static/Announcements/header.png
+0
-0
styles.css
WidgetFEKK/Announcements/static/Announcements/styles.css
+44
-0
details.html
...etFEKK/Announcements/templates/announcements/details.html
+28
-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/header.png
0 → 100644
View file @
592cf44e
45.8 KB
WidgetFEKK/Announcements/static/Announcements/styles.css
0 → 100644
View file @
592cf44e
@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
;
}
#back
{
padding
:
2rem
0
;
}
#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 @
592cf44e
{% extends "base.html" %}
{% load static %}
{% block styles %}
<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>
<div
align=
"center"
><img
id=
"header"
src=
"{% static 'Announcements/header.png' %}"
alt=
"a header"
></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>
<div
id=
"reactions-container"
align=
"center"
>
<p
class=
"reactions"
>
{% for reactions in reaction_sorted %}
<strong>
{{ reactions.reaction_name }}
</strong>
: {{ reactions.tally }}
{% endfor %}
</p>
</div>
</article>
{% endblock %}
\ No newline at end of file
WidgetFEKK/Announcements/templates/announcements/index.html
0 → 100644
View file @
592cf44e
{% 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 @
592cf44e
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>"
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>'
return
render
(
request
,
'announcements/index.html'
,
{
'announcement_sorted'
:
Announcement
.
objects
.
order_by
(
'-pub_date'
)})
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 @
592cf44e
...
...
@@ -15,6 +15,7 @@ Including another URLconf
"""
from
django.contrib
import
admin
from
django.urls
import
path
,
include
import
Announcements.views
as
Announcements_views
import
Forum.views
as
Forum_views
urlpatterns
=
[
...
...
@@ -23,5 +24,6 @@ urlpatterns = [
path
(
'posts/<int:post_id>/details/'
,
Forum_views
.
details
,
name
=
'post_details'
),
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 @
592cf44e
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