diff --git a/emailPremium/static/emailPremium/emailPremium.js b/emailPremium/static/emailPremium/emailPremium.js index 450232127..48f7109fc 100755 --- a/emailPremium/static/emailPremium/emailPremium.js +++ b/emailPremium/static/emailPremium/emailPremium.js @@ -1144,6 +1144,147 @@ app.controller('mailQueue', function($scope,$http) { }; $scope.fetchMailQueue(); + + $scope.fetchMessage = function (id) { + $scope.cyberpanelLoading = false; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + id: id + }; + + dataurl = "/emailPremium/fetchMessage"; + + $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Successfully fetched.', + type: 'success' + }); + $scope.emailMessageContent = response.data.emailMessageContent; + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } + + + }; + + $scope.delete = function (type) { + $scope.cyberpanelLoading = false; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + type: type + }; + + dataurl = "/emailPremium/delete"; + + $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Successfully deleted.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } + + + }; + + $scope.flushQueue = function () { + $scope.cyberpanelLoading = false; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + }; + + dataurl = "/emailPremium/flushQueue"; + + $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Delivery scheduled.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } + + + }; }); /* Java script code to manage mail queue ends here */ \ No newline at end of file diff --git a/emailPremium/templates/emailPremium/mailQueue.html b/emailPremium/templates/emailPremium/mailQueue.html index 73135a0c5..78c9600df 100755 --- a/emailPremium/templates/emailPremium/mailQueue.html +++ b/emailPremium/templates/emailPremium/mailQueue.html @@ -26,7 +26,7 @@
-
+ - {% trans 'Refresh' %} + + + + +
@@ -51,7 +57,8 @@ - + + @@ -62,51 +69,79 @@ - - --> + View Message + +
Size Sender RecipientsTimeDeliver
- - - -
-
-
-
-
-
-
-
- -
-
-
-
-
- +
+
+ diff --git a/emailPremium/urls.py b/emailPremium/urls.py index 5526113c8..50bff1050 100755 --- a/emailPremium/urls.py +++ b/emailPremium/urls.py @@ -35,6 +35,9 @@ urlpatterns = [ url(r'^savePolicyServerStatus$', views.savePolicyServerStatus, name='savePolicyServerStatus'), url(r'^mailQueue$', views.mailQueue, name='mailQueue'), url(r'^fetchMailQueue$', views.fetchMailQueue, name='fetchMailQueue'), + url(r'^fetchMessage$', views.fetchMessage, name='fetchMessage'), + url(r'^flushQueue$', views.flushQueue, name='flushQueue'), + url(r'^delete$', views.delete, name='delete'), url(r'^(?P(.*))$', views.emailLimits, name='emailLimits'), diff --git a/emailPremium/views.py b/emailPremium/views.py index be4e548ad..c2df2a0a1 100755 --- a/emailPremium/views.py +++ b/emailPremium/views.py @@ -1072,3 +1072,98 @@ def fetchMailQueue(request): dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) + +def fetchMessage(request): + try: + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson() + try: + + data = json.loads(request.body) + id = data['id'] + + command = 'postcat -vq %s' % (id) + emailMessageContent = ProcessUtilities.outputExecutioner(command) + + + dic = {'status': 1, 'error_message': 'None', 'emailMessageContent': emailMessageContent} + json_data = json.dumps(dic) + return HttpResponse(json_data) + + except BaseException as msg: + dic = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(dic) + return HttpResponse(json_data) + + except KeyError as msg: + dic = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(dic) + return HttpResponse(json_data) + +def flushQueue(request): + try: + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson() + try: + + command = 'postqueue -f' + ProcessUtilities.executioner(command) + + dic = {'status': 1, 'error_message': 'None'} + json_data = json.dumps(dic) + return HttpResponse(json_data) + + except BaseException as msg: + dic = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(dic) + return HttpResponse(json_data) + + except KeyError as msg: + dic = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(dic) + return HttpResponse(json_data) + +def delete(request): + try: + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson() + try: + + data = json.loads(request.body) + type = data['type'] + + if type == 'all': + command = 'postsuper -d ALL' + else: + command = 'postsuper -d ALL deferred' + + ProcessUtilities.executioner(command) + + dic = {'status': 1, 'error_message': 'None'} + json_data = json.dumps(dic) + return HttpResponse(json_data) + + except BaseException as msg: + dic = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(dic) + return HttpResponse(json_data) + + except KeyError as msg: + dic = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(dic) + return HttpResponse(json_data) \ No newline at end of file diff --git a/static/emailPremium/emailPremium.js b/static/emailPremium/emailPremium.js index 450232127..48f7109fc 100644 --- a/static/emailPremium/emailPremium.js +++ b/static/emailPremium/emailPremium.js @@ -1144,6 +1144,147 @@ app.controller('mailQueue', function($scope,$http) { }; $scope.fetchMailQueue(); + + $scope.fetchMessage = function (id) { + $scope.cyberpanelLoading = false; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + id: id + }; + + dataurl = "/emailPremium/fetchMessage"; + + $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Successfully fetched.', + type: 'success' + }); + $scope.emailMessageContent = response.data.emailMessageContent; + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } + + + }; + + $scope.delete = function (type) { + $scope.cyberpanelLoading = false; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + type: type + }; + + dataurl = "/emailPremium/delete"; + + $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Successfully deleted.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } + + + }; + + $scope.flushQueue = function () { + $scope.cyberpanelLoading = false; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + }; + + dataurl = "/emailPremium/flushQueue"; + + $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Delivery scheduled.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } + + + }; }); /* Java script code to manage mail queue ends here */ \ No newline at end of file diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 7b69a09d9..08fe0ad7e 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -4073,12 +4073,10 @@ StrictHostKeyChecking no try: web = Websites.objects.get(domain=self.domain) self.web = web - externalApp = web.externalApp self.folder = '/home/%s/public_html' % (domain) self.masterDomain = domain except: web = ChildDomains.objects.get(domain=self.domain) - externalApp = web.master.externalApp self.folder = web.path self.masterDomain = web.master.domain self.web = web.master