Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_nicsbabes
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
Nics De Vega
midterm_nicsbabes
Commits
759a399a
Commit
759a399a
authored
Mar 06, 2023
by
Tanya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edited the url views for app forum
parent
754ddf32
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletion
+30
-1
views.py
widget_nicsbabes/forum/views.py
+30
-1
No files found.
widget_nicsbabes/forum/views.py
View file @
759a399a
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
.models
import
ForumPost
,
Reply
from
dashboard.models
import
WidgetUser
def
index
(
request
):
return
HttpResponse
(
'Hello! This is the Forum.'
)
\ No newline at end of file
return_string
=
'<body>'
for
post
in
ForumPost
.
objects
.
all
():
post_heading
=
'{} by {} {} posted {}:<br>'
.
format
(
post
.
title
,
post
.
author
.
first_name
,
post
.
author
.
last_name
,
post
.
pub_datetime
.
strftime
(
"
%
m/
%
d/
%
Y,
%
I:
%
M
%
p"
)
)
post_body
=
'{}<br>'
.
format
(
post
.
body
)
post_replies
=
''
for
reply
in
Reply
.
objects
.
filter
(
forum_post
=
post
):
post_replies
+=
'Reply by {} {} posted {}:<br>'
.
format
(
reply
.
author
.
first_name
,
reply
.
author
.
last_name
,
reply
.
pub_datetime
.
strftime
(
"
%
m/
%
d/
%
Y,
%
I:
%
M
%
p"
)
)
post_replies
+=
'{}<br>'
.
format
(
reply
.
body
)
return_string
+=
post_heading
+
post_body
+
post_replies
+
'<br>'
html_string
=
'<html>{}</html>'
.
format
(
return_string
)
return
HttpResponse
(
'Widget’s Forum<br><br>Forum Posts:<br>'
+
html_string
)
\ 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