Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_Francoconuts
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Chester Tan
widget_Francoconuts
Commits
426515eb
Commit
426515eb
authored
May 22, 2022
by
Bryan Carlo Guanlao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Announcement Forms
used CreateView for creating new announcements. added templates for form.
parent
71657ded
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
6 deletions
+32
-6
announcement_detail.html
...ncements/templates/announcements/announcement_detail.html
+1
-0
announcement_form.html
...ouncements/templates/announcements/announcement_form.html
+10
-0
announcement_list.html
...ouncements/templates/announcements/announcement_list.html
+3
-2
urls.py
widget_Francoconuts/announcements/urls.py
+7
-2
views.py
widget_Francoconuts/announcements/views.py
+11
-2
No files found.
widget_Francoconuts/announcements/templates/announcements/announcement_detail.html
View file @
426515eb
...
...
@@ -29,6 +29,7 @@
{% endfor %}
{% endif %}
<a
href=
"{% url 'announcements:announcement-list' %}"
><button>
Go back
</button></a>
{% load static %}
<img
src=
"{% static 'announcements/tsukasa.png' %}"
alt=
"image"
>
...
...
widget_Francoconuts/announcements/templates/announcements/announcement_form.html
0 → 100644
View file @
426515eb
{% extends 'base.html' %}
{% block content %}
<h1>
New Announcement
</h1>
<form
method=
"POST"
>
{% csrf_token %}
{{form.as_p}}
<input
type=
"submit"
value=
"Save Announcement"
>
</form>
<a
href=
"{% url 'announcements:announcement-list' %}"
><button>
Go back
</button></a>
{% endblock content %}
\ No newline at end of file
widget_Francoconuts/announcements/templates/announcements/announcement_list.html
View file @
426515eb
{% extends 'base.html' %}
{% block content %}
<h1>
Announcements
</h1>
<
ul
>
<
div
>
{% for announcement in object_list %}
<li>
<a
href=
"{% url 'announcements:announcement-detail' announcement.id %}"
>
...
...
@@ -10,5 +10,6 @@
{{announcement.pub_date|date:"d/m/Y"}}
</a>
</li>
{% endfor %}
</ul>
<a
href=
"{% url 'announcements:announcement-add' %}"
><button>
New Announcement
</button></a>
</div>
{% endblock content %}
\ No newline at end of file
widget_Francoconuts/announcements/urls.py
View file @
426515eb
from
django.urls
import
path
from
.views
import
AnnouncementsDetailView
,
AnnouncementsListView
from
.views
import
(
AnnouncementCreateView
,
AnnouncementsDetailView
,
AnnouncementsListView
,
AnnouncementCreateView
,
)
urlpatterns
=
[
path
(
''
,
AnnouncementsListView
.
as_view
(),
name
=
'announcement-list'
),
path
(
'<int:pk>/details/'
,
AnnouncementsDetailView
.
as_view
(),
name
=
'announcement-detail'
),
path
(
'add/'
,
AnnouncementCreateView
.
as_view
(),
name
=
'announcement-add'
),
]
app_name
=
'announcements'
widget_Francoconuts/announcements/views.py
View file @
426515eb
from
django.shortcuts
import
render
from
django.http
import
Http404
,
HttpRequest
,
HttpResponse
from
.models
import
Announcement
,
Reaction
,
WidgetUser
from
.models
import
Announcement
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
from
django.urls
import
reverse
class
AnnouncementsListView
(
ListView
):
...
...
@@ -12,3 +13,11 @@ class AnnouncementsListView(ListView):
class
AnnouncementsDetailView
(
DetailView
):
model
=
Announcement
class
AnnouncementCreateView
(
CreateView
):
model
=
Announcement
fields
=
"__all__"
def
get_success_url
(
self
):
return
reverse
(
'announcements:announcement-list'
)
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