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
Hide 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
.models
import
ForumPost
,
Reply
def
index
(
request
):
return_string
=
"<p>Widget's Forum</p>Forum Posts:"
for
post
in
ForumPost
.
objects
.
all
():
counter
=
0
for
reply
in
Reply
.
objects
.
all
():
if
counter
==
0
and
post
.
title
==
reply
.
forumpost
.
title
:
return_string
+=
'<br>{} by {} {} posted {}<br>{}'
.
format
(
reply
.
forumpost
.
title
,
reply
.
forumpost
.
author
.
first_name
,
reply
.
forumpost
.
author
.
last_name
,
reply
.
forumpost
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y,
%
H:
%
M
%
p:'
),
reply
.
forumpost
.
body
,
)
return_string
+=
'<br>Reply by {} {} posted {}<br>{}'
.
format
(
reply
.
author
.
first_name
,
reply
.
author
.
last_name
,
reply
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y,
%
H:
%
M
%
p:'
),
reply
.
body
,
)
counter
+=
1
continue
elif
counter
==
1
and
post
.
title
==
reply
.
forumpost
.
title
:
return_string
+=
'<br>Reply by {} {} posted {}<br>{}'
.
format
(
reply
.
author
.
first_name
,
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
)
from
django.shortcuts
import
render
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
ForumPost
def
forum
(
request
):
posts
=
ForumPost
.
objects
.
all
()
return
render
(
request
,
'forum/forum.html'
,
{
'posts'
:
posts
})
class
ForumPostDetailView
(
DetailView
):
model
=
ForumPost
template_name
=
'forum/forumpost-details.html'
class
ForumPostCreateView
(
CreateView
):
model
=
ForumPost
fields
=
'__all__'
template_name
=
'forum/forumpost-add.html'
class
ForumPostUpdateView
(
UpdateView
):
model
=
ForumPost
fields
=
'__all__'
template_name
=
'forum/forumpost-edit.html'
\ No newline at end of file
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