Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_vincentdjango
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
1
Merge Requests
1
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
Almira Redoble
midterm_vincentdjango
Commits
d815dee3
Commit
d815dee3
authored
May 11, 2023
by
Jayson Lim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created announcement-add.html and implemented CreateView
parent
bed1aa58
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
4 deletions
+26
-4
models.py
widget_vincentdjango/announcements/models.py
+1
-1
announcement-add.html
...nouncements/templates/announcements/announcement-add.html
+15
-0
announcement-details.html
...cements/templates/announcements/announcement-details.html
+0
-1
announcements.html
.../announcements/templates/announcements/announcements.html
+3
-1
urls.py
widget_vincentdjango/announcements/urls.py
+2
-1
views.py
widget_vincentdjango/announcements/views.py
+5
-0
db.sqlite3
widget_vincentdjango/db.sqlite3
+0
-0
No files found.
widget_vincentdjango/announcements/models.py
View file @
d815dee3
...
...
@@ -22,7 +22,7 @@ class Announcement(models.Model):
return
self
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y,
%
I:
%
M
%
p'
)
def
get_absolute_url
(
self
):
return
reverse
(
'announcements:announcement-detail'
,
kwargs
=
{
'pk'
:
self
.
pk
})
return
reverse
(
'announcements:announcement
s
-detail'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Reaction
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
5
,
choices
=
[(
'Like'
,
'Like'
),
...
...
widget_vincentdjango/announcements/templates/announcements/announcement-add.html
0 → 100644
View file @
d815dee3
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Announcement {% endblock %}
{% block heading %}
<h1>
Add a new announcement:
</h1>
{% endblock %}
{% block content %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<div
class=
"separator-bar"
></div><br>
<input
type=
"submit"
value=
"Save New Post"
>
</form>
{% endblock %}
widget_vincentdjango/announcements/templates/announcements/announcement-details.html
View file @
d815dee3
...
...
@@ -12,6 +12,5 @@
<p>
{{ reaction.name }}: {{ reaction.tally }}
</p>
<br>
{% endfor %}
{% endblock %}
\ No newline at end of file
widget_vincentdjango/announcements/templates/announcements/announcements.html
View file @
d815dee3
...
...
@@ -16,4 +16,6 @@
</li>
{% endfor %}
</ul>
<hr>
<button
onclick=
"window.location.href='{% url 'announcements:announcements-add' %}'"
>
New Announcement
</button>
{% endblock %}
widget_vincentdjango/announcements/urls.py
View file @
d815dee3
from
django.urls
import
path
from
.views
import
index
,
AnnouncementsDetailView
from
.views
import
index
,
AnnouncementsDetailView
,
AnnouncementsCreateView
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
'announcements/<int:pk>/details'
,
AnnouncementsDetailView
.
as_view
(),
name
=
'announcements-detail'
),
path
(
'announcements/add'
,
AnnouncementsCreateView
.
as_view
(),
name
=
'announcements-add'
),
]
...
...
widget_vincentdjango/announcements/views.py
View file @
d815dee3
...
...
@@ -12,3 +12,8 @@ def index(request):
class
AnnouncementsDetailView
(
DetailView
):
model
=
Announcement
template_name
=
'announcements/announcement-details.html'
class
AnnouncementsCreateView
(
CreateView
):
model
=
Announcement
template_name
=
'announcements/announcement-add.html'
fields
=
[
"title"
,
"body"
,
"author"
]
\ No newline at end of file
widget_vincentdjango/db.sqlite3
View file @
d815dee3
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