mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 21:35:55 +01:00
combine robert changes
This commit is contained in:
@@ -13,6 +13,8 @@ from mailServer.mailserverManager import MailServerManager
|
|||||||
from ftp.ftpManager import FTPManager
|
from ftp.ftpManager import FTPManager
|
||||||
from manageSSL.views import issueSSL
|
from manageSSL.views import issueSSL
|
||||||
from plogical.backupManager import BackupManager
|
from plogical.backupManager import BackupManager
|
||||||
|
import userManagment.views as um
|
||||||
|
from packages.packagesManager import PackagesManager
|
||||||
|
|
||||||
class CloudManager:
|
class CloudManager:
|
||||||
|
|
||||||
@@ -729,4 +731,321 @@ class CloudManager:
|
|||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
return self.ajaxPre(0, str(msg))
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchACLs(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
|
||||||
|
userID = admin.pk
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
|
||||||
|
if currentACL['admin'] == 1:
|
||||||
|
aclNames = ACLManager.unFileteredACLs()
|
||||||
|
elif currentACL['changeUserACL'] == 1:
|
||||||
|
aclNames = ACLManager.unFileteredACLs()
|
||||||
|
elif currentACL['createNewUser'] == 1:
|
||||||
|
aclNames = ['user']
|
||||||
|
else:
|
||||||
|
return ACLManager.loadError()
|
||||||
|
|
||||||
|
json_data = "["
|
||||||
|
checker = 0
|
||||||
|
|
||||||
|
for items in aclNames:
|
||||||
|
dic = {'acl': items}
|
||||||
|
|
||||||
|
if checker == 0:
|
||||||
|
json_data = json_data + json.dumps(dic)
|
||||||
|
checker = 1
|
||||||
|
else:
|
||||||
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
|
json_data = json_data + ']'
|
||||||
|
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
|
||||||
|
return HttpResponse(final_json)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitUserCreation(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['serverUserName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
return um.submitUserCreation(request)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchUsers(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['serverUserName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
|
||||||
|
userID = admin.pk
|
||||||
|
allUsers = ACLManager.loadUserObjects(userID)
|
||||||
|
|
||||||
|
json_data = "["
|
||||||
|
checker = 0
|
||||||
|
|
||||||
|
for user in allUsers:
|
||||||
|
dic = {
|
||||||
|
"id": user.id,
|
||||||
|
"userName": user.userName,
|
||||||
|
"firstName": user.firstName,
|
||||||
|
"lastName": user.lastName,
|
||||||
|
"email": user.email,
|
||||||
|
"acl": user.acl.name,
|
||||||
|
"websitesLimit": user.initWebsitesLimit
|
||||||
|
}
|
||||||
|
|
||||||
|
if checker == 0:
|
||||||
|
json_data = json_data + json.dumps(dic)
|
||||||
|
checker = 1
|
||||||
|
else:
|
||||||
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
|
json_data = json_data + ']'
|
||||||
|
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
|
||||||
|
return HttpResponse(final_json)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitUserDeletion(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['serverUserName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
return um.submitUserDeletion(request)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def saveModificationsUser(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['serverUserName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
return um.saveModifications(request)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def userWithResellerPriv(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['serverUserName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
|
||||||
|
userID = admin.pk
|
||||||
|
allUsers = ACLManager.userWithResellerPriv(userID)
|
||||||
|
|
||||||
|
json_data = "["
|
||||||
|
checker = 0
|
||||||
|
|
||||||
|
for user in allUsers:
|
||||||
|
dic = {
|
||||||
|
"userName": user,
|
||||||
|
}
|
||||||
|
|
||||||
|
if checker == 0:
|
||||||
|
json_data = json_data + json.dumps(dic)
|
||||||
|
checker = 1
|
||||||
|
else:
|
||||||
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
|
json_data = json_data + ']'
|
||||||
|
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
|
||||||
|
return HttpResponse(final_json)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def saveResellerChanges(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['serverUserName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
return um.saveResellerChanges(request)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def changeACLFunc(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['serverUserName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
return um.changeACLFunc(request)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def createACLFunc(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['serverUserName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
return um.createACLFunc(request)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def findAllACLs(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['serverUserName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
|
||||||
|
userID = admin.pk
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
|
||||||
|
if currentACL['admin'] == 1:
|
||||||
|
aclNames = ACLManager.findAllACLs()
|
||||||
|
else:
|
||||||
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
|
json_data = "["
|
||||||
|
checker = 0
|
||||||
|
|
||||||
|
for items in aclNames:
|
||||||
|
dic = {'acl': items}
|
||||||
|
|
||||||
|
if checker == 0:
|
||||||
|
json_data = json_data + json.dumps(dic)
|
||||||
|
checker = 1
|
||||||
|
else:
|
||||||
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
|
json_data = json_data + ']'
|
||||||
|
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
|
||||||
|
return HttpResponse(final_json)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def deleteACLFunc(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['serverUserName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
return um.deleteACLFunc(request)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchACLDetails(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['serverUserName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
return um.fetchACLDetails(request)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitACLModifications(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['serverUserName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
return um.submitACLModifications(request)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitPackage(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['serverUserName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
pm = PackagesManager(request)
|
||||||
|
return pm.submitPackage()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,34 @@ def router(request):
|
|||||||
return cm.getCurrentBackups()
|
return cm.getCurrentBackups()
|
||||||
elif controller == 'deleteBackup':
|
elif controller == 'deleteBackup':
|
||||||
return cm.deleteBackup()
|
return cm.deleteBackup()
|
||||||
|
elif controller == 'fetchACLs':
|
||||||
|
return cm.fetchACLs()
|
||||||
|
elif controller == 'submitUserCreation':
|
||||||
|
return cm.submitUserCreation(request)
|
||||||
|
elif controller == 'fetchUsers':
|
||||||
|
return cm.fetchUsers()
|
||||||
|
elif controller == 'submitUserDeletion':
|
||||||
|
return cm.submitUserDeletion(request)
|
||||||
|
elif controller == 'saveModificationsUser':
|
||||||
|
return cm.saveModificationsUser(request)
|
||||||
|
elif controller == 'userWithResellerPriv':
|
||||||
|
return cm.userWithResellerPriv()
|
||||||
|
elif controller == 'saveResellerChanges':
|
||||||
|
return cm.saveResellerChanges(request)
|
||||||
|
elif controller == 'changeACLFunc':
|
||||||
|
return cm.changeACLFunc(request)
|
||||||
|
elif controller == 'createACLFunc':
|
||||||
|
return cm.createACLFunc(request)
|
||||||
|
elif controller == 'findAllACLs':
|
||||||
|
return cm.findAllACLs(request)
|
||||||
|
elif controller == 'deleteACLFunc':
|
||||||
|
return cm.deleteACLFunc(request)
|
||||||
|
elif controller == 'fetchACLDetails':
|
||||||
|
return cm.fetchACLDetails(request)
|
||||||
|
elif controller == 'submitACLModifications':
|
||||||
|
return cm.submitACLModifications(request)
|
||||||
|
elif controller == 'submitPackage':
|
||||||
|
return cm.submitPackage(request)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
cm = CloudManager(None)
|
cm = CloudManager(None)
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
import sys
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
|
||||||
import installLog as logging
|
|
||||||
import argparse
|
|
||||||
import os
|
|
||||||
import shlex
|
import shlex
|
||||||
import socket
|
|
||||||
|
|
||||||
class FirewallUtilities:
|
class FirewallUtilities:
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -69,6 +69,10 @@ class PackagesManager:
|
|||||||
ftpAccounts = int(data['ftpAccounts'])
|
ftpAccounts = int(data['ftpAccounts'])
|
||||||
emails = int(data['emails'])
|
emails = int(data['emails'])
|
||||||
allowedDomains = int(data['allowedDomains'])
|
allowedDomains = int(data['allowedDomains'])
|
||||||
|
try:
|
||||||
|
api = data['api']
|
||||||
|
except:
|
||||||
|
api = '0'
|
||||||
|
|
||||||
if packageSpace < 0 or packageBandwidth < 0 or packageDatabases < 0 or ftpAccounts < 0 or emails < 0 or allowedDomains < 0:
|
if packageSpace < 0 or packageBandwidth < 0 or packageDatabases < 0 or ftpAccounts < 0 or emails < 0 or allowedDomains < 0:
|
||||||
data_ret = {'saveStatus': 0, 'error_message': "All values should be positive or 0."}
|
data_ret = {'saveStatus': 0, 'error_message': "All values should be positive or 0."}
|
||||||
@@ -77,6 +81,7 @@ class PackagesManager:
|
|||||||
|
|
||||||
admin = Administrator.objects.get(pk=userID)
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
|
if api == '0':
|
||||||
packageName = admin.userName + "_" + packageName
|
packageName = admin.userName + "_" + packageName
|
||||||
|
|
||||||
package = Package(admin=admin, packageName=packageName, diskSpace=packageSpace,
|
package = Package(admin=admin, packageName=packageName, diskSpace=packageSpace,
|
||||||
@@ -85,12 +90,12 @@ class PackagesManager:
|
|||||||
|
|
||||||
package.save()
|
package.save()
|
||||||
|
|
||||||
data_ret = {'saveStatus': 1, 'error_message': "None"}
|
data_ret = {'status': 1, 'saveStatus': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|||||||
@@ -230,6 +230,24 @@ class ACLManager:
|
|||||||
adminNames.append(admin.userName)
|
adminNames.append(admin.userName)
|
||||||
return adminNames
|
return adminNames
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def loadUserObjects(userID):
|
||||||
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
adminObjects = []
|
||||||
|
|
||||||
|
finalResponse = ACLManager.loadedACL(userID)
|
||||||
|
|
||||||
|
if finalResponse['admin'] == 1:
|
||||||
|
return Administrator.objects.all()
|
||||||
|
else:
|
||||||
|
admins = Administrator.objects.filter(owner=admin.pk)
|
||||||
|
for items in admins:
|
||||||
|
adminObjects.append(items)
|
||||||
|
|
||||||
|
adminObjects.append(admin)
|
||||||
|
|
||||||
|
return adminObjects
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def loadDeletionUsers(userID, finalResponse):
|
def loadDeletionUsers(userID, finalResponse):
|
||||||
admin = Administrator.objects.get(pk=userID)
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|||||||
@@ -1,33 +1,35 @@
|
|||||||
import sys
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
|
||||||
import CyberCPLogFileWriter as logging
|
import CyberCPLogFileWriter as logging
|
||||||
import argparse
|
|
||||||
import os
|
|
||||||
import shlex
|
import shlex
|
||||||
import socket
|
from processUtilities import ProcessUtilities
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FirewallUtilities:
|
class FirewallUtilities:
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def resFailed(res):
|
||||||
|
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu and res != 0:
|
||||||
|
return True
|
||||||
|
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos and res == 1:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def doCommand(command):
|
def doCommand(command):
|
||||||
import install as inst
|
|
||||||
try:
|
try:
|
||||||
cmd = shlex.split(command)
|
cmd = shlex.split(command)
|
||||||
res = subprocess.call(cmd)
|
res = subprocess.call(cmd)
|
||||||
if inst.preFlightsChecks.resFailed(inst.get_distro(), res):
|
if FirewallUtilities.resFailed(res):
|
||||||
inst.preFlightsChecks.stdOut("Failed to apply rule: " + command + " Error #" + str(res), 1)
|
logging.CyberCPLogFileWriter.writeToFile("Failed to apply rule: " + command + " Error #" + str(res))
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
except OSError, msg:
|
except OSError, msg:
|
||||||
inst.preFlightsChecks.stdOut("Failed to apply rule: " + command + " Error: " + str(msg), 1)
|
logging.CyberCPLogFileWriter.writeToFile("Failed to apply rule: " + command + " Error: " + str(msg))
|
||||||
return 0
|
return 0
|
||||||
except ValueError, msg:
|
except ValueError, msg:
|
||||||
inst.preFlightsChecks.stdOut("Failed to apply rule: " + command + " Error: " + str(msg), 1)
|
logging.CyberCPLogFileWriter.writeToFile("Failed to apply rule: " + command + " Error: " + str(msg), 1)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
@@ -41,7 +43,7 @@ class FirewallUtilities:
|
|||||||
|
|
||||||
command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
||||||
|
|
||||||
if not FirewallUtilities.doComamnd(command):
|
if not FirewallUtilities.doCommand(command):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
ruleFamily = 'rule family="ipv6"'
|
ruleFamily = 'rule family="ipv6"'
|
||||||
@@ -49,12 +51,12 @@ class FirewallUtilities:
|
|||||||
|
|
||||||
command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
||||||
|
|
||||||
if not FirewallUtilities.doComamnd(command):
|
if not FirewallUtilities.doCommand(command):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
command = 'sudo firewall-cmd --reload'
|
command = 'sudo firewall-cmd --reload'
|
||||||
|
|
||||||
if not FirewallUtilities.doComamnd(command):
|
if not FirewallUtilities.doCommand(command):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
@@ -68,7 +70,7 @@ class FirewallUtilities:
|
|||||||
|
|
||||||
command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
||||||
|
|
||||||
if not FirewallUtilities.doComamnd(command):
|
if not FirewallUtilities.doCommand(command):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
ruleFamily = 'rule family="ipv6"'
|
ruleFamily = 'rule family="ipv6"'
|
||||||
@@ -76,12 +78,12 @@ class FirewallUtilities:
|
|||||||
|
|
||||||
command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
||||||
|
|
||||||
if not FirewallUtilities.doComamnd(command):
|
if not FirewallUtilities.doCommand(command):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
command = 'sudo firewall-cmd --reload'
|
command = 'sudo firewall-cmd --reload'
|
||||||
|
|
||||||
if not FirewallUtilities.doComamnd(command):
|
if not FirewallUtilities.doCommand(command):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
@@ -1268,9 +1268,6 @@ app.controller('modifyACLCtrl', function($scope,$http) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
/* Java script code to create acl ends here */
|
/* Java script code to create acl ends here */
|
||||||
|
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
{% block title %}{% trans "Create new ACL - CyberPanel" %}{% endblock %}
|
{% block title %}{% trans "Create new ACL - CyberPanel" %}{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% get_current_language as LANGUAGE_CODE %}
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div id="page-title">
|
<div id="page-title">
|
||||||
<h2>{% trans "Create New ACL" %}</h2>
|
<h2>{% trans "Create New ACL" %}</h2>
|
||||||
<p>{% trans "Create new Access Control defination, that specifies what CyberPanel users can do." %}</p>
|
<p>{% trans "Create new Access Control defination, that specifies what CyberPanel users can do." %}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div ng-controller="createACLCTRL" class="panel-body">
|
<div ng-controller="createACLCTRL" class="panel-body">
|
||||||
<h3 class="title-hero">
|
<h3 class="title-hero">
|
||||||
{% trans "ACL Details" %}
|
{% trans "ACL Details" %}
|
||||||
@@ -27,7 +27,8 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "ACL Name" %}</label>
|
<label class="col-sm-3 control-label">{% trans "ACL Name" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input placeholder="E.g support" type="text" class="form-control" ng-model="aclName" required>
|
<input placeholder="E.g support" type="text" class="form-control" ng-model="aclName"
|
||||||
|
required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -352,7 +353,7 @@
|
|||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
<input ng-model="scheDuleBackups" type="checkbox" value="">
|
<input ng-model="scheDuleBackups" type="checkbox" value="">
|
||||||
{% trans "Achedule Back up" %}
|
{% trans "Schedule Back up" %}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -402,22 +403,21 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label"></label>
|
<label class="col-sm-3 control-label"></label>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<button type="button" ng-click="createACLFunc()" class="btn btn-primary btn-lg btn-block">{% trans "Create ACL" %} <img ng-hide="aclLoading" src="{% static 'images/loading.gif' %}"></button>
|
<button type="button" ng-click="createACLFunc()"
|
||||||
|
class="btn btn-primary btn-lg btn-block">{% trans "Create ACL" %} <img
|
||||||
|
ng-hide="aclLoading" src="{% static 'images/loading.gif' %}"></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -3,20 +3,21 @@
|
|||||||
{% block title %}{% trans "Create New User - CyberPanel" %}{% endblock %}
|
{% block title %}{% trans "Create New User - CyberPanel" %}{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% get_current_language as LANGUAGE_CODE %}
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div id="page-title">
|
<div id="page-title">
|
||||||
<h2>{% trans "Create New User" %}</h2>
|
<h2>{% trans "Create New User" %}</h2>
|
||||||
<p>{% trans "Create root, reseller or normal users on this page." %}</p>
|
<p>{% trans "Create root, reseller or normal users on this page." %}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div ng-controller="createUserCtr" class="panel-body">
|
<div ng-controller="createUserCtr" class="panel-body">
|
||||||
<h3 class="title-hero">
|
<h3 class="title-hero">
|
||||||
{% trans "User Details" %} <img ng-hide="userCreationLoading" src="{% static 'images/loading.gif' %}">
|
{% trans "User Details" %} <img ng-hide="userCreationLoading"
|
||||||
|
src="{% static 'images/loading.gif' %}">
|
||||||
</h3>
|
</h3>
|
||||||
<div class="example-box-wrapper">
|
<div class="example-box-wrapper">
|
||||||
|
|
||||||
@@ -27,18 +28,22 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "First Name" %}</label>
|
<label class="col-sm-3 control-label">{% trans "First Name" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input name="firstName" ng-pattern="/^[a-zA-Z]+$/" type="text" class="form-control" ng-model="firstName" required>
|
<input name="firstName" ng-pattern="/^[a-zA-Z]+$/" type="text" class="form-control"
|
||||||
|
ng-model="firstName" required>
|
||||||
</div>
|
</div>
|
||||||
<div ng-show="createUser.firstName.$error.pattern" class="current-pack">{% trans "First Name should contain only alphabetic characters." %}</div>
|
<div ng-show="createUser.firstName.$error.pattern"
|
||||||
|
class="current-pack">{% trans "First Name should contain only alphabetic characters." %}</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "Last Name" %}</label>
|
<label class="col-sm-3 control-label">{% trans "Last Name" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input name="lastName" ng-pattern="/^[a-zA-Z]+$/" type="text" class="form-control" ng-model="lastName" required>
|
<input name="lastName" ng-pattern="/^[a-zA-Z]+$/" type="text" class="form-control"
|
||||||
|
ng-model="lastName" required>
|
||||||
</div>
|
</div>
|
||||||
<div ng-show="createUser.lastName.$error.pattern" class="current-pack">{% trans "Last Name should contain only alphabetic characters." %}</div>
|
<div ng-show="createUser.lastName.$error.pattern"
|
||||||
|
class="current-pack">{% trans "Last Name should contain only alphabetic characters." %}</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -48,12 +53,12 @@
|
|||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input name="email" type="email" class="form-control" ng-model="email" required>
|
<input name="email" type="email" class="form-control" ng-model="email" required>
|
||||||
</div>
|
</div>
|
||||||
<div ng-show="createUser.email.$error.email" class="current-pack">{% trans "Invalid Email" %}</div>
|
<div ng-show="createUser.email.$error.email"
|
||||||
|
class="current-pack">{% trans "Invalid Email" %}</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!------------ Account ACL ------------>
|
<!------------ Account ACL ------------>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -73,7 +78,8 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "Websites Limit" %}</label>
|
<label class="col-sm-3 control-label">{% trans "Websites Limit" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input placeholder="0 = Unlimited" type="number" class="form-control" ng-model="websitesLimits" required>
|
<input placeholder="0 = Unlimited" type="number" class="form-control"
|
||||||
|
ng-model="websitesLimits" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -85,31 +91,31 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
|
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input name="password" type="password" class="form-control" ng-model="password" required>
|
<input name="password" type="password" class="form-control" ng-model="password"
|
||||||
|
required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label"></label>
|
<label class="col-sm-3 control-label"></label>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<button type="button" ng-click="createUserFunc()" class="btn btn-primary btn-lg btn-block">{% trans "Create User" %}</button>
|
<button type="button" ng-click="createUserFunc()"
|
||||||
|
class="btn btn-primary btn-lg btn-block">{% trans "Create User" %}</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label"></label>
|
<label class="col-sm-3 control-label"></label>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<div ng-hide="userCreated" class="alert alert-success">
|
<div ng-hide="userCreated" class="alert alert-success">
|
||||||
<p>{% trans "Account with username:" %} <strong>{$ userName $}</strong> {% trans "is successfully created." %}</p>
|
<p>{% trans "Account with username:" %} <strong>{$ userName
|
||||||
|
$}</strong> {% trans "is successfully created." %}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-hide="userCreationFailed" class="alert alert-danger">
|
<div ng-hide="userCreationFailed" class="alert alert-danger">
|
||||||
@@ -125,26 +131,21 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.shortcuts import render,redirect
|
from django.shortcuts import render, redirect
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from loginSystem.views import loadLoginPage
|
from loginSystem.views import loadLoginPage
|
||||||
from loginSystem.models import Administrator, ACL
|
from loginSystem.models import Administrator, ACL
|
||||||
@@ -10,16 +10,15 @@ from plogical import hashPassword
|
|||||||
from plogical import CyberCPLogFileWriter as logging
|
from plogical import CyberCPLogFileWriter as logging
|
||||||
from plogical.acl import ACLManager
|
from plogical.acl import ACLManager
|
||||||
|
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
def loadUserHome(request):
|
def loadUserHome(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
try:
|
try:
|
||||||
|
|
||||||
admin = Administrator.objects.get(pk=val)
|
admin = Administrator.objects.get(pk=val)
|
||||||
|
return render(request, 'userManagment/index.html', {"type": admin.type})
|
||||||
return render(request, 'userManagment/index.html',{"type":admin.type})
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||||
return HttpResponse(str(msg))
|
return HttpResponse(str(msg))
|
||||||
@@ -27,6 +26,7 @@ def loadUserHome(request):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def viewProfile(request):
|
def viewProfile(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -42,10 +42,11 @@ def viewProfile(request):
|
|||||||
AdminData['email'] = admin.email
|
AdminData['email'] = admin.email
|
||||||
AdminData['accountACL'] = admin.acl.name
|
AdminData['accountACL'] = admin.acl.name
|
||||||
|
|
||||||
return render(request, 'userManagment/userProfile.html',AdminData)
|
return render(request, 'userManagment/userProfile.html', AdminData)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def createUser(request):
|
def createUser(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -53,7 +54,7 @@ def createUser(request):
|
|||||||
|
|
||||||
if currentACL['admin'] == 1:
|
if currentACL['admin'] == 1:
|
||||||
aclNames = ACLManager.unFileteredACLs()
|
aclNames = ACLManager.unFileteredACLs()
|
||||||
return render(request, 'userManagment/createUser.html', {'aclNames' : aclNames})
|
return render(request, 'userManagment/createUser.html', {'aclNames': aclNames})
|
||||||
elif currentACL['changeUserACL'] == 1:
|
elif currentACL['changeUserACL'] == 1:
|
||||||
aclNames = ACLManager.unFileteredACLs()
|
aclNames = ACLManager.unFileteredACLs()
|
||||||
return render(request, 'userManagment/createUser.html', {'aclNames': aclNames})
|
return render(request, 'userManagment/createUser.html', {'aclNames': aclNames})
|
||||||
@@ -63,10 +64,11 @@ def createUser(request):
|
|||||||
else:
|
else:
|
||||||
return ACLManager.loadError()
|
return ACLManager.loadError()
|
||||||
|
|
||||||
except BaseException,msg:
|
except BaseException, msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def submitUserCreation(request):
|
def submitUserCreation(request):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@@ -94,7 +96,7 @@ def submitUserCreation(request):
|
|||||||
currentAdmin = Administrator.objects.get(pk=userID)
|
currentAdmin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
if ACLManager.websitesLimitCheck(currentAdmin, websitesLimit) == 0:
|
if ACLManager.websitesLimitCheck(currentAdmin, websitesLimit) == 0:
|
||||||
data_ret = {'createStatus': 0,
|
data_ret = {'status': 0, 'createStatus': 0,
|
||||||
'error_message': "You've reached maximum websites limit as a reseller."}
|
'error_message': "You've reached maximum websites limit as a reseller."}
|
||||||
|
|
||||||
final_json = json.dumps(data_ret)
|
final_json = json.dumps(data_ret)
|
||||||
@@ -141,35 +143,37 @@ def submitUserCreation(request):
|
|||||||
)
|
)
|
||||||
newAdmin.save()
|
newAdmin.save()
|
||||||
else:
|
else:
|
||||||
data_ret = {'createStatus': 0,
|
data_ret = {'status': 0, 'createStatus': 0,
|
||||||
'error_message': "You are not authorized to access this resource."}
|
'error_message': "You are not authorized to access this resource."}
|
||||||
|
|
||||||
final_json = json.dumps(data_ret)
|
final_json = json.dumps(data_ret)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
data_ret = {'createStatus': 1,
|
data_ret = {'status': 1, 'createStatus': 1,
|
||||||
'error_message': "None"}
|
'error_message': "None"}
|
||||||
final_json = json.dumps(data_ret)
|
final_json = json.dumps(data_ret)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'createStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'createStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
data_ret = {'createStatus': 0, 'error_message': "Not logged in as admin",}
|
data_ret = {'status': 0, 'createStatus': 0, 'error_message': "Not logged in as admin", }
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def modifyUsers(request):
|
def modifyUsers(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
adminNames = ACLManager.loadAllUsers(userID)
|
adminNames = ACLManager.loadAllUsers(userID)
|
||||||
return render(request, 'userManagment/modifyUser.html',{"acctNames":adminNames})
|
return render(request, 'userManagment/modifyUser.html', {"acctNames": adminNames})
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def fetchUserDetails(request):
|
def fetchUserDetails(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
@@ -186,27 +190,30 @@ def fetchUserDetails(request):
|
|||||||
|
|
||||||
websitesLimit = user.initWebsitesLimit
|
websitesLimit = user.initWebsitesLimit
|
||||||
|
|
||||||
userDetails = {"firstName":firstName,
|
userDetails = {
|
||||||
|
"id": user.id,
|
||||||
|
"firstName": firstName,
|
||||||
"lastName": lastName,
|
"lastName": lastName,
|
||||||
"email": email,
|
"email": email,
|
||||||
"acl": user.acl.name,
|
"acl": user.acl.name,
|
||||||
"websitesLimit": websitesLimit}
|
"websitesLimit": websitesLimit
|
||||||
|
}
|
||||||
|
|
||||||
data_ret = {'fetchStatus': 1, 'error_message': 'None',"userDetails":userDetails}
|
data_ret = {'fetchStatus': 1, 'error_message': 'None', "userDetails": userDetails}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'fetchStatus': 0, 'error_message': str(msg)}
|
data_ret = {'fetchStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
data_ret = {'fetchStatus': 0, 'error_message': "Not logged in as admin",}
|
data_ret = {'fetchStatus': 0, 'error_message': "Not logged in as admin", }
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def saveModifications(request):
|
def saveModifications(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
@@ -231,20 +238,21 @@ def saveModifications(request):
|
|||||||
|
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
data_ret = {'saveStatus': 1, 'error_message': 'None'}
|
data_ret = {'status': 1, 'saveStatus': 1, 'error_message': 'None'}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
data_ret = {'saveStatus': 0, 'error_message': "Not logged in as admin",}
|
data_ret = {'status': 0, 'saveStatus': 0, 'error_message': "Not logged in as admin", }
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def deleteUser(request):
|
def deleteUser(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -264,6 +272,7 @@ def deleteUser(request):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def submitUserDeletion(request):
|
def submitUserDeletion(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -275,30 +284,34 @@ def submitUserDeletion(request):
|
|||||||
|
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
|
||||||
|
if accountUsername == 'admin':
|
||||||
|
data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': 'You can not delete the super user.'}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
if currentACL['admin'] == 1:
|
if currentACL['admin'] == 1:
|
||||||
user = Administrator.objects.get(userName=accountUsername)
|
user = Administrator.objects.get(userName=accountUsername)
|
||||||
user.delete()
|
user.delete()
|
||||||
|
|
||||||
data_ret = {'deleteStatus': 1, 'error_message': 'None'}
|
data_ret = {'status': 1, 'deleteStatus': 1, 'error_message': 'None'}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
else:
|
else:
|
||||||
data_ret = {'deleteStatus': 1, 'error_message': 'Not enough privileges'}
|
data_ret = {'status': 0, 'deleteStatus': 1, 'error_message': 'Not enough privileges'}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'deleteStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
data_ret = {'deleteStatus': 0, 'error_message': "Not logged in as admin",}
|
data_ret = {'deleteStatus': 0, 'error_message': "Not logged in as admin", }
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def createNewACL(request):
|
def createNewACL(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -311,6 +324,7 @@ def createNewACL(request):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def createACLFunc(request):
|
def createACLFunc(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
@@ -323,85 +337,84 @@ def createACLFunc(request):
|
|||||||
## Version Management
|
## Version Management
|
||||||
|
|
||||||
newACL = ACL(name=data['aclName'],
|
newACL = ACL(name=data['aclName'],
|
||||||
adminStatus = int(data['makeAdmin']),
|
adminStatus=int(data['makeAdmin']),
|
||||||
|
|
||||||
versionManagement=int(data['versionManagement']),
|
versionManagement=int(data['versionManagement']),
|
||||||
|
|
||||||
## User Management
|
## User Management
|
||||||
createNewUser = int(data['createNewUser']),
|
createNewUser=int(data['createNewUser']),
|
||||||
resellerCenter = int(data['resellerCenter']),
|
resellerCenter=int(data['resellerCenter']),
|
||||||
deleteUser = int(data['deleteUser']),
|
deleteUser=int(data['deleteUser']),
|
||||||
changeUserACL= int(data['changeUserACL']),
|
changeUserACL=int(data['changeUserACL']),
|
||||||
|
|
||||||
## Website Management
|
## Website Management
|
||||||
|
|
||||||
createWebsite = int(data['createWebsite']),
|
createWebsite=int(data['createWebsite']),
|
||||||
modifyWebsite = int(data['modifyWebsite']),
|
modifyWebsite=int(data['modifyWebsite']),
|
||||||
suspendWebsite = int(data['suspendWebsite']),
|
suspendWebsite=int(data['suspendWebsite']),
|
||||||
deleteWebsite = int(data['deleteWebsite']),
|
deleteWebsite=int(data['deleteWebsite']),
|
||||||
|
|
||||||
## Package Management
|
## Package Management
|
||||||
|
|
||||||
createPackage = int(data['createPackage']),
|
createPackage=int(data['createPackage']),
|
||||||
deletePackage = int(data['deletePackage']),
|
deletePackage=int(data['deletePackage']),
|
||||||
modifyPackage = int(data['modifyPackage']),
|
modifyPackage=int(data['modifyPackage']),
|
||||||
|
|
||||||
## Database Management
|
## Database Management
|
||||||
|
|
||||||
createDatabase = int(data['createDatabase']),
|
createDatabase=int(data['createDatabase']),
|
||||||
deleteDatabase = int(data['deleteDatabase']),
|
deleteDatabase=int(data['deleteDatabase']),
|
||||||
listDatabases = int(data['listDatabases']),
|
listDatabases=int(data['listDatabases']),
|
||||||
|
|
||||||
## DNS Management
|
## DNS Management
|
||||||
|
|
||||||
createNameServer = int(data['createNameServer']),
|
createNameServer=int(data['createNameServer']),
|
||||||
createDNSZone = int(data['createDNSZone']),
|
createDNSZone=int(data['createDNSZone']),
|
||||||
deleteZone = int(data['deleteZone']),
|
deleteZone=int(data['deleteZone']),
|
||||||
addDeleteRecords = int(data['addDeleteRecords']),
|
addDeleteRecords=int(data['addDeleteRecords']),
|
||||||
|
|
||||||
## Email Management
|
## Email Management
|
||||||
|
|
||||||
createEmail = int(data['createEmail']),
|
createEmail=int(data['createEmail']),
|
||||||
deleteEmail = int(data['deleteEmail']),
|
deleteEmail=int(data['deleteEmail']),
|
||||||
emailForwarding = int(data['emailForwarding']),
|
emailForwarding=int(data['emailForwarding']),
|
||||||
changeEmailPassword = int(data['changeEmailPassword']),
|
changeEmailPassword=int(data['changeEmailPassword']),
|
||||||
dkimManager = int(data['dkimManager']),
|
dkimManager=int(data['dkimManager']),
|
||||||
|
|
||||||
## FTP Management
|
## FTP Management
|
||||||
|
|
||||||
createFTPAccount = int(data['createFTPAccount']),
|
createFTPAccount=int(data['createFTPAccount']),
|
||||||
deleteFTPAccount = int(data['deleteFTPAccount']),
|
deleteFTPAccount=int(data['deleteFTPAccount']),
|
||||||
listFTPAccounts = int(data['listFTPAccounts']),
|
listFTPAccounts=int(data['listFTPAccounts']),
|
||||||
|
|
||||||
## Backup Management
|
## Backup Management
|
||||||
|
|
||||||
createBackup = int(data['createBackup']),
|
createBackup=int(data['createBackup']),
|
||||||
restoreBackup = int(data['restoreBackup']),
|
restoreBackup=int(data['restoreBackup']),
|
||||||
addDeleteDestinations = int(data['addDeleteDestinations']),
|
addDeleteDestinations=int(data['addDeleteDestinations']),
|
||||||
scheDuleBackups = int(data['scheDuleBackups']),
|
scheDuleBackups=int(data['scheDuleBackups']),
|
||||||
remoteBackups = int(data['remoteBackups']),
|
remoteBackups=int(data['remoteBackups']),
|
||||||
|
|
||||||
## SSL Management
|
## SSL Management
|
||||||
|
|
||||||
manageSSL = int(data['manageSSL']),
|
manageSSL=int(data['manageSSL']),
|
||||||
hostnameSSL = int(data['hostnameSSL']),
|
hostnameSSL=int(data['hostnameSSL']),
|
||||||
mailServerSSL = int(data['mailServerSSL']),
|
mailServerSSL=int(data['mailServerSSL']),
|
||||||
)
|
)
|
||||||
newACL.save()
|
newACL.save()
|
||||||
|
|
||||||
|
finalResponse = {'status': 1}
|
||||||
|
|
||||||
finalResponse = { 'status': 1}
|
|
||||||
else:
|
else:
|
||||||
return ACLManager.loadErrorJson()
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
json_data = json.dumps(finalResponse)
|
json_data = json.dumps(finalResponse)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
finalResponse = {'status':0, 'errorMessage': str(msg)}
|
finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)}
|
||||||
json_data = json.dumps(finalResponse)
|
json_data = json.dumps(finalResponse)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def deleteACL(request):
|
def deleteACL(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -409,7 +422,7 @@ def deleteACL(request):
|
|||||||
|
|
||||||
if currentACL['admin'] == 1:
|
if currentACL['admin'] == 1:
|
||||||
aclNames = ACLManager.findAllACLs()
|
aclNames = ACLManager.findAllACLs()
|
||||||
return render(request, 'userManagment/deleteACL.html', {'aclNames' : aclNames})
|
return render(request, 'userManagment/deleteACL.html', {'aclNames': aclNames})
|
||||||
else:
|
else:
|
||||||
return ACLManager.loadError()
|
return ACLManager.loadError()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -429,17 +442,18 @@ def deleteACLFunc(request):
|
|||||||
acl.delete()
|
acl.delete()
|
||||||
finalResponse = {'status': 1}
|
finalResponse = {'status': 1}
|
||||||
else:
|
else:
|
||||||
finalResponse = {'status': 0, 'errorMesssage' : 'This ACL is currently in used by existing users.'}
|
finalResponse = {'status': 0, 'errorMesssage': 'This ACL is currently in used by existing users.', 'error_message': 'This ACL is currently in used by existing users.'}
|
||||||
else:
|
else:
|
||||||
return ACLManager.loadErrorJson()
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
json_data = json.dumps(finalResponse)
|
json_data = json.dumps(finalResponse)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
finalResponse = {'status':0, 'errorMessage': str(msg)}
|
finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)}
|
||||||
json_data = json.dumps(finalResponse)
|
json_data = json.dumps(finalResponse)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def modifyACL(request):
|
def modifyACL(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -447,12 +461,13 @@ def modifyACL(request):
|
|||||||
|
|
||||||
if currentACL['admin'] == 1:
|
if currentACL['admin'] == 1:
|
||||||
aclNames = ACLManager.findAllACLs()
|
aclNames = ACLManager.findAllACLs()
|
||||||
return render(request, 'userManagment/modifyACL.html', {'aclNames' : aclNames})
|
return render(request, 'userManagment/modifyACL.html', {'aclNames': aclNames})
|
||||||
else:
|
else:
|
||||||
return ACLManager.loadError()
|
return ACLManager.loadError()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def fetchACLDetails(request):
|
def fetchACLDetails(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
@@ -517,7 +532,6 @@ def fetchACLDetails(request):
|
|||||||
finalResponse['deleteFTPAccount'] = acl.deleteFTPAccount
|
finalResponse['deleteFTPAccount'] = acl.deleteFTPAccount
|
||||||
finalResponse['listFTPAccounts'] = acl.listFTPAccounts
|
finalResponse['listFTPAccounts'] = acl.listFTPAccounts
|
||||||
|
|
||||||
|
|
||||||
## Backup Management
|
## Backup Management
|
||||||
|
|
||||||
finalResponse['createBackup'] = acl.createBackup
|
finalResponse['createBackup'] = acl.createBackup
|
||||||
@@ -526,7 +540,6 @@ def fetchACLDetails(request):
|
|||||||
finalResponse['scheDuleBackups'] = acl.scheDuleBackups
|
finalResponse['scheDuleBackups'] = acl.scheDuleBackups
|
||||||
finalResponse['remoteBackups'] = acl.remoteBackups
|
finalResponse['remoteBackups'] = acl.remoteBackups
|
||||||
|
|
||||||
|
|
||||||
## SSL Management
|
## SSL Management
|
||||||
|
|
||||||
finalResponse['manageSSL'] = acl.manageSSL
|
finalResponse['manageSSL'] = acl.manageSSL
|
||||||
@@ -544,6 +557,7 @@ def fetchACLDetails(request):
|
|||||||
json_data = json.dumps(finalResponse)
|
json_data = json.dumps(finalResponse)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def submitACLModifications(request):
|
def submitACLModifications(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
@@ -635,18 +649,18 @@ def submitACLModifications(request):
|
|||||||
items.type = 3
|
items.type = 3
|
||||||
items.save()
|
items.save()
|
||||||
|
|
||||||
|
finalResponse = {'status': 1}
|
||||||
finalResponse = { 'status': 1}
|
|
||||||
else:
|
else:
|
||||||
finalResponse = ACLManager.loadErrorJson()
|
finalResponse = ACLManager.loadErrorJson()
|
||||||
|
|
||||||
json_data = json.dumps(finalResponse)
|
json_data = json.dumps(finalResponse)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
finalResponse = {'status':0, 'errorMessage': str(msg)}
|
finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)}
|
||||||
json_data = json.dumps(finalResponse)
|
json_data = json.dumps(finalResponse)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def changeUserACL(request):
|
def changeUserACL(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -655,7 +669,7 @@ def changeUserACL(request):
|
|||||||
if currentACL['admin'] == 1:
|
if currentACL['admin'] == 1:
|
||||||
aclNames = ACLManager.unFileteredACLs()
|
aclNames = ACLManager.unFileteredACLs()
|
||||||
userNames = ACLManager.findAllUsers()
|
userNames = ACLManager.findAllUsers()
|
||||||
return render(request, 'userManagment/changeUserACL.html', {'aclNames' : aclNames, 'usersList': userNames})
|
return render(request, 'userManagment/changeUserACL.html', {'aclNames': aclNames, 'usersList': userNames})
|
||||||
elif currentACL['changeUserACL'] == 1:
|
elif currentACL['changeUserACL'] == 1:
|
||||||
aclNames = ACLManager.unFileteredACLs()
|
aclNames = ACLManager.unFileteredACLs()
|
||||||
userNames = ACLManager.findAllUsers()
|
userNames = ACLManager.findAllUsers()
|
||||||
@@ -668,14 +682,22 @@ def changeUserACL(request):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def changeACLFunc(request):
|
def changeACLFunc(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
|
data = json.loads(request.body)
|
||||||
|
|
||||||
|
if data['selectedUser'] == 'admin':
|
||||||
|
finalResponse = {'status': 0,
|
||||||
|
'errorMessage': "Super user can not be modified.",
|
||||||
|
'error_message': "Super user can not be modified."}
|
||||||
|
json_data = json.dumps(finalResponse)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
currentACL = ACLManager.loadedACL(val)
|
currentACL = ACLManager.loadedACL(val)
|
||||||
|
|
||||||
if currentACL['admin'] == 1:
|
if currentACL['admin'] == 1:
|
||||||
data = json.loads(request.body)
|
|
||||||
selectedACL = ACL.objects.get(name=data['selectedACL'])
|
selectedACL = ACL.objects.get(name=data['selectedACL'])
|
||||||
selectedUser = Administrator.objects.get(userName=data['selectedUser'])
|
selectedUser = Administrator.objects.get(userName=data['selectedUser'])
|
||||||
|
|
||||||
@@ -684,7 +706,6 @@ def changeACLFunc(request):
|
|||||||
|
|
||||||
finalResponse = {'status': 1}
|
finalResponse = {'status': 1}
|
||||||
elif currentACL['changeUserACL'] == 1:
|
elif currentACL['changeUserACL'] == 1:
|
||||||
data = json.loads(request.body)
|
|
||||||
selectedACL = ACL.objects.get(name=data['selectedACL'])
|
selectedACL = ACL.objects.get(name=data['selectedACL'])
|
||||||
selectedUser = Administrator.objects.get(userName=data['selectedUser'])
|
selectedUser = Administrator.objects.get(userName=data['selectedUser'])
|
||||||
|
|
||||||
@@ -698,10 +719,11 @@ def changeACLFunc(request):
|
|||||||
json_data = json.dumps(finalResponse)
|
json_data = json.dumps(finalResponse)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
finalResponse = {'status':0, 'errorMessage': str(msg)}
|
finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)}
|
||||||
json_data = json.dumps(finalResponse)
|
json_data = json.dumps(finalResponse)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def resellerCenter(request):
|
def resellerCenter(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -710,11 +732,13 @@ def resellerCenter(request):
|
|||||||
if currentACL['admin'] == 1:
|
if currentACL['admin'] == 1:
|
||||||
userNames = ACLManager.loadDeletionUsers(userID, currentACL)
|
userNames = ACLManager.loadDeletionUsers(userID, currentACL)
|
||||||
resellerPrivUsers = ACLManager.userWithResellerPriv(userID)
|
resellerPrivUsers = ACLManager.userWithResellerPriv(userID)
|
||||||
return render(request, 'userManagment/resellerCenter.html', {'userToBeModified': userNames, 'resellerPrivUsers': resellerPrivUsers})
|
return render(request, 'userManagment/resellerCenter.html',
|
||||||
|
{'userToBeModified': userNames, 'resellerPrivUsers': resellerPrivUsers})
|
||||||
elif currentACL['resellerCenter'] == 1:
|
elif currentACL['resellerCenter'] == 1:
|
||||||
userNames = ACLManager.loadDeletionUsers(userID, currentACL)
|
userNames = ACLManager.loadDeletionUsers(userID, currentACL)
|
||||||
resellerPrivUsers = ACLManager.userWithResellerPriv(userID)
|
resellerPrivUsers = ACLManager.userWithResellerPriv(userID)
|
||||||
return render(request, 'userManagment/resellerCenter.html',{'userToBeModified': userNames, 'resellerPrivUsers': resellerPrivUsers})
|
return render(request, 'userManagment/resellerCenter.html',
|
||||||
|
{'userToBeModified': userNames, 'resellerPrivUsers': resellerPrivUsers})
|
||||||
else:
|
else:
|
||||||
return ACLManager.loadError()
|
return ACLManager.loadError()
|
||||||
|
|
||||||
@@ -722,17 +746,26 @@ def resellerCenter(request):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def saveResellerChanges(request):
|
def saveResellerChanges(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
|
|
||||||
|
if data['userToBeModified'] == 'admin':
|
||||||
|
finalResponse = {'status': 0,
|
||||||
|
'errorMessage': "Super user can not be modified.",
|
||||||
|
'error_message': "Super user can not be modified."}
|
||||||
|
json_data = json.dumps(finalResponse)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
userToBeModified = Administrator.objects.get(userName=data['userToBeModified'])
|
userToBeModified = Administrator.objects.get(userName=data['userToBeModified'])
|
||||||
newOwner = Administrator.objects.get(userName=data['newOwner'])
|
newOwner = Administrator.objects.get(userName=data['newOwner'])
|
||||||
|
|
||||||
if ACLManager.websitesLimitCheck(newOwner, data['websitesLimit'], userToBeModified) == 0:
|
if ACLManager.websitesLimitCheck(newOwner, data['websitesLimit'], userToBeModified) == 0:
|
||||||
finalResponse = {'status': 0,
|
finalResponse = {'status': 0,
|
||||||
'errorMessage': "You've reached maximum websites limit as a reseller."}
|
'errorMessage': "You've reached maximum websites limit as a reseller.",
|
||||||
|
'error_message': "You've reached maximum websites limit as a reseller."}
|
||||||
json_data = json.dumps(finalResponse)
|
json_data = json.dumps(finalResponse)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -744,6 +777,6 @@ def saveResellerChanges(request):
|
|||||||
json_data = json.dumps(finalResponse)
|
json_data = json.dumps(finalResponse)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
finalResponse = {'status':0, 'errorMessage': str(msg)}
|
finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)}
|
||||||
json_data = json.dumps(finalResponse)
|
json_data = json.dumps(finalResponse)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
Reference in New Issue
Block a user