Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_someone here is possessed by an owl
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
Laetitia de Castro
widget_someone here is possessed by an owl
Commits
39ee8f3a
Commit
39ee8f3a
authored
Apr 03, 2022
by
Titia de Castro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added get methods for announcement and reaction models
parent
98d5040b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
models.cpython-310.pyc
announcements/__pycache__/models.cpython-310.pyc
+0
-0
models.py
announcements/models.py
+16
-1
No files found.
announcements/__pycache__/models.cpython-310.pyc
View file @
39ee8f3a
No preview for this file type
announcements/models.py
View file @
39ee8f3a
...
@@ -12,6 +12,18 @@ class Announcement(models.Model):
...
@@ -12,6 +12,18 @@ class Announcement(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
announcement_title
return
self
.
announcement_title
def
getAnnouncement
(
self
):
return
'{} by {} {} dated {}:<br>{}<br>Like: {}<br>Love: {}<br>Angry: {}<br>'
.
format
(
self
.
announcement_title
,
self
.
author
.
first_name
,
self
.
author
.
last_name
,
self
.
pub_date
,
self
.
announcement_body
,
self
.
reactions
.
get
(
reaction_name
=
"Like"
)
.
getTally
(),
self
.
reactions
.
get
(
reaction_name
=
"Love"
)
.
getTally
(),
self
.
reactions
.
get
(
reaction_name
=
"Angry"
)
.
getTally
()
)
class
Reaction
(
models
.
Model
):
class
Reaction
(
models
.
Model
):
class
ReactionNames
(
models
.
TextChoices
):
class
ReactionNames
(
models
.
TextChoices
):
LIKE
=
'Like'
LIKE
=
'Like'
...
@@ -24,3 +36,6 @@ class Reaction(models.Model):
...
@@ -24,3 +36,6 @@ class Reaction(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
'{} {} reactions'
.
format
(
self
.
announcement
.
announcement_title
,
self
.
reaction_name
)
return
'{} {} reactions'
.
format
(
self
.
announcement
.
announcement_title
,
self
.
reaction_name
)
def
getTally
(
self
):
return
self
.
tally
\ 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