mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-12 16:26:12 +01:00
backupstart
This commit is contained in:
@@ -1376,6 +1376,50 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
|
||||
|
||||
};
|
||||
|
||||
|
||||
$scope.CreateBackup = function (){
|
||||
$('#wordpresshomeloading').show();
|
||||
var data = {
|
||||
WPid: $('#WPid').html(),
|
||||
}
|
||||
var url = "/websites/WPCreateBackup";
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$('#wordpresshomeloading').hide();
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Backup Created!.',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$('#wordpresshomeloading').hide();
|
||||
alert(response)
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
var DeploytoProductionID;
|
||||
|
||||
@@ -396,6 +396,11 @@
|
||||
</svg>
|
||||
Autoupdate Configurations
|
||||
</a>
|
||||
<div class="col-sm-12" style="margin-top: 1%">
|
||||
<button type="button"
|
||||
ng-click="CreateBackup()"
|
||||
class="btn btn-primary btn-lg center-div">{% trans "Create Backup" %}</button>
|
||||
</div>
|
||||
<div id="autoUpdateConfig" class="modal fade" tabindex="-1" role="dialog"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
|
||||
@@ -39,6 +39,7 @@ urlpatterns = [
|
||||
url(r'^fetchstaging', views.fetchstaging, name='fetchstaging'),
|
||||
url(r'^SaveUpdateConfig', views.SaveUpdateConfig, name='SaveUpdateConfig'),
|
||||
url(r'^DeploytoProduction', views.DeploytoProduction, name='DeploytoProduction'),
|
||||
url(r'^WPCreateBackup', views.WPCreateBackup, name='WPCreateBackup'),
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -322,6 +322,27 @@ def DeploytoProduction(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def WPCreateBackup(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
result = pluginManager.preWebsiteCreation(request)
|
||||
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.WPCreateBackup(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
|
||||
def GetCurrentThemes(request):
|
||||
|
||||
@@ -692,6 +692,46 @@ class WebsiteManager:
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def WPCreateBackup(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
WPManagerID = data['WPid']
|
||||
|
||||
wpsite = WPSites.objects.get(pk=WPManagerID)
|
||||
|
||||
|
||||
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
# extraArgs = {}
|
||||
# extraArgs['adminID'] = admin.pk
|
||||
# extraArgs['StagingDomain'] = StagingObj.FinalURL
|
||||
# extraArgs['StagingName'] = StagingObj.title
|
||||
# extraArgs['WPid'] = WPManagerID
|
||||
# extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
|
||||
|
||||
# background = ApplicationInstaller('CreateStagingNow', extraArgs)
|
||||
# background.start()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def UpdatePlugins(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user