Skip to content

Commit

Permalink
Fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuelle Helly committed Aug 2, 2022
1 parent 7d53f16 commit 771d178
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions geotrek/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ def save(self, *args, **kwargs):
aggr.save()
self._is_reversed = False

# If draft is True, send email to managers
if (self.pk and self.__class__.objects.get(pk=self.pk).draft != self.draft and self.draft) \
# If draft is set from False to True, and setting ALERT_DRAFT is True, send email to managers
if (self.pk and self.draft and self.__class__.objects.get(pk=self.pk).draft != self.draft) \
and settings.ALERT_DRAFT:
subject = _("{obj} has been set to draft").format(obj=self)
message = render_to_string('core/draft_email_message.txt', {"obj": self})
Expand Down
4 changes: 2 additions & 2 deletions geotrek/core/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def test_status_draft_alert(self):
p1.save()
self.assertEqual(len(mail.outbox), 1)

@override_settings(ALERT_REVIEW=True)
@mock.patch('geotrek.common.mixins.models.mail_managers')
@override_settings(ALERT_DRAFT=True)
@mock.patch('geotrek.core.models.mail_managers')
def test_status_draft_fail_mail(self, mock_mail):
mock_mail.side_effect = Exception("Test")
p1 = PathFactory.create()
Expand Down

0 comments on commit 771d178

Please sign in to comment.