Usman Nasir
2020-05-07 13:36:32 +05:00
parent 9cc29b4a8e
commit 5f589d0569
2 changed files with 23 additions and 5 deletions

View File

@@ -126,7 +126,7 @@ def sslForHostName(request):
else: else:
return ACLManager.loadError() return ACLManager.loadError()
websitesName = ACLManager.findAllSites(currentACL, userID) websitesName = ACLManager.findAllSites(currentACL, userID, 1)
return render(request, 'manageSSL/sslForHostName.html', {'websiteList': websitesName}) return render(request, 'manageSSL/sslForHostName.html', {'websiteList': websitesName})
except KeyError: except KeyError:
@@ -151,11 +151,15 @@ def obtainHostNameSSL(request):
data = json.loads(request.body) data = json.loads(request.body)
virtualHost = data['virtualHost'] virtualHost = data['virtualHost']
try:
website = Websites.objects.get(domain=virtualHost)
path = "/home/" + virtualHost + "/public_html" path = "/home/" + virtualHost + "/public_html"
except:
website = ChildDomains.objects.get(domain=virtualHost)
path = website.path
data = json.loads(request.body)
virtualHost = data['virtualHost']
admin = Administrator.objects.get(pk=userID) admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(virtualHost, admin, currentACL) == 1: if ACLManager.checkOwnership(virtualHost, admin, currentACL) == 1:
pass pass
else: else:

View File

@@ -405,13 +405,19 @@ class ACLManager:
return admin.package_set.all() return admin.package_set.all()
@staticmethod @staticmethod
def findAllSites(currentACL, userID): def findAllSites(currentACL, userID, fetchChilds = 0):
websiteNames = [] websiteNames = []
if currentACL['admin'] == 1: if currentACL['admin'] == 1:
allWebsites = Websites.objects.all() allWebsites = Websites.objects.all()
for items in allWebsites: for items in allWebsites:
websiteNames.append(items.domain) websiteNames.append(items.domain)
if fetchChilds:
for child in items.childdomains_set.all():
websiteNames.append(child.domain)
else: else:
admin = Administrator.objects.get(pk=userID) admin = Administrator.objects.get(pk=userID)
@@ -421,11 +427,19 @@ class ACLManager:
for items in websites: for items in websites:
websiteNames.append(items.domain) websiteNames.append(items.domain)
if fetchChilds:
for child in items.childdomains_set.all():
websiteNames.append(child.domain)
for items in admins: for items in admins:
webs = items.websites_set.all() webs = items.websites_set.all()
for web in webs: for web in webs:
websiteNames.append(web.domain) websiteNames.append(web.domain)
if fetchChilds:
for child in web.childdomains_set.all():
websiteNames.append(child.domain)
return websiteNames return websiteNames