Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group3
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
Jonathan Talbot
widget_group3
Commits
a4e83b42
Commit
a4e83b42
authored
Apr 08, 2022
by
Isaiah Flores
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update widget_group3/widget_group3/views.py
parent
fe94ab32
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
4 deletions
+36
-4
views.py
widget_group3/widget_group3/views.py
+36
-4
No files found.
widget_group3/widget_group3/views.py
View file @
a4e83b42
from
django.http
import
HttpResponse
from
.models
import
WidgetUser
,
Post
,
Reply
,
Announcement
,
Assignment
,
Department
def
homepage
(
request
):
widget_users
=
WidgetUser
.
objects
.
all
()
output
=
"WIDGET USERS:
\n
"
+
"
\n
"
.
join
([
str
(
user
)
for
user
in
widget_users
])
departments
=
Department
.
objects
.
all
()
output
=
"WIDGET USERS:
\n
"
+
"
\n
"
.
join
(
[
'{}: {}, {}, {}'
.
format
(
str
(
user
.
full_name
),
str
(
user
.
id_num
),
str
(
user
.
email
),
str
(
user
.
department
))
for
user
in
widget_users
]
)
return
HttpResponse
(
output
,
content_type
=
"text/plain"
)
def
assignments
(
request
):
...
...
@@ -18,6 +25,7 @@ def forum(request):
output
=
"FORUM POSTS:<br>"
+
"<br>"
.
join
([
str
(
x
)
for
x
in
post
])
+
"<br>"
.
join
([
str
(
z
)
for
z
in
reply
])
return
HttpResponse
(
output
,
content_type
=
"text/plain"
)
# If the above code doesn't work please use this one below
# def forum(request):
# post = Post.objects.all()
# reply = Reply.objects.all()
...
...
@@ -25,9 +33,33 @@ def forum(request):
# replies = ""
# for x in post:
# posts += '<br>{} by {} dated {}:<br> {}'.format(
x.post_title, x.author.full_name(), x.pub_date, x.post_body
)
# posts += '<br>{} by {} dated {}:<br> {}'.format(
str(x.post_title), str(x.author.full_name()), str(x.pub_date), str(x.post_body)
)
# for y in reply:
# replies += '<br>Reply by {} dated {}:<br> {}'.format(
y.author.full_name(), y.pub_date, y.reply_body
)
# replies += '<br>Reply by {} dated {}:<br> {}'.format(
str(y.author.full_name()), str(y.pub_date), str(y.reply_body)
)
# output = "FORUM POSTS:" + posts + replies
# return HttpResponse(output, content_type="text/plain")
# If the above code doesn't work again please use this one instead
# def forum(request):
# forum_posts = Post.objects.all()
# forum_replies = Reply.objects.all()
# output1 = "FORUM POSTS:<br>" + "<br>".join(
# ['{} by {} dated {}:<br> {}'.format(str(post.post_title),
# str(post.author.full_name()),
# str(post.pub_date),
# str(post.post_body))
# for post in forum_posts]
# )
# output2 = "<br>".join(
# ['<br>Reply by {} dated {}:<br> {}'.format(str(reply.author.full_name()),
# str(reply.pub_date),
# str(reply.reply_body))
# for reply in forum_replies]
# )
# output = output1+output2
# return HttpResponse(output, content_type="text/plain")
\ 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