Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_casanatics
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
John Aidan Vincent M. Ng
midterm_casanatics
Commits
2b522e43
Commit
2b522e43
authored
May 06, 2023
by
Javi Ng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed reverse_url error, added comments to all relevant files
parent
28ff3b64
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
60 additions
and
29 deletions
+60
-29
models.cpython-310.pyc
...ics/announcement_board/__pycache__/models.cpython-310.pyc
+0
-0
urls.cpython-310.pyc
...atics/announcement_board/__pycache__/urls.cpython-310.pyc
+0
-0
views.cpython-310.pyc
...tics/announcement_board/__pycache__/views.cpython-310.pyc
+0
-0
models.py
widget_casanatics/announcement_board/models.py
+2
-1
announcement-add.html
..._board/templates/announcement_board/announcement-add.html
+3
-0
announcement-details.html
...rd/templates/announcement_board/announcement-details.html
+23
-13
announcement-edit.html
...board/templates/announcement_board/announcement-edit.html
+3
-0
announcements.html
...ent_board/templates/announcement_board/announcements.html
+21
-14
urls.py
widget_casanatics/announcement_board/urls.py
+7
-0
views.py
widget_casanatics/announcement_board/views.py
+1
-1
No files found.
widget_casanatics/announcement_board/__pycache__/models.cpython-310.pyc
View file @
2b522e43
No preview for this file type
widget_casanatics/announcement_board/__pycache__/urls.cpython-310.pyc
View file @
2b522e43
No preview for this file type
widget_casanatics/announcement_board/__pycache__/views.cpython-310.pyc
View file @
2b522e43
No preview for this file type
widget_casanatics/announcement_board/models.py
View file @
2b522e43
...
@@ -15,8 +15,9 @@ class Announcement(models.Model):
...
@@ -15,8 +15,9 @@ class Announcement(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
title
return
self
.
title
# get corresponding detail page
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
reverse
(
'announcement_board:announcement-details'
,
kwargs
=
{
'pk'
:
self
.
pk
}
)
return
(
reverse
(
'announcement_board:announcementdetail'
,
kwargs
=
{
'pk'
:
self
.
pk
})
)
class
Reaction
(
models
.
Model
):
class
Reaction
(
models
.
Model
):
...
...
widget_casanatics/announcement_board/templates/announcement_board/announcement-add.html
View file @
2b522e43
...
@@ -2,12 +2,15 @@
...
@@ -2,12 +2,15 @@
{% load static %}
{% load static %}
{% block title %} Add Announcement {% endblock %}
{% block title %} Add Announcement {% endblock %}
{% block content %}
{% block content %}
<h1>
Add a new announcement:
</h1>
<h1>
Add a new announcement:
</h1>
<form
method=
"POST"
>
<form
method=
"POST"
>
{% csrf_token %}
{% csrf_token %}
{# iterate through fields in the form #}
{% for field in form%}
{% for field in form%}
<b>
{{ field.label }}:
</b>
{{ field }}
<br><br>
<b>
{{ field.label }}:
</b>
{{ field }}
<br><br>
{% endfor %}
{% endfor %}
...
...
widget_casanatics/announcement_board/templates/announcement_board/announcement-details.html
View file @
2b522e43
...
@@ -2,19 +2,29 @@
...
@@ -2,19 +2,29 @@
{% load static %}
{% load static %}
{% block title %} {{ object.title }} {% endblock %}
{% block title %} {{ object.title }} {% endblock %}
{% block content %}
{% block content %}
<h1>
{{ object.title }}
</h1>
{# announcement title #}
<h2>
{{ object.author.displayName }}
</h2>
<h1>
{{ object.title }}
</h1>
<h3>
{{ object.pub_datetime|date:"m/d/Y, h:i A" }}
</h3>
<p>
{{ object.body }}
</p>
<br>
{# announcement author using displayName method in model #}
Reactions:
<h2>
by {{ object.author.displayName }}
</h2>
<ul>
{# format datetime with tags #}
<h3>
{{ object.pub_datetime|date:"m/d/Y, h:i A" }}
</h3>
{# announcement body #}
<p>
{{ object.body }}
</p>
<br>
{# iterate through reactions, show name: tally #}
Reactions:
<ul>
{% for reaction in object.reactlist.all %}
{% for reaction in object.reactlist.all %}
<li>
{{ reaction.name}}:
{{ reaction.tally }}
</li>
<li>
<b>
{{ reaction.name}}:
</b>
{{ reaction.tally }}
</li>
{% endfor %}
{% endfor %}
</ul>
</ul>
<form
action=
"../edit"
>
<form
action=
"../edit"
>
<button
type=
"Submit"
>
Edit Announcement
</button>
<button
type=
"Submit"
>
Edit Announcement
</button>
</form>
</form>
{% endblock %}
{% endblock %}
\ No newline at end of file
widget_casanatics/announcement_board/templates/announcement_board/announcement-edit.html
View file @
2b522e43
...
@@ -2,12 +2,15 @@
...
@@ -2,12 +2,15 @@
{% load static %}
{% load static %}
{% block title %} Edit Announcement {% endblock %}
{% block title %} Edit Announcement {% endblock %}
{% block content %}
{% block content %}
<h1>
Edit announcement:
</h1>
<h1>
Edit announcement:
</h1>
<form
method=
"POST"
>
<form
method=
"POST"
>
{% csrf_token %}
{% csrf_token %}
{# iterate through fields #}
{% for field in form%}
{% for field in form%}
<b>
{{ field.label }}:
</b>
{{ field }}
<br><br>
<b>
{{ field.label }}:
</b>
{{ field }}
<br><br>
{% endfor %}
{% endfor %}
...
...
widget_casanatics/announcement_board/templates/announcement_board/announcements.html
View file @
2b522e43
...
@@ -2,22 +2,29 @@
...
@@ -2,22 +2,29 @@
{% load static %}
{% load static %}
{% block title %} Widget's Announcement Board {% endblock %}
{% block title %} Widget's Announcement Board {% endblock %}
{% block content %}
{% block content %}
<h1>
Welcome to Widget's Announcement Board!
</h1>
<h2>
Announcements:
</h2>
<h1>
Welcome to Widget's Announcement Board!
</h1>
<ul>
<h2>
Announcements:
</h2>
{# iterate through announcement_list from context, use get url function to link to detail page #}
<ul>
{% for announcement in announcement_list %}
{% for announcement in announcement_list %}
<li><a
href=
"{{ announcement.get_absolute_url }}"
>
{{ announcement.title }} by {{ announcement.author.displayName }}
</a></li>
<li><a
href=
"{{ announcement.get_absolute_url }}"
>
{{ announcement.title }} by {{ announcement.author.displayName }}
</a></li>
{% endfor %}
{% endfor %}
</ul>
</ul>
<form
action=
"./add"
>
<br>
<form
action=
"./add"
>
<button
type=
"Submit"
>
New Announcement
</button>
<button
type=
"Submit"
>
New Announcement
</button>
</form>
</form>
<br>
<a
href=
"../dashboard/"
>
Dashboard
</a>
<br>
<a
href=
"../dashboard/"
>
Dashboard
</a>
<br>
<a
href=
"../forum/"
>
Forum
</a>
<br>
<a
href=
"../forum/"
>
Forum
</a>
<br>
<a
href=
"../assignments/"
>
Assignments
</a>
<br>
<a
href=
"../assignments/"
>
Assignments
</a>
<br>
<a
href=
"../calendar/"
>
Calendar
</a>
<br>
<a
href=
"../calendar/"
>
Calendar
</a>
<br>
{% endblock %}
{% endblock %}
\ No newline at end of file
widget_casanatics/announcement_board/urls.py
View file @
2b522e43
...
@@ -2,9 +2,16 @@ from django.urls import path
...
@@ -2,9 +2,16 @@ from django.urls import path
from
.
import
views
from
.
import
views
urlpatterns
=
[
urlpatterns
=
[
# main page listing announcements
path
(
""
,
views
.
announcements
,
name
=
"announcements"
),
path
(
""
,
views
.
announcements
,
name
=
"announcements"
),
# detail page for each announcement
path
(
"<int:pk>/details/"
,
views
.
AnnouncementDetailView
.
as_view
(),
name
=
"announcementdetail"
),
path
(
"<int:pk>/details/"
,
views
.
AnnouncementDetailView
.
as_view
(),
name
=
"announcementdetail"
),
# create page
path
(
"add/"
,
views
.
AnnouncementCreateView
.
as_view
(),
name
=
"announcementadd"
),
path
(
"add/"
,
views
.
AnnouncementCreateView
.
as_view
(),
name
=
"announcementadd"
),
# edit page for each announcement
path
(
"<int:pk>/edit/"
,
views
.
AnnouncementUpdateView
.
as_view
(),
name
=
"announcementupdate"
),
path
(
"<int:pk>/edit/"
,
views
.
AnnouncementUpdateView
.
as_view
(),
name
=
"announcementupdate"
),
]
]
...
...
widget_casanatics/announcement_board/views.py
View file @
2b522e43
...
@@ -10,7 +10,7 @@ def announcements(request):
...
@@ -10,7 +10,7 @@ def announcements(request):
# use context to pass announcements sorted by pubdate
# use context to pass announcements sorted by pubdate
context
=
{
context
=
{
"announcement_list"
:
Announcement
.
objects
.
all
()
.
order_by
(
'pub_datetime'
),
"announcement_list"
:
Announcement
.
objects
.
all
()
.
order_by
(
'
-
pub_datetime'
),
}
}
return
render
(
request
,
'announcement_board/announcements.html'
,
context
)
return
render
(
request
,
'announcement_board/announcements.html'
,
context
)
...
...
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