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
a49c4caa
Commit
a49c4caa
authored
May 07, 2023
by
Joaquin Inigo Crisologo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created ForumPostUpdateView and forumpost-edit.html
parent
d95510dc
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
28 additions
and
5 deletions
+28
-5
db.sqlite3
widget_vincentdjango/db.sqlite3
+0
-0
models.py
widget_vincentdjango/forum/models.py
+2
-1
forum.html
widget_vincentdjango/forum/templates/forum/forum.html
+1
-1
forumpost-add.html
...et_vincentdjango/forum/templates/forum/forumpost-add.html
+2
-2
forumpost-details.html
...incentdjango/forum/templates/forum/forumpost-details.html
+1
-0
forumpost-edit.html
...t_vincentdjango/forum/templates/forum/forumpost-edit.html
+15
-0
urls.py
widget_vincentdjango/forum/urls.py
+2
-1
views.py
widget_vincentdjango/forum/views.py
+5
-0
No files found.
widget_vincentdjango/db.sqlite3
View file @
a49c4caa
No preview for this file type
widget_vincentdjango/forum/models.py
View file @
a49c4caa
...
@@ -14,7 +14,8 @@ class ForumPost(models.Model):
...
@@ -14,7 +14,8 @@ class ForumPost(models.Model):
on_delete
=
models
.
CASCADE
,
on_delete
=
models
.
CASCADE
,
)
)
pub_datetime
=
models
.
DateTimeField
(
pub_datetime
=
models
.
DateTimeField
(
default
=
datetime
.
now
(),
default
=
datetime
.
now
(),
editable
=
False
,
)
)
def
__str__
(
self
):
def
__str__
(
self
):
...
...
widget_vincentdjango/forum/templates/forum/forum.html
View file @
a49c4caa
...
@@ -16,4 +16,4 @@
...
@@ -16,4 +16,4 @@
</ul>
</ul>
<hr>
<hr>
<button
onclick=
"window.location.href='{% url 'forum:forumpost-add' %}';"
>
New Post
</button>
<button
onclick=
"window.location.href='{% url 'forum:forumpost-add' %}';"
>
New Post
</button>
{% endblock %}4
{% endblock %}
\ No newline at end of file
\ No newline at end of file
widget_vincentdjango/forum/templates/forum/forumpost-add.html
View file @
a49c4caa
...
@@ -3,13 +3,13 @@
...
@@ -3,13 +3,13 @@
{% block title %} Add Post {% endblock %}
{% block title %} Add Post {% endblock %}
{% block heading %}
{% block heading %}
<h1>
Add a new
p
ost:
</h1>
<h1>
Add a new
P
ost:
</h1>
{% endblock %}
{% endblock %}
{% block content %}
{% block content %}
<form
method=
"post"
>
<form
method=
"post"
>
{% csrf_token %}
{% csrf_token %}
{{ form.as_p }}
{{ form.as_p }}
<
div
class=
"separator-bar"
></div><
br>
<br>
<input
type=
"submit"
value=
"Save New Post"
>
<input
type=
"submit"
value=
"Save New Post"
>
</form>
</form>
{% endblock %}
{% endblock %}
\ No newline at end of file
widget_vincentdjango/forum/templates/forum/forumpost-details.html
View file @
a49c4caa
...
@@ -18,4 +18,5 @@
...
@@ -18,4 +18,5 @@
<br>
<br>
{% endfor %}
{% endfor %}
<hr>
<hr>
<button
onclick=
"window.location.href='{% url 'forum:forumpost-edit' pk=object.pk %}';"
>
Edit Post
</button>
{% endblock %}
{% endblock %}
\ No newline at end of file
widget_vincentdjango/forum/templates/forum/forumpost-edit.html
0 → 100644
View file @
a49c4caa
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Post {% endblock %}
{% block heading %}
<h1>
Edit Post:
</h1>
{% endblock %}
{% block content %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<br>
<input
type=
"submit"
value=
"Save Changes"
>
</form>
{% endblock %}
\ No newline at end of file
widget_vincentdjango/forum/urls.py
View file @
a49c4caa
# forum/urls.py
# forum/urls.py
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
index
,
ForumPostDetailView
,
ForumPostCreateView
from
.views
import
index
,
ForumPostDetailView
,
ForumPostCreateView
,
ForumPostUpdateView
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
''
,
index
,
name
=
'index'
),
path
(
'forumposts/<int:pk>/details'
,
ForumPostDetailView
.
as_view
(),
name
=
'forumpost-details'
),
path
(
'forumposts/<int:pk>/details'
,
ForumPostDetailView
.
as_view
(),
name
=
'forumpost-details'
),
path
(
'forumposts/add'
,
ForumPostCreateView
.
as_view
(),
name
=
'forumpost-add'
),
path
(
'forumposts/add'
,
ForumPostCreateView
.
as_view
(),
name
=
'forumpost-add'
),
path
(
'forumposts/<int:pk>/edit'
,
ForumPostUpdateView
.
as_view
(),
name
=
'forumpost-edit'
),
]
]
# This might be needed, depending on your Django version
# This might be needed, depending on your Django version
...
...
widget_vincentdjango/forum/views.py
View file @
a49c4caa
...
@@ -20,3 +20,8 @@ class ForumPostCreateView(CreateView):
...
@@ -20,3 +20,8 @@ class ForumPostCreateView(CreateView):
model
=
ForumPost
model
=
ForumPost
template_name
=
'forum/forumpost-add.html'
template_name
=
'forum/forumpost-add.html'
fields
=
[
"title"
,
"body"
,
"author"
]
fields
=
[
"title"
,
"body"
,
"author"
]
class
ForumPostUpdateView
(
UpdateView
):
model
=
ForumPost
template_name
=
'forum/forumpost-edit.html'
fields
=
'__all__'
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