Skip to content

Commit

Permalink
fix issue with creating campaigns when segments spanned multiple grou…
Browse files Browse the repository at this point in the history
…pings
  • Loading branch information
tmog committed Nov 12, 2013
1 parent fa6bed8 commit 4c9caea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -6,6 +6,9 @@ Unreleased

Changes:

- Fix issue with creating campaigns when segments span multiple groupings.
[tmog]

- Add option to make interests required when subscribing via
list subscribe form.
[tmog]
Expand Down
23 changes: 15 additions & 8 deletions src/collective/chimpfeed/form.py
Expand Up @@ -647,14 +647,21 @@ def getSegmentConditions(self, interest_groups):
if not interest_groups:
return []

(grouping_id, interest_description, group_id) = interest_groups[0]
groupings = {}
for grouping_id, group_name, _ in interest_groups:
groupings.setdefault(grouping_id, []).append(group_name)

segments = []
for grouping, interests in groupings.items():
segments.append({
'field': 'interests-' + str(grouping),
'op': 'one',
'value': ','.join(
[i.encode("utf-8") for i in interests]
)
})

return [{'field': 'interests-' + str(grouping_id),
'op': 'one',
'value': ','.join([interest[1].encode("utf-8")
for interest
in interest_groups])
}]
return segments

@button.buttonAndHandler(_(u'Preview'))
def handlePreview(self, action):
Expand Down Expand Up @@ -709,7 +716,7 @@ def process(self, method, subject=None,
api_key, method, subject,
create_draft, schedule, rendered, next_url,
segment_conditions and {
'match': 'all',
'match': 'any',
'conditions': segment_conditions
} or None
)
Expand Down

0 comments on commit 4c9caea

Please sign in to comment.