Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_gitgud
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
Neal Luigi D. Rodriguez
midterm_gitgud
Commits
ec031afe
Commit
ec031afe
authored
May 12, 2023
by
Eury See
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created Add New Forum Post Page for the Forum application.
parent
ae66f7b7
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
2 deletions
+70
-2
0005_alter_forumpost_pub_datetime_alter_reply_author.py
...s/0005_alter_forumpost_pub_datetime_alter_reply_author.py
+25
-0
models.py
widget_gitgud/Forum/models.py
+4
-1
forumpost-add.html
widget_gitgud/Forum/templates/forumpost-add.html
+26
-0
urls.py
widget_gitgud/Forum/urls.py
+3
-1
views.py
widget_gitgud/Forum/views.py
+12
-0
db.sqlite3
widget_gitgud/db.sqlite3
+0
-0
No files found.
widget_gitgud/Forum/migrations/0005_alter_forumpost_pub_datetime_alter_reply_author.py
0 → 100644
View file @
ec031afe
# Generated by Django 4.1.7 on 2023-05-12 17:16
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'Dashboard'
,
'0002_alter_widgetuser_department'
),
(
'Forum'
,
'0004_forumpost_replies'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'forumpost'
,
name
=
'pub_datetime'
,
field
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
),
),
migrations
.
AlterField
(
model_name
=
'reply'
,
name
=
'author'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
PROTECT
,
related_name
=
'replies'
,
to
=
'Dashboard.widgetuser'
),
),
]
widget_gitgud/Forum/models.py
View file @
ec031afe
...
...
@@ -6,11 +6,14 @@ class ForumPost(models.Model):
title
=
models
.
CharField
(
max_length
=
100
)
body
=
models
.
TextField
()
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
PROTECT
)
pub_datetime
=
models
.
DateTimeField
()
pub_datetime
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
)
def
__str__
(
self
):
return
self
.
title
def
get_absolute_url
(
self
):
return
reverse
(
'Forum:forumpost-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
replies
=
models
.
ManyToManyField
(
'self'
,
blank
=
True
)
class
Reply
(
models
.
Model
):
...
...
widget_gitgud/Forum/templates/forumpost-add.html
0 → 100644
View file @
ec031afe
<title>
{% block title %} Add Post {% endblock %}
</title>
{% block styles %}
<style>
body
{
background-color
:
#FEA8A5
;
font-family
:
Georgia
,
serif
;
font-size
:
16px
;
font-weight
:
bold
;
color
:
#c35c5a
;
}
</style>
{% endblock %}
{% block content %}
<div
style=
"text-align: left;"
>
<h1>
Add a new post:
</h1>
</div>
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<button
type=
"submit"
>
Save New Post
</button>
</form>
{% endblock %}
\ No newline at end of file
widget_gitgud/Forum/urls.py
View file @
ec031afe
from
django.urls
import
path
from
.views
import
(
index
,
forum
,
ForumDetailView
)
index
,
forum
,
ForumDetailView
,
AddForumPostView
)
from
.
import
views
urlpatterns
=
[
path
(
""
,
views
.
index
,
name
=
"index"
),
path
(
'forum/'
,
forum
,
name
=
'forum'
),
path
(
'forum/forumposts/<int:pk>/details/'
,
ForumDetailView
.
as_view
(),
name
=
'forumpost-details'
),
path
(
'forum/forumposts/add/'
,
AddForumPostView
.
as_view
(),
name
=
'forumpost-add'
),
]
app_name
=
"Forum"
\ No newline at end of file
widget_gitgud/Forum/views.py
View file @
ec031afe
...
...
@@ -2,6 +2,7 @@ from django.shortcuts import render
from
django.http
import
HttpResponse
from
django.views
import
View
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
from
.models
import
ForumPost
,
Reply
...
...
@@ -30,3 +31,14 @@ class ForumDetailView(DetailView):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'replies'
]
=
self
.
object
.
replies
.
all
()
return
context
class
AddForumPostView
(
CreateView
):
model
=
ForumPost
fields
=
[
'title'
,
'body'
,
'author'
]
template_name
=
'forumpost-add.html'
class
AddForumPostView
(
CreateView
):
model
=
ForumPost
fields
=
[
'title'
,
'body'
,
'author'
]
template_name
=
'forumpost-add.html'
widget_gitgud/db.sqlite3
View file @
ec031afe
No preview for this file type
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