mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-12 16:26:12 +01:00
further refoctor default render mailserver
This commit is contained in:
@@ -6,8 +6,6 @@ from pathlib import Path
|
|||||||
from random import randint
|
from random import randint
|
||||||
|
|
||||||
from django.shortcuts import HttpResponse, redirect
|
from django.shortcuts import HttpResponse, redirect
|
||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
from loginSystem.models import Administrator
|
from loginSystem.models import Administrator
|
||||||
from loginSystem.views import loadLoginPage
|
from loginSystem.views import loadLoginPage
|
||||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||||
|
|||||||
@@ -58,53 +58,42 @@ class MailServerManager(multi.Thread):
|
|||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [MailServerManager.run]')
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [MailServerManager.run]')
|
||||||
|
|
||||||
def loadEmailHome(self):
|
def loadEmailHome(self):
|
||||||
try:
|
proc = httpProc(self.request, 'mailServer/index.html',
|
||||||
proc = httpProc(self.request, 'mailServer/index.html',
|
None, 'createEmail')
|
||||||
None, 'createEmail')
|
return proc.render()
|
||||||
return proc.render()
|
|
||||||
except KeyError:
|
|
||||||
return redirect(loadLoginPage)
|
|
||||||
|
|
||||||
|
|
||||||
def createEmailAccount(self):
|
def createEmailAccount(self):
|
||||||
try:
|
userID = self.request.session['userID']
|
||||||
userID = self.request.session['userID']
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
|
||||||
|
|
||||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
|
||||||
proc = httpProc(self.request, 'mailServer/createEmailAccount.html',
|
|
||||||
{ "status": 0}, 'createEmail')
|
|
||||||
return proc.render()
|
|
||||||
|
|
||||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
|
||||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
|
||||||
|
|
||||||
|
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||||
proc = httpProc(self.request, 'mailServer/createEmailAccount.html',
|
proc = httpProc(self.request, 'mailServer/createEmailAccount.html',
|
||||||
{'websiteList': websitesName, "status": 1}, 'createEmail')
|
{"status": 0}, 'createEmail')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
|
|
||||||
except BaseException as msg:
|
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||||
return redirect(loadLoginPage)
|
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||||
|
|
||||||
|
proc = httpProc(self.request, 'mailServer/createEmailAccount.html',
|
||||||
|
{'websiteList': websitesName, "status": 1}, 'createEmail')
|
||||||
|
return proc.render()
|
||||||
|
|
||||||
def listEmails(self):
|
def listEmails(self):
|
||||||
try:
|
userID = self.request.session['userID']
|
||||||
userID = self.request.session['userID']
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
|
||||||
|
|
||||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
|
||||||
proc = httpProc(self.request, 'mailServer/listEmails.html',
|
|
||||||
{ "status": 0}, 'listEmails')
|
|
||||||
return proc.render()
|
|
||||||
|
|
||||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
|
||||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
|
||||||
|
|
||||||
|
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||||
proc = httpProc(self.request, 'mailServer/listEmails.html',
|
proc = httpProc(self.request, 'mailServer/listEmails.html',
|
||||||
{'websiteList': websitesName, "status": 1}, 'listEmails')
|
{"status": 0}, 'listEmails')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
|
|
||||||
except BaseException as msg:
|
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||||
return redirect(loadLoginPage)
|
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||||
|
|
||||||
|
proc = httpProc(self.request, 'mailServer/listEmails.html',
|
||||||
|
{'websiteList': websitesName, "status": 1}, 'listEmails')
|
||||||
|
return proc.render()
|
||||||
|
|
||||||
def submitEmailCreation(self):
|
def submitEmailCreation(self):
|
||||||
try:
|
try:
|
||||||
@@ -148,26 +137,20 @@ class MailServerManager(multi.Thread):
|
|||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
def deleteEmailAccount(self):
|
def deleteEmailAccount(self):
|
||||||
try:
|
userID = self.request.session['userID']
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
userID = self.request.session['userID']
|
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
|
||||||
|
|
||||||
|
|
||||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
|
||||||
proc = httpProc(self.request, 'mailServer/deleteEmailAccount.html',
|
|
||||||
{ "status": 0}, 'deleteEmail')
|
|
||||||
return proc.render()
|
|
||||||
|
|
||||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
|
||||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
|
||||||
|
|
||||||
|
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||||
proc = httpProc(self.request, 'mailServer/deleteEmailAccount.html',
|
proc = httpProc(self.request, 'mailServer/deleteEmailAccount.html',
|
||||||
{'websiteList': websitesName, "status": 1}, 'deleteEmail')
|
{"status": 0}, 'deleteEmail')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
|
|
||||||
except BaseException as msg:
|
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||||
return redirect(loadLoginPage)
|
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||||
|
|
||||||
|
proc = httpProc(self.request, 'mailServer/deleteEmailAccount.html',
|
||||||
|
{'websiteList': websitesName, "status": 1}, 'deleteEmail')
|
||||||
|
return proc.render()
|
||||||
|
|
||||||
def getEmailsForDomain(self):
|
def getEmailsForDomain(self):
|
||||||
try:
|
try:
|
||||||
@@ -292,23 +275,20 @@ class MailServerManager(multi.Thread):
|
|||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
def emailForwarding(self):
|
def emailForwarding(self):
|
||||||
try:
|
userID = self.request.session['userID']
|
||||||
userID = self.request.session['userID']
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
|
||||||
|
|
||||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
|
||||||
proc = httpProc(self.request, 'mailServer/emailForwarding.html',
|
|
||||||
{ "status": 0}, 'emailForwarding')
|
|
||||||
return proc.render()
|
|
||||||
|
|
||||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
|
||||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
|
||||||
|
|
||||||
|
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||||
proc = httpProc(self.request, 'mailServer/emailForwarding.html',
|
proc = httpProc(self.request, 'mailServer/emailForwarding.html',
|
||||||
{'websiteList': websitesName, "status": 1}, 'emailForwarding')
|
{"status": 0}, 'emailForwarding')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
except BaseException as msg:
|
|
||||||
return redirect(loadLoginPage)
|
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||||
|
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||||
|
|
||||||
|
proc = httpProc(self.request, 'mailServer/emailForwarding.html',
|
||||||
|
{'websiteList': websitesName, "status": 1}, 'emailForwarding')
|
||||||
|
return proc.render()
|
||||||
|
|
||||||
def fetchCurrentForwardings(self):
|
def fetchCurrentForwardings(self):
|
||||||
try:
|
try:
|
||||||
@@ -582,26 +562,20 @@ class MailServerManager(multi.Thread):
|
|||||||
#######
|
#######
|
||||||
|
|
||||||
def changeEmailAccountPassword(self):
|
def changeEmailAccountPassword(self):
|
||||||
try:
|
userID = self.request.session['userID']
|
||||||
userID = self.request.session['userID']
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
|
||||||
|
|
||||||
if ACLManager.currentContextPermission(currentACL, 'changeEmailPassword') == 0:
|
|
||||||
return ACLManager.loadError()
|
|
||||||
|
|
||||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
|
||||||
proc = httpProc(self.request, 'mailServer/changeEmailPassword.html',
|
|
||||||
{"status": 0}, 'changeEmailPassword')
|
|
||||||
return proc.render()
|
|
||||||
|
|
||||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
|
||||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
|
||||||
|
|
||||||
|
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||||
proc = httpProc(self.request, 'mailServer/changeEmailPassword.html',
|
proc = httpProc(self.request, 'mailServer/changeEmailPassword.html',
|
||||||
{'websiteList': websitesName, "status": 1}, 'changeEmailPassword')
|
{"status": 0}, 'changeEmailPassword')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
except BaseException as msg:
|
|
||||||
return redirect(loadLoginPage)
|
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||||
|
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||||
|
|
||||||
|
proc = httpProc(self.request, 'mailServer/changeEmailPassword.html',
|
||||||
|
{'websiteList': websitesName, "status": 1}, 'changeEmailPassword')
|
||||||
|
return proc.render()
|
||||||
|
|
||||||
def submitPasswordChange(self):
|
def submitPasswordChange(self):
|
||||||
try:
|
try:
|
||||||
@@ -653,24 +627,17 @@ class MailServerManager(multi.Thread):
|
|||||||
#######
|
#######
|
||||||
|
|
||||||
def dkimManager(self):
|
def dkimManager(self):
|
||||||
try:
|
userID = self.request.session['userID']
|
||||||
userID = self.request.session['userID']
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
|
||||||
|
|
||||||
if ACLManager.currentContextPermission(currentACL, 'dkimManager') == 0:
|
openDKIMInstalled = 1
|
||||||
return ACLManager.loadError()
|
|
||||||
|
|
||||||
openDKIMInstalled = 1
|
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||||
|
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||||
|
|
||||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
proc = httpProc(self.request, 'mailServer/dkimManager.html',
|
||||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
{'websiteList': websitesName, 'openDKIMInstalled': openDKIMInstalled}, 'dkimManager')
|
||||||
|
return proc.render()
|
||||||
proc = httpProc(self.request, 'mailServer/dkimManager.html',
|
|
||||||
{'websiteList': websitesName, 'openDKIMInstalled': openDKIMInstalled}, 'dkimManager')
|
|
||||||
return proc.render()
|
|
||||||
|
|
||||||
except BaseException as msg:
|
|
||||||
return redirect(loadLoginPage)
|
|
||||||
|
|
||||||
def fetchDKIMKeys(self):
|
def fetchDKIMKeys(self):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user