Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group22
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 Tamano
widget_group22
Commits
090ad272
Commit
090ad272
authored
Apr 06, 2022
by
Julliana Zarah C. Cruz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Applied migrations and updated tally field and views.py
parent
4558cfc7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
5 deletions
+25
-5
0008_reaction_tally.py
...t_group22/announcements/migrations/0008_reaction_tally.py
+18
-0
models.py
widget_group22/announcements/models.py
+4
-1
views.py
widget_group22/announcements/views.py
+3
-4
No files found.
widget_group22/announcements/migrations/0008_reaction_tally.py
0 → 100644
View file @
090ad272
# Generated by Django 4.0.3 on 2022-04-06 07:24
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'announcements'
,
'0007_remove_reaction_tally_reaction_id'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'reaction'
,
name
=
'tally'
,
field
=
models
.
IntegerField
(
default
=
1
),
),
]
widget_group22/announcements/models.py
View file @
090ad272
...
...
@@ -18,11 +18,14 @@ class Reaction(models.Model):
max_length
=
5
,
choices
=
REACTION_CHOICES
,
)
tally
=
models
.
IntegerField
(
default
=
1
)
tally
=
models
.
IntegerField
(
default
=
0
)
def
__str__
(
self
):
return
'{}'
.
format
(
self
.
reaction_name
)
def
get_tally
(
self
):
return
'{}'
.
format
(
self
.
tally
)
class
Announcement
(
models
.
Model
):
announcement_title
=
models
.
CharField
(
max_length
=
100
)
...
...
widget_group22/announcements/views.py
View file @
090ad272
...
...
@@ -6,7 +6,6 @@ from .models import Announcement, Reaction
def
index
(
request
):
return
HttpResponse
(
'This is the Announcement Board!'
)
def
announcements
(
request
):
all_announcements
=
models
.
Announcement
.
objects
.
all
()
all_reactions
=
models
.
Reaction
.
objects
.
all
()
...
...
@@ -19,9 +18,9 @@ def announcements(request):
date
=
str
(
i
.
pub_date
)
last_name
=
i
.
author
.
last_name
first_name
=
i
.
author
.
first_name
like_tally
=
Reaction
.
objects
.
filter
(
reaction_name
=
'Like'
,
announcement
=
i
)
love_tally
=
Reaction
.
objects
.
filter
(
reaction_name
=
'Love'
,
announcement
=
i
)
angry_tally
=
Reaction
.
objects
.
filter
(
reaction_name
=
'Angry'
,
announcement
=
i
)
like_tally
=
str
(
Reaction
.
objects
.
get
(
reaction_name
=
'Like'
,
announcement
=
i
)
.
get_tally
()
)
love_tally
=
str
(
Reaction
.
objects
.
get
(
reaction_name
=
'Love'
,
announcement
=
i
)
.
get_tally
()
)
angry_tally
=
str
(
Reaction
.
objects
.
get
(
reaction_name
=
'Angry'
,
announcement
=
i
)
.
get_tally
()
)
output
=
(
title
+
' by '
+
first_name
+
' '
+
last_name
+
' dated '
+
date
+
':<br>'
+
body
+
'<br>'
...
...
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