Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_k3git
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
Stefan Gomez
midterm_k3git
Commits
9e9c3b8f
Commit
9e9c3b8f
authored
Mar 05, 2023
by
Migs Atienza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished Views + Updated Models' __str__
parent
eb27b0c9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
4 deletions
+12
-4
db.sqlite3
widget_k3git/db.sqlite3
+0
-0
models.cpython-39.pyc
widget_k3git/forum/__pycache__/models.cpython-39.pyc
+0
-0
views.cpython-39.pyc
widget_k3git/forum/__pycache__/views.cpython-39.pyc
+0
-0
models.py
widget_k3git/forum/models.py
+6
-0
views.py
widget_k3git/forum/views.py
+6
-4
settings.cpython-39.pyc
...et_k3git/widget_k3git/__pycache__/settings.cpython-39.pyc
+0
-0
No files found.
widget_k3git/db.sqlite3
View file @
9e9c3b8f
No preview for this file type
widget_k3git/forum/__pycache__/models.cpython-39.pyc
View file @
9e9c3b8f
No preview for this file type
widget_k3git/forum/__pycache__/views.cpython-39.pyc
View file @
9e9c3b8f
No preview for this file type
widget_k3git/forum/models.py
View file @
9e9c3b8f
...
...
@@ -7,10 +7,16 @@ class ForumPost(models.Model):
author
=
models
.
CharField
(
max_length
=
100
)
pub_datetime
=
models
.
DateTimeField
()
def
__str__
(
self
):
return
'{} by {}'
.
format
(
self
.
title
,
self
.
author
)
class
Reply
(
models
.
Model
):
body
=
models
.
TextField
(
max_length
=
1000
)
author
=
models
.
CharField
(
max_length
=
100
)
pub_datetime
=
models
.
DateTimeField
()
forum_post
=
models
.
ForeignKey
(
ForumPost
,
on_delete
=
models
.
CASCADE
)
def
__str__
(
self
):
return
'{}
\'
s reply to {}'
.
format
(
self
.
author
,
self
.
forum_post
)
# Create your models here.
widget_k3git/forum/views.py
View file @
9e9c3b8f
...
...
@@ -7,15 +7,17 @@ from .models import ForumPost, Reply
def
index
(
request
):
page_content
=
"""<H1>Widget’s Forum</H1>"""
for
forum
in
ForumPost
.
objects
.
all
():
newForumDateTime
=
forum
.
pub_datetime
.
strftime
(
"
%
m-
%
d-
%
Y
%
I:
%
M
%
p"
)
page_content
+=
"""<br>
{} by {} posted {}:<br>
{}<br>
"""
.
format
(
forum
.
title
,
forum
.
author
,
forum
.
pub_datet
ime
,
forum
.
body
)
"""
.
format
(
forum
.
title
,
forum
.
author
,
newForumDateT
ime
,
forum
.
body
)
for
reply
in
Reply
.
objects
.
all
():
if
reply
.
forum_post
==
forum
:
page_content
+=
"""Reply by {} posted {}:
{}
"""
.
format
(
reply
.
author
,
reply
.
pub_datetime
,
reply
.
body
)
newReplyDateTime
=
reply
.
pub_datetime
.
strftime
(
"
%
m-
%
d-
%
Y
%
I:
%
M
%
p"
)
page_content
+=
"""Reply by {} posted {}:<br>
{}<br>
"""
.
format
(
reply
.
author
,
newReplyDateTime
,
reply
.
body
)
return
HttpResponse
(
page_content
)
# Create your views here.
widget_k3git/widget_k3git/__pycache__/settings.cpython-39.pyc
View file @
9e9c3b8f
No preview for this file type
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