Skip to content

Commit

Permalink
feat: fixing state when setting is missing (#294)
Browse files Browse the repository at this point in the history
this package was causing problems when imported into a situation where
settings.ACE_CHANNEL_DEFAULT_PUSH  was not set.
  • Loading branch information
deborahgu authored Aug 1, 2024
1 parent 0c11505 commit 6d883f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion edx_ace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .recipient import Recipient
from .recipient_resolver import RecipientResolver

__version__ = '1.10.0'
__version__ = '1.10.1'


__all__ = [
Expand Down
6 changes: 4 additions & 2 deletions edx_ace/channel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Developers wanting to add a new deliver channel should subclass :class:`Channel`,
and then add an entry to the ``openedx.ace.channel`` entrypoint in their ``setup.py``.
"""

import abc
import itertools
from collections import OrderedDict, defaultdict
Expand All @@ -24,6 +25,7 @@ class ChannelType(Enum):
"""
All supported communication channels.
"""

EMAIL = 'email'
PUSH = 'push'

Expand Down Expand Up @@ -127,7 +129,7 @@ def get_default_channel(self, channel_type):
except (StopIteration, KeyError) as error:
raise UnsupportedChannelError(
f'No implementation for channel {channel_type} is registered. '
f'Available channels are: {channels()}'
f'Available channels are: {channels()}',
) from error

def __str__(self):
Expand Down Expand Up @@ -178,7 +180,7 @@ def get_channel_for_message(channel_type, message):
channel_names = [settings.ACE_CHANNEL_TRANSACTIONAL_EMAIL, settings.ACE_CHANNEL_DEFAULT_EMAIL]
else:
channel_names = [settings.ACE_CHANNEL_DEFAULT_EMAIL]
elif channel_type == ChannelType.PUSH:
elif channel_type == ChannelType.PUSH and getattr(settings, "ACE_CHANNEL_DEFAULT_PUSH", None):
channel_names = [settings.ACE_CHANNEL_DEFAULT_PUSH]

try:
Expand Down

0 comments on commit 6d883f8

Please sign in to comment.