mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 13:25:51 +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 manageSSL.views import issueSSL
|
||||
from plogical.backupManager import BackupManager
|
||||
import userManagment.views as um
|
||||
from packages.packagesManager import PackagesManager
|
||||
|
||||
class CloudManager:
|
||||
|
||||
@@ -729,4 +731,321 @@ class CloudManager:
|
||||
except BaseException, 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()
|
||||
elif controller == '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:
|
||||
cm = CloudManager(None)
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
import installLog as logging
|
||||
import argparse
|
||||
import os
|
||||
import shlex
|
||||
import socket
|
||||
|
||||
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'])
|
||||
emails = int(data['emails'])
|
||||
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:
|
||||
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)
|
||||
|
||||
if api == '0':
|
||||
packageName = admin.userName + "_" + packageName
|
||||
|
||||
package = Package(admin=admin, packageName=packageName, diskSpace=packageSpace,
|
||||
@@ -85,12 +90,12 @@ class PackagesManager:
|
||||
|
||||
package.save()
|
||||
|
||||
data_ret = {'saveStatus': 1, 'error_message': "None"}
|
||||
data_ret = {'status': 1, 'saveStatus': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
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)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
@@ -230,6 +230,24 @@ class ACLManager:
|
||||
adminNames.append(admin.userName)
|
||||
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
|
||||
def loadDeletionUsers(userID, finalResponse):
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
@@ -1,33 +1,35 @@
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
import CyberCPLogFileWriter as logging
|
||||
import argparse
|
||||
import os
|
||||
import shlex
|
||||
import socket
|
||||
from processUtilities import ProcessUtilities
|
||||
|
||||
|
||||
|
||||
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
|
||||
def doCommand(command):
|
||||
import install as inst
|
||||
try:
|
||||
cmd = shlex.split(command)
|
||||
res = subprocess.call(cmd)
|
||||
if inst.preFlightsChecks.resFailed(inst.get_distro(), res):
|
||||
inst.preFlightsChecks.stdOut("Failed to apply rule: " + command + " Error #" + str(res), 1)
|
||||
if FirewallUtilities.resFailed(res):
|
||||
logging.CyberCPLogFileWriter.writeToFile("Failed to apply rule: " + command + " Error #" + str(res))
|
||||
return 0
|
||||
|
||||
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
|
||||
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 1
|
||||
|
||||
|
||||
@@ -41,7 +43,7 @@ class FirewallUtilities:
|
||||
|
||||
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
|
||||
|
||||
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'"
|
||||
|
||||
if not FirewallUtilities.doComamnd(command):
|
||||
if not FirewallUtilities.doCommand(command):
|
||||
return 0
|
||||
|
||||
command = 'sudo firewall-cmd --reload'
|
||||
|
||||
if not FirewallUtilities.doComamnd(command):
|
||||
if not FirewallUtilities.doCommand(command):
|
||||
return 0
|
||||
|
||||
return 1
|
||||
@@ -68,7 +70,7 @@ class FirewallUtilities:
|
||||
|
||||
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
|
||||
|
||||
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'"
|
||||
|
||||
if not FirewallUtilities.doComamnd(command):
|
||||
if not FirewallUtilities.doCommand(command):
|
||||
return 0
|
||||
|
||||
command = 'sudo firewall-cmd --reload'
|
||||
|
||||
if not FirewallUtilities.doComamnd(command):
|
||||
if not FirewallUtilities.doCommand(command):
|
||||
return 0
|
||||
|
||||
return 1
|
||||
@@ -1268,9 +1268,6 @@ app.controller('modifyACLCtrl', function($scope,$http) {
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
/* Java script code to create acl ends here */
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
{% block title %}{% trans "Create new ACL - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Create New ACL" %}</h2>
|
||||
<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">
|
||||
<h3 class="title-hero">
|
||||
{% trans "ACL Details" %}
|
||||
@@ -27,7 +27,8 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "ACL Name" %}</label>
|
||||
<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>
|
||||
@@ -352,7 +353,7 @@
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input ng-model="scheDuleBackups" type="checkbox" value="">
|
||||
{% trans "Achedule Back up" %}
|
||||
{% trans "Schedule Back up" %}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -402,22 +403,21 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<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>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -3,20 +3,21 @@
|
||||
{% block title %}{% trans "Create New User - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Create New User" %}</h2>
|
||||
<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">
|
||||
<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>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
@@ -27,18 +28,22 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "First Name" %}</label>
|
||||
<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 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 class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Last Name" %}</label>
|
||||
<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 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>
|
||||
|
||||
@@ -48,12 +53,12 @@
|
||||
<div class="col-sm-6">
|
||||
<input name="email" type="email" class="form-control" ng-model="email" required>
|
||||
</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>
|
||||
|
||||
|
||||
|
||||
<!------------ Account ACL ------------>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -73,7 +78,8 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Websites Limit" %}</label>
|
||||
<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>
|
||||
|
||||
@@ -85,31 +91,31 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
|
||||
<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 class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<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 class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<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 ng-hide="userCreationFailed" class="alert alert-danger">
|
||||
@@ -125,26 +131,21 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.shortcuts import render,redirect
|
||||
from django.shortcuts import render, redirect
|
||||
from django.http import HttpResponse
|
||||
from loginSystem.views import loadLoginPage
|
||||
from loginSystem.models import Administrator, ACL
|
||||
@@ -10,16 +10,15 @@ from plogical import hashPassword
|
||||
from plogical import CyberCPLogFileWriter as logging
|
||||
from plogical.acl import ACLManager
|
||||
|
||||
|
||||
# Create your views here.
|
||||
|
||||
def loadUserHome(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
try:
|
||||
|
||||
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:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse(str(msg))
|
||||
@@ -27,6 +26,7 @@ def loadUserHome(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def viewProfile(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -42,10 +42,11 @@ def viewProfile(request):
|
||||
AdminData['email'] = admin.email
|
||||
AdminData['accountACL'] = admin.acl.name
|
||||
|
||||
return render(request, 'userManagment/userProfile.html',AdminData)
|
||||
return render(request, 'userManagment/userProfile.html', AdminData)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def createUser(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -53,7 +54,7 @@ def createUser(request):
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
aclNames = ACLManager.unFileteredACLs()
|
||||
return render(request, 'userManagment/createUser.html', {'aclNames' : aclNames})
|
||||
return render(request, 'userManagment/createUser.html', {'aclNames': aclNames})
|
||||
elif currentACL['changeUserACL'] == 1:
|
||||
aclNames = ACLManager.unFileteredACLs()
|
||||
return render(request, 'userManagment/createUser.html', {'aclNames': aclNames})
|
||||
@@ -63,10 +64,11 @@ def createUser(request):
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
except BaseException,msg:
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def submitUserCreation(request):
|
||||
try:
|
||||
|
||||
@@ -94,7 +96,7 @@ def submitUserCreation(request):
|
||||
currentAdmin = Administrator.objects.get(pk=userID)
|
||||
|
||||
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."}
|
||||
|
||||
final_json = json.dumps(data_ret)
|
||||
@@ -141,35 +143,37 @@ def submitUserCreation(request):
|
||||
)
|
||||
newAdmin.save()
|
||||
else:
|
||||
data_ret = {'createStatus': 0,
|
||||
data_ret = {'status': 0, 'createStatus': 0,
|
||||
'error_message': "You are not authorized to access this resource."}
|
||||
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
data_ret = {'createStatus': 1,
|
||||
data_ret = {'status': 1, 'createStatus': 1,
|
||||
'error_message': "None"}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
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)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
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)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def modifyUsers(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
adminNames = ACLManager.loadAllUsers(userID)
|
||||
return render(request, 'userManagment/modifyUser.html',{"acctNames":adminNames})
|
||||
return render(request, 'userManagment/modifyUser.html', {"acctNames": adminNames})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def fetchUserDetails(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
@@ -186,27 +190,30 @@ def fetchUserDetails(request):
|
||||
|
||||
websitesLimit = user.initWebsitesLimit
|
||||
|
||||
userDetails = {"firstName":firstName,
|
||||
userDetails = {
|
||||
"id": user.id,
|
||||
"firstName": firstName,
|
||||
"lastName": lastName,
|
||||
"email": email,
|
||||
"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)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'fetchStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
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)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def saveModifications(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
@@ -231,20 +238,21 @@ def saveModifications(request):
|
||||
|
||||
user.save()
|
||||
|
||||
data_ret = {'saveStatus': 1, 'error_message': 'None'}
|
||||
data_ret = {'status': 1, 'saveStatus': 1, 'error_message': 'None'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
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)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
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)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def deleteUser(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -264,6 +272,7 @@ def deleteUser(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def submitUserDeletion(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -275,30 +284,34 @@ def submitUserDeletion(request):
|
||||
|
||||
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:
|
||||
user = Administrator.objects.get(userName=accountUsername)
|
||||
user.delete()
|
||||
|
||||
data_ret = {'deleteStatus': 1, 'error_message': 'None'}
|
||||
data_ret = {'status': 1, 'deleteStatus': 1, 'error_message': 'None'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
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)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
|
||||
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)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
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)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def createNewACL(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -311,6 +324,7 @@ def createNewACL(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def createACLFunc(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
@@ -323,85 +337,84 @@ def createACLFunc(request):
|
||||
## Version Management
|
||||
|
||||
newACL = ACL(name=data['aclName'],
|
||||
adminStatus = int(data['makeAdmin']),
|
||||
adminStatus=int(data['makeAdmin']),
|
||||
|
||||
versionManagement=int(data['versionManagement']),
|
||||
|
||||
## User Management
|
||||
createNewUser = int(data['createNewUser']),
|
||||
resellerCenter = int(data['resellerCenter']),
|
||||
deleteUser = int(data['deleteUser']),
|
||||
changeUserACL= int(data['changeUserACL']),
|
||||
createNewUser=int(data['createNewUser']),
|
||||
resellerCenter=int(data['resellerCenter']),
|
||||
deleteUser=int(data['deleteUser']),
|
||||
changeUserACL=int(data['changeUserACL']),
|
||||
|
||||
## Website Management
|
||||
|
||||
createWebsite = int(data['createWebsite']),
|
||||
modifyWebsite = int(data['modifyWebsite']),
|
||||
suspendWebsite = int(data['suspendWebsite']),
|
||||
deleteWebsite = int(data['deleteWebsite']),
|
||||
createWebsite=int(data['createWebsite']),
|
||||
modifyWebsite=int(data['modifyWebsite']),
|
||||
suspendWebsite=int(data['suspendWebsite']),
|
||||
deleteWebsite=int(data['deleteWebsite']),
|
||||
|
||||
## Package Management
|
||||
|
||||
createPackage = int(data['createPackage']),
|
||||
deletePackage = int(data['deletePackage']),
|
||||
modifyPackage = int(data['modifyPackage']),
|
||||
createPackage=int(data['createPackage']),
|
||||
deletePackage=int(data['deletePackage']),
|
||||
modifyPackage=int(data['modifyPackage']),
|
||||
|
||||
## Database Management
|
||||
|
||||
createDatabase = int(data['createDatabase']),
|
||||
deleteDatabase = int(data['deleteDatabase']),
|
||||
listDatabases = int(data['listDatabases']),
|
||||
createDatabase=int(data['createDatabase']),
|
||||
deleteDatabase=int(data['deleteDatabase']),
|
||||
listDatabases=int(data['listDatabases']),
|
||||
|
||||
## DNS Management
|
||||
|
||||
createNameServer = int(data['createNameServer']),
|
||||
createDNSZone = int(data['createDNSZone']),
|
||||
deleteZone = int(data['deleteZone']),
|
||||
addDeleteRecords = int(data['addDeleteRecords']),
|
||||
createNameServer=int(data['createNameServer']),
|
||||
createDNSZone=int(data['createDNSZone']),
|
||||
deleteZone=int(data['deleteZone']),
|
||||
addDeleteRecords=int(data['addDeleteRecords']),
|
||||
|
||||
## Email Management
|
||||
|
||||
createEmail = int(data['createEmail']),
|
||||
deleteEmail = int(data['deleteEmail']),
|
||||
emailForwarding = int(data['emailForwarding']),
|
||||
changeEmailPassword = int(data['changeEmailPassword']),
|
||||
dkimManager = int(data['dkimManager']),
|
||||
createEmail=int(data['createEmail']),
|
||||
deleteEmail=int(data['deleteEmail']),
|
||||
emailForwarding=int(data['emailForwarding']),
|
||||
changeEmailPassword=int(data['changeEmailPassword']),
|
||||
dkimManager=int(data['dkimManager']),
|
||||
|
||||
## FTP Management
|
||||
|
||||
createFTPAccount = int(data['createFTPAccount']),
|
||||
deleteFTPAccount = int(data['deleteFTPAccount']),
|
||||
listFTPAccounts = int(data['listFTPAccounts']),
|
||||
createFTPAccount=int(data['createFTPAccount']),
|
||||
deleteFTPAccount=int(data['deleteFTPAccount']),
|
||||
listFTPAccounts=int(data['listFTPAccounts']),
|
||||
|
||||
## Backup Management
|
||||
|
||||
createBackup = int(data['createBackup']),
|
||||
restoreBackup = int(data['restoreBackup']),
|
||||
addDeleteDestinations = int(data['addDeleteDestinations']),
|
||||
scheDuleBackups = int(data['scheDuleBackups']),
|
||||
remoteBackups = int(data['remoteBackups']),
|
||||
createBackup=int(data['createBackup']),
|
||||
restoreBackup=int(data['restoreBackup']),
|
||||
addDeleteDestinations=int(data['addDeleteDestinations']),
|
||||
scheDuleBackups=int(data['scheDuleBackups']),
|
||||
remoteBackups=int(data['remoteBackups']),
|
||||
|
||||
## SSL Management
|
||||
|
||||
manageSSL = int(data['manageSSL']),
|
||||
hostnameSSL = int(data['hostnameSSL']),
|
||||
mailServerSSL = int(data['mailServerSSL']),
|
||||
manageSSL=int(data['manageSSL']),
|
||||
hostnameSSL=int(data['hostnameSSL']),
|
||||
mailServerSSL=int(data['mailServerSSL']),
|
||||
)
|
||||
newACL.save()
|
||||
|
||||
|
||||
|
||||
finalResponse = { 'status': 1}
|
||||
finalResponse = {'status': 1}
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
json_data = json.dumps(finalResponse)
|
||||
return HttpResponse(json_data)
|
||||
except BaseException, msg:
|
||||
finalResponse = {'status':0, 'errorMessage': str(msg)}
|
||||
finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)}
|
||||
json_data = json.dumps(finalResponse)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def deleteACL(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -409,7 +422,7 @@ def deleteACL(request):
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
aclNames = ACLManager.findAllACLs()
|
||||
return render(request, 'userManagment/deleteACL.html', {'aclNames' : aclNames})
|
||||
return render(request, 'userManagment/deleteACL.html', {'aclNames': aclNames})
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
except KeyError:
|
||||
@@ -429,17 +442,18 @@ def deleteACLFunc(request):
|
||||
acl.delete()
|
||||
finalResponse = {'status': 1}
|
||||
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:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
json_data = json.dumps(finalResponse)
|
||||
return HttpResponse(json_data)
|
||||
except BaseException, msg:
|
||||
finalResponse = {'status':0, 'errorMessage': str(msg)}
|
||||
finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)}
|
||||
json_data = json.dumps(finalResponse)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def modifyACL(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -447,12 +461,13 @@ def modifyACL(request):
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
aclNames = ACLManager.findAllACLs()
|
||||
return render(request, 'userManagment/modifyACL.html', {'aclNames' : aclNames})
|
||||
return render(request, 'userManagment/modifyACL.html', {'aclNames': aclNames})
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def fetchACLDetails(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
@@ -517,7 +532,6 @@ def fetchACLDetails(request):
|
||||
finalResponse['deleteFTPAccount'] = acl.deleteFTPAccount
|
||||
finalResponse['listFTPAccounts'] = acl.listFTPAccounts
|
||||
|
||||
|
||||
## Backup Management
|
||||
|
||||
finalResponse['createBackup'] = acl.createBackup
|
||||
@@ -526,7 +540,6 @@ def fetchACLDetails(request):
|
||||
finalResponse['scheDuleBackups'] = acl.scheDuleBackups
|
||||
finalResponse['remoteBackups'] = acl.remoteBackups
|
||||
|
||||
|
||||
## SSL Management
|
||||
|
||||
finalResponse['manageSSL'] = acl.manageSSL
|
||||
@@ -544,6 +557,7 @@ def fetchACLDetails(request):
|
||||
json_data = json.dumps(finalResponse)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def submitACLModifications(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
@@ -635,18 +649,18 @@ def submitACLModifications(request):
|
||||
items.type = 3
|
||||
items.save()
|
||||
|
||||
|
||||
finalResponse = { 'status': 1}
|
||||
finalResponse = {'status': 1}
|
||||
else:
|
||||
finalResponse = ACLManager.loadErrorJson()
|
||||
|
||||
json_data = json.dumps(finalResponse)
|
||||
return HttpResponse(json_data)
|
||||
except BaseException, msg:
|
||||
finalResponse = {'status':0, 'errorMessage': str(msg)}
|
||||
finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)}
|
||||
json_data = json.dumps(finalResponse)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def changeUserACL(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -655,7 +669,7 @@ def changeUserACL(request):
|
||||
if currentACL['admin'] == 1:
|
||||
aclNames = ACLManager.unFileteredACLs()
|
||||
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:
|
||||
aclNames = ACLManager.unFileteredACLs()
|
||||
userNames = ACLManager.findAllUsers()
|
||||
@@ -668,14 +682,22 @@ def changeUserACL(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def changeACLFunc(request):
|
||||
try:
|
||||
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)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
data = json.loads(request.body)
|
||||
selectedACL = ACL.objects.get(name=data['selectedACL'])
|
||||
selectedUser = Administrator.objects.get(userName=data['selectedUser'])
|
||||
|
||||
@@ -684,7 +706,6 @@ def changeACLFunc(request):
|
||||
|
||||
finalResponse = {'status': 1}
|
||||
elif currentACL['changeUserACL'] == 1:
|
||||
data = json.loads(request.body)
|
||||
selectedACL = ACL.objects.get(name=data['selectedACL'])
|
||||
selectedUser = Administrator.objects.get(userName=data['selectedUser'])
|
||||
|
||||
@@ -698,10 +719,11 @@ def changeACLFunc(request):
|
||||
json_data = json.dumps(finalResponse)
|
||||
return HttpResponse(json_data)
|
||||
except BaseException, msg:
|
||||
finalResponse = {'status':0, 'errorMessage': str(msg)}
|
||||
finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)}
|
||||
json_data = json.dumps(finalResponse)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def resellerCenter(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -710,11 +732,13 @@ def resellerCenter(request):
|
||||
if currentACL['admin'] == 1:
|
||||
userNames = ACLManager.loadDeletionUsers(userID, currentACL)
|
||||
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:
|
||||
userNames = ACLManager.loadDeletionUsers(userID, currentACL)
|
||||
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:
|
||||
return ACLManager.loadError()
|
||||
|
||||
@@ -722,17 +746,26 @@ def resellerCenter(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def saveResellerChanges(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
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'])
|
||||
newOwner = Administrator.objects.get(userName=data['newOwner'])
|
||||
|
||||
if ACLManager.websitesLimitCheck(newOwner, data['websitesLimit'], userToBeModified) == 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)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
@@ -744,6 +777,6 @@ def saveResellerChanges(request):
|
||||
json_data = json.dumps(finalResponse)
|
||||
return HttpResponse(json_data)
|
||||
except BaseException, msg:
|
||||
finalResponse = {'status':0, 'errorMessage': str(msg)}
|
||||
finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)}
|
||||
json_data = json.dumps(finalResponse)
|
||||
return HttpResponse(json_data)
|
||||
Reference in New Issue
Block a user