Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
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
ecommerce
Commits
a107bb2e
Commit
a107bb2e
authored
May 24, 2018
by
Zia Fazal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed management command to handle a scenario when dns is changed
parent
782f2f29
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
12 deletions
+28
-12
ecommerce/theming/management/commands/create_sites_and_partners.py
+19
-12
ecommerce/theming/management/commands/tests/test_create_sites_and_partners.py
+9
-0
No files found.
ecommerce/theming/management/commands/create_sites_and_partners.py
View file @
a107bb2e
...
...
@@ -59,26 +59,33 @@ class Command(BaseCommand):
"""
Create Sites, SiteThemes, SiteConfigurations, and Courses (if requested)
"""
site
,
_
=
Site
.
objects
.
get_or_create
(
domain
=
site_domain
,
defaults
=
{
"name"
:
theme_dir_name
}
logger
.
info
(
'Creating or updating
%
s Partner'
,
partner_code
)
partner
,
_
=
Partner
.
objects
.
get_or_create
(
short_code
=
partner_code
,
defaults
=
{
"name"
:
partner_code
}
)
logger
.
info
(
'Finding if site already exists for
%
s partner'
,
partner_code
)
try
:
site_config
=
SiteConfiguration
.
objects
.
get
(
partner
=
partner
)
site_id
=
site_config
.
site
.
id
logger
.
info
(
'Site already exists for
%
s partner with site id
%
s'
,
partner_code
,
site_id
)
except
SiteConfiguration
.
DoesNotExist
:
site_id
=
None
logger
.
info
(
'Creating or updating site
%
s '
,
site_domain
)
site
=
Site
(
id
=
site_id
,
domain
=
site_domain
,
name
=
theme_dir_name
)
site
.
save
()
logger
.
info
(
'Creating
%
s SiteTheme'
,
site_domain
)
SiteTheme
.
objects
.
get_or_create
(
site
=
site
,
theme_dir_name
=
theme_dir_name
)
logger
.
info
(
'Creating
%
s Partner'
,
site_domain
)
partner
,
_
=
Partner
.
objects
.
get_or_create
(
short_code
=
partner_code
,
defaults
=
{
"name"
:
partner_code
}
)
logger
.
info
(
'Creating
%
s SiteConfiguration'
,
site_domain
)
logger
.
info
(
'Creating or updating
%
s SiteConfiguration'
,
site_domain
)
SiteConfiguration
.
objects
.
get_or_create
(
site
=
site
,
partner
=
partner
,
...
...
ecommerce/theming/management/commands/tests/test_create_sites_and_partners.py
View file @
a107bb2e
...
...
@@ -160,3 +160,12 @@ class TestCreateSitesAndPartners(TestCase):
)
# if we run command with same dns then it will not duplicates the sites and partners.
self
.
_assert_sites_data_is_valid
()
self
.
dns_name
=
"new-dns"
call_command
(
"create_sites_and_partners"
,
"--dns-name"
,
self
.
dns_name
,
"--theme-path"
,
self
.
theme_path
)
# if we run command with same partner but different dns then it should update sites.
self
.
_assert_sites_data_is_valid
()
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