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
bbab1cb3
Commit
bbab1cb3
authored
Mar 05, 2023
by
Jayson Lim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated model class and its attributes, also updated the implementation of view
parent
7cc4c2cc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
20 deletions
+18
-20
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
+10
-5
views.py
widget_vincentdjango/announcementBoard/views.py
+8
-15
db.sqlite3
widget_vincentdjango/db.sqlite3
+0
-0
No files found.
widget_vincentdjango/announcementBoard/__pycache__/models.cpython-39.pyc
View file @
bbab1cb3
No preview for this file type
widget_vincentdjango/announcementBoard/__pycache__/views.cpython-39.pyc
View file @
bbab1cb3
No preview for this file type
widget_vincentdjango/announcementBoard/models.py
View file @
bbab1cb3
from
django.db
import
models
from
dashboard.models
import
WidgetUser
class
Announcement
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
250
,
default
=
""
)
body
=
models
.
TextField
(
null
=
True
,
blank
=
True
)
...
...
@@ -8,9 +9,9 @@ class Announcement(models.Model):
WidgetUser
,
null
=
True
,
default
=
True
,
on_delete
=
models
.
SET_DEFAULT
,
on_delete
=
models
.
CASCADE
,
related_name
=
'announcements'
,
)
pub_datetime
=
models
.
DateTimeField
(
auto_now_add
=
True
)
def
__str__
(
self
):
...
...
@@ -20,14 +21,18 @@ class Announcement(models.Model):
return
self
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y
%
I:
%
M
%
p'
)
class
Reaction
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
5
,
default
=
''
)
name
=
models
.
CharField
(
max_length
=
5
,
choices
=
[(
'Like'
,
'Like'
),
(
'Love'
,
'Love'
),
(
'Angry'
,
'Angry'
)],
default
=
'Like'
)
tally
=
models
.
PositiveIntegerField
(
default
=
0
)
annoucement
=
models
.
ForeignKey
(
Announcement
,
null
=
True
,
default
=
True
,
on_delete
=
models
.
SET_DEFAULT
on_delete
=
models
.
CASCADE
,
related_name
=
'reactions'
)
def
__str__
(
self
):
return
self
.
name
\ No newline at end of file
return
self
.
name
widget_vincentdjango/announcementBoard/views.py
View file @
bbab1cb3
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
.models
import
Announcement
from
.models
import
Reaction
from
dashboard.models
import
WidgetUser
def
index
(
request
):
...
...
@@ -12,27 +12,20 @@ def index(request):
</h1>"
body
=
"<h2>Announcements:</h2>"
announcements
=
Announcement
.
objects
.
all
()
reactions
=
Reaction
.
objects
.
all
()
for
i
in
range
(
0
,
len
(
announcements
),
1
):
announcement
=
announcements
[
i
]
for
x
in
Announcement
.
objects
.
all
():
reaction
=
x
.
reactions
.
all
()
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
]
</p>"
.
format
(
x
.
title
,
x
.
author
,
x
.
format_pub_datetime
(),
x
.
body
)
for
y
in
reaction
:
body
+=
"<p>{}: {}
\
</p>"
.
format
(
reaction
.
name
,
reaction
.
tally
)
</p>"
.
format
(
y
.
name
,
y
.
tally
)
body
+=
'<p> </p>'
...
...
widget_vincentdjango/db.sqlite3
View file @
bbab1cb3
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