Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group 25
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
Andre Matthew Dumandan
widget_group 25
Commits
42e475ad
Commit
42e475ad
authored
May 18, 2022
by
Stephanie Tullao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Forum's urls.py and added templates for forum list and details in views.py
parent
6945a987
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
78 additions
and
19 deletions
+78
-19
urls.py
widget_group_25/forum/urls.py
+3
-2
views.py
widget_group_25/forum/views.py
+16
-17
.DS_Store
widget_group_25/widget_group_25/static/forum/.DS_Store
+0
-0
detail_styles.css
...oup_25/widget_group_25/static/forum/css/detail_styles.css
+0
-0
list_styles.css
...group_25/widget_group_25/static/forum/css/list_styles.css
+0
-0
.DS_Store
widget_group_25/widget_group_25/static/forum/img/.DS_Store
+0
-0
GitBranch.png
...t_group_25/widget_group_25/static/forum/img/GitBranch.png
+0
-0
GitBranchCreate.png
...p_25/widget_group_25/static/forum/img/GitBranchCreate.png
+0
-0
GitCheckout.png
...group_25/widget_group_25/static/forum/img/GitCheckout.png
+0
-0
forum_details.html
...oup_25/widget_group_25/templates/forum/forum_details.html
+33
-0
forum_list.html
..._group_25/widget_group_25/templates/forum/forum_list.html
+26
-0
No files found.
widget_group_25/forum/urls.py
View file @
42e475ad
from
django.urls
import
path
from
.views
import
index
from
.views
import
post_list_view
,
post_detail_view
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
''
,
post_list_view
,
name
=
'post-list'
),
path
(
'<int:pk>/details'
,
post_detail_view
,
name
=
'post-details'
),
]
app_name
=
'forum'
\ No newline at end of file
widget_group_25/forum/views.py
View file @
42e475ad
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.views.generic.list
import
ListView
from
django.views.generic.detail
import
DetailView
from
.models
import
Post
,
Reply
def
index
(
request
):
heading
=
'FORUM POSTS:<br>'
posts
=
Post
.
objects
.
all
()
body
=
''
for
post
in
posts
:
post_replies
=
Reply
.
objects
.
filter
(
original_post
=
post
)
body
+=
'{} by {} {} dated {}:<br>{}<br>'
.
format
(
post
.
post_title
,
post
.
author
.
first_name
,
post
.
author
.
last_name
,
post
.
pub_date
,
post
.
post_body
)
for
post_reply
in
post_replies
:
body
+=
'Reply by {} {} dated {}:<br>{}<br>'
.
format
(
post_reply
.
author
.
first_name
,
post_reply
.
author
.
last_name
,
post_reply
.
pub_date
,
post_reply
.
reply_body
)
body
+=
'<br>'
return
HttpResponse
(
heading
+
body
)
def
post_list_view
(
request
):
context
=
{}
context
[
'post_list'
]
=
Post
.
objects
.
order_by
(
'-pub_date'
)
.
all
()
return
render
(
request
,
'forum/forum_list.html'
,
context
)
def
post_detail_view
(
request
,
pk
):
post
=
Post
.
objects
.
get
(
pk
=
pk
)
reply_list
=
Reply
.
objects
.
filter
(
original_post
=
post
)
.
order_by
(
'-pub_date'
)
.
all
()
context
=
{
'post'
:
post
,
'reply_list'
:
reply_list
}
return
render
(
request
,
'forum/forum_details.html'
,
context
)
widget_group_25/widget_group_25/static/forum/.DS_Store
0 → 100644
View file @
42e475ad
File added
widget_group_25/widget_group_25/static/forum/css/detail_styles.css
0 → 100644
View file @
42e475ad
widget_group_25/widget_group_25/static/forum/css/list_styles.css
0 → 100644
View file @
42e475ad
widget_group_25/widget_group_25/static/forum/img/.DS_Store
0 → 100644
View file @
42e475ad
File added
widget_group_25/widget_group_25/static/forum/img/GitBranch.png
0 → 100644
View file @
42e475ad
23.6 KB
widget_group_25/widget_group_25/static/forum/img/GitBranchCreate.png
0 → 100644
View file @
42e475ad
28.8 KB
widget_group_25/widget_group_25/static/forum/img/GitCheckout.png
0 → 100644
View file @
42e475ad
31.7 KB
widget_group_25/widget_group_25/templates/forum/forum_details.html
0 → 100644
View file @
42e475ad
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ post.post_title }}{% endblock %}
{% block styles %}
<link
rel=
"stylesheet"
href=
"{% static 'forum/css/detail_styles.css' %}"
>
{% endblock %}
{% block content %}
{% if post.id == 1 %}
<img
src=
"{% static 'forum/img/GitBranch.png' %}"
alt=
"view branch"
>
{% endif %}
{% if post.id == 2 %}
<img
src=
"{% static 'forum/img/GitCheckout.png' %}"
alt=
"switch branch"
>
{% endif %}
{% if post.id == 3 %}
<img
src=
"{% static 'forum/img/GitBranchCreate.png' %}"
alt=
"create branch"
>
{% endif %}
<h1>
{{ post.post_title }}
</h1>
<h2>
by {{ post.author.first_name }} {{ post.author.last_name }}, {{ post.pub_date|date:'d/m/Y' }}
</h2>
{{ post.post_body }}
<h3>
Replies:
</h3>
{% for reply in reply_list %}
<h2>
by {{ reply.author.first_name }} {{ reply.author.last_name }}, {{ reply.pub_date|date:'d/m/Y' }}
</h2>
{{ reply.reply_body }}
{% endfor %}
{% endblock %}
\ No newline at end of file
widget_group_25/widget_group_25/templates/forum/forum_list.html
0 → 100644
View file @
42e475ad
{% extends 'base.html' %}
{% load static %}
{% block title %}Forum{% endblock %}
{% block styles %}
<link
rel=
"stylesheet"
href=
"{% static 'forum/css/list_styles.css' %}"
>
{% endblock %}
{% block content %}
<header>
<h1>
Welcome to Widget’s Forum!
</h1>
</header>
<p>
<h3>
Forum posts:
</h3>
{% for post in post_list %}
<li>
<a
href=
"{% url 'forum:post-details' pk=post.pk %}"
>
{{ post.post_title }} by {{ post.author.first_name }} {{ post.author.last_name }} dated {{ post.pub_date|date:"d/m/Y" }}
</a>
</li>
{% endfor %}
</p>
{% endblock %}
\ 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