Skip to content

Commit

Permalink
Merge pull request #73 from collective/maurits-groups
Browse files Browse the repository at this point in the history
Catch errors in newsletter page when getting groups.
  • Loading branch information
mauritsvanrees authored Jun 22, 2024
2 parents d3388e4 + 92f84a4 commit 2a7a285
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
4.0.0a5 (unreleased)
--------------------

- Nothing changed yet.
- Catch errors in newsletter page when getting groups.
[maurits]


4.0.0a4 (2024-06-22)
Expand Down
8 changes: 7 additions & 1 deletion src/collective/mailchimp/browser/newsletter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
from zope.interface import implementer
from zope.interface import Invalid

import logging
import re


logger = logging.getLogger(__name__)
# Characters that are allowed in some fields.
# This tries to prevent hacking attempts that get us blocked.
CHARS_ALLOWED = re.compile(r"^[a-zA-Z0-9\-_\./@\+]*$").match
Expand Down Expand Up @@ -78,7 +80,11 @@ def updateWidgets(self):
widgets['list_id'].value = list_id

# Show/hide interest_groups widget
self.available_interest_groups = self.mailchimp.groups(list_id=list_id)
try:
self.available_interest_groups = self.mailchimp.groups(list_id=list_id)
except Exception as exc:
logger.warning(exc)
self.available_interest_groups = []
if not self.available_interest_groups or \
self.available_interest_groups.get('total_items') == 0:
widgets['interest_groups'].mode = HIDDEN_MODE
Expand Down

0 comments on commit 2a7a285

Please sign in to comment.