Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def start_building():


def submit_new_site_build(
form, domain, subdomain, login_token, app_config=None
form, domain, subdomain, login_token, app_config=None, session=None
): # noqa: E501
"""Submit a new site build
Take form submission and build new site from it
Expand All @@ -51,6 +51,7 @@ def submit_new_site_build(
:param subdomain: The subdomain for new shop e.g. abc. Which
:param app_config: The flask app config type casted to a dict
when combined with domain, becomes abc.example.com
:param session: The serialized flask session data
"""
payload = {}
payload["version"] = 1
Expand All @@ -59,6 +60,9 @@ def submit_new_site_build(
payload["login_token"] = login_token
company_name = form.company_name.data
payload["company"] = {"name": company_name, "logo": "", "start_image": ""}
# If possible, get country code and send to subscribie deployer
# Ref: https://github.com/Subscribie/module-builder/issues/33
payload["country_code"] = session.get("country_code", "GB")
payload["theme"] = {"name": "jesmond", "static_folder": "./static/"}

# Custom styles prepare as empty
Expand Down Expand Up @@ -140,18 +144,24 @@ def save_plans():

login_token = generate_login_token()

session[
"site-url"
] = f'https://{subdomain}.{app.config.get("SUBSCRIBIE_DOMAIN", ".subscriby.shop")}' # noqa: E501

# Start new site build in background thread
app_config = dict(app.config)
session_dict = dict(session)
task_queue.put(
lambda: submit_new_site_build(
form, domain, subdomain, login_token, app_config
) # noqa: E501
form,
domain,
subdomain,
login_token,
app_config,
session=session_dict, # noqa: E501
)
) # noqa: E501

session[
"site-url"
] = f'https://{subdomain}.{app.config.get("SUBSCRIBIE_DOMAIN", ".subscriby.shop")}' # noqa: E501

# Redirect to their site, auto login using login_token
auto_login_url = f'{session["site-url"]}/auth/login/{login_token}'
session["login-url"] = auto_login_url
Expand Down