Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group22
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
John Tamano
widget_group22
Commits
838646ed
Commit
838646ed
authored
May 20, 2022
by
Julliana Zarah C. Cruz
Browse files
Options
Browse Files
Download
Plain Diff
Made changes for Final project and merged
parents
b1718512
aae85b93
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
18 deletions
+70
-18
forms.py
widget_group22/announcements/forms.py
+7
-0
style.css
widget_group22/announcements/static/css/style.css
+3
-1
addAnnouncements.html
...nouncements/templates/announcements/addAnnouncements.html
+21
-0
announcements.html
.../announcements/templates/announcements/announcements.html
+4
-0
details.html
...roup22/announcements/templates/announcements/details.html
+9
-4
urls.py
widget_group22/announcements/urls.py
+5
-3
views.py
widget_group22/announcements/views.py
+21
-10
No files found.
widget_group22/announcements/forms.py
0 → 100644
View file @
838646ed
from
django
import
forms
from
.models
import
Announcement
,
Reaction
class
AddAnnouncementForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Announcement
fields
=
'__all__'
widget_group22/announcements/static/css/style.css
View file @
838646ed
h1
{
font-family
:
verdana
;
color
:
Maroon
;
}
body
{
font-family
:
verdana
;
background-color
:
hotpink
;
background-color
:
MistyRose
;
color
:
SaddleBrown
;
}
\ No newline at end of file
widget_group22/announcements/templates/announcements/addAnnouncements.html
0 → 100644
View file @
838646ed
{% extends "announcements/base.html" %}
{% load static %}
{% block styles %}
<link
rel=
"stylesheet"
href=
"{% static 'css/style.css' %}"
>
{% endblock %}
{% block content %}
<h1>
New Announcement
</h1>
<form
action=
"{% url 'announcements:addAnnouncement' %}"
method=
"POST"
>
{% csrf_token %}
{{ add_announcement }}
<p><button
class=
"button"
type=
"submit"
>
Save Announcement
</button></p>
</form>
<br>
<p1>
<a
href =
"/announcements/"
>
Back to Announcement Page
</a>
</p1>
{% endblock %}
\ No newline at end of file
widget_group22/announcements/templates/announcements/announcements.html
View file @
838646ed
...
...
@@ -22,6 +22,10 @@
</p>
{% endfor %}
</ol>
<form
action=
"/announcements/add"
>
<input
type=
"submit"
value=
"New Announcement"
/>
</form>
</body>
{% endblock %}
widget_group22/announcements/templates/announcements/details.html
View file @
838646ed
{% extends "announcements/base.html" %}
{% load static %}
{% block styles %}
<link
rel=
"stylesheet"
href=
"{% static 'css/style.css' %}"
>
{% endblock %}
{% block content %}
<h1>
{{announcement_details.announcement_title}}
</h1>
<h
2
>
<h
4
>
by
{{announcement_details.author.first_name}}
{{announcement_details.author.last_name}}
dated {{announcement_details.pub_date|date:"d/m/Y"}}
</h
2
>
<p>
</h
4
>
<p
style=
"border:PaleVioletRed; border-width:5px; border-style:dotted; border-radius: 10px"
>
{{announcement_details.announcement_body}}
</p>
<li>
Like: {{like}}
</li>
<li>
Love: {{love}}
</li>
<li>
Angry: {{angry}}
</li>
<img
src=
http
://images.gmanews.tv/webpics/2021/11/rastaman_2021_11_07_16_56_21.pn
g
>
<img
src=
http
s://cdn.w600.comps.canstockphoto.com/announcement-red-vintage-isolated-seal-drawings_csp24798234.jp
g
>
{% endblock %}
\ No newline at end of file
widget_group22/announcements/urls.py
View file @
838646ed
from
django.urls
import
path
from
.views
import
announcements
,
details
from
.views
import
AnnouncementView
,
details
,
addAnnouncement
urlpatterns
=
[
path
(
''
,
announcements
,
name
=
'announcements'
),
path
(
'announcements/<int:announcement_id>/details/'
,
details
,
name
=
'details'
)
#path('', announcements, name='announcements'),
path
(
''
,
AnnouncementView
.
as_view
(),
name
=
'announcement'
),
path
(
'<int:announcement_id>/details/'
,
details
,
name
=
'details'
),
path
(
'add/'
,
addAnnouncement
,
name
=
'addAnnouncement'
)
]
app_name
=
"announcements"
widget_group22/announcements/views.py
View file @
838646ed
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
django.http
import
HttpResponse
from
.
import
models
from
.models
import
Announcement
,
Reaction
from
.forms
import
AddAnnouncementForm
from
django.views
import
View
from
django.views.generic.list
import
ListView
def
index
(
request
):
return
HttpResponse
(
'This is the Announcement Board!'
)
def
announcements
(
request
):
all_announcements
=
models
.
Announcement
.
objects
.
order_by
(
"-id"
)
context
=
{
"all_announcements"
:
all_announcements
}
return
render
(
request
,
'announcements/announcements.html'
,
context
)
class
AnnouncementView
(
View
):
def
get
(
self
,
request
):
all_announcements
=
models
.
Announcement
.
objects
.
order_by
(
"-id"
)
context
=
{
"all_announcements"
:
all_announcements
}
return
render
(
request
,
'announcements/announcements.html'
,
context
)
def
details
(
request
,
announcement_id
):
announcement_details
=
models
.
Announcement
.
objects
.
get
(
pk
=
announcement_id
)
...
...
@@ -33,3 +34,13 @@ def details(request, announcement_id):
"angry"
:
angry
,
}
return
render
(
request
,
"announcements/details.html"
,
context
)
def
addAnnouncement
(
request
):
if
request
.
method
==
'POST'
:
add_announcement
=
AddAnnouncementForm
(
request
.
POST
)
if
add_announcement
.
is_valid
():
new_announcement
=
add_announcement
.
save
()
return
redirect
(
'announcements:addAnnouncement'
)
else
:
add_announcement
=
AddAnnouncementForm
()
return
render
(
request
,
'announcements/addAnnouncements.html'
,
{
'add_announcement'
:
add_announcement
})
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