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
a29cbfc6
Commit
a29cbfc6
authored
May 15, 2022
by
Christian Sarabia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix forum page and subpages
parent
f0e3ec1f
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
164 additions
and
16 deletions
+164
-16
index.html
..._alipins/announcements/templates/announcements/index.html
+1
-1
views.py
widget_alipins/announcements/views.py
+1
-1
db.sqlite3
widget_alipins/db.sqlite3
+0
-0
0004_post_post_image.py
widget_alipins/forum/migrations/0004_post_post_image.py
+18
-0
models.py
widget_alipins/forum/models.py
+1
-0
detail.html
widget_alipins/forum/templates/forum/detail.html
+33
-0
index.html
widget_alipins/forum/templates/forum/index.html
+23
-0
urls.py
widget_alipins/forum/urls.py
+3
-2
views.py
widget_alipins/forum/views.py
+31
-12
laundry.jpg
widget_alipins/media/forum/laundry.jpg
+0
-0
member.jpg
widget_alipins/media/forum/member.jpg
+0
-0
query.png
widget_alipins/media/forum/query.png
+0
-0
style.css
widget_alipins/static/forum/style.css
+53
-0
No files found.
widget_alipins/announcements/templates/announcements/index.html
View file @
a29cbfc6
...
...
@@ -20,4 +20,4 @@
<p>
There are no announcements.
</p>
{% endif %}
</div>
{% endblock %}
\ No newline at end of file
{% endblock %}
\ No newline at end of file
widget_alipins/announcements/views.py
View file @
a29cbfc6
...
...
@@ -5,7 +5,7 @@ from django.shortcuts import render
# Create your views here.
def
index
(
request
):
announcement_list
=
Announcement
.
objects
.
order_by
(
"pub_date"
)
announcement_list
=
Announcement
.
objects
.
order_by
(
"
-
pub_date"
)
context
=
{
"announcement_list"
:
announcement_list
,
}
...
...
widget_alipins/db.sqlite3
View file @
a29cbfc6
No preview for this file type
widget_alipins/forum/migrations/0004_post_post_image.py
0 → 100644
View file @
a29cbfc6
# Generated by Django 3.2.12 on 2022-05-15 07:54
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'forum'
,
'0003_alter_reply_options'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'post'
,
name
=
'post_image'
,
field
=
models
.
ImageField
(
blank
=
True
,
null
=
True
,
upload_to
=
'forum/'
),
),
]
widget_alipins/forum/models.py
View file @
a29cbfc6
...
...
@@ -7,6 +7,7 @@ class Post(models.Model):
post_body
=
models
.
TextField
(
max_length
=
1500
)
pub_date
=
models
.
DateTimeField
(
"date published"
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
post_image
=
models
.
ImageField
(
null
=
True
,
blank
=
True
,
upload_to
=
"forum/"
)
def
__str__
(
self
):
return
self
.
post_title
...
...
widget_alipins/forum/templates/forum/detail.html
0 → 100644
View file @
a29cbfc6
{% extends 'base.html' %}
{% load static %}
{% block styles %}
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'forum/style.css' %}"
>
{% endblock %}
{% block title %}{{post.post_title}}{% endblock %}
{% block content %}
<h1>
{{post.post_title}}
</h1>
<h2>
by {{post.author.first_name}} {{post.author.last_name}}, {{post.pub_date|date:"d/m/Y"}}
</h2>
<div>
<p>
{{post.post_body}}
<br><br>
{% if post.post_image %}
<p
style=
"text-align:center"
><img
src =
"{{ post.post_image.url }}"
></p><br>
{% endif %}
{% if replies %}
Replies:
<br>
<ul>
{% for reply in replies %}
<li>
<h4>
by {{reply.author.first_name}} {{reply.author.last_name}}, {{reply.pub_date|date:"d/m/Y"}}:
</h4>
<p>
{{reply.reply_body}}
</p>
</li>
{% endfor %}
</ul>
{% endif %}
</p>
</div>
{% endblock %}
\ No newline at end of file
widget_alipins/forum/templates/forum/index.html
0 → 100644
View file @
a29cbfc6
{% extends 'base.html' %}
{% load static %}
{% block styles %}
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'forum/style.css' %}"
>
{% endblock %}
{% block title %}Welcome to Widget's Forum{% endblock %}
{% block content %}
<h1>
Forum
</h1>
<div>
<h2>
Forum posts:
</h2>
{% if posts %}
<ul>
{% for post in posts %}
<li><a
href=
"{% url 'forum:details' post.id%}"
>
{{post.post_title}}
</a>
by {{post.author.first_name}} {{post.author.last_name}} dated {{post.pub_date|date:"d/m/Y"}}
</li>
{% endfor %}
</ul>
{% else %}
<p>
There is no post.
</p>
{% endif %}
</div>
{% endblock %}
\ No newline at end of file
widget_alipins/forum/urls.py
View file @
a29cbfc6
from
django.urls
import
path
from
.
import
views
app_name
=
"forum"
urlpatterns
=
[
path
(
''
,
views
.
index
,
name
=
"indexForum"
)
path
(
''
,
views
.
index
,
name
=
"indexForum"
),
path
(
'<int:post_id>/details'
,
views
.
details
,
name
=
"details"
)
]
widget_alipins/forum/views.py
View file @
a29cbfc6
from
django.http
import
Http
Response
from
django.http
import
Http
404
from
.models
import
Post
,
Reply
from
django.shortcuts
import
render
# Create your views here.
def
index
(
request
):
display_output
=
"<u><b>FORUM POSTS</u></b>:<br>"
posts
=
Post
.
objects
.
order_by
(
"-pub_date"
)
context
=
{
"posts"
:
posts
}
return
render
(
request
,
"forum/index.html"
,
context
)
for
post
in
Post
.
objects
.
all
():
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 = "<u><b>FORUM POSTS</u></b>:<br>"
# for post in Post.objects.all():
# 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>"
# display_output += "<br><br>"
# return HttpResponse(display_output)
return
HttpResponse
(
display_output
)
\ No newline at end of file
def
details
(
request
,
post_id
):
try
:
post
=
Post
.
objects
.
get
(
pk
=
post_id
)
replies
=
Reply
.
objects
.
filter
(
post
=
post
)
.
order_by
(
"-pub_date"
)
except
Post
.
DoesNotExist
:
raise
Http404
(
"Announcement does not exist!"
)
context
=
{
"post"
:
post
,
"replies"
:
replies
}
return
render
(
request
,
"forum/detail.html"
,
context
)
\ No newline at end of file
widget_alipins/media/forum/laundry.jpg
0 → 100644
View file @
a29cbfc6
29.7 KB
widget_alipins/media/forum/member.jpg
0 → 100644
View file @
a29cbfc6
10.1 KB
widget_alipins/media/forum/query.png
0 → 100644
View file @
a29cbfc6
18.4 KB
widget_alipins/static/forum/style.css
0 → 100644
View file @
a29cbfc6
body
{
font-family
:
sans-serif
,
Arial
,
Helvetica
;
color
:
#035700
;
line-height
:
2
;
}
div
{
margin
:
auto
;
width
:
50%
;
border
:
3px
solid
rgb
(
194
,
7
,
169
);
padding
:
30px
40px
40px
40px
;
}
h1
{
font-size
:
40px
;
text-align
:
center
;
text-decoration
:
underline
;
}
h2
{
font-size
:
28px
;
margin
:
0px
0px
10px
0px
;
text-align
:
center
;
}
li
{
font-size
:
20px
;
}
p
{
font-size
:
20px
;
}
span
{
font-weight
:
bold
;
}
span
.perfect
{
color
:
rgb
(
96
,
189
,
96
);
}
span
.passing
{
color
:
#bb5959
}
img
{
max-width
:
100%
;
height
:
auto
;
}
a
{
color
:
#891fa3
;
}
\ 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