Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
final_quintupoltrobol
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
Matthew Karl David P. Arpas
final_quintupoltrobol
Commits
6e60c621
Commit
6e60c621
authored
May 15, 2023
by
karin-kurusu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated views.py pageview to reflect specifications, implemented DetailView, CreateView, UpdateView
parent
52f439b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
24 deletions
+18
-24
views.py
widget_quintupoltrobol/forum/views.py
+18
-24
No files found.
widget_quintupoltrobol/forum/views.py
View file @
6e60c621
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
.models
import
ForumPost
,
Reply
from
.models
import
ForumPost
,
Reply
from
django.http
import
HttpResponse
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
def
pageview
(
request
):
def
pageview
(
request
):
forumposts
=
ForumPost
.
objects
.
all
(
)
forumposts
=
ForumPost
.
objects
.
order_by
(
"-pub_datetime"
)
replys
=
Reply
.
objects
.
all
()
replys
=
Reply
.
objects
.
all
()
string_builder
=
"Widget's Forum <br> <br> Forum Posts: <br> "
return
render
(
request
,
'forum/forum.html'
,
{
'forumposts'
:
forumposts
,
'replys'
:
replys
})
for
forumpost
in
forumposts
:
class
ForumpostDetailView
(
DetailView
):
def
get
(
self
,
request
,
pk
):
forumpost
=
ForumPost
.
objects
.
get
(
pk
=
pk
)
reply
=
Reply
.
objects
.
filter
(
forum_post
=
forumpost
)
return
render
(
request
,
'forum/forumpost-details.html'
,
{
'forumpost'
:
forumpost
,
'reply'
:
reply
})
string_builder
=
"{} <br> {} by {} posted {} <br> {}"
.
format
(
class
ForumpostCreateView
(
CreateView
):
string_builder
,
model
=
ForumPost
forumpost
.
title
,
fields
=
'__all__'
forumpost
.
author
,
template_name
=
'forum/forumpost-add.html'
forumpost
.
pub_datetime
.
strftime
(
"
%
m/
%
d/
%
Y,
%
I:
%
M
%
p:"
),
forumpost
.
body
class
ForumpostUpdateView
(
UpdateView
):
)
model
=
ForumPost
fields
=
'__all__'
for
reply
in
replys
:
template_name
=
'forum/forumpost-edit.html'
if
reply
.
forum_post
==
forumpost
:
string_builder
=
"{} <br> Reply by {} posted {} <br> {}"
.
format
(
string_builder
,
reply
.
author
,
reply
.
pub_datetime
.
strftime
(
"
%
m/
%
d/
%
Y,
%
I:
%
M
%
p:"
),
reply
.
body
)
string_builder
+=
"<br>"
return
HttpResponse
(
string_builder
)
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