Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_huli
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
Izaac Daniel B. Muncal
midterm_huli
Commits
c8875447
Commit
c8875447
authored
May 12, 2023
by
Anchilla Vera Marie Silang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Views
parent
5ab80d8f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
17 deletions
+25
-17
views.py
widget_huli/forum/views.py
+25
-17
No files found.
widget_huli/forum/views.py
View file @
c8875447
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.urls
import
reverse
from
django.views.generic
import
DetailView
,
CreateView
,
UpdateView
from
.models
import
ForumPost
,
Reply
from
.models
import
ForumPost
,
Reply
from
.forms
import
ForumPostForm
# Create your views here.
# Create your views here.
def
index
(
request
):
def
ForumViews
(
request
):
return_string
=
'<body> <ul>'
forum
=
ForumPost
.
objects
.
all
()
context
=
{
'forum'
:
forum
}
return
render
(
request
,
'forum.html'
,
context
)
for
post
in
ForumPost
.
objects
.
all
():
class
ForumPostDetails
(
DetailView
):
return_string
+=
'<li>{} by {} posted {}:<br>{}</li>'
.
format
(
template_name
=
"forumpost-details.html"
post
.
title
,
post
.
author
,
post
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y
%
H:
%
M
%
p'
),
post
.
body
model
=
ForumPost
)
for
replypost
in
Reply
.
objects
.
all
():
if
replypost
.
forum_post
==
post
:
return_string
+=
'<li>Reply by {} posted {}:<br>{}</li>'
.
format
(
replypost
.
author
,
replypost
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y
%
I:
%
M
%
p'
),
replypost
.
body
)
return_string
+=
'<br>'
return_string
+=
'</ul></body>'
class
ForumPostNew
(
CreateView
):
form_class
=
ForumPostForm
template_name
=
"forumpost-add.html"
html_string
=
'<html>{}</html>'
.
format
(
return_string
)
def
get_success
(
self
):
return
reverse
(
'forum:forumpostnew'
,
kwargs
=
{
'pk'
:
self
.
object
.
id
},
current_app
=
self
.
request
.
resolver_match
.
namespace
)
return
HttpResponse
(
html_string
)
class
ForumPostEdit
(
UpdateView
):
\ No newline at end of file
form_class
=
ForumPostForm
template_name
=
"forumpost-edit.html"
queryset
=
ForumPost
.
objects
.
all
()
def
get_success_url
(
self
):
return
reverse
(
'forum:forumpostdetails'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
},
current_app
=
self
.
request
.
resolver_match
.
namespace
)
\ 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