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
aae85b93
Commit
aae85b93
authored
May 20, 2022
by
Julliana Zarah C. Cruz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added addAnnouncement for announcement app and other requirements for Final project
parent
7843baa5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
13 deletions
+58
-13
forms.py
widget_group22/announcements/forms.py
+7
-0
addAnnouncements.html
...nouncements/templates/announcements/addAnnouncements.html
+21
-0
announcements.html
.../announcements/templates/announcements/announcements.html
+4
-0
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 @
aae85b93
from
django
import
forms
from
.models
import
Announcement
,
Reaction
class
AddAnnouncementForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Announcement
fields
=
'__all__'
widget_group22/announcements/templates/announcements/addAnnouncements.html
0 → 100644
View file @
aae85b93
{% 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 @
aae85b93
...
@@ -22,6 +22,10 @@
...
@@ -22,6 +22,10 @@
</p>
</p>
{% endfor %}
{% endfor %}
</ol>
</ol>
<form
action=
"/announcements/add"
>
<input
type=
"submit"
value=
"New Announcement"
/>
</form>
</body>
</body>
{% endblock %}
{% endblock %}
widget_group22/announcements/urls.py
View file @
aae85b93
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
announcements
,
details
from
.views
import
AnnouncementView
,
details
,
addAnnouncement
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
announcements
,
name
=
'announcements'
),
#path('', announcements, name='announcements'),
path
(
'announcements/<int:announcement_id>/details/'
,
details
,
name
=
'details'
)
path
(
''
,
AnnouncementView
.
as_view
(),
name
=
'announcement'
),
path
(
'<int:announcement_id>/details/'
,
details
,
name
=
'details'
),
path
(
'add/'
,
addAnnouncement
,
name
=
'addAnnouncement'
)
]
]
app_name
=
"announcements"
app_name
=
"announcements"
widget_group22/announcements/views.py
View file @
aae85b93
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
.
import
models
from
.
import
models
from
.models
import
Announcement
,
Reaction
from
.models
import
Announcement
,
Reaction
from
.forms
import
AddAnnouncementForm
from
django.views
import
View
from
django.views.generic.list
import
ListView
def
index
(
request
):
class
AnnouncementView
(
View
):
return
HttpResponse
(
'This is the Announcement Board!'
)
def
get
(
self
,
request
):
def
announcements
(
request
):
all_announcements
=
models
.
Announcement
.
objects
.
order_by
(
"-id"
)
all_announcements
=
models
.
Announcement
.
objects
.
order_by
(
"-id"
)
context
=
{
context
=
{
"all_announcements"
:
all_announcements
"all_announcements"
:
all_announcements
...
@@ -33,3 +34,13 @@ def details(request, announcement_id):
...
@@ -33,3 +34,13 @@ def details(request, announcement_id):
"angry"
:
angry
,
"angry"
:
angry
,
}
}
return
render
(
request
,
"announcements/details.html"
,
context
)
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