diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html
index f87a70cbe..c73ceeaf2 100755
--- a/baseTemplate/templates/baseTemplate/index.html
+++ b/baseTemplate/templates/baseTemplate/index.html
@@ -410,6 +410,9 @@
+
+
+
{% trans "List Child Domains" %}

+
{% trans "On this page you can launch, list, modify and delete child domains from your server." %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
diff --git a/websiteFunctions/urls.py b/websiteFunctions/urls.py
index c59d536cb..7d9500173 100755
--- a/websiteFunctions/urls.py
+++ b/websiteFunctions/urls.py
@@ -6,6 +6,7 @@ urlpatterns = [
url(r'^$', views.loadWebsitesHome, name='loadWebsitesHome'),
url(r'^createWebsite$', views.createWebsite, name='createWebsite'),
url(r'^listWebsites$', views.listWebsites, name='listWebsites'),
+ url(r'^listChildDomains$', views.listChildDomains, name='listChildDomains'),
url(r'^modifyWebsite$', views.modifyWebsite, name='modifyWebsite'),
url(r'^deleteWebsite$', views.deleteWebsite, name='deleteWebsite'),
url(r'^siteState$', views.siteState, name='siteState'),
@@ -18,6 +19,7 @@ urlpatterns = [
url(r'^submitWebsiteDeletion$', views.submitWebsiteDeletion, name='submitWebsiteDeletion'),
url(r'^submitWebsiteListing$', views.getFurtherAccounts, name='submitWebsiteListing'),
url(r'^fetchWebsitesList$', views.fetchWebsitesList, name='fetchWebsitesList'),
+ url(r'^fetchChildDomainsMain$', views.fetchChildDomainsMain, name='fetchChildDomainsMain'),
url(r'^searchWebsites$', views.searchWebsites, name='searchWebsites'),
url(r'^submitWebsiteModification$', views.deleteWebsite, name='submitWebsiteModification'),
url(r'^submitWebsiteStatus$', views.submitWebsiteStatus, name='submitWebsiteStatus'),
diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py
index 45a8068fc..d908519d6 100755
--- a/websiteFunctions/views.py
+++ b/websiteFunctions/views.py
@@ -61,6 +61,14 @@ def listWebsites(request):
except KeyError:
return redirect(loadLoginPage)
+def listChildDomains(request):
+ try:
+ userID = request.session['userID']
+ wm = WebsiteManager()
+ return wm.listChildDomains(request, userID)
+ except KeyError:
+ return redirect(loadLoginPage)
+
def submitWebsiteCreation(request):
try:
userID = request.session['userID']
@@ -133,6 +141,14 @@ def fetchWebsitesList(request):
except KeyError:
return redirect(loadLoginPage)
+def fetchChildDomainsMain(request):
+ try:
+ userID = request.session['userID']
+ wm = WebsiteManager()
+ return wm.fetchChildDomainsMain(userID, json.loads(request.body))
+ except KeyError:
+ return redirect(loadLoginPage)
+
def submitWebsiteDeletion(request):
try:
userID = request.session['userID']
diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py
index fe6f08cc9..007502745 100755
--- a/websiteFunctions/website.py
+++ b/websiteFunctions/website.py
@@ -115,6 +115,15 @@ class WebsiteManager:
except BaseException as msg:
return HttpResponse(str(msg))
+ def listChildDomains(self, request=None, userID=None, data=None):
+ try:
+ currentACL = ACLManager.loadedACL(userID)
+ pagination = self.websitePagination(currentACL, userID)
+
+ return render(request, 'websiteFunctions/listChildDomains.html', {"pagination": pagination})
+ except BaseException as msg:
+ return HttpResponse(str(msg))
+
def listCron(self, request=None, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
@@ -355,6 +364,32 @@ class WebsiteManager:
json_data = json.dumps(dic)
return HttpResponse(json_data)
+ def fetchChildDomainsMain(self, userID=None, data=None):
+ try:
+ currentACL = ACLManager.loadedACL(userID)
+ pageNumber = int(data['page'])
+ recordsToShow = int(data['recordsToShow'])
+
+ endPageNumber, finalPageNumber = self.recordsPointer(pageNumber, recordsToShow)
+ websites = ACLManager.findWebsiteObjects(currentACL, userID)
+ childDomains = []
+
+ for web in websites:
+ for child in web.childdomains_set.all():
+ childDomains.append(child)
+
+ pagination = self.getPagination(len(childDomains), recordsToShow)
+ json_data = self.findChildsListJson(childDomains[finalPageNumber:endPageNumber])
+
+ final_dic = {'status': 1, 'listWebSiteStatus': 1, 'error_message': "None", "data": json_data,
+ 'pagination': pagination}
+ final_json = json.dumps(final_dic)
+ return HttpResponse(final_json)
+ except BaseException as msg:
+ dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
def findWebsitesListJson(self, websites):
json_data = "["
@@ -390,6 +425,35 @@ class WebsiteManager:
return json_data
+ def findChildsListJson(self, childs):
+
+ json_data = "["
+ checker = 0
+
+ try:
+ ipFile = "/etc/cyberpanel/machineIP"
+ f = open(ipFile)
+ ipData = f.read()
+ ipAddress = ipData.split('\n', 1)[0]
+ except BaseException as msg:
+ logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg))
+ ipAddress = "192.168.100.1"
+
+ for items in childs:
+
+ dic = {'domain': items.domain, 'masterDomain': items.master.domain, 'adminEmail': items.master.adminEmail, 'ipAddress': ipAddress,
+ 'admin': items.master.admin.userName, 'package': items.master.package.packageName, 'path': items.path}
+
+ if checker == 0:
+ json_data = json_data + json.dumps(dic)
+ checker = 1
+ else:
+ json_data = json_data + ',' + json.dumps(dic)
+
+ json_data = json_data + ']'
+
+ return json_data
+
def recordsPointer(self, page, toShow):
finalPageNumber = ((page * toShow)) - toShow
endPageNumber = finalPageNumber + toShow