Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_princessgabi
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
Ysabella Panghulan
midterm_princessgabi
Commits
03d1052b
Commit
03d1052b
authored
Mar 06, 2023
by
Ysabella Panghulan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed views format and typo in models and admin, changed post to forum_post
parent
e2b352df
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
9 deletions
+10
-9
admin.py
widget_princessgabi/forum/admin.py
+1
-1
models.py
widget_princessgabi/forum/models.py
+3
-3
views.py
widget_princessgabi/forum/views.py
+6
-5
No files found.
widget_princessgabi/forum/admin.py
View file @
03d1052b
...
@@ -3,7 +3,7 @@ from .models import ForumPost, Reply
...
@@ -3,7 +3,7 @@ from .models import ForumPost, Reply
# Register your models here.
# Register your models here.
class
ReplyInLine
(
admin
.
TabularIn
L
ine
):
class
ReplyInLine
(
admin
.
TabularIn
l
ine
):
model
=
Reply
model
=
Reply
class
ForumPostAdmin
(
admin
.
ModelAdmin
):
class
ForumPostAdmin
(
admin
.
ModelAdmin
):
...
...
widget_princessgabi/forum/models.py
View file @
03d1052b
...
@@ -9,14 +9,14 @@ class ForumPost(models.Model):
...
@@ -9,14 +9,14 @@ class ForumPost(models.Model):
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
pub_datetime
=
models
.
DateTimeField
()
pub_datetime
=
models
.
DateTimeField
()
def
_
str
_
(
self
):
def
_
_str_
_
(
self
):
return
self
.
title
return
self
.
title
class
Reply
(
models
.
Model
):
class
Reply
(
models
.
Model
):
body
=
models
.
CharField
(
max_length
=
300
)
body
=
models
.
CharField
(
max_length
=
300
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
pub_datetime
=
models
.
DateTimeField
()
pub_datetime
=
models
.
DateTimeField
()
post
=
models
.
ForeignKey
(
ForumPost
,
on_delete
=
models
.
CASCADE
)
forum_
post
=
models
.
ForeignKey
(
ForumPost
,
on_delete
=
models
.
CASCADE
)
def
_
str
_
(
self
):
def
_
_str_
_
(
self
):
return
self
.
author
return
self
.
author
widget_princessgabi/forum/views.py
View file @
03d1052b
...
@@ -2,16 +2,17 @@ from django.shortcuts import render
...
@@ -2,16 +2,17 @@ from django.shortcuts import render
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
.models
import
ForumPost
,
Reply
from
.models
import
ForumPost
,
Reply
# Create your views here.
def
index
(
request
):
def
index
(
request
):
posts
=
ForumPost
.
objects
.
all
()
posts
=
ForumPost
.
objects
.
all
()
replies
=
Reply
.
objects
.
all
()
replies
=
Reply
.
objects
.
all
()
welcomeMessage
=
"Widget's Forum<br><br>Forum Posts:<br>"
welcomeMessage
=
'Widget
\'
s Forum<br><br>Forum Posts:<br>'
for
post
in
posts
:
for
post
in
posts
:
for
reply
in
replies
:
for
reply
in
replies
:
if
reply
.
post
.
title
==
post
.
title
:
if
reply
.
forum_post
.
title
==
post
.
title
:
welcomeMessage
=
welcomeMessage
+
post
.
title
+
" by "
+
post
.
author
.
first_name
+
" "
+
post
.
author
.
last_name
+
" posted "
+
post
.
pub_datetime
.
strftime
(
'
%
I:
%
M
%
p'
)
+
":<br>"
+
post
.
body
+
"<br>"
+
"Reply by "
+
reply
.
author
.
first_name
+
" "
+
reply
.
author
.
last_name
+
" posted "
+
reply
.
pub_datetime
.
strftime
(
'
%
I:
%
M
%
p'
)
+
":<br>"
+
reply
.
body
+
"<br><br>"
welcomeMessage
+=
post
.
title
+
' by '
+
post
.
author
.
first_name
+
' '
+
post
.
author
.
last_name
welcomeMessage
+=
' posted '
+
post
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y,
%
I:
%
M
%
p'
)
+
':<br>'
+
post
.
body
+
'<br>'
welcomeMessage
+=
'Reply by '
+
reply
.
author
.
first_name
+
' '
+
reply
.
author
.
last_name
+
' posted '
welcomeMessage
+=
reply
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y,
%
I:
%
M
%
p'
)
+
':<br>'
+
reply
.
body
+
'<br><br>'
return
HttpResponse
(
welcomeMessage
)
return
HttpResponse
(
welcomeMessage
)
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