backupstart

This commit is contained in:
Hassan Hashmi
2022-06-06 13:47:09 +05:00
parent 2e61794c50
commit 791860d1ee
5 changed files with 111 additions and 0 deletions

View File

@@ -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; var DeploytoProductionID;

View File

@@ -396,6 +396,11 @@
</svg> </svg>
Autoupdate Configurations Autoupdate Configurations
</a> </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" <div id="autoUpdateConfig" class="modal fade" tabindex="-1" role="dialog"
aria-hidden="true"> aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">

View File

@@ -39,6 +39,7 @@ urlpatterns = [
url(r'^fetchstaging', views.fetchstaging, name='fetchstaging'), url(r'^fetchstaging', views.fetchstaging, name='fetchstaging'),
url(r'^SaveUpdateConfig', views.SaveUpdateConfig, name='SaveUpdateConfig'), url(r'^SaveUpdateConfig', views.SaveUpdateConfig, name='SaveUpdateConfig'),
url(r'^DeploytoProduction', views.DeploytoProduction, name='DeploytoProduction'), url(r'^DeploytoProduction', views.DeploytoProduction, name='DeploytoProduction'),
url(r'^WPCreateBackup', views.WPCreateBackup, name='WPCreateBackup'),

View File

@@ -322,6 +322,27 @@ def DeploytoProduction(request):
except KeyError: except KeyError:
return redirect(loadLoginPage) 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): def GetCurrentThemes(request):

View File

@@ -692,6 +692,46 @@ class WebsiteManager:
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)
return HttpResponse(json_data) 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): def UpdatePlugins(self, userID=None, data=None):
try: try: