Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group17
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
Vaughn Nephi Fajardo
widget_group17
Commits
874353d9
Commit
874353d9
authored
May 17, 2022
by
Miguel Luis D. Bandelaria
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: modified the urls in buttons to open the correct URL for the new forum post
parent
8d4a32ff
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
14 deletions
+14
-14
urls.cpython-39.pyc
widget_group_17/forum/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
widget_group_17/forum/__pycache__/views.cpython-39.pyc
+0
-0
index.html
widget_group_17/forum/templates/forum/index.html
+2
-2
post_add.html
widget_group_17/forum/templates/forum/post_add.html
+1
-1
urls.py
widget_group_17/forum/urls.py
+3
-3
views.py
widget_group_17/forum/views.py
+8
-8
No files found.
widget_group_17/forum/__pycache__/urls.cpython-39.pyc
View file @
874353d9
No preview for this file type
widget_group_17/forum/__pycache__/views.cpython-39.pyc
View file @
874353d9
No preview for this file type
widget_group_17/forum/templates/forum/index.html
View file @
874353d9
...
@@ -9,10 +9,10 @@
...
@@ -9,10 +9,10 @@
{% for post in posts_list %}
{% for post in posts_list %}
<li><a
href=
"{% url 'forum:detail' post.id %}"
>
{{ post.post_title }}
</a>
by {{ post.author.first_name }} {{ post.author.last_name}} dated {{ post.pub_date|date:"SHORT_DATE_FORMAT" }}
</li>
<li><a
href=
"{% url 'forum:detail' post.id %}"
>
{{ post.post_title }}
</a>
by {{ post.author.first_name }} {{ post.author.last_name}} dated {{ post.pub_date|date:"SHORT_DATE_FORMAT" }}
</li>
{% endfor %}
{% endfor %}
<button
onclick=
"location.href = '/posts/add'"
>
New Forum Post
</button>
<button
onclick=
"location.href = '/
forum/
posts/add'"
>
New Forum Post
</button>
</ul>
</ul>
{% else %}
{% else %}
<p>
No posts are available.
</p>
<p>
No posts are available.
</p>
<button
onclick=
"location.href = '/posts/add'"
>
New Forum Post
</button>
<button
onclick=
"location.href = '/
forum/
posts/add'"
>
New Forum Post
</button>
{% endif %}
{% endif %}
{% endblock %}
{% endblock %}
\ No newline at end of file
widget_group_17/forum/templates/forum/post_add.html
View file @
874353d9
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<h1>
NEW FORUM POST
</h1>
<h1>
NEW FORUM POST
</h1>
</div>
</div>
<div
style =
"position: relative; left:80px; top:30px;"
>
<div
style =
"position: relative; left:80px; top:30px;"
>
<form
method=
"POST"
action =
"{% url 'forum:add' %}"
enctype=
"multipart/form-data"
>
<form
method=
"POST"
action =
"{% url 'forum:
post_
add' %}"
enctype=
"multipart/form-data"
>
{% csrf_token %}
{% csrf_token %}
{{ post_form.as_p }}
{{ post_form.as_p }}
<button
class=
"button"
type=
"Save Post"
>
Save Post
</button>
<button
class=
"button"
type=
"Save Post"
>
Save Post
</button>
...
...
widget_group_17/forum/urls.py
View file @
874353d9
from
django.urls
import
path
from
django.urls
import
path
from
.
import
views
from
.
import
views
app_name
=
"forum"
app_name
=
'forum'
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
views
.
index
,
name
=
"index"
),
path
(
''
,
views
.
ForumView
.
as_view
()
,
name
=
"index"
),
path
(
'posts/<int:post_id>/details/'
,
views
.
detail
,
name
=
"detail"
),
path
(
'posts/<int:post_id>/details/'
,
views
.
detail
,
name
=
"detail"
),
path
(
'posts/add/'
,
views
.
add
,
name
=
"post_add"
),
path
(
'posts/add/'
,
views
.
add
,
name
=
"post_add"
),
#
path('welcome', views.welcome, name='welcome')
path
(
'welcome'
,
views
.
welcome
,
name
=
'welcome'
)
]
]
\ No newline at end of file
widget_group_17/forum/views.py
View file @
874353d9
from
django.shortcuts
import
render
,
redirect
from
django.shortcuts
import
render
,
redirect
from
django.http
import
HttpResponse
,
Http404
from
django.http
import
HttpResponse
,
Http404
from
django.
template
import
loader
from
django.
views
import
View
from
.models
import
Post
,
Reply
from
.models
import
Post
,
Reply
from
.forms
import
PostForm
from
.forms
import
PostForm
# Create your views here.
# Create your views here.
def
index
(
request
):
def
welcome
(
request
):
posts_list
=
Post
.
objects
.
order_by
(
"pub_date"
)
return
HttpResponse
(
'Welcome to Widget Forum!'
)
template
=
loader
.
get_template
(
"forum/index.html"
)
context
=
{
class
ForumView
(
View
):
"posts_list"
:
posts_list
,
def
get
(
self
,
request
):
}
posts_list
=
Post
.
objects
.
order_by
(
"pub_date"
)
return
HttpResponse
(
template
.
render
(
context
,
request
)
)
return
render
(
request
,
"forum/index.html"
,
{
"posts_list"
:
posts_list
}
)
def
detail
(
request
,
post_id
):
def
detail
(
request
,
post_id
):
try
:
try
:
...
...
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