Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
midterm_OhMyBash
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
Nheo Samson
midterm_OhMyBash
Commits
d1ab89bb
Commit
d1ab89bb
authored
May 13, 2023
by
Alliyah Marcelo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified views.py for FBV and CBV implementations of the respective Forum app pages.
parent
7da5c966
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
41 deletions
+27
-41
views.py
widget_OhMyBash/forum/views.py
+27
-41
No files found.
widget_OhMyBash/forum/views.py
View file @
d1ab89bb
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
from
.models
import
ForumPost
,
Reply
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
def
index
(
request
):
from
.models
import
ForumPost
return_string
=
"<p>Widget's Forum</p>Forum Posts:"
for
post
in
ForumPost
.
objects
.
all
():
counter
=
0
def
forum
(
request
):
for
reply
in
Reply
.
objects
.
all
():
posts
=
ForumPost
.
objects
.
all
()
if
counter
==
0
and
post
.
title
==
reply
.
forumpost
.
title
:
return
render
(
request
,
'forum/forum.html'
,
{
'posts'
:
posts
})
return_string
+=
'<br>{} by {} {} posted {}<br>{}'
.
format
(
reply
.
forumpost
.
title
,
reply
.
forumpost
.
author
.
first_name
,
class
ForumPostDetailView
(
DetailView
):
reply
.
forumpost
.
author
.
last_name
,
model
=
ForumPost
reply
.
forumpost
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y,
%
H:
%
M
%
p:'
),
template_name
=
'forum/forumpost-details.html'
reply
.
forumpost
.
body
,
)
return_string
+=
'<br>Reply by {} {} posted {}<br>{}'
.
format
(
class
ForumPostCreateView
(
CreateView
):
reply
.
author
.
first_name
,
model
=
ForumPost
reply
.
author
.
last_name
,
fields
=
'__all__'
reply
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y,
%
H:
%
M
%
p:'
),
template_name
=
'forum/forumpost-add.html'
reply
.
body
,
)
counter
+=
1
class
ForumPostUpdateView
(
UpdateView
):
continue
model
=
ForumPost
elif
counter
==
1
and
post
.
title
==
reply
.
forumpost
.
title
:
fields
=
'__all__'
return_string
+=
'<br>Reply by {} {} posted {}<br>{}'
.
format
(
template_name
=
'forum/forumpost-edit.html'
reply
.
author
.
first_name
,
\ No newline at end of file
reply
.
author
.
last_name
,
reply
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y,
%
H:
%
M
%
p:'
),
reply
.
body
,
)
continue
elif
counter
==
1
and
post
.
title
!=
reply
.
forumpost
.
title
:
return_string
+=
'<br>'
break
else
:
continue
html_string
=
'<html><body>{}</body></html>'
.
format
(
return_string
)
return
HttpResponse
(
html_string
)
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