Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_vincentdjango
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
1
Merge Requests
1
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
Almira Redoble
midterm_vincentdjango
Commits
7cc4c2cc
Commit
7cc4c2cc
authored
Mar 04, 2023
by
Jayson Lim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented view according to the guidelines
parent
426d6222
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
6 deletions
+47
-6
models.cpython-39.pyc
...jango/announcementBoard/__pycache__/models.cpython-39.pyc
+0
-0
views.cpython-39.pyc
...django/announcementBoard/__pycache__/views.cpython-39.pyc
+0
-0
models.py
widget_vincentdjango/announcementBoard/models.py
+6
-5
views.py
widget_vincentdjango/announcementBoard/views.py
+41
-1
db.sqlite3
widget_vincentdjango/db.sqlite3
+0
-0
No files found.
widget_vincentdjango/announcementBoard/__pycache__/models.cpython-39.pyc
View file @
7cc4c2cc
No preview for this file type
widget_vincentdjango/announcementBoard/__pycache__/views.cpython-39.pyc
View file @
7cc4c2cc
No preview for this file type
widget_vincentdjango/announcementBoard/models.py
View file @
7cc4c2cc
...
...
@@ -8,18 +8,19 @@ class Announcement(models.Model):
WidgetUser
,
null
=
True
,
default
=
True
,
on_delete
=
models
.
SET_DEFAULT
on_delete
=
models
.
SET_DEFAULT
,
)
pub_datetime
=
models
.
DateTimeField
(
auto_now_add
=
True
)
def
__str__
(
self
):
return
self
.
title
def
format_pub_datetime
(
self
):
return
self
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y
%
I:
%
M
%
p'
)
class
Reaction
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
5
,
choices
=
[
(
'Like'
,
'Like'
),
(
'Love'
,
'Love'
),
(
'Angry'
,
'Angry'
)],
default
=
'Like'
)
name
=
models
.
CharField
(
max_length
=
5
,
default
=
''
)
tally
=
models
.
PositiveIntegerField
(
default
=
0
)
annoucement
=
models
.
ForeignKey
(
Announcement
,
...
...
widget_vincentdjango/announcementBoard/views.py
View file @
7cc4c2cc
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
.models
import
Announcement
from
.models
import
Reaction
def
index
(
request
):
return
HttpResponse
(
'placeholder'
)
head
=
"<h1 style='border-bottom:4px solid lightgray;
\
padding-bottom:30px;
\
font-size:450
%
;'>
\
Widget's Announcement Board
\
</h1>"
body
=
"<h2>Announcements:</h2>"
announcements
=
Announcement
.
objects
.
all
()
reactions
=
Reaction
.
objects
.
all
()
for
i
in
range
(
0
,
len
(
announcements
),
1
):
announcement
=
announcements
[
i
]
body
+=
"<p style='border: 2px solid gray;
\
border-radius:5px;
\
padding:20px 30px;'>
\
{} by {} published {}:
\
<br>
\
{}
\
</p>"
.
format
(
announcement
.
title
,
announcement
.
author
,
announcement
.
format_pub_datetime
(),
announcement
.
body
)
for
j
in
range
(
i
*
3
,
(
i
+
1
)
*
3
):
if
j
>=
len
(
reactions
):
break
reaction
=
reactions
[
j
]
body
+=
"<p>{}: {}
\
</p>"
.
format
(
reaction
.
name
,
reaction
.
tally
)
body
+=
'<p> </p>'
return_string
=
"<html>
\
<body style = 'font-family:helvetica;
\
padding:30px;'>
\
{}{}
\
</body></html>"
.
format
(
head
,
body
)
return
HttpResponse
(
return_string
)
\ No newline at end of file
widget_vincentdjango/db.sqlite3
View file @
7cc4c2cc
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