Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_tee jays angelos
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
Ramon Angelo Enriquez
widget_tee jays angelos
Commits
0347c901
Commit
0347c901
authored
May 24, 2022
by
Ryan Angelo G. Lim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added feature on forum app that allows a user to create a new post.
parent
cec79492
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
55 additions
and
36 deletions
+55
-36
db.sqlite3
widget_tee_jays_angelos/db.sqlite3
+0
-0
forms.py
widget_tee_jays_angelos/forum/forms.py
+8
-0
0008_post_post_img.py
...t_tee_jays_angelos/forum/migrations/0008_post_post_img.py
+18
-0
models.py
widget_tee_jays_angelos/forum/models.py
+1
-0
Bee Movie.jpg
widget_tee_jays_angelos/forum/static/forum/Bee Movie.jpg
+0
-0
Enriquez.jpg
widget_tee_jays_angelos/forum/static/forum/Enriquez.jpg
+0
-0
Lim.jpg
widget_tee_jays_angelos/forum/static/forum/Lim.jpg
+0
-0
Sumawang.jpg
widget_tee_jays_angelos/forum/static/forum/Sumawang.jpg
+0
-0
Sy.jpg
widget_tee_jays_angelos/forum/static/forum/Sy.jpg
+0
-0
add.html
widget_tee_jays_angelos/forum/templates/forum/add.html
+11
-0
details.html
widget_tee_jays_angelos/forum/templates/forum/details.html
+2
-2
index.html
widget_tee_jays_angelos/forum/templates/forum/index.html
+1
-0
urls.py
widget_tee_jays_angelos/forum/urls.py
+2
-0
views.py
widget_tee_jays_angelos/forum/views.py
+12
-34
Bee-Movie.jpg
widget_tee_jays_angelos/static/images/forumimg/Bee-Movie.jpg
+0
-0
Goodbye.jpg
widget_tee_jays_angelos/static/images/forumimg/Goodbye.jpg
+0
-0
Hello.jpg
widget_tee_jays_angelos/static/images/forumimg/Hello.jpg
+0
-0
test-image.jpg
...et_tee_jays_angelos/static/images/forumimg/test-image.jpg
+0
-0
test-image_ReaqfRW.jpg
...ays_angelos/static/images/forumimg/test-image_ReaqfRW.jpg
+0
-0
No files found.
widget_tee_jays_angelos/db.sqlite3
View file @
0347c901
No preview for this file type
widget_tee_jays_angelos/forum/forms.py
0 → 100644
View file @
0347c901
from
django
import
forms
from
django.forms
import
ModelForm
from
.models
import
*
class
PostForm
(
ModelForm
):
class
Meta
:
model
=
Post
fields
=
'__all__'
widget_tee_jays_angelos/forum/migrations/0008_post_post_img.py
0 → 100644
View file @
0347c901
# Generated by Django 4.0.3 on 2022-05-24 10:28
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'forum'
,
'0007_alter_post_pub_date_alter_reply_reply_pub_date'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'post'
,
name
=
'post_img'
,
field
=
models
.
ImageField
(
blank
=
True
,
null
=
True
,
upload_to
=
''
),
),
]
widget_tee_jays_angelos/forum/models.py
View file @
0347c901
...
@@ -7,6 +7,7 @@ class Post(models.Model):
...
@@ -7,6 +7,7 @@ class Post(models.Model):
post_body
=
models
.
CharField
(
max_length
=
500
)
post_body
=
models
.
CharField
(
max_length
=
500
)
pub_date
=
models
.
DateField
(
"date published"
,
auto_now_add
=
True
)
pub_date
=
models
.
DateField
(
"date published"
,
auto_now_add
=
True
)
post_author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
null
=
True
,
related_name
=
'post_author'
)
post_author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
null
=
True
,
related_name
=
'post_author'
)
post_img
=
models
.
ImageField
(
upload_to
=
"forumimg/"
,
height_field
=
None
,
width_field
=
None
,
max_length
=
100
,
null
=
True
,
blank
=
True
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
post_title
return
self
.
post_title
...
...
widget_tee_jays_angelos/forum/static/forum/Bee Movie.jpg
deleted
100644 → 0
View file @
cec79492
588 KB
widget_tee_jays_angelos/forum/static/forum/Enriquez.jpg
deleted
100644 → 0
View file @
cec79492
862 KB
widget_tee_jays_angelos/forum/static/forum/Lim.jpg
deleted
100644 → 0
View file @
cec79492
17 KB
widget_tee_jays_angelos/forum/static/forum/Sumawang.jpg
deleted
100644 → 0
View file @
cec79492
46.3 KB
widget_tee_jays_angelos/forum/static/forum/Sy.jpg
deleted
100644 → 0
View file @
cec79492
13 KB
widget_tee_jays_angelos/forum/templates/forum/add.html
0 → 100644
View file @
0347c901
{% extends "forum/base.html" %}
{% block content %}
<div
class=
"RectangularShadow"
></div>
<h1
style=
"text-align: center"
>
New Post
</h1>
<form
action=
"{% url 'forum:add' %}"
method =
"POST"
enctype=
"multipart/form-data"
>
{% csrf_token %}
{{post_form.as_p}}
<button
class=
"button"
type=
"submit"
>
Save Post
</button>
</form>
<a
href=
"/forum/"
>
<button>
Back to Forums
</button>
</a>
{% endblock %}
widget_tee_jays_angelos/forum/templates/forum/details.html
View file @
0347c901
{% extends "forum/base.html" %}
{% extends "forum/base.html" %}
{% block content %}
{% block content %}
{% if Post %}
{% if Post %}
<img
src=
"
/static/forum/{{Post.post_title}}.jpg
"
class=
"detailsRelatedPicture"
>
<img
src=
"
{{ Post.post_img.url }}
"
class=
"detailsRelatedPicture"
>
<img
src=
"
/static/forum/{{Post.post_author.last_name}}.jpg
"
class=
"detailsProfilePicture"
>
<img
src=
"
{{ Post.post_author.picture.url }}
"
class=
"detailsProfilePicture"
>
<div
class=
"RectangularShadow"
></div>
<div
class=
"RectangularShadow"
></div>
<h1
style=
"text-align: center"
>
{{Post.post_title}}
</h1>
<h1
style=
"text-align: center"
>
{{Post.post_title}}
</h1>
<h2>
by {{Post.post_author.first_name}} {{Post.post_author.last_name}}, {{Post.pub_date}}
</h2>
<h2>
by {{Post.post_author.first_name}} {{Post.post_author.last_name}}, {{Post.pub_date}}
</h2>
...
...
widget_tee_jays_angelos/forum/templates/forum/index.html
View file @
0347c901
...
@@ -12,4 +12,5 @@
...
@@ -12,4 +12,5 @@
{% else %}
{% else %}
<p>
No Posts are available
</p>
<p>
No Posts are available
</p>
{% endif %}
{% endif %}
<a
href=
"posts/add"
>
<button>
Create a Post
</button>
</a>
{% endblock %}
{% endblock %}
widget_tee_jays_angelos/forum/urls.py
View file @
0347c901
...
@@ -2,7 +2,9 @@ from django.urls import path
...
@@ -2,7 +2,9 @@ from django.urls import path
from
.
import
views
from
.
import
views
app_name
=
"forum"
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
views
.
index
,
name
=
"forum"
),
path
(
''
,
views
.
index
,
name
=
"forum"
),
path
(
'posts/add/'
,
views
.
add
,
name
=
"add"
),
path
(
'posts/<int:post_id>/details/'
,
views
.
details
,
name
=
"details"
),
path
(
'posts/<int:post_id>/details/'
,
views
.
details
,
name
=
"details"
),
]
]
widget_tee_jays_angelos/forum/views.py
View file @
0347c901
from
array
import
array
from
array
import
array
from
django.http
import
HttpResponse
,
Http404
from
django.http
import
HttpResponse
,
Http404
from
forum.models
import
Post
,
Reply
,
WidgetUser
from
forum.models
import
Post
,
Reply
,
WidgetUser
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
django.template
import
loader
from
django.template
import
loader
from
.forms
import
PostForm
# Create your views here.
# Create your views here.
def
index
(
request
):
def
index
(
request
):
...
@@ -12,45 +13,12 @@ def index(request):
...
@@ -12,45 +13,12 @@ def index(request):
}
}
return
render
(
request
,
"forum/index.html"
,
context
)
return
render
(
request
,
"forum/index.html"
,
context
)
#entries = Post.objects.all().count()
#n = 1
#forum = "FORUM POSTS:<br/>"
#while(n<=entries):
# forum += getPost(n)
# forum += getReply(n)
# n += 1
#return HttpResponse(forum)
#def getPost(pk):
# postFirstLine = ""
# postSecondLine = ""
# post = ""
# postTitle = Post.objects.get(pk=pk).post_title
# authorFirstName = Post.objects.get(pk=pk).post_author.first_name
# authorLastName = Post.objects.get(pk=pk).post_author.last_name
# publicationDate = Post.objects.get(pk=pk).pub_date
# postBody = Post.objects.get(pk=pk).post_body
# postFirstLine = "{} by {} {} dated {}:<br/>" .format(postTitle, authorFirstName, authorLastName, publicationDate)
# postSecondLine = "{}<br/>" .format(postBody)
# post += postFirstLine + postSecondLine
# return post
def
getReply
(
pk
):
def
getReply
(
pk
):
postReply
=
[]
postReply
=
[]
for
reply
in
Post
.
objects
.
get
(
pk
=
pk
)
.
posts
.
all
():
for
reply
in
Post
.
objects
.
get
(
pk
=
pk
)
.
posts
.
all
():
postReply
.
append
(
reply
)
postReply
.
append
(
reply
)
return
postReply
return
postReply
#replies = ""
#for reply in Post.objects.get(pk=pk).posts.all():
# replies += "Reply by {} {} {}:<br/>{}" .format(reply.reply_author.first_name, reply.reply_author.last_name, reply.reply_pub_date, reply.reply_body)
# replies += "<br/>"
#replies += "<br/>"
#return replies
def
details
(
request
,
post_id
):
def
details
(
request
,
post_id
):
try
:
try
:
post
=
Post
.
objects
.
get
(
pk
=
post_id
)
post
=
Post
.
objects
.
get
(
pk
=
post_id
)
...
@@ -65,3 +33,13 @@ def details(request, post_id):
...
@@ -65,3 +33,13 @@ def details(request, post_id):
"reply"
:
reply
"reply"
:
reply
}
}
return
render
(
request
,
"forum/details.html"
,
context
)
return
render
(
request
,
"forum/details.html"
,
context
)
def
add
(
request
):
if
request
.
method
==
"POST"
:
post_form
=
PostForm
(
request
.
POST
,
request
.
FILES
)
if
post_form
.
is_valid
():
post_form
.
save
()
return
redirect
(
"forum:add"
)
else
:
post_form
=
PostForm
()
return
render
(
request
,
"forum/add.html"
,
{
"post_form"
:
post_form
})
widget_tee_jays_angelos/static/images/forumimg/Bee-Movie.jpg
0 → 100644
View file @
0347c901
201 KB
widget_tee_jays_angelos/
forum/static/forum
/Goodbye.jpg
→
widget_tee_jays_angelos/
static/images/forumimg
/Goodbye.jpg
View file @
0347c901
File moved
widget_tee_jays_angelos/
forum/static/forum
/Hello.jpg
→
widget_tee_jays_angelos/
static/images/forumimg
/Hello.jpg
View file @
0347c901
File moved
widget_tee_jays_angelos/static/images/forumimg/test-image.jpg
0 → 100644
View file @
0347c901
3.71 KB
widget_tee_jays_angelos/static/images/forumimg/test-image_ReaqfRW.jpg
0 → 100644
View file @
0347c901
3.71 KB
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