Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
oser-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hamza Touizrat
oser-backend
Commits
7306f599
Commit
7306f599
authored
May 26, 2018
by
florimondmanca
Browse files
Options
Downloads
Patches
Plain Diff
fix bug preventing notification on participation creation
parent
77a36eed
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
oser_backend/tests/test_visits/test_signals.py
+8
-5
8 additions, 5 deletions
oser_backend/tests/test_visits/test_signals.py
oser_backend/visits/signals.py
+2
-2
2 additions, 2 deletions
oser_backend/visits/signals.py
with
10 additions
and
7 deletions
oser_backend/tests/test_visits/test_signals.py
+
8
−
5
View file @
7306f599
...
@@ -14,9 +14,8 @@ class NotifyParticipationTest(SignalTestMixin, TestCase):
...
@@ -14,9 +14,8 @@ class NotifyParticipationTest(SignalTestMixin, TestCase):
"""
Test the notify_participation signal handler.
"""
"""
Test the notify_participation signal handler.
"""
def
setUp
(
self
):
def
setUp
(
self
):
VisitFactory
.
create
()
VisitFactory
.
create_batch
(
5
)
user
=
UserFactory
.
create
()
self
.
obj
=
ParticipationFactory
.
create
(
accepted
=
None
)
self
.
obj
=
ParticipationFactory
.
create
(
user
=
user
,
accepted
=
None
)
def
change
(
self
,
accepted
=
True
):
def
change
(
self
,
accepted
=
True
):
self
.
obj
.
accepted
=
accepted
self
.
obj
.
accepted
=
accepted
...
@@ -26,10 +25,14 @@ class NotifyParticipationTest(SignalTestMixin, TestCase):
...
@@ -26,10 +25,14 @@ class NotifyParticipationTest(SignalTestMixin, TestCase):
with
self
.
assertCalled
(
accepted_changed
):
with
self
.
assertCalled
(
accepted_changed
):
self
.
change
()
self
.
change
()
def
test_notification_sent_called_by_accepted
(
self
):
def
test_accepted_changed_called_when_creating_accepted_partipant
(
self
):
with
self
.
assertCalled
(
accepted_changed
):
ParticipationFactory
.
create
(
accepted
=
True
)
def
test_notification_sent_is_called_by_accepted
(
self
):
with
self
.
assertCalled
(
notification_sent
,
sender
=
Accepted
):
with
self
.
assertCalled
(
notification_sent
,
sender
=
Accepted
):
self
.
change
(
accepted
=
True
)
self
.
change
(
accepted
=
True
)
def
test_notification_sent_called_by_rejected
(
self
):
def
test_notification_sent_
is_
called_by_rejected
(
self
):
with
self
.
assertCalled
(
notification_sent
,
sender
=
Rejected
):
with
self
.
assertCalled
(
notification_sent
,
sender
=
Rejected
):
self
.
change
(
accepted
=
False
)
self
.
change
(
accepted
=
False
)
This diff is collapsed.
Click to expand it.
oser_backend/visits/signals.py
+
2
−
2
View file @
7306f599
...
@@ -10,9 +10,9 @@ accepted_changed = Signal()
...
@@ -10,9 +10,9 @@ accepted_changed = Signal()
@receiver
(
post_save
,
sender
=
Participation
)
@receiver
(
post_save
,
sender
=
Participation
)
def
fire_accepted_changed
(
sender
,
instance
:
Participation
,
**
kwargs
):
def
fire_accepted_changed
(
sender
,
instance
:
Participation
,
created
,
**
kwargs
):
"""
Fire an event if the participation status has changed.
"""
"""
Fire an event if the participation status has changed.
"""
if
instance
.
accepted_changed
():
if
created
or
instance
.
accepted_changed
():
accepted_changed
.
send
(
sender
=
sender
,
instance
=
instance
)
accepted_changed
.
send
(
sender
=
sender
,
instance
=
instance
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment