Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Maják
Merge requests
!1288
Fix Ecomail newsletter tag updates
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Fix Ecomail newsletter tag updates
feat/future-calendars
into
test
Overview
0
Commits
1
Pipelines
1
Changes
1
Merged
Alexa Valentová
requested to merge
feat/future-calendars
into
test
1 week ago
Overview
0
Commits
1
Pipelines
1
Changes
1
Expand
0
0
Merge request reports
Compare
test
test (base)
and
latest version
latest version
3725a3fa
1 commit,
1 week ago
1 file
+
16
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
shared/utils.py
+
16
−
4
Options
@@ -72,11 +72,11 @@ def subscribe_to_newsletter(email, list_id):
def
subscribe_to_ecomail_newsletter
(
email
:
str
,
categorie
s
:
str
,
tag
s
:
str
,
source
:
str
,
list_id
:
int
|
None
=
None
,
custom_data
:
dict
|
None
=
None
,
update_existing
:
bool
=
True
update_existing
:
bool
=
True
,
):
if
custom_data
is
None
:
custom_data
=
{}
@@ -84,13 +84,25 @@ def subscribe_to_ecomail_newsletter(
if
not
list_id
:
list_id
=
settings
.
ECOMAIL_DEFAULT_LIST_ID
split_categories
=
categories
.
split
(
"
,
"
)
if
categories
is
not
None
else
[]
existing_subscriber_data
=
requests
.
get
(
urljoin
(
settings
.
ECOMAIL_API_URL
,
f
"
lists/
{
list_id
}
/subscriber/
{
email
}
"
),
headers
=
{
"
key
"
:
settings
.
ECOMAIL_API_KEY
},
)
existing_tags
=
[]
if
existing_subscriber_data
.
status_code
==
200
:
existing_subscriber_data
=
existing_subscriber_data
.
json
()
existing_tags
=
existing_subscriber_data
[
"
subscriber
"
][
"
tags
"
]
split_tags
=
tags
.
split
(
"
,
"
)
if
tags
is
not
None
else
[]
split_tags
+=
existing_tags
data
=
{
"
subscriber_data
"
:
{
"
email
"
:
email
,
"
source
"
:
source
,
"
tags
"
:
split_
categorie
s
,
"
tags
"
:
split_
tag
s
,
**
custom_data
,
},
"
update_existing
"
:
update_existing
,
Loading