Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable configurable silent email failures #64

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions djangocms_version_locking/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.conf import settings


EMAIL_NOTIFICATIONS_FAIL_SILENTLY = getattr(
settings, "EMAIL_NOTIFICATIONS_FAIL_SILENTLY", False
)
5 changes: 4 additions & 1 deletion djangocms_version_locking/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from djangocms_versioning.models import Version

from .admin import VersionLockAdminMixin
from .conf import EMAIL_NOTIFICATIONS_FAIL_SILENTLY
from .models import VersionLock


Expand Down Expand Up @@ -147,7 +148,9 @@ def send_email(
from_email=settings.DEFAULT_FROM_EMAIL,
to=recipients,
)
return message.send()
return message.send(
fail_silently=EMAIL_NOTIFICATIONS_FAIL_SILENTLY
)


def get_latest_draft_version(version):
Expand Down
11 changes: 6 additions & 5 deletions djangocms_version_locking/test_utils/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
from django.contrib.contenttypes.models import ContentType

import factory
from factory.django import DjangoModelFactory
from factory.fuzzy import FuzzyChoice, FuzzyText

from ..models import Version
from .polls.models import Answer, Poll, PollContent


class UserFactory(factory.django.DjangoModelFactory):
class UserFactory(DjangoModelFactory):
username = FuzzyText(length=12)
first_name = factory.Faker('first_name')
last_name = factory.Faker('last_name')
Expand All @@ -19,7 +20,7 @@ class Meta:
model = User


class AbstractVersionFactory(factory.DjangoModelFactory):
class AbstractVersionFactory(DjangoModelFactory):
object_id = factory.SelfAttribute('content.id')
content_type = factory.LazyAttribute(
lambda o: ContentType.objects.get_for_model(o.content))
Expand All @@ -30,14 +31,14 @@ class Meta:
abstract = True


class PollFactory(factory.django.DjangoModelFactory):
class PollFactory(DjangoModelFactory):
name = FuzzyText(length=6)

class Meta:
model = Poll


class PollContentFactory(factory.django.DjangoModelFactory):
class PollContentFactory(DjangoModelFactory):
poll = factory.SubFactory(PollFactory)
language = FuzzyChoice(['en', 'fr', 'it'])
text = FuzzyText(length=24)
Expand Down Expand Up @@ -65,7 +66,7 @@ def version(self, create, extracted, **kwargs):
PollVersionFactory(content=self, **kwargs)


class AnswerFactory(factory.django.DjangoModelFactory):
class AnswerFactory(DjangoModelFactory):
poll_content = factory.SubFactory(PollContentFactory)
text = factory.LazyAttributeSequence(
lambda o, n: 'Poll %s - Answer %d' % (o.poll_content.poll.name, n))
Expand Down
7 changes: 7 additions & 0 deletions docs/notifications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Notifications
==========================


Email notifications
------------------------
Configure email notifications to fail silently by setting: ``EMAIL_NOTIFICATIONS_FAIL_SILENTLY=True``
5 changes: 5 additions & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ isort
mock
djangocms_helper
factory-boy
django-classy-tags<2.0.0 # Support Django<2.0
django-sekizai<2.0.0 # Support Django<2.0

# Get the latest cms v4 compatible djangocms-text-ckeditor
https://github.com/divio/djangocms-text-ckeditor/tarball/support/4.0.x#egg=djangocms-text-ckeditor