Added optional redirect value for siteClone (#2032)
* Added optional redirect value; see #1891 * Return address of the newly cloned site
This commit is contained in:
parent
9c0e8ee833
commit
7262fbfb4e
1 changed files with 10 additions and 5 deletions
|
@ -968,15 +968,17 @@ class UiWebsocket(object):
|
||||||
else:
|
else:
|
||||||
self.response(to, {"error": "Unknown site: %s" % address})
|
self.response(to, {"error": "Unknown site: %s" % address})
|
||||||
|
|
||||||
def cbSiteClone(self, to, address, root_inner_path="", target_address=None):
|
def cbSiteClone(self, to, address, root_inner_path="", target_address=None, redirect=True):
|
||||||
self.cmd("notification", ["info", _["Cloning site..."]])
|
self.cmd("notification", ["info", _["Cloning site..."]])
|
||||||
site = self.server.sites.get(address)
|
site = self.server.sites.get(address)
|
||||||
|
response = {}
|
||||||
if target_address:
|
if target_address:
|
||||||
target_site = self.server.sites.get(target_address)
|
target_site = self.server.sites.get(target_address)
|
||||||
privatekey = self.user.getSiteData(target_site.address).get("privatekey")
|
privatekey = self.user.getSiteData(target_site.address).get("privatekey")
|
||||||
site.clone(target_address, privatekey, root_inner_path=root_inner_path)
|
site.clone(target_address, privatekey, root_inner_path=root_inner_path)
|
||||||
self.cmd("notification", ["done", _["Site source code upgraded!"]])
|
self.cmd("notification", ["done", _["Site source code upgraded!"]])
|
||||||
site.publish()
|
site.publish()
|
||||||
|
response = {"address": target_address}
|
||||||
else:
|
else:
|
||||||
# Generate a new site from user's bip32 seed
|
# Generate a new site from user's bip32 seed
|
||||||
new_address, new_address_index, new_site_data = self.user.getNewSiteData()
|
new_address, new_address_index, new_site_data = self.user.getNewSiteData()
|
||||||
|
@ -984,11 +986,14 @@ class UiWebsocket(object):
|
||||||
new_site.settings["own"] = True
|
new_site.settings["own"] = True
|
||||||
new_site.saveSettings()
|
new_site.saveSettings()
|
||||||
self.cmd("notification", ["done", _["Site cloned"]])
|
self.cmd("notification", ["done", _["Site cloned"]])
|
||||||
self.cmd("redirect", "/%s" % new_address)
|
if redirect :
|
||||||
|
self.cmd("redirect", "/%s" % new_address)
|
||||||
gevent.spawn(new_site.announce)
|
gevent.spawn(new_site.announce)
|
||||||
|
response = {"address": new_address}
|
||||||
|
self.response(to, response)
|
||||||
return "ok"
|
return "ok"
|
||||||
|
|
||||||
def actionSiteClone(self, to, address, root_inner_path="", target_address=None):
|
def actionSiteClone(self, to, address, root_inner_path="", target_address=None, redirect=True):
|
||||||
if not SiteManager.site_manager.isAddress(address):
|
if not SiteManager.site_manager.isAddress(address):
|
||||||
self.response(to, {"error": "Not a site: %s" % address})
|
self.response(to, {"error": "Not a site: %s" % address})
|
||||||
return
|
return
|
||||||
|
@ -1006,12 +1011,12 @@ class UiWebsocket(object):
|
||||||
return {"error": "Site still in sync"}
|
return {"error": "Site still in sync"}
|
||||||
|
|
||||||
if "ADMIN" in self.getPermissions(to):
|
if "ADMIN" in self.getPermissions(to):
|
||||||
self.cbSiteClone(to, address, root_inner_path, target_address)
|
self.cbSiteClone(to, address, root_inner_path, target_address, redirect)
|
||||||
else:
|
else:
|
||||||
self.cmd(
|
self.cmd(
|
||||||
"confirm",
|
"confirm",
|
||||||
[_["Clone site <b>%s</b>?"] % address, _["Clone"]],
|
[_["Clone site <b>%s</b>?"] % address, _["Clone"]],
|
||||||
lambda res: self.cbSiteClone(to, address, root_inner_path, target_address)
|
lambda res: self.cbSiteClone(to, address, root_inner_path, target_address, redirect)
|
||||||
)
|
)
|
||||||
|
|
||||||
def actionSiteSetLimit(self, to, size_limit):
|
def actionSiteSetLimit(self, to, size_limit):
|
||||||
|
|
Loading…
Reference in a new issue