Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_Alipins
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
Angelico Ruiz T. Teaño
widget_Alipins
Commits
538be088
Commit
538be088
authored
Apr 03, 2022
by
Christian Sarabia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Reply model, associations, and Forum page view
parent
5f5ec24c
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
11 deletions
+52
-11
views.py
widget_alipins/announcements/views.py
+2
-2
views.py
widget_alipins/assignments/views.py
+2
-2
db.sqlite3
widget_alipins/db.sqlite3
+0
-0
admin.py
widget_alipins/forum/admin.py
+12
-2
models.py
widget_alipins/forum/models.py
+18
-2
views.py
widget_alipins/forum/views.py
+16
-1
views.py
widget_alipins/homepage/views.py
+2
-2
No files found.
widget_alipins/announcements/views.py
View file @
538be088
...
...
@@ -5,10 +5,10 @@ def index(request):
return
HttpResponse
(
display_announcementboard
(
Announcement
.
objects
.
all
()))
def
display_announcementboard
(
announcement_data
):
display_output
=
"
ANNOUNCEMENTS
: <br>"
display_output
=
"
<u><b>ANNOUNCEMENTS</u></b>
: <br>"
for
object
in
announcement_data
:
display_output
+=
'''
{title} by {first_name} {last_name}
dated {date}:<br>
<b>{title} by {first_name} {last_name}</b>
dated {date}:<br>
{body}<br>
Like: {like_tally}<br>
Love: {love_tally}<br>
...
...
widget_alipins/assignments/views.py
View file @
538be088
...
...
@@ -7,11 +7,11 @@ def index(request):
return
HttpResponse
(
display_assignments
(
Assignment
.
objects
.
all
()))
def
display_assignments
(
data_set_assignment
):
display_output
=
"
ASSIGNMENTS
: <br>"
display_output
=
"
<u><b>ASSIGNMENTS</u></b>
: <br>"
for
object
in
data_set_assignment
:
display_output
+=
'''
Assignment Name:
{name}
<br>
Assignment Name:
<b>{name}</b>
<br>
Description: {description}<br>
Perfect Score: {max_points}<br>
Passing Score: {passing_score}<br>
...
...
widget_alipins/db.sqlite3
View file @
538be088
No preview for this file type
widget_alipins/forum/admin.py
View file @
538be088
from
django.contrib
import
admin
# Register your models here.
from
.models
import
Post
from
.models
import
Post
,
Reply
admin
.
site
.
register
(
Post
)
\ No newline at end of file
class
PostAdmin
(
admin
.
ModelAdmin
):
model
=
Post
search_fields
=
[
'post_title'
,
'post_body'
,
'author'
]
list_display
=
(
'post_title'
,
'post_body'
,
'pub_date'
,
'author'
)
class
ReplyAdmin
(
admin
.
ModelAdmin
):
model
=
Reply
search_fields
=
[
'post'
,
'reply_body'
,
'author'
]
list_display
=
(
'post'
,
'reply_body'
,
'pub_date'
,
'author'
)
admin
.
site
.
register
(
Post
,
PostAdmin
)
admin
.
site
.
register
(
Reply
,
ReplyAdmin
)
\ No newline at end of file
widget_alipins/forum/models.py
View file @
538be088
from
calendar
import
c
from
django.db
import
models
from
homepage.models
import
WidgetUser
# Create your models here.
class
Post
(
models
.
Model
):
post_title
=
models
.
CharField
(
max_length
=
50
)
post_body
=
models
.
CharField
(
max_length
=
500
)
post_body
=
models
.
TextField
(
max_length
=
1
500
)
pub_date
=
models
.
DateTimeField
(
"date published"
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
def
__str__
(
self
):
return
self
.
post_title
class
Reply
(
models
.
Model
):
post
=
models
.
ForeignKey
(
Post
,
on_delete
=
models
.
CASCADE
)
reply_body
=
models
.
TextField
(
max_length
=
1500
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
default
=
1
)
pub_date
=
models
.
DateTimeField
(
"date published"
)
def
__str__
(
self
):
return
"Reply from "
+
self
.
author
.
first_name
+
" "
+
self
.
author
.
last_name
class
Meta
:
verbose_name_plural
=
"Replies"
\ No newline at end of file
widget_alipins/forum/views.py
View file @
538be088
from
django.http
import
HttpResponse
from
.models
import
Post
,
Reply
# Create your views here.
def
index
(
request
):
return
HttpResponse
(
"Welcome to Widget’s Forum!"
)
return
HttpResponse
(
display_forum
(
Post
.
objects
.
all
()))
def
display_forum
(
post_data
):
display_output
=
"<u><b>FORUM POSTS</u></b>:<br>"
for
post
in
post_data
:
display_output
+=
f
"<b>{post.post_title} by {post.author.first_name} {post.author.last_name}</b> dated {str(post.pub_date)}:
\
<br>{post.post_body}"
replies
=
Reply
.
objects
.
filter
(
post
=
post
)
for
reply
in
replies
:
display_output
+=
f
"<br><b>Reply by {reply.author.first_name} {reply.author.last_name}</b> dated {reply.pub_date}:
\
<br>{reply.reply_body}"
display_output
+=
"<br><br>"
return
display_output
\ No newline at end of file
widget_alipins/homepage/views.py
View file @
538be088
...
...
@@ -6,11 +6,11 @@ def index(request):
return
HttpResponse
(
display_users
(
WidgetUser
.
objects
.
all
()))
def
display_users
(
data_list
):
display_output
=
"
WIDGET USERS
: <br>"
display_output
=
"
<u><b>WIDGET USERS</u></b>
: <br>"
for
objects
in
data_list
:
display_output
+=
'''
{last_name}, {first_name} {middle_name}
: {id}, {email}, {dept}, {home}<br>
<b>{last_name}, {first_name} {middle_name}</b>
: {id}, {email}, {dept}, {home}<br>
'''
.
format
(
last_name
=
objects
.
last_name
,
first_name
=
objects
.
first_name
,
middle_name
=
objects
.
middle_name
,
...
...
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