roundabout,
created on Sunday, 28 April 2024, 12:59:42 (1714309182),
received on Wednesday, 31 July 2024, 06:54:47 (1722408887)
Author identity: vlad <vlad.muntoiu@gmail.com>
1bfd45f5a5f03c1c1860809421e5327c1bd11638
app.py
@@ -1484,6 +1484,7 @@ def repository_settings_post(username, repository):
# Update site settings had_site = repo.has_site old_branch = repo.site_branchif flask.request.form.get("site_branch"): repo.site_branch = flask.request.form.get("site_branch") if flask.request.form.get("primary_site") and had_site != 2:
@@ -1503,10 +1504,14 @@ def repository_settings_post(username, repository):
db.session.commit() if not had_site and repo.has_site:if not (had_site, old_branch) == (repo.has_site, repo.site_branch):# Deploy the newly activated site result = celery_tasks.copy_site.delay(repo.route) if had_site and not repo.has_site: # Remove the site result = celery_tasks.delete_site.delay(repo.route) return flask.redirect(f"/{username}/{repository}/settings", 303)
celery_tasks.py
@@ -105,3 +105,16 @@ def copy_site(route):
shutil.rmtree(site_location) common.git_command(config.SITE_PATH, b"", "clone", "--depth=1", f"--branch={branch}", os.path.join(os.getcwd(), server_repo_location), subdomain) @shared_task(ignore_result=False) def delete_site(route): from models import Repo repo = db.session.get(Repo, route) if repo.has_site == 2: subdomain = repo.owner.username else: subdomain = repo.name + "." + repo.owner.username site_location = os.path.join(config.SITE_PATH, subdomain) if os.path.isdir(site_location): shutil.rmtree(site_location)