Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_placeholdername
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
Rajo Christian Cadorna
widget_placeholdername
Commits
2c12061b
Commit
2c12061b
authored
May 25, 2022
by
Eugene Ezekiel P. Tan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Tan/Forum' & pyc conflicts
parents
13f71a47
4d3f3e72
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
94 additions
and
7 deletions
+94
-7
forms.cpython-39.pyc
Forum/__pycache__/forms.cpython-39.pyc
+0
-0
forms.py
Forum/forms.py
+7
-0
0005_alter_post_pub_date.py
Forum/migrations/0005_alter_post_pub_date.py
+18
-0
0006_alter_post_post_imageurl.py
Forum/migrations/0006_alter_post_post_imageurl.py
+18
-0
0005_alter_post_pub_date.cpython-39.pyc
...tions/__pycache__/0005_alter_post_pub_date.cpython-39.pyc
+0
-0
0005_remove_post_post_imageurl.cpython-39.pyc
...__pycache__/0005_remove_post_post_imageurl.cpython-39.pyc
+0
-0
0006_alter_post_post_imageurl.cpython-39.pyc
.../__pycache__/0006_alter_post_post_imageurl.cpython-39.pyc
+0
-0
0006_post_post_imageurl.cpython-39.pyc
...ations/__pycache__/0006_post_post_imageurl.cpython-39.pyc
+0
-0
models.py
Forum/models.py
+2
-2
addPost.html
Forum/templates/Forum/addPost.html
+13
-0
post.html
Forum/templates/Forum/post.html
+6
-0
view.html
Forum/templates/Forum/view.html
+7
-2
urls.py
Forum/urls.py
+6
-1
views.py
Forum/views.py
+17
-2
No files found.
Forum/__pycache__/forms.cpython-39.pyc
0 → 100644
View file @
2c12061b
File added
Forum/forms.py
0 → 100644
View file @
2c12061b
from
django.forms
import
ModelForm
from
.models
import
Post
class
PostForm
(
ModelForm
):
class
Meta
:
model
=
Post
fields
=
[
"post_title"
,
"post_body"
,
"post_author"
,
"post_imageUrl"
]
\ No newline at end of file
Forum/migrations/0005_alter_post_pub_date.py
0 → 100644
View file @
2c12061b
# Generated by Django 4.0.3 on 2022-05-25 08:35
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'Forum'
,
'0004_reply_reply_post'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'post'
,
name
=
'pub_date'
,
field
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'date published'
),
),
]
Forum/migrations/0006_alter_post_post_imageurl.py
0 → 100644
View file @
2c12061b
# Generated by Django 4.0.3 on 2022-05-25 08:38
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'Forum'
,
'0005_alter_post_pub_date'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'post'
,
name
=
'post_imageUrl'
,
field
=
models
.
CharField
(
max_length
=
999
,
null
=
True
),
),
]
Forum/migrations/__pycache__/0005_alter_post_pub_date.cpython-39.pyc
0 → 100644
View file @
2c12061b
File added
Forum/migrations/__pycache__/0005_remove_post_post_imageurl.cpython-39.pyc
0 → 100644
View file @
2c12061b
File added
Forum/migrations/__pycache__/0006_alter_post_post_imageurl.cpython-39.pyc
0 → 100644
View file @
2c12061b
File added
Forum/migrations/__pycache__/0006_post_post_imageurl.cpython-39.pyc
0 → 100644
View file @
2c12061b
File added
Forum/models.py
View file @
2c12061b
...
@@ -5,9 +5,9 @@ from homepage.models import WidgetUser
...
@@ -5,9 +5,9 @@ from homepage.models import WidgetUser
class
Post
(
models
.
Model
):
class
Post
(
models
.
Model
):
post_title
=
models
.
CharField
(
max_length
=
50
)
post_title
=
models
.
CharField
(
max_length
=
50
)
post_body
=
models
.
CharField
(
max_length
=
500
)
post_body
=
models
.
CharField
(
max_length
=
500
)
pub_date
=
models
.
DateTimeField
(
"date published"
)
pub_date
=
models
.
DateTimeField
(
"date published"
,
auto_now_add
=
True
)
post_author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
default
=
1
)
post_author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
default
=
1
)
post_imageUrl
=
models
.
CharField
(
max_length
=
999
,
default
=
1
)
post_imageUrl
=
models
.
CharField
(
max_length
=
999
,
null
=
True
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
post_title
return
self
.
post_title
...
...
Forum/templates/Forum/addPost.html
0 → 100644
View file @
2c12061b
{% extends "Forum/base.html" %}
{% block content %}
<h1>
Contribute a new post to the Epic Gamer Forums
</h1>
<form
action=
"{% url 'Forum:index' %}"
>
<button
type=
"submit"
>
Go Back
</button>
</form>
<form
method=
"POST"
action=
"{% url 'Forum:addPost' %}"
>
{% csrf_token %}
{{post_Form.as_p}}
<button
class=
"button"
type=
"submit"
>
Submit Post
</button>
</form>
{% endblock %}
\ No newline at end of file
Forum/templates/Forum/post.html
View file @
2c12061b
...
@@ -2,6 +2,10 @@
...
@@ -2,6 +2,10 @@
{% block content %}
{% block content %}
<form
action=
"{% url 'Forum:index' %}"
>
<button
type=
"submit"
>
Go Back
</button>
</form>
<h1>
{{post.post_title}}
</h1>
<h1>
{{post.post_title}}
</h1>
<h4>
{{post.post_author.first_name}} {{post.post_author.last_name}}, {{post.pub_date.day}}/{{post.pub_date.month}}/{{post.pub_date.year}}
</h4>
<h4>
{{post.post_author.first_name}} {{post.post_author.last_name}}, {{post.pub_date.day}}/{{post.pub_date.month}}/{{post.pub_date.year}}
</h4>
...
@@ -9,6 +13,7 @@
...
@@ -9,6 +13,7 @@
<img
src=
{{post.post_imageUrl}}
>
<img
src=
{{post.post_imageUrl}}
>
<ul>
<ul>
<h4>
Replies:
</h4>
{% for reply in reply_list %}
{% for reply in reply_list %}
{% if reply.reply_post.post_title == post.post_title %}
{% if reply.reply_post.post_title == post.post_title %}
...
@@ -21,4 +26,5 @@
...
@@ -21,4 +26,5 @@
{% endfor %}
{% endfor %}
</ul>
</ul>
{% endblock %}
{% endblock %}
\ No newline at end of file
Forum/templates/Forum/view.html
View file @
2c12061b
{% extends "Forum/base.html" %}
{% extends "Forum/base.html" %}
{% block content %}
{% block content %}
<h1>
Welcome to the Widget's Forum!
</h1>
<h1>
Welcome to the Epic Gamers Forum!
</h1>
{% if post_list %}
{% if post_list %}
<ul>
<ul>
{% for post in post_list %}
{% for post in post_list %}
<h3><li><a
href =
"{% url 'post' post.id %}"
>
{{post.post_title}}
</a>
<h3><li><a
href =
"{% url '
Forum:
post' post.id %}"
>
{{post.post_title}}
</a>
</br>
by {{post.post_author.first_name}} {{post.post_author.last_name}} dated {{post.pub_date.day}}/{{post.pub_date.month}}/{{post.pub_date.year}}
</li></h3>
</br>
by {{post.post_author.first_name}} {{post.post_author.last_name}} dated {{post.pub_date.day}}/{{post.pub_date.month}}/{{post.pub_date.year}}
</li></h3>
{% endfor %}
{% endfor %}
</ul>
</ul>
...
@@ -13,4 +14,8 @@
...
@@ -13,4 +14,8 @@
<p>
No posts available.
</p>
<p>
No posts available.
</p>
{% endif %}
{% endif %}
<form
action=
"{% url 'Forum:addPost' %}"
>
<button
type=
"submit"
>
New Forum Post
</button>
</form>
{% endblock %}
{% endblock %}
\ No newline at end of file
Forum/urls.py
View file @
2c12061b
...
@@ -2,7 +2,12 @@ from django.urls import path
...
@@ -2,7 +2,12 @@ from django.urls import path
from
.
import
views
from
.
import
views
app_name
=
"Forum"
urlpatterns
=
[
urlpatterns
=
[
#forum home page
path
(
''
,
views
.
index
,
name
=
'index'
),
path
(
''
,
views
.
index
,
name
=
'index'
),
path
(
"<int:post_id>/details/"
,
views
.
posts
,
name
=
'post'
)
#forum posts
path
(
"<int:post_id>/details/"
,
views
.
posts
,
name
=
'post'
),
#making new forum posts
path
(
"posts/add/"
,
views
.
newPost
,
name
=
'addPost'
)
]
]
Forum/views.py
View file @
2c12061b
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
import
Forum
from
.forms
import
PostForm
from
.
models
import
Post
,
Reply
from
.
models
import
Post
,
Reply
from
homepage.models
import
WidgetUser
from
homepage.models
import
WidgetUser
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
def
index
(
request
):
def
index
(
request
):
Posts
=
Post
.
objects
.
all
()
Posts
=
Post
.
objects
.
all
()
...
@@ -22,3 +24,16 @@ def posts(request, post_id):
...
@@ -22,3 +24,16 @@ def posts(request, post_id):
raise
Http404
(
"post doesnt exist"
)
raise
Http404
(
"post doesnt exist"
)
return
render
(
request
,
"Forum/post.html"
,{
"post"
:
post
,
'reply_list'
:
reply_list
})
return
render
(
request
,
"Forum/post.html"
,{
"post"
:
post
,
'reply_list'
:
reply_list
})
def
newPost
(
request
):
post_Form
=
PostForm
()
if
request
.
method
==
"POST"
:
post_Form
=
PostForm
(
request
.
POST
)
if
post_Form
.
is_valid
():
post_Form
.
save
()
return
redirect
(
"Forum:addPost"
)
else
:
post_Form
=
PostForm
()
return
render
(
request
,
"Forum/addPost.html"
,
{
"post_Form"
:
post_Form
})
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