Skip to content

Commit

Permalink
adjust some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Dec 22, 2023
1 parent af6a5dc commit e4f31be
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 18 deletions.
5 changes: 5 additions & 0 deletions dockerManager/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from django.conf.urls import url
from django.urls import path

from . import views
from websiteFunctions.views import Dockersitehome

urlpatterns = [
url(r'^$', views.loadDockerHome, name='dockerHome'),
Expand All @@ -26,4 +29,6 @@
url(r'^installDocker', views.installDocker, name='installDocker'),
url(r'^images', views.images, name='containerImage'),
url(r'^view/(?P<name>(.*))$', views.viewContainer, name='viewContainer'),

path('manage/<int:dockerapp>/app', Dockersitehome, name='Dockersitehome'),
]
9 changes: 6 additions & 3 deletions plogical/DockerSites.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ def SetupHTAccess(port, htaccess):
WriteToFile.write(HTAccessContent)
WriteToFile.close()

from plogical.installUtilities import installUtilities
installUtilities.reStartLiteSpeed()

# Takes
# ComposePath, MySQLPath, MySQLRootPass, MySQLDBName, MySQLDBNUser, MySQLPassword, CPUsMySQL, MemoryMySQL,
# port, SitePath, CPUsSite, MemorySite, ComposePath, SiteName
Expand Down Expand Up @@ -336,6 +333,11 @@ def DeployWPContainer(self):
command = f"chown -R nobody:{group} /home/docker/{self.data['finalURL']}/data"
ProcessUtilities.executioner(command)

### just restart ls for htaccess

from plogical.installUtilities import installUtilities
installUtilities.reStartLiteSpeed()

logging.statusWriter(self.JobID, 'Completed. [200]')

# command = f"docker-compose -f {self.data['ComposePath']} ps -q wordpress"
Expand Down Expand Up @@ -592,6 +594,7 @@ def ContainerLogs(self):
return 0, str(msg)

### pass container id and number of lines to fetch from logs

def ContainerInfo(self):
try:
import docker
Expand Down
2 changes: 1 addition & 1 deletion plogical/acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,6 @@ def checkGDriveOwnership(gD, admin, currentACL):
except:
return 0


@staticmethod
def checkOwnershipZone(domain, admin, currentACL):
try:
Expand Down Expand Up @@ -1086,3 +1085,4 @@ def ReplaceDocRootApache(vhostConf, domainName, NewDocRoot):
pass



Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
</script>

<h2> Docker Site Home</h2>
<p>{{ dockerSite.SiteName }}</p>

{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h2 style="display: inline; color: #414C59;" ng-bind="web.domain"></h2>
{% trans "File Manager" %}</a>
</div>
<div class="col-md-2 content-box-header" style="text-transform: none;">
<a href="/websites/{$ web.domain $}/Dockersitehome" target="_self" title="Manage Website">
<a href="/docker/manage/{$ web.id $}/app" target="_self" title="Manage Website">
<i class="p fa fa-external-link btn-icon">&emsp;</i>
<span>{% trans "Manage" %}</span>
</a>
Expand Down
2 changes: 1 addition & 1 deletion websiteFunctions/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
url(r'^submitDockerSiteCreation$', views.submitDockerSiteCreation, name='submitDockerSiteCreation'),
url(r'^ListDockerSites$', views.ListDockerSites, name='ListDockerSites'),
url(r'^fetchDockersite$', views.fetchDockersite, name='fetchDockersite'),
url(r'^(?P<domain>(.*))/Dockersitehome', views.Dockersitehome, name='Dockersitehome'),


### SSH Configs

Expand Down
4 changes: 2 additions & 2 deletions websiteFunctions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1846,10 +1846,10 @@ def fetchDockersite(request):
except KeyError:
return redirect(loadLoginPage)

def Dockersitehome(request, domain):
def Dockersitehome(request, dockerapp):
try:
userID = request.session['userID']
wm = WebsiteManager(domain)
wm = WebsiteManager(dockerapp)
return wm.Dockersitehome(request, userID, None)
except KeyError:
return redirect(loadLoginPage)
69 changes: 59 additions & 10 deletions websiteFunctions/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -6608,6 +6608,13 @@ def saveApacheConfigsToFile(self, userID=None, data=None):
def CreateDockerPackage(self, request=None, userID=None, data=None, DeleteID=None):
Data = {}

currentACL = ACLManager.loadedACL(userID)

if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()

try:
if DeleteID != None:
DockerPackagesDelete = DockerPackages.objects.get(pk=DeleteID)
Expand All @@ -6623,6 +6630,13 @@ def CreateDockerPackage(self, request=None, userID=None, data=None, DeleteID=Non

def AssignPackage(self, request=None, userID=None, data=None, DeleteID=None):

currentACL = ACLManager.loadedACL(userID)

if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()

try:
if DeleteID != None:
DockerPackagesDelete = PackageAssignment.objects.get(pk=DeleteID)
Expand All @@ -6647,6 +6661,13 @@ def CreateDockersite(self, request=None, userID=None, data=None):
def AddDockerpackage(self, userID=None, data=None):
try:

currentACL = ACLManager.loadedACL(userID)

if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()

admin = Administrator.objects.get(pk=userID)

name = data['name']
Expand All @@ -6668,6 +6689,13 @@ def AddDockerpackage(self, userID=None, data=None):

def Getpackage(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)

if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()

admin = Administrator.objects.get(pk=userID)
id = data['id']

Expand All @@ -6694,6 +6722,14 @@ def Getpackage(self, userID=None, data=None):

def Updatepackage(self, userID=None, data=None):
try:

currentACL = ACLManager.loadedACL(userID)

if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()

admin = Administrator.objects.get(pk=userID)
id = data['id']
CPU = data['CPU']
Expand All @@ -6720,6 +6756,15 @@ def Updatepackage(self, userID=None, data=None):

def AddAssignment(self, userID=None, data=None):
try:

currentACL = ACLManager.loadedACL(userID)

if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()


admin = Administrator.objects.get(pk=userID)

package = data['package']
Expand Down Expand Up @@ -6845,11 +6890,19 @@ def submitDockerSiteCreation(self, userID=None, data=None):
return HttpResponse(final_json)

def ListDockerSites(self, request=None, userID=None, data=None, DeleteID=None):
admin = Administrator.objects.get(pk=userID)
currentACL = ACLManager.loadedACL(userID)
fdata={}

try:
if DeleteID != None:

DockerSitesDelete = DockerSites.objects.get(pk=DeleteID)
if ACLManager.checkOwnership(DockerSitesDelete.admin, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()

passdata={}
passdata["domain"] = DockerSitesDelete.admin.domain
passdata["JobID"] = None
Expand All @@ -6875,21 +6928,13 @@ def fetchDockersite(self, userID=None, data=None):
recordsToShow = int(data['recordsToShow'])



endPageNumber, finalPageNumber = self.recordsPointer(pageNumber, recordsToShow)



dockersites = ACLManager.findDockersiteObjects(currentACL, userID)



pagination = self.getPagination(len(dockersites), recordsToShow)

logging.CyberCPLogFileWriter.writeToFile("Our dockersite" + str(dockersites))



json_data = self.findDockersitesListJson(dockersites[finalPageNumber:endPageNumber])


Expand All @@ -6904,13 +6949,17 @@ def fetchDockersite(self, userID=None, data=None):
return HttpResponse(final_json)

def Dockersitehome(self, request=None, userID=None, data=None, DeleteID=None):

currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:

ds = DockerSites.objects.get(pk=self.domain)

if ACLManager.checkOwnership(ds.admin.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()

proc = httpProc(request, 'websiteFunctions/DockerSiteHome.html',
None)
{'dockerSite': ds})
return proc.render()

0 comments on commit e4f31be

Please sign in to comment.