diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js
index dcb72ef15..78f213b6f 100755
--- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js
+++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js
@@ -5793,6 +5793,7 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
$scope.loadingSticks = true;
$scope.gitTracking = true;
$scope.gitEnable = true;
+ $scope.statusBox = true;
var statusFile;
@@ -6029,6 +6030,122 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
}
};
+ $scope.createNewBranch = function () {
+ $scope.cyberpanelLoading = false;
+ $scope.commandStatus = "";
+ $scope.statusBox = false;
+
+ url = "/websites/createNewBranch";
+
+
+ var data = {
+ domain: $("#domain").text(),
+ folder: $scope.folder,
+ newBranchName: $scope.newBranchName
+
+ };
+
+ 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: 'Changes applied.',
+ type: 'success'
+ });
+ $scope.commandStatus = response.data.commandStatus;
+ $scope.fetchFolderDetails();
+ } else {
+ new PNotify({
+ title: 'Operation Failed!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ $scope.commandStatus = response.data.commandStatus;
+ }
+
+
+ }
+
+ function cantLoadInitialDatas(response) {
+ $scope.cyberpanelLoading = false;
+ new PNotify({
+ title: 'Operation Failed!',
+ text: 'Could not connect to server, please refresh this page.',
+ type: 'error'
+ });
+
+
+ }
+ };
+
+ $scope.commitChanges = function () {
+ $scope.cyberpanelLoading = false;
+ $scope.commandStatus = "";
+ $scope.statusBox = false;
+
+ url = "/websites/commitChanges";
+
+
+ var data = {
+ domain: $("#domain").text(),
+ folder: $scope.folder,
+ commitMessage: $scope.commitMessage
+
+ };
+
+ 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: 'Changes applied.',
+ type: 'success'
+ });
+ $scope.commandStatus = response.data.commandStatus;
+ $scope.fetchFolderDetails();
+ } else {
+ new PNotify({
+ title: 'Operation Failed!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ $scope.commandStatus = response.data.commandStatus;
+ }
+
+
+ }
+
+ function cantLoadInitialDatas(response) {
+ $scope.cyberpanelLoading = false;
+ new PNotify({
+ title: 'Operation Failed!',
+ text: 'Could not connect to server, please refresh this page.',
+ type: 'error'
+ });
+
+
+ }
+ };
+
function getCreationStatus() {
url = "/websites/installWordpressStatus";
diff --git a/websiteFunctions/templates/websiteFunctions/manageGIT.html b/websiteFunctions/templates/websiteFunctions/manageGIT.html
index 886d0dfe4..9f0423338 100755
--- a/websiteFunctions/templates/websiteFunctions/manageGIT.html
+++ b/websiteFunctions/templates/websiteFunctions/manageGIT.html
@@ -40,6 +40,131 @@
Init Repo
+
+
@@ -52,7 +177,7 @@
- | {$ totalCommits $} |
+ {$ totalCommits $} |
|
+
diff --git a/websiteFunctions/urls.py b/websiteFunctions/urls.py
index 212c0e448..d717491c5 100755
--- a/websiteFunctions/urls.py
+++ b/websiteFunctions/urls.py
@@ -124,6 +124,8 @@ urlpatterns = [
url(r'^initRepo$', views.initRepo, name='initRepo'),
url(r'^setupRemote$', views.setupRemote, name='setupRemote'),
url(r'^changeGitBranch$', views.changeGitBranch, name='changeGitBranch'),
+ url(r'^createNewBranch$', views.createNewBranch, name='createNewBranch'),
+ url(r'^commitChanges$', views.commitChanges, name='commitChanges'),
## Catch all for domains
url(r'^(?P(.*))/(?P(.*))$', views.launchChild, name='launchChild'),
url(r'^(?P(.*))$', views.domain, name='domain'),
diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py
index 113ea683f..e88de38ea 100755
--- a/websiteFunctions/views.py
+++ b/websiteFunctions/views.py
@@ -755,5 +755,21 @@ def changeGitBranch(request):
userID = request.session['userID']
wm = WebsiteManager()
return wm.changeGitBranch(userID, json.loads(request.body))
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def createNewBranch(request):
+ try:
+ userID = request.session['userID']
+ wm = WebsiteManager()
+ return wm.createNewBranch(userID, json.loads(request.body))
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def commitChanges(request):
+ try:
+ userID = request.session['userID']
+ wm = WebsiteManager()
+ return wm.commitChanges(userID, json.loads(request.body))
except KeyError:
return redirect(loadLoginPage)
\ No newline at end of file
diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py
index 4cbdf8a38..f00b6cf39 100755
--- a/websiteFunctions/website.py
+++ b/websiteFunctions/website.py
@@ -3140,3 +3140,84 @@ StrictHostKeyChecking no
data_ret = {'status': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
+
+ def createNewBranch(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.newBranchName = data['newBranchName']
+
+ if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson('status', 0)
+
+ if self.folderCheck():
+ pass
+ else:
+ return ACLManager.loadErrorJson()
+
+ ## Check if remote exists
+
+ command = 'git -C %s checkout -b %s' % (self.folder, self.newBranchName)
+ commandStatus = ProcessUtilities.outputExecutioner(command)
+
+ if commandStatus.find(self.newBranchName) > -1:
+ data_ret = {'status': 1, 'commandStatus': commandStatus}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+ else:
+ data_ret = {'status': 0, 'error_message': 'Failed to create branch', 'commandStatus': commandStatus}
+ 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 commitChanges(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.commitMessage = data['commitMessage']
+
+ if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson('status', 0)
+
+ if self.folderCheck():
+ pass
+ else:
+ return ACLManager.loadErrorJson()
+
+ ## Check if remote exists
+
+ command = 'git -C %s add -A' % (self.folder)
+ ProcessUtilities.outputExecutioner(command)
+
+ command = 'git -C %s commit -m %s' % (self.folder, self.commitMessage)
+ commandStatus = ProcessUtilities.outputExecutioner(command)
+
+ if commandStatus.find('nothing to commit') == -1:
+ data_ret = {'status': 1, 'commandStatus': commandStatus}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+ else:
+ data_ret = {'status': 0, 'error_message': 'Nothing to commit.', 'commandStatus': commandStatus}
+ 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)