Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_casanatics
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 Aidan Vincent M. Ng
midterm_casanatics
Commits
89800a4e
Commit
89800a4e
authored
May 08, 2023
by
Andre Dalwin C. Tan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added forumpost-details.html
parent
eb52c5d5
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
2 deletions
+50
-2
models.cpython-310.pyc
widget_casanatics/forum/__pycache__/models.cpython-310.pyc
+0
-0
urls.cpython-310.pyc
widget_casanatics/forum/__pycache__/urls.cpython-310.pyc
+0
-0
views.cpython-310.pyc
widget_casanatics/forum/__pycache__/views.cpython-310.pyc
+0
-0
models.py
widget_casanatics/forum/models.py
+6
-1
forumpost-details.html
...t_casanatics/forum/templates/forum/forumpost-details.html
+25
-0
urls.py
widget_casanatics/forum/urls.py
+4
-0
views.py
widget_casanatics/forum/views.py
+15
-1
No files found.
widget_casanatics/forum/__pycache__/models.cpython-310.pyc
View file @
89800a4e
No preview for this file type
widget_casanatics/forum/__pycache__/urls.cpython-310.pyc
View file @
89800a4e
No preview for this file type
widget_casanatics/forum/__pycache__/views.cpython-310.pyc
View file @
89800a4e
No preview for this file type
widget_casanatics/forum/models.py
View file @
89800a4e
from
django.db
import
models
from
dashboard.models
import
WidgetUser
from
django.urls
import
reverse
class
ForumPost
(
models
.
Model
):
...
...
@@ -11,9 +12,13 @@ class ForumPost(models.Model):
def
__str__
(
self
):
return
self
.
title
def
get_absolute_url
(
self
):
return
reverse
(
'forum:forumpostdetails'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Reply
(
models
.
Model
):
forum_post
=
models
.
ForeignKey
(
ForumPost
,
on_delete
=
models
.
CASCADE
)
forum_post
=
models
.
ForeignKey
(
ForumPost
,
on_delete
=
models
.
CASCADE
,
related_name
=
"replies"
)
body
=
models
.
CharField
(
max_length
=
1000
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
pub_datetime
=
models
.
DateTimeField
(
"Published Date and Time"
,
auto_now_add
=
True
)
...
...
widget_casanatics/forum/templates/forum/forumpost-details.html
0 → 100644
View file @
89800a4e
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.title }} {% endblock %}
{% block content %}
<h1>
{{ object.title }}
</h1>
<h2>
{{ object.author.first_name }} {{ object.author.last_name }}
</h2>
<h3>
{{ object.pub_datetime|date:"m/d/Y, h:i A" }}
</h3>
<p>
{{ object.body }}
</p>
<br>
Post Replies:
<ul>
{% for reply in object.replies.all %}
<li>
<p>
by {{ reply.author.first_name }} {{ reply.author.last_name }}
</p>
<p>
{{ reply.pub_datetime|date:"m/d/Y, h:i A" }}
</p>
<p>
{{ reply.body }}
</p>
</li>
{% endfor %}
</ul>
<form
action=
"../edit"
>
<button
type=
"Submit"
>
Edit Post
</button>
</form>
{% endblock %}
widget_casanatics/forum/urls.py
View file @
89800a4e
...
...
@@ -4,6 +4,10 @@ from . import views
urlpatterns
=
[
path
(
""
,
views
.
forum
,
name
=
"index"
),
path
(
"forumpost/<int:pk>/details/"
,
views
.
ForumDetailView
.
as_view
(),
name
=
"forumpostdetails"
),
path
(
"forumpost/add/"
,
views
.
ForumCreateView
.
as_view
(),
name
=
"forumpostadd"
),
path
(
"forumpost/<int:pk>/edit/"
,
views
.
ForumUpdateView
.
as_view
(),
name
=
"forumpostedit"
),
]
...
...
widget_casanatics/forum/views.py
View file @
89800a4e
...
...
@@ -9,6 +9,20 @@ from django.shortcuts import render
def
forum
(
request
):
context
=
{
"forumpost"
:
ForumPost
.
objects
.
all
()
,
#.order_by('pub_datetime')
"forumpost"
:
ForumPost
.
objects
.
all
()
.
order_by
(
'pub_datetime'
),
}
return
render
(
request
,
'forum/forum.html'
,
context
)
class
ForumDetailView
(
DetailView
):
model
=
ForumPost
template_name
=
'forum/forumpost-details.html'
class
ForumCreateView
(
CreateView
):
model
=
ForumPost
template_name
=
'forum/forumpost-add.html'
fields
=
[
'title'
,
'body'
,
'author'
]
class
ForumUpdateView
(
UpdateView
):
model
=
ForumPost
template_name
=
'forum/forumpost-edit.html'
fields
=
[
'title'
,
'body'
,
'author'
]
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