Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_nicsbabes
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
Nics De Vega
midterm_nicsbabes
Commits
fe45b7c1
Commit
fe45b7c1
authored
May 11, 2023
by
Tanya Yotoko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified forum templates and models.py
parent
7ee9735c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
101 additions
and
7 deletions
+101
-7
0002_alter_forumpost_pub_datetime_alter_reply_forum_post.py
...02_alter_forumpost_pub_datetime_alter_reply_forum_post.py
+25
-0
models.py
widget_nicsbabes/forum/models.py
+1
-1
forum.html
widget_nicsbabes/forum/templates/forum/forum.html
+27
-0
forumpost-add.html
widget_nicsbabes/forum/templates/forum/forumpost-add.html
+11
-0
forumpost-details.html
...et_nicsbabes/forum/templates/forum/forumpost-details.html
+24
-0
forumpost-edit.html
widget_nicsbabes/forum/templates/forum/forumpost-edit.html
+11
-0
urls.py
widget_nicsbabes/forum/urls.py
+1
-3
views.py
widget_nicsbabes/forum/views.py
+1
-3
No files found.
widget_nicsbabes/forum/migrations/0002_alter_forumpost_pub_datetime_alter_reply_forum_post.py
0 → 100644
View file @
fe45b7c1
# Generated by Django 4.1.7 on 2023-05-10 11:51
from
django.db
import
migrations
,
models
import
django.db.models.deletion
import
django.utils.timezone
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'forum'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'forumpost'
,
name
=
'pub_datetime'
,
field
=
models
.
DateTimeField
(
default
=
django
.
utils
.
timezone
.
now
),
),
migrations
.
AlterField
(
model_name
=
'reply'
,
name
=
'forum_post'
,
field
=
models
.
ForeignKey
(
default
=
''
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'forum_reply'
,
to
=
'forum.forumpost'
),
),
]
widget_nicsbabes/forum/models.py
View file @
fe45b7c1
...
...
@@ -19,7 +19,7 @@ class Reply(models.Model):
body
=
models
.
TextField
(
default
=
""
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
pub_datetime
=
models
.
DateTimeField
()
forum_post
=
models
.
ForeignKey
(
ForumPost
,
on_delete
=
models
.
CASCADE
,
default
=
""
)
forum_post
=
models
.
ForeignKey
(
ForumPost
,
on_delete
=
models
.
CASCADE
,
default
=
""
,
related_name
=
'forum_reply'
)
def
__str__
(
self
):
return
'{}'
.
format
(
self
.
body
)
\ No newline at end of file
widget_nicsbabes/forum/templates/forum/forum.html
View file @
fe45b7c1
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Forum{% endblock %}
{% block content %}
<h1>
Welcome to Widget's Forum
</h1>
<h2>
Forum posts:
</h2>
<h3>
{% for object in forum %}
<a
href=
"{{ object.get_absolute_url }}"
>
{{object.title}} by {{object.author.first_name}} {{object.author.last_name}}
</a>
<br>
{% endfor %}
</h3>
<br>
<form
action=
"forumposts/add"
>
<input
type=
"submit"
value=
"Add Post"
>
</form>
<h3>
<a
href=
"../dashboard/"
>
Dashboard
</a>
<br>
<a
href=
"../announcements/"
>
Announcements
</a>
<br>
<a
href=
"../assignments/"
>
Assignments
</a>
<br>
<a
href=
"../calendar/"
>
Calendar
</a>
</h3>
{% endblock %}
\ No newline at end of file
widget_nicsbabes/forum/templates/forum/forumpost-add.html
View file @
fe45b7c1
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Post{% endblock %}
{% block content %}
<h1>
Add a New Post:
</h1>
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save New Post"
>
</form>
{% endblock %}
\ No newline at end of file
widget_nicsbabes/forum/templates/forum/forumpost-details.html
View file @
fe45b7c1
{% extends 'base.html' %}
{% load static %}
{% block title %}{{object.title}}{% endblock %}
{% block content %}
<h1>
{{object.title}}
</h1>
<h3>
by {{object.author.first_name}} {{object.author.last_name}}
</h3>
<h3>
{{object.pub_datetime|date:'m/d/Y, h:i A'}}
</h3>
<h3>
{{object.body}}
</h3>
<br>
<h2>
POST REPLIES:
</h2>
{% for reply in object.forum_reply.all %}
<h3>
by {{reply.author.first_name}} {{reply.author.last_name}}
</h3>
<h3>
{{reply.pub_datetime|date:'m/d/Y, h:i A'}}
</h3>
<h3>
{{reply.body}}
</h3>
<br>
{% endfor %}
<form
action=
"../edit/"
>
<input
type=
"submit"
value=
"Edit Post"
>
</form>
{% endblock %}
\ No newline at end of file
widget_nicsbabes/forum/templates/forum/forumpost-edit.html
View file @
fe45b7c1
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Post{% endblock %}
{% block content %}
<h1>
Edit Post
</h1>
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes to Post"
>
</form>
{% endblock %}
\ No newline at end of file
widget_nicsbabes/forum/urls.py
View file @
fe45b7c1
...
...
@@ -6,8 +6,6 @@ urlpatterns = [
path
(
'forumposts/<int:pk>/details/'
,
ForumPostDetailView
.
as_view
(),
name
=
'forumpost-details'
),
path
(
'forumposts/add/'
,
ForumPostCreateView
.
as_view
(),
name
=
'forumpost-add'
),
path
(
'forumposts/<int:pk>/edit/'
,
ForumPostUpdateView
.
as_view
(),
name
=
'forumpost-edit'
),
]
app_name
=
"forum"
app_name
=
"forum"
\ No newline at end of file
widget_nicsbabes/forum/views.py
View file @
fe45b7c1
...
...
@@ -20,6 +20,4 @@ class ForumPostCreateView(CreateView):
class
ForumPostUpdateView
(
UpdateView
):
model
=
ForumPost
fields
=
[
'title'
,
'body'
,
'author'
]
template_name
=
'forum/forumpost-edit.html'
template_name
=
'forum/forumpost-edit.html'
\ 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