Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_robo_mommy
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Raul Jarod Conanan
midterm_robo_mommy
Commits
e92d174c
Commit
e92d174c
authored
May 13, 2023
by
Jiuvi Anne Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated templates, view, and url.
parent
0e90f3f3
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
70 additions
and
28 deletions
+70
-28
__init__.cpython-38.pyc
...o_mommy/announcements/__pycache__/__init__.cpython-38.pyc
+0
-0
apps.cpython-38.pyc
..._robo_mommy/announcements/__pycache__/apps.cpython-38.pyc
+0
-0
urls.cpython-38.pyc
..._robo_mommy/announcements/__pycache__/urls.cpython-38.pyc
+0
-0
announcement-add.html
...nouncements/templates/announcements/announcement-add.html
+7
-2
announcement-details.html
...cements/templates/announcements/announcement-details.html
+11
-1
announcement-edit.html
...ouncements/templates/announcements/announcement-edit.html
+7
-2
announcements.html
.../announcements/templates/announcements/announcements.html
+13
-6
urls.py
widget_robo_mommy/announcements/urls.py
+4
-1
views.py
widget_robo_mommy/announcements/views.py
+28
-16
__init__.cpython-38.pyc
...mmy/widget_robo_mommy/__pycache__/__init__.cpython-38.pyc
+0
-0
settings.cpython-38.pyc
...mmy/widget_robo_mommy/__pycache__/settings.cpython-38.pyc
+0
-0
urls.cpython-38.pyc
...o_mommy/widget_robo_mommy/__pycache__/urls.cpython-38.pyc
+0
-0
No files found.
widget_robo_mommy/announcements/__pycache__/__init__.cpython-38.pyc
0 → 100644
View file @
e92d174c
File added
widget_robo_mommy/announcements/__pycache__/apps.cpython-38.pyc
0 → 100644
View file @
e92d174c
File added
widget_robo_mommy/announcements/__pycache__/urls.cpython-38.pyc
0 → 100644
View file @
e92d174c
File added
widget_robo_mommy/announcements/templates/announcements/announcement-add.html
View file @
e92d174c
...
...
@@ -3,7 +3,12 @@
{% block content %}
<title>
Add Announcement
</title>
<title>
Add Announcement
</title>
<h1>
Add a new announcement:
</h1>
<form
action=
"/"
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes to Announcement"
>
</form>
{% endblock content %}
\ No newline at end of file
widget_robo_mommy/announcements/templates/announcements/announcement-details.html
View file @
e92d174c
...
...
@@ -3,7 +3,17 @@
{% block content %}
<title>
Widget's Announcement Board
</title>
<title>
{{announcement.title}}
</title>
<h1>
{{announcement.title}}
</h1><br>
<h2>
by
</h2><br>
<p>
{{ announcement.body }}
</p><br>
<p>
{% for reaction in reaction.model.all %}
{{ reaction. name }}: {{ reaction.tally }}
<br>
{% endfor %}
</p>
<a
href =
"announcements/<int:pk>/edit/"
><button
value=
""
>
Edit Announcement
</button></a>
{% endblock content %}
\ No newline at end of file
widget_robo_mommy/announcements/templates/announcements/announcement-edit.html
View file @
e92d174c
...
...
@@ -3,7 +3,12 @@
{% block content %}
<title>
Edit Announcement
</title>
<title>
Edit Announcement
</title>
<h1>
Edit announcement:
</h1>
<form
action=
"/"
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes to Announcement"
>
</form>
{% endblock content %}
\ No newline at end of file
widget_robo_mommy/announcements/templates/announcements/announcements.html
View file @
e92d174c
...
...
@@ -3,12 +3,19 @@
{% block content %}
<title>
Widget's Announcement Board
</title>
<h1>
Welcome to Widget's Announcement Board!
</h1>
<title>
Widget's Announcement Board
</title>
<h1>
Welcome to Widget's Announcement Board!
</h1>
<a
href =
"/Dashboard/"
>
Dashboard
</a><br>
<a
href =
"/forum/"
>
Forum
</a><br>
<a
href =
"/Assignments/"
>
Assignments
</a><br>
<a
href =
"/widget_Calendar/"
>
Calendar
</a>
<h3>
Announcements:
</h3>
{% for announcement in announcements %}
<a
href =
"{{announcement.pk}}/details/"
>
{{ announcement.title }} by {{ announcement.author.first_name }} {{ announcement.author.last_name }}
</a><br>
{% endfor %}
<br>
<a
href=
"announcements/add/"
><button
value=
"click here"
>
Add Announcement
</button></a>
<a
href =
"/Dashboard/"
>
Dashboard
</a><br>
<a
href =
"/forum/"
>
Forum
</a><br>
<a
href =
"/Assignments/"
>
Assignments
</a><br>
<a
href =
"/widget_Calendar/"
>
Calendar
</a>
{% endblock content %}
\ No newline at end of file
widget_robo_mommy/announcements/urls.py
View file @
e92d174c
...
...
@@ -2,7 +2,10 @@ from django.urls import path
from
.views
import
index
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
'announcements/'
,
index
,
name
=
'index'
),
path
(
'announcements/<int:pk>/details/'
,
AnnouncementDetailView
.
as_view
(),
name
=
'announcement-detail'
),
path
(
'announcements/add/'
,
AnnouncementDetailView
.
as_view
(),
name
=
'announcement-add'
),
path
(
'announcements/<int:pk>/edit/'
,
AnnouncementDetailView
.
as_view
(),
name
=
'announcement-edit'
),
]
app_name
=
"announcements"
\ No newline at end of file
widget_robo_mommy/announcements/views.py
View file @
e92d174c
...
...
@@ -6,29 +6,41 @@ from django.utils import timezone
def
convert_to_localtime
(
utctime
):
format
=
'
%
d/
%
m
/
%
Y
%
I:
%
M
%
p'
format
=
'
%
m/
%
d
/
%
Y
%
I:
%
M
%
p'
utc
=
utctime
.
replace
(
tzinfo
=
pytz
.
UTC
)
localtz
=
utc
.
astimezone
(
timezone
.
get_current_timezone
())
return
localtz
.
strftime
(
format
)
def
index
(
request
):
html_string_1
=
'<html lang="en"><head><meta charset="UTF-8"></head>
\
<b><h1>Widget
\'
s Announcement Board</h1></b>
\
<h2>Announcements:</h2><br/>'
announcement
=
Announcement
.
objects
.
all
()
.
order_by
(
'-pub_datetime'
)
context
=
{
'announcement'
:
announcement
}
html_string_2
=
""
for
announced
in
Announcement
.
objects
.
all
():
html_string_2
+=
"{} by {} {} published {}:<br />
\
{}<br/>"
.
format
(
announced
.
title
,
announced
.
author
.
first_name
,
announced
.
author
.
last_name
,
convert_to_localtime
(
announced
.
pub_datetime
),
announced
.
body
)
for
reacts
in
announced
.
reaction_set
.
all
():
html_string_2
+=
"{}: {}<br/>"
.
format
(
reacts
.
name
,
reacts
.
tally
)
html_string_2
+=
'<br/>'
html_string_final
=
html_string_1
+
html_string_2
+
"</html>"
return
render
(
request
,
'announcements/announcements.html'
,
context
)
class
AnnouncementDetailView
(
DetailView
)
model
=
Announcement
template_name
=
'announcements/announcement-detail.html'
queryset
=
Annoucement
.
objects
.
all
()
context_object_name
=
'annoucement-details'
class
AnnouncementAddView
(
CreateView
)
model
=
Announcement
fields
=
'__all__'
template_name
=
'announcement-add.html'
return
HttpResponse
(
html_string_final
)
def
get_success_url
(
self
):
return
reverse
(
'announcement:announcementdetailview'
,
kwargs
=
{
'pk'
:
self
.
object
.
id
},
current_app
=
self
.
request
.
resolver_match
.
namespace
)
class
AnnouncementEditView
(
UpdateView
)
model
=
Announcement
template_name
=
'announcements/announcement-edit'
def
get_success_url
(
self
):
return
reverse
(
'announcement:announcementdetailview'
,
kwargs
=
{
'pk'
:
self
.
object
.
id
},
current_app
=
self
.
request
.
resolver_match
.
namespace
)
# Create your views here.
widget_robo_mommy/widget_robo_mommy/__pycache__/__init__.cpython-38.pyc
0 → 100644
View file @
e92d174c
File added
widget_robo_mommy/widget_robo_mommy/__pycache__/settings.cpython-38.pyc
0 → 100644
View file @
e92d174c
File added
widget_robo_mommy/widget_robo_mommy/__pycache__/urls.cpython-38.pyc
0 → 100644
View file @
e92d174c
File added
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