mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
add/edit .gitignore
This commit is contained in:
@@ -6371,12 +6371,16 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function getCreationStatus() {
|
$scope.fetchGitignore = function () {
|
||||||
|
|
||||||
|
$scope.cyberpanelLoading = false;
|
||||||
|
|
||||||
|
url = "/websites/fetchGitignore";
|
||||||
|
|
||||||
url = "/websites/installWordpressStatus";
|
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
statusFile: statusFile
|
domain: $("#domain").text(),
|
||||||
|
folder: $scope.folder
|
||||||
};
|
};
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
@@ -6385,62 +6389,92 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||||
|
|
||||||
|
|
||||||
function ListInitialDatas(response) {
|
function ListInitialDatas(response) {
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
if (response.data.status === 1) {
|
||||||
if (response.data.abort === 1) {
|
new PNotify({
|
||||||
|
title: 'Success',
|
||||||
if (response.data.installStatus === 1) {
|
text: 'Successfully fetched.',
|
||||||
|
type: 'success'
|
||||||
$scope.cyberpanelLoading = true;
|
});
|
||||||
$scope.installationDetailsForm = true;
|
$scope.gitIgnoreContent = response.data.gitIgnoreContent;
|
||||||
$scope.installationProgress = false;
|
|
||||||
$scope.goBackDisable = false;
|
|
||||||
|
|
||||||
$("#installProgress").css("width", "100%");
|
|
||||||
$scope.installPercentage = "100";
|
|
||||||
$scope.currentStatus = response.data.currentStatus;
|
|
||||||
$timeout.cancel();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$scope.cyberpanelLoading = true;
|
|
||||||
$scope.installationDetailsForm = true;
|
|
||||||
$scope.installationProgress = false;
|
|
||||||
$scope.goBackDisable = false;
|
|
||||||
|
|
||||||
$scope.currentStatus = response.data.error_message;
|
|
||||||
|
|
||||||
$("#installProgress").css("width", "0%");
|
|
||||||
$scope.installPercentage = "0";
|
|
||||||
$scope.goBackDisable = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$("#installProgress").css("width", response.data.installationProgress + "%");
|
new PNotify({
|
||||||
$scope.installPercentage = response.data.installationProgress;
|
title: 'Operation Failed!',
|
||||||
$scope.currentStatus = response.data.currentStatus;
|
text: response.data.error_message,
|
||||||
$timeout(getCreationStatus, 1000);
|
type: 'error'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cantLoadInitialDatas(response) {
|
function cantLoadInitialDatas(response) {
|
||||||
|
|
||||||
$scope.cyberpanelLoading = true;
|
$scope.cyberpanelLoading = true;
|
||||||
$scope.installationDetailsForm = true;
|
new PNotify({
|
||||||
$scope.installationProgress = false;
|
title: 'Operation Failed!',
|
||||||
$scope.goBackDisable = false;
|
text: 'Could not connect to server, please refresh this page.',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.saveGitIgnore = function () {
|
||||||
|
|
||||||
|
$scope.cyberpanelLoading = false;
|
||||||
|
|
||||||
|
url = "/websites/saveGitIgnore";
|
||||||
|
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
domain: $("#domain").text(),
|
||||||
|
folder: $scope.folder,
|
||||||
|
gitIgnoreContent: $scope.gitIgnoreContent
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||||
|
|
||||||
|
function ListInitialDatas(response) {
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
if (response.data.status === 1) {
|
||||||
|
new PNotify({
|
||||||
|
title: 'Success',
|
||||||
|
text: 'Successfully saved.',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
new PNotify({
|
||||||
|
title: 'Operation Failed!',
|
||||||
|
text: response.data.error_message,
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cantLoadInitialDatas(response) {
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
new PNotify({
|
||||||
|
title: 'Operation Failed!',
|
||||||
|
text: 'Could not connect to server, please refresh this page.',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
|
||||||
}
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
/* Java script code to git tracking ends here */
|
/* Java script code to git tracking ends here */
|
||||||
|
|||||||
@@ -384,10 +384,56 @@
|
|||||||
<input name="radio-toggle-1" type="radio">
|
<input name="radio-toggle-1" type="radio">
|
||||||
Push To Remote
|
Push To Remote
|
||||||
</a>
|
</a>
|
||||||
<a href="#" class="btn btn-info">
|
<a ng-click="fetchGitignore()" data-toggle="modal" data-target="#gitignore" href="#" class="btn btn-info">
|
||||||
<input name="radio-toggle-1" type="radio">
|
<input name="radio-toggle-1" type="radio">
|
||||||
Edit .gitignore
|
Edit .gitignore
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<div id="gitignore" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×
|
||||||
|
</button>
|
||||||
|
<h4 class="modal-title">{% trans "Edit .gitignore" %}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
|
||||||
|
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-12 control-label" style="text-align: center;">{% trans "Contents of .gitignore, use the box below to Add/Edit content of .gitingore file." %}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<textarea ng-model="gitIgnoreContent" rows="3" class="form-control"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button"
|
||||||
|
class="btn btn-primary"
|
||||||
|
ng-click="saveGitIgnore()">Save<img ng-hide="$parent.cyberpanelLoading"
|
||||||
|
src="/static/images/loading.gif"
|
||||||
|
style="display: none;">
|
||||||
|
</button>
|
||||||
|
<button type="button"
|
||||||
|
class="btn btn-default" data-dismiss="modal">
|
||||||
|
Close
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<a data-toggle="modal" data-target="#removeGit" href="#" class="btn btn-info">
|
<a data-toggle="modal" data-target="#removeGit" href="#" class="btn btn-info">
|
||||||
<input name="radio-toggle-1" type="radio">
|
<input name="radio-toggle-1" type="radio">
|
||||||
Remove Git
|
Remove Git
|
||||||
@@ -405,7 +451,7 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|
||||||
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
||||||
<div ng-hide="installationDetailsForm" class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-13 control-label" style="text-align: center;">{% trans "Removing git tracking is not reversible, it will delete all of your commit history, however your files stays there." %}</label>
|
<label class="col-sm-13 control-label" style="text-align: center;">{% trans "Removing git tracking is not reversible, it will delete all of your commit history, however your files stays there." %}</label>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -435,13 +481,14 @@
|
|||||||
<th>Total Commits</th>
|
<th>Total Commits</th>
|
||||||
<th>Branch</th>
|
<th>Branch</th>
|
||||||
<th>Remote</th>
|
<th>Remote</th>
|
||||||
|
<th>Commits</th>
|
||||||
<th>Manage</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><span class="bs-badge badge-success">{$ totalCommits $}</span></td>
|
<td>
|
||||||
|
<span class="bs-badge badge-success">{$ totalCommits $}</span>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select ng-change="changeBranch()" ng-model="branchName" class="form-control">
|
<select ng-change="changeBranch()" ng-model="branchName" class="form-control">
|
||||||
<option ng-repeat="branch in branches track by $index">{$ branch $}</option>
|
<option ng-repeat="branch in branches track by $index">{$ branch $}</option>
|
||||||
@@ -568,7 +615,162 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td>
|
||||||
|
<button data-toggle="modal" data-target="#settings" style="margin-left: 2%"
|
||||||
|
type="button" class="btn btn-primary">
|
||||||
|
{% trans "View Commits" %}
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<table ng-hide="gitCommitsTable" style="margin-top: 2%" class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Total Commits</th>
|
||||||
|
<th>Branch</th>
|
||||||
|
<th>Remote</th>
|
||||||
|
<th>Commits</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<span class="bs-badge badge-success">{$ totalCommits $}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select ng-change="changeBranch()" ng-model="branchName" class="form-control">
|
||||||
|
<option ng-repeat="branch in branches track by $index">{$ branch $}</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<button data-toggle="modal" data-target="#settings" style="margin-left: 2%"
|
||||||
|
type="button" class="btn btn-primary">
|
||||||
|
{% trans "View/Setup Remote" %}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div id="settings" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×
|
||||||
|
</button>
|
||||||
|
<h4 class="modal-title">{% trans "Setup Remote" %}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
|
||||||
|
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
||||||
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Git Host" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input placeholder="Ex. github.com or gitlab.com"
|
||||||
|
name="gitHost" type="text" class="form-control"
|
||||||
|
ng-model="$parent.gitHost" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Username" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input name="gitUsername" type="text" class="form-control"
|
||||||
|
ng-model="$parent.gitUsername" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Repo Name" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input name="gitReponame" type="text" class="form-control"
|
||||||
|
ng-model="$parent.gitReponame" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
|
||||||
|
<div class="col-sm-12">
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{% trans "Current Remote" %}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<textarea rows="2"
|
||||||
|
class="form-control">{$ remoteResult $}</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
|
||||||
|
<div class="col-sm-12">
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{% trans "Deployment Key" %}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<textarea rows="5"
|
||||||
|
class="form-control">{$ deploymentKey $}</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" ng-disabled="savingSettings"
|
||||||
|
class="btn btn-primary"
|
||||||
|
ng-click="setupRemote()">Save <img ng-hide="cyberpanelLoading"
|
||||||
|
src="/static/images/loading.gif"
|
||||||
|
style="display: none;">
|
||||||
|
</button>
|
||||||
|
<button type="button" ng-disabled="savingSettings"
|
||||||
|
class="btn btn-default" data-dismiss="modal">
|
||||||
|
Close
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button data-toggle="modal" data-target="#settings" style="margin-left: 2%"
|
||||||
|
type="button" class="btn btn-primary">
|
||||||
|
{% trans "View Commits" %}
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -130,6 +130,8 @@ urlpatterns = [
|
|||||||
url(r'^gitPush$', views.gitPush, name='gitPush'),
|
url(r'^gitPush$', views.gitPush, name='gitPush'),
|
||||||
url(r'^attachRepoGIT$', views.attachRepoGIT, name='attachRepoGIT'),
|
url(r'^attachRepoGIT$', views.attachRepoGIT, name='attachRepoGIT'),
|
||||||
url(r'^removeTracking$', views.removeTracking, name='removeTracking'),
|
url(r'^removeTracking$', views.removeTracking, name='removeTracking'),
|
||||||
|
url(r'^fetchGitignore$', views.fetchGitignore, name='fetchGitignore'),
|
||||||
|
url(r'^saveGitIgnore$', views.saveGitIgnore, name='saveGitIgnore'),
|
||||||
|
|
||||||
|
|
||||||
## Catch all for domains
|
## Catch all for domains
|
||||||
|
|||||||
@@ -805,3 +805,19 @@ def removeTracking(request):
|
|||||||
return wm.removeTracking(userID, json.loads(request.body))
|
return wm.removeTracking(userID, json.loads(request.body))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
def fetchGitignore(request):
|
||||||
|
try:
|
||||||
|
userID = request.session['userID']
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.fetchGitignore(userID, json.loads(request.body))
|
||||||
|
except KeyError:
|
||||||
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
def saveGitIgnore(request):
|
||||||
|
try:
|
||||||
|
userID = request.session['userID']
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.saveGitIgnore(userID, json.loads(request.body))
|
||||||
|
except KeyError:
|
||||||
|
return redirect(loadLoginPage)
|
||||||
@@ -3150,6 +3150,12 @@ StrictHostKeyChecking no
|
|||||||
else:
|
else:
|
||||||
return ACLManager.loadErrorJson()
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
|
|
||||||
|
if self.branchName.find('*') > -1:
|
||||||
|
data_ret = {'status': 0, 'commandStatus': 'Already on this branch.', 'error_message': 'Already on this branch.'}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
## Check if remote exists
|
## Check if remote exists
|
||||||
|
|
||||||
command = 'git -C %s checkout %s' % (self.folder, self.branchName.strip(' '))
|
command = 'git -C %s checkout %s' % (self.folder, self.branchName.strip(' '))
|
||||||
@@ -3401,12 +3407,22 @@ StrictHostKeyChecking no
|
|||||||
command = 'git config --global --unset core.sshCommand'
|
command = 'git config --global --unset core.sshCommand'
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
from filemanager.filemanager import FileManager
|
||||||
|
|
||||||
|
fm = FileManager(None, None)
|
||||||
|
fm.fixPermissions(self.domain)
|
||||||
|
|
||||||
data_ret = {'status': 1, 'commandStatus': commandStatus}
|
data_ret = {'status': 1, 'commandStatus': commandStatus}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
from filemanager.filemanager import FileManager
|
||||||
|
|
||||||
|
fm = FileManager(None, None)
|
||||||
|
fm.fixPermissions(self.domain)
|
||||||
|
|
||||||
command = 'git config --global --unset core.sshCommand'
|
command = 'git config --global --unset core.sshCommand'
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
@@ -3450,3 +3466,88 @@ StrictHostKeyChecking no
|
|||||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
def fetchGitignore(self, userID=None, data=None):
|
||||||
|
try:
|
||||||
|
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
|
self.domain = data['domain']
|
||||||
|
self.folder = data['folder']
|
||||||
|
|
||||||
|
|
||||||
|
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ACLManager.loadErrorJson('status', 0)
|
||||||
|
|
||||||
|
if self.folderCheck():
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
|
command = 'cat %s/.gitignore' % (self.folder)
|
||||||
|
gitIgnoreContent = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
|
if gitIgnoreContent.find('No such file or directory') > -1:
|
||||||
|
gitIgnoreContent = 'File is currently empty.'
|
||||||
|
|
||||||
|
data_ret = {'status': 1, 'gitIgnoreContent': gitIgnoreContent}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
def saveGitIgnore(self, userID=None, data=None):
|
||||||
|
try:
|
||||||
|
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
|
self.domain = data['domain']
|
||||||
|
self.folder = data['folder']
|
||||||
|
self.gitIgnoreContent = data['gitIgnoreContent']
|
||||||
|
|
||||||
|
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||||
|
|
||||||
|
|
||||||
|
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ACLManager.loadErrorJson('status', 0)
|
||||||
|
|
||||||
|
if self.folderCheck():
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
|
## Write to temp file
|
||||||
|
|
||||||
|
writeToFile = open(tempPath, 'w')
|
||||||
|
writeToFile.write(self.gitIgnoreContent)
|
||||||
|
writeToFile.close()
|
||||||
|
|
||||||
|
## Move to original file
|
||||||
|
|
||||||
|
command = 'mv %s %s/.gitignore' % (tempPath, self.folder)
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
## Fix permissions
|
||||||
|
|
||||||
|
from filemanager.filemanager import FileManager
|
||||||
|
|
||||||
|
fm = FileManager(None, None)
|
||||||
|
fm.fixPermissions(self.domain)
|
||||||
|
|
||||||
|
data_ret = {'status': 1}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
Reference in New Issue
Block a user