mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-07 08:37:32 +02:00
wpmanager
This commit is contained in:
@@ -422,6 +422,12 @@ app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $
|
||||
|
||||
app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $window) {
|
||||
$scope.wordpresshomeloading = true;
|
||||
$scope.stagingDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = true;
|
||||
$(document).ready(function () {
|
||||
var checkstatus = document.getElementById("wordpresshome");
|
||||
if (checkstatus !== null) {
|
||||
@@ -1004,6 +1010,197 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
|
||||
AppendToTable('#ThemeBody', temp)
|
||||
}
|
||||
|
||||
$scope.CreateStagingNow = function () {
|
||||
|
||||
$scope.wordpresshomeloading = false;
|
||||
$scope.stagingDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
|
||||
$scope.currentStatus = "Starting creation Staging..";
|
||||
var data = {
|
||||
StagingName: $('#stagingName').val(),
|
||||
StagingDomain: $('#stagingDomain').val(),
|
||||
WPid: $('#WPid').html(),
|
||||
}
|
||||
var url = "/websites/CreateStagingNow";
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.status === 1) {
|
||||
statusFile = response.data.tempStatusPath;
|
||||
getCreationStatus();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.wordpresshomeloading = true;
|
||||
alert(response)
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function getCreationStatus() {
|
||||
|
||||
url = "/websites/installWordpressStatus";
|
||||
|
||||
var data = {
|
||||
statusFile: statusFile
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.abort === 1) {
|
||||
|
||||
if (response.data.installStatus === 1) {
|
||||
|
||||
|
||||
$scope.wordpresshomeloading = true;
|
||||
$scope.stagingDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$("#installProgress").css("width", "100%");
|
||||
$scope.installPercentage = "100";
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout.cancel();
|
||||
|
||||
} else {
|
||||
|
||||
$scope.wordpresshomeloading = true;
|
||||
$scope.stagingDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = false;
|
||||
$scope.success = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$("#installProgress").css("width", "0%");
|
||||
$scope.installPercentage = "0";
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
$("#installProgress").css("width", response.data.installationProgress + "%");
|
||||
$scope.installPercentage = response.data.installationProgress;
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout(getCreationStatus, 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.wordpresshomeloading = true;
|
||||
$scope.stagingDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$scope.goBack = function () {
|
||||
$scope.wordpresshomeloading = true;
|
||||
$scope.stagingDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = true;
|
||||
$("#installProgress").css("width", "0%");
|
||||
};
|
||||
|
||||
$scope.fetchstaging = function () {
|
||||
$scope.wordpresshomeloading = false;
|
||||
|
||||
var url = "/websites/fetchstaging";
|
||||
|
||||
var data = {
|
||||
WPid: $('#WPid').html(),
|
||||
}
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
wordpresshomeloading = true;
|
||||
|
||||
if (response.data.status === 1) {
|
||||
|
||||
// $('#ThemeBody').html('');
|
||||
// var themes = JSON.parse(response.data.themes);
|
||||
// themes.forEach(AddThemes);
|
||||
|
||||
$('#StagingBody').html('');
|
||||
var staging = JSON.parse(response.data.wpsites);
|
||||
staging.forEach(AddStagings);
|
||||
|
||||
} else {
|
||||
alert("Error data.error_message:" + response.data.error_message)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
alert("Error"+response)
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
$scope.autoLogin = function () {
|
||||
var url = "/websites/DeleteThemes";
|
||||
//window.open("/wpmanager/" + $('#HostingCompanyID').html() + "/manage/" + server + "/" + wordpress + "/AutoLogin");
|
||||
@@ -1011,8 +1208,76 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
|
||||
window.open("/websites/AutoLogin?WordPressID="+sub.id);
|
||||
}
|
||||
|
||||
$scope.SaveUpdateConfig =function () {
|
||||
var data = {
|
||||
AutomaticUpdates: $('#AutomaticUpdates').find(":selected").text(),
|
||||
Plugins: $('#Plugins').find(":selected").text(),
|
||||
Themes: $('#Themes').find(":selected").text(),
|
||||
WPid: $('#WPid').html(),
|
||||
}
|
||||
|
||||
$scope.wordpresshomeloading = false;
|
||||
|
||||
var url = "/websites/SaveUpdateConfig";
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.wordpresshomeloading = true;
|
||||
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Update Configurations Sucessfully!.',
|
||||
type: 'success'
|
||||
});
|
||||
$("#autoUpdateConfig").modal('hide');
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
function AddStagings(value, index, array) {
|
||||
var FinalMarkup = '<tr>'
|
||||
for (let x in value) {
|
||||
if (x === 'name') {
|
||||
FinalMarkup = FinalMarkup + '<td><a href="' + value.url + '">' + value[x] + '</a></td>';
|
||||
} else if (x !== 'url' && x !== 'deleteURL' && x !== 'id') {
|
||||
FinalMarkup = FinalMarkup + '<td>' + value[x] + "</td>";
|
||||
}
|
||||
}
|
||||
FinalMarkup = FinalMarkup + '<td><button onclick="DeployToProductionInitial(' + value.id + ')" data-toggle="modal" data-target="#DeployToProduction" style="margin-bottom: 2%; display: block" aria-label="" type="button" class="btn btn-outline-primary">Deploy to Production</button>' +
|
||||
'<a href="' + value.deleteURL + '"> <button aria-label="" class="btn btn-danger btn-icon-left m-b-10" type="button">Delete</button></a></td>'
|
||||
FinalMarkup = FinalMarkup + '</tr>'
|
||||
AppendToTable('#StagingBody', FinalMarkup);
|
||||
}
|
||||
|
||||
var PluginsList = [];
|
||||
|
||||
|
||||
|
||||
@@ -61,75 +61,69 @@
|
||||
<div id="autoUpdateConfig" class="modal fade" tabindex="-1" role="dialog"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<div class="text-center mt-2 mb-4">
|
||||
</div>
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×
|
||||
</button>
|
||||
<h4 class="modal-title">{% trans "Updates" %}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
|
||||
|
||||
<h3 style="margin-top: 2%">UPDATES</h3>
|
||||
<p>Configure setting for automatic updates.</p>
|
||||
<div class="row">
|
||||
<h5 class="font-arial">Automatic Updates
|
||||
(Currently: {{ wpsite.AutoUpdates }})</h5>
|
||||
<div class="col-12">
|
||||
<select id="AutomaticUpdates"
|
||||
class="form-group form-group-default"
|
||||
style="padding: 10px">
|
||||
<option>Disabled</option>
|
||||
<option>Minor and Security Updates</option>
|
||||
<option>All (minor and major)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<h5 class="font-arial">Plugins
|
||||
(Currently: {{ wpsite.PluginUpdates }})</h5>
|
||||
<div class="col-12">
|
||||
<select id="Plugins"
|
||||
class="form-group form-group-default"
|
||||
style="padding: 10px">
|
||||
<option>Enabled</option>
|
||||
<option>Disabled</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<h5 class="font-arial">Themes
|
||||
(Currently: {{ wpsite.ThemeUpdates }})</h5>
|
||||
<div class="col-12">
|
||||
<select id="Themes"
|
||||
class="form-group form-group-default"
|
||||
style="padding: 10px">
|
||||
<option>Enabled</option>
|
||||
<option>Disabled</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row bg-dark"
|
||||
style="border-radius: 2%;margin-top: 1%">
|
||||
<div class="v-align-middle col-12 ">
|
||||
<button onclick="SaveAutoUpdateSettings()"
|
||||
aria-label=""
|
||||
type="button"
|
||||
class="v-align-middle btn bg-dark col-12"
|
||||
style="color: white; padding: 15px">
|
||||
Save Changes <img
|
||||
class="LPLoader"
|
||||
style="margin-left: 2%"
|
||||
src="{% static 'BaseTemplates/images/loader.gif' %}">
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<h4 style="margin: 2%">Configure setting for automatic updates.</h4>
|
||||
<div class="row">
|
||||
<label class="col-lg-6">Automatic Updates (Currently:
|
||||
{{ wpsite.AutoUpdates }})</label>
|
||||
<div class="col-lg-6">
|
||||
<select id="AutomaticUpdates"
|
||||
style="padding: 10px">
|
||||
<option>Disabled</option>
|
||||
<option>Minor and Security Updates</option>
|
||||
<option>All (minor and major)</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col-lg-4">Plugins (Currently: {{ wpsite.PluginUpdates }})</label>
|
||||
<div class="col-lg-8">
|
||||
<select id="Plugins"
|
||||
|
||||
style="padding: 10px">
|
||||
<option>Enabled</option>
|
||||
<option>Disabled</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col-lg-4">Themes (Currently: {{ wpsite.ThemeUpdates }})</label>
|
||||
<div class="col-lg-8">
|
||||
<select id="Themes"
|
||||
|
||||
style="padding: 10px">
|
||||
<option>Enabled</option>
|
||||
<option>Disabled</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary"
|
||||
ng-click="SaveUpdateConfig()">Save
|
||||
</button>
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
@@ -154,7 +148,8 @@
|
||||
data-toggle="tab">Plugins</a></li>
|
||||
<li class=""><a href="#tab3" ng-click="GetCurrentThemes()"
|
||||
data-toggle="tab">Themes</a></li>
|
||||
<li><a href="#tab4" data-toggle="tab">Staging</a></li>
|
||||
<li><a href="#tab4" data-toggle="tab"
|
||||
ng-click="fetchstaging()">Staging</a></li>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@@ -210,7 +205,7 @@
|
||||
Login
|
||||
</a>
|
||||
<a style="margin-left: 4%" target="_blank"
|
||||
href="/websites/{{ wpsite.owner.domain}}/manageGIT">
|
||||
href="/websites/{{ wpsite.owner.domain }}/manageGIT">
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
aria-hidden="true" focusable="false" width="1em"
|
||||
@@ -392,10 +387,90 @@
|
||||
</table>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab4">
|
||||
<p>Howdy, I'm in Section 4.</p>
|
||||
<h2>Create Staging site</h2>
|
||||
<div ng-hide="stagingDetailsForm" class="form-group">
|
||||
<label style="margin-bottom: 2%!important; margin-top: 2%!important;"
|
||||
class="col-sm-2 control-label">Name</label>
|
||||
<div class="col-sm-10">
|
||||
<input style="margin-bottom: 2%!important; margin-top: 2%!important;"
|
||||
type="text" class="form-control" id="stagingName">
|
||||
</div>
|
||||
</div>
|
||||
<div ng-hide="stagingDetailsForm" class="form-group mt-5">
|
||||
<label style="margin-bottom: 2%!important;"
|
||||
class="col-sm-2 control-label">Domain Name</label>
|
||||
<div class="col-sm-10">
|
||||
<input style="margin-bottom: 2%!important;"
|
||||
type="text" class="form-control" id="stagingDomain">
|
||||
</div>
|
||||
</div>
|
||||
<div ng-hide="stagingDetailsForm" class="center-div mt-5">
|
||||
<button ng-click="CreateStagingNow()"
|
||||
style="margin-bottom: 2%!important;"
|
||||
class="btn btn-alt btn-hover btn-blue-alt">
|
||||
<span>Create Now</span>
|
||||
<i class="glyph-icon icon-arrow-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div ng-hide="installationProgress" class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-7">
|
||||
|
||||
<div class="alert alert-success text-center">
|
||||
<h2>{$ currentStatus $}</h2>
|
||||
</div>
|
||||
|
||||
<div class="progress">
|
||||
<div id="installProgress" class="progress-bar"
|
||||
role="progressbar" aria-valuenow="70"
|
||||
aria-valuemin="0" aria-valuemax="100"
|
||||
style="width:0%">
|
||||
<span class="sr-only">70% Complete</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="errorMessageBox" class="alert alert-danger">
|
||||
<p>{% trans "Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="success" class="alert alert-success">
|
||||
<p>{% trans "Website succesfully created." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationProgress" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-disabled="goBackDisable"
|
||||
ng-click="goBack()"
|
||||
class="btn btn-primary btn-lg center-div">{% trans "Go Back" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<h3>List staging site</h3>
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Domain</th>
|
||||
<th>Path</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="StagingBody">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ urlpatterns = [
|
||||
url(r'^UpdateThemes', views.UpdateThemes, name='UpdateThemes'),
|
||||
url(r'^DeleteThemes', views.DeleteThemes, name='DeleteThemes'),
|
||||
url(r'^StatusThemes', views.StatusThemes, name='StatusThemes'),
|
||||
url(r'^CreateStagingNow', views.CreateStagingNow, name='CreateStagingNow'),
|
||||
url(r'^fetchstaging', views.fetchstaging, name='fetchstaging'),
|
||||
url(r'^SaveUpdateConfig', views.SaveUpdateConfig, name='SaveUpdateConfig'),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -50,8 +50,9 @@ def WPHome(request):
|
||||
userID = request.session['userID']
|
||||
|
||||
WPid = request.GET.get('ID')
|
||||
DeleteID = request.GET.get('DeleteID')
|
||||
wm = WebsiteManager()
|
||||
return wm.WPHome(request, userID, WPid)
|
||||
return wm.WPHome(request, userID, WPid, DeleteID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
def AutoLogin(request):
|
||||
@@ -89,6 +90,9 @@ def Addnewplugin(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
|
||||
|
||||
def SearchOnkeyupPlugin(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -243,6 +247,50 @@ def GetCurrentPlugins(request):
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.GetCurrentPlugins(userID, json.loads(request.body))
|
||||
# coreResult = wm.GetCsurrentPlugins(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def fetchstaging(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
result = pluginManager.preWebsiteCreation(request)
|
||||
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.fetchstaging(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def SaveUpdateConfig(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
result = pluginManager.preWebsiteCreation(request)
|
||||
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.SaveUpdateConfig(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
@@ -431,6 +479,28 @@ def StatusThemes(request):
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def CreateStagingNow(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
result = pluginManager.preWebsiteCreation(request)
|
||||
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.CreateStagingNow(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
|
||||
def modifyWebsite(request):
|
||||
try:
|
||||
|
||||
@@ -12,7 +12,7 @@ django.setup()
|
||||
import json
|
||||
from plogical.acl import ACLManager
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from websiteFunctions.models import Websites, ChildDomains, GitLogs, wpplugins, WPSites
|
||||
from websiteFunctions.models import Websites, ChildDomains, GitLogs, wpplugins, WPSites, WPStaging
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
import subprocess
|
||||
import shlex
|
||||
@@ -113,13 +113,23 @@ class WebsiteManager:
|
||||
{"wpsite": tata['wpsites']})
|
||||
return proc.render()
|
||||
|
||||
def WPHome(self, request=None, userID=None, WPid=None):
|
||||
def WPHome(self, request=None, userID=None, WPid=None, DeleteID=None):
|
||||
Data = {}
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
WPobj = WPSites.objects.get(pk=WPid)
|
||||
|
||||
Data['wpsite'] = WPobj
|
||||
|
||||
try:
|
||||
DeleteID = request.GET.get('DeleteID', None)
|
||||
|
||||
if DeleteID != None:
|
||||
wstagingDelete = WPStaging.objects.get(pk=DeleteID)
|
||||
wstagingDelete.delete()
|
||||
|
||||
except BaseException as msg:
|
||||
|
||||
da= str(msg)
|
||||
|
||||
proc = httpProc(request, 'websiteFunctions/WPsiteHome.html',
|
||||
Data, 'createWebsite')
|
||||
@@ -548,6 +558,63 @@ class WebsiteManager:
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def fetchstaging(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
WPManagerID = data['WPid']
|
||||
wpsite = WPSites.objects.get(pk=WPManagerID)
|
||||
|
||||
|
||||
from plogical.phpUtilities import phpUtilities
|
||||
|
||||
|
||||
json_data = phpUtilities.GetStagingInJson(wpsite.wpstaging_set.all().order_by('-id'))
|
||||
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None', 'wpsites': json_data}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
|
||||
def SaveUpdateConfig(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
WPManagerID = data['WPid']
|
||||
Plugins = data['Plugins']
|
||||
Themes = data['Themes']
|
||||
AutomaticUpdates = data['AutomaticUpdates']
|
||||
|
||||
wpsite = WPSites.objects.get(pk=WPManagerID)
|
||||
|
||||
wpsite.AutoUpdates = AutomaticUpdates
|
||||
wpsite.PluginUpdates = Plugins
|
||||
wpsite.ThemeUpdates = Themes
|
||||
wpsite.save()
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None',}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def UpdatePlugins(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
@@ -828,6 +895,35 @@ class WebsiteManager:
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def CreateStagingNow(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
extraArgs = {}
|
||||
extraArgs['adminID'] = admin.pk
|
||||
extraArgs['StagingDomain'] = data['StagingDomain']
|
||||
extraArgs['StagingName'] = data['StagingName']
|
||||
extraArgs['WPid'] = data['WPid']
|
||||
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
background = ApplicationInstaller('CreateStagingNow', extraArgs)
|
||||
background.start()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',
|
||||
'tempStatusPath': extraArgs['tempStatusPath']}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
|
||||
|
||||
def UpdateWPSettings(self, userID=None, data=None):
|
||||
|
||||
Reference in New Issue
Block a user