Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_robo_mommy
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Raul Jarod Conanan
midterm_robo_mommy
Commits
9e635913
Commit
9e635913
authored
May 11, 2023
by
RJC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified forumpost list view and added detail view for forumpost objects
parent
d8225ce7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
23 deletions
+12
-23
views.py
widget_robo_mommy/forum/views.py
+12
-23
No files found.
widget_robo_mommy/forum/views.py
View file @
9e635913
from
django.shortcuts
import
render
from
django.
http
import
HttpResponse
from
django.
views
import
generic
from
.models
import
ForumPost
import
pytz
from
django.utils
import
timezone
...
...
@@ -14,26 +14,15 @@ def convert_utc_to_local(utctime, format):
def
forum_post_list_view
(
request
):
html_string_1
=
'<html lang="en"><head><meta charset="UTF-8"><title>Forum Post List</title>'
\
'<h1>Forum Post List</h1></head><ul>'
html_string_2
=
''
for
fp
in
ForumPost
.
objects
.
all
():
html_string_2
+=
'<li><b style="font-size: 30px">{}</b>'
\
' by <b style="font-size: large">{} {}</b>'
\
' posted <b>{}</b><p>{}</p><ul>'
.
format
(
fp
.
title
,
fp
.
author
.
first_name
,
fp
.
author
.
last_name
,
convert_utc_to_local
(
fp
.
pub_datetime
,
'
%
d/
%
m/
%
Y
%
I:
%
M
%
p'
),
fp
.
body
)
for
replies
in
fp
.
reply
.
all
():
html_string_2
+=
'<li> Reply by <b>{} {}</b> '
\
'posted <b>{}</b><p>{}</p></li>'
.
format
(
replies
.
author
.
first_name
,
replies
.
author
.
last_name
,
convert_utc_to_local
(
replies
.
pub_datetime
,
'
%
d/
%
m/
%
Y
%
I:
%
M
%
p'
),
replies
.
body
)
html_string_2
+=
'</ul></li>'
html_string_final
=
html_string_1
+
html_string_2
+
'</ul></html>'
posts
=
ForumPost
.
objects
.
all
()
.
order_by
(
'-pub_datetime'
)
context
=
{
'posts'
:
posts
}
return
render
(
request
,
'forum/forum.html'
,
context
)
return
HttpResponse
(
html_string_final
)
class
ForumPostDetailView
(
generic
.
DetailView
):
model
=
ForumPost
template_name
=
'forum/forumpost-details.html'
queryset
=
ForumPost
.
objects
.
all
()
context_object_name
=
'posts'
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