diff --git a/plogical/IncScheduler.py b/plogical/IncScheduler.py index 479a0840f..40e0ca245 100644 --- a/plogical/IncScheduler.py +++ b/plogical/IncScheduler.py @@ -1090,6 +1090,7 @@ Automatic backup failed for %s on %s. obj.lastrun = time.time() obj.save() except BaseException as msg: + print("Error in Sites:%s"%str(msg)) continue except BaseException as msg: print("Error: [RemoteBackup]: %s"%str(msg)) diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index c743a525d..7b10360e8 100755 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -2049,7 +2049,7 @@ app.controller('RemoteBackupConfig', function ($scope, $http, $timeout, $window) }); - +var UpdatescheduleID; app.controller('BackupSchedule', function ($scope, $http, $timeout, $window) { $scope.BackupScheduleLoading = true; $scope.SaveBackupSchedule = function () { @@ -2108,8 +2108,67 @@ app.controller('BackupSchedule', function ($scope, $http, $timeout, $window) { } + }; + + + + + $scope.getupdateid = function (ID) { + UpdatescheduleID = ID; } + $scope.UpdateRemoteschedules = function () { + $scope.RemoteBackupLoading = false; + var Frequency = $scope.RemoteFrequency; + var fretention = $scope.RemoteFileretention; + + var data = { + ScheduleID:UpdatescheduleID, + Frequency: Frequency, + FileRetention: fretention + } + var url = "/websites/UpdateRemoteschedules"; + + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.RemoteBackupLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Successfully Updated!.', + type: 'success' + }); + location.reload(); + + + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.RemoteBackupLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + + + } + }; $scope.AddWPsiteforRemoteBackup = function () { $scope.RemoteBackupLoading = false; @@ -2163,7 +2222,7 @@ app.controller('BackupSchedule', function ($scope, $http, $timeout, $window) { } - } + }; }); /* Java script code to create account */ app.controller('createWebsite', function ($scope, $http, $timeout, $window) { diff --git a/websiteFunctions/templates/websiteFunctions/BackupfileConfig.html b/websiteFunctions/templates/websiteFunctions/BackupfileConfig.html index c57fb4064..8824c3035 100644 --- a/websiteFunctions/templates/websiteFunctions/BackupfileConfig.html +++ b/websiteFunctions/templates/websiteFunctions/BackupfileConfig.html @@ -27,6 +27,7 @@ + @@ -86,6 +87,10 @@ ID Schedule Name + Backup Frequency + Backup File Retention + + Last Run Remote Configuration Action @@ -97,6 +102,9 @@ {{ sub.id }} {{ sub.Name }} + {{ sub.Frequency }} + {{ sub.Retention }} + {{ sub.LastRun }} {{ sub.RemoteConfiguration }} + Add WordPress Sites @@ -117,6 +130,68 @@ + + diff --git a/websiteFunctions/urls.py b/websiteFunctions/urls.py index 9d812686a..6a97fe0df 100755 --- a/websiteFunctions/urls.py +++ b/websiteFunctions/urls.py @@ -52,6 +52,7 @@ urlpatterns = [ url(r'^SaveBackupConfig', views.SaveBackupConfig, name='SaveBackupConfig'), url(r'^SaveBackupSchedule', views.SaveBackupSchedule, name='SaveBackupSchedule'), url(r'^AddWPsiteforRemoteBackup', views.AddWPsiteforRemoteBackup, name='AddWPsiteforRemoteBackup'), + url(r'^UpdateRemoteschedules', views.UpdateRemoteschedules, name='UpdateRemoteschedules'), diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py index 96bc48d33..7c93504c0 100755 --- a/websiteFunctions/views.py +++ b/websiteFunctions/views.py @@ -502,6 +502,27 @@ def AddWPsiteforRemoteBackup(request): return redirect(loadLoginPage) +def UpdateRemoteschedules(request): + try: + userID = request.session['userID'] + + result = pluginManager.preWebsiteCreation(request) + if result != 200: + return result + + wm = WebsiteManager() + coreResult = wm.UpdateRemoteschedules(userID, json.loads(request.body)) + + result = pluginManager.postWebsiteCreation(request, coreResult) + if result != 200: + return result + + return coreResult + + except KeyError: + return redirect(loadLoginPage) + + def installwpcore(request): try: userID = request.session['userID'] diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 30799a0eb..928e471c4 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -254,10 +254,15 @@ class WebsiteManager: allsechedule = RemoteBackupSchedule.objects.filter(RemoteBackupConfig=RemoteConfigobj) Data['Backupschedule'] = [] for i in allsechedule: + lastrun = i.lastrun + LastRun = time.strftime('%Y-%m-%d', time.localtime(float(lastrun))) Data['Backupschedule'].append({ 'id': i.pk, 'Name': i.Name, - 'RemoteConfiguration': i.RemoteBackupConfig.configtype + 'RemoteConfiguration': i.RemoteBackupConfig.configtype, + 'Retention': i.fileretention, + 'Frequency': i.timeintervel, + 'LastRun': LastRun }) proc = httpProc(request, 'websiteFunctions/BackupfileConfig.html', Data, 'createWebsite') @@ -1241,6 +1246,30 @@ class WebsiteManager: return HttpResponse(json_data) + def UpdateRemoteschedules(self, userID=None, data=None): + try: + + currentACL = ACLManager.loadedACL(userID) + admin = Administrator.objects.get(pk=userID) + ScheduleID = data['ScheduleID'] + Frequency = data['Frequency'] + FileRetention = data['FileRetention'] + + scheduleobj = RemoteBackupSchedule.objects.get(pk=ScheduleID) + scheduleobj.timeintervel = Frequency + scheduleobj.fileretention = FileRetention + scheduleobj.save() + + data_ret = {'status': 1, 'error_message': 'None',} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException as msg: + data_ret = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + def installwpcore(self, userID=None, data=None): try: