Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
390c5368
Commit
390c5368
authored
Nov 23, 2017
by
asadiqbal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the SailThru var with Enterprise learner information
parent
53fea6a4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
135 additions
and
1 deletions
+135
-1
lms/envs/common.py
+1
-1
openedx/features/enterprise_support/apps.py
+15
-0
openedx/features/enterprise_support/signals.py
+21
-0
openedx/features/enterprise_support/tests/factories.py
+61
-0
openedx/features/enterprise_support/tests/test_signals.py
+37
-0
No files found.
lms/envs/common.py
View file @
390c5368
...
...
@@ -2313,7 +2313,7 @@ INSTALLED_APPS = [
'openedx.features.course_bookmarks'
,
'openedx.features.course_experience'
,
'openedx.features.course_search'
,
'openedx.features.enterprise_support'
,
'openedx.features.enterprise_support
.apps.EnterpriseSupportConfig
'
,
'openedx.features.learner_profile'
,
'experiments'
,
...
...
openedx/features/enterprise_support/apps.py
0 → 100644
View file @
390c5368
"""
Configuration for enterprise_support
"""
from
django.apps
import
AppConfig
class
EnterpriseSupportConfig
(
AppConfig
):
"""
Configuration class for enterprise_support
"""
name
=
'openedx.features.enterprise_support'
def
ready
(
self
):
# Import signals to activate signal handler for enterprise.
from
.
import
signals
# pylint: disable=unused-import, unused-variable
openedx/features/enterprise_support/signals.py
0 → 100644
View file @
390c5368
"""
This module contains signals related to enterprise.
"""
from
django.dispatch
import
receiver
from
django.db.models.signals
import
post_save
from
django.contrib.auth.models
import
User
from
enterprise.models
import
EnterpriseCustomerUser
from
email_marketing.tasks
import
update_user
# pylint: disable=import-error
@receiver
(
post_save
,
sender
=
EnterpriseCustomerUser
)
def
update_email_marketing_user_with_enterprise_flag
(
sender
,
instance
,
**
kwargs
):
# pylint: disable=unused-argument, invalid-name
"""
Enable the is_enterprise_learner flag in SailThru vars.
"""
user
=
User
.
objects
.
get
(
id
=
instance
.
user_id
)
# perform update asynchronously
update_user
.
delay
(
sailthru_vars
=
{
'is_enterprise_learner'
:
True
},
email
=
user
.
email
)
openedx/features/enterprise_support/tests/factories.py
0 → 100644
View file @
390c5368
"""
Factoryboy factories.
"""
from
__future__
import
absolute_import
,
unicode_literals
from
uuid
import
UUID
import
factory
from
faker
import
Factory
as
FakerFactory
from
openedx.core.djangoapps.site_configuration.tests.factories
import
SiteFactory
from
enterprise.models
import
(
EnterpriseCustomer
,
EnterpriseCustomerUser
,
)
FAKER
=
FakerFactory
.
create
()
class
EnterpriseCustomerFactory
(
factory
.
django
.
DjangoModelFactory
):
"""
EnterpriseCustomer factory.
Creates an instance of EnterpriseCustomer with minimal boilerplate - uses this class' attributes as default
parameters for EnterpriseCustomer constructor.
"""
class
Meta
(
object
):
"""
Meta for EnterpriseCustomerFactory.
"""
model
=
EnterpriseCustomer
uuid
=
factory
.
LazyAttribute
(
lambda
x
:
UUID
(
FAKER
.
uuid4
()))
# pylint: disable=no-member
name
=
factory
.
LazyAttribute
(
lambda
x
:
FAKER
.
company
())
# pylint: disable=no-member
active
=
True
site
=
factory
.
SubFactory
(
SiteFactory
)
catalog
=
factory
.
LazyAttribute
(
lambda
x
:
FAKER
.
random_int
(
min
=
0
,
max
=
1000000
))
# pylint: disable=no-member
enable_data_sharing_consent
=
True
enforce_data_sharing_consent
=
EnterpriseCustomer
.
AT_ENROLLMENT
class
EnterpriseCustomerUserFactory
(
factory
.
django
.
DjangoModelFactory
):
"""
EnterpriseCustomer factory.
Creates an instance of EnterpriseCustomerUser with minimal boilerplate - uses this class' attributes as default
parameters for EnterpriseCustomerUser constructor.
"""
class
Meta
(
object
):
"""
Meta for EnterpriseCustomerFactory.
"""
model
=
EnterpriseCustomerUser
enterprise_customer
=
factory
.
SubFactory
(
EnterpriseCustomerFactory
)
user_id
=
factory
.
LazyAttribute
(
lambda
x
:
FAKER
.
pyint
())
# pylint: disable=no-member
openedx/features/enterprise_support/tests/test_signals.py
0 → 100644
View file @
390c5368
"""Tests of email marketing signal handlers."""
import
logging
import
ddt
from
django.test
import
TestCase
from
mock
import
patch
from
student.tests.factories
import
UserFactory
from
openedx.features.enterprise_support.tests.factories
import
EnterpriseCustomerFactory
,
EnterpriseCustomerUserFactory
log
=
logging
.
getLogger
(
__name__
)
LOGGER_NAME
=
"enterprise_support.signals"
TEST_EMAIL
=
"test@edx.org"
@ddt.ddt
class
EnterpriseSupportSignals
(
TestCase
):
"""
Tests for the enterprise support signals.
"""
def
setUp
(
self
):
self
.
user
=
UserFactory
.
create
(
username
=
'test'
,
email
=
TEST_EMAIL
)
super
(
EnterpriseSupportSignals
,
self
)
.
setUp
()
@patch
(
'openedx.features.enterprise_support.signals.update_user.delay'
)
def
test_register_user
(
self
,
mock_update_user
):
"""
make sure marketing enterprise user call invokes update_user
"""
enterprise_customer
=
EnterpriseCustomerFactory
()
EnterpriseCustomerUserFactory
(
user_id
=
self
.
user
.
id
,
enterprise_customer
=
enterprise_customer
)
self
.
assertTrue
(
mock_update_user
.
called
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment