Merge pull request #3460 from vismay-golwala/project_admin_issue

Project admin manual SCM Type creation bug fix

Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
softwarefactory-project-zuul[bot]
2019-04-05 15:43:49 +00:00
committed by GitHub
3 changed files with 7 additions and 19 deletions

View File

@@ -221,7 +221,8 @@ class ApiV1ConfigView(APIView):
if request.user.is_superuser \ if request.user.is_superuser \
or request.user.is_system_auditor \ or request.user.is_system_auditor \
or Organization.accessible_objects(request.user, 'admin_role').exists() \ or Organization.accessible_objects(request.user, 'admin_role').exists() \
or Organization.accessible_objects(request.user, 'auditor_role').exists(): or Organization.accessible_objects(request.user, 'auditor_role').exists() \
or Organization.accessible_objects(request.user, 'project_admin_role').exists():
data.update(dict( data.update(dict(
project_base_dir = settings.PROJECTS_ROOT, project_base_dir = settings.PROJECTS_ROOT,
project_local_paths = Project.get_local_path_choices(), project_local_paths = Project.get_local_path_choices(),

View File

@@ -51,20 +51,7 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
$scope.projectLoadedRemove(); $scope.projectLoadedRemove();
} }
$scope.projectLoadedRemove = $scope.$on('projectLoaded', function() { $scope.projectLoadedRemove = $scope.$on('projectLoaded', function() {
var opts = []; GetProjectPath({ scope: $scope, master: master });
if (Authorization.getUserInfo('is_superuser') === true) {
GetProjectPath({ scope: $scope, master: master });
} else {
opts.push({
label: $scope.local_path,
value: $scope.local_path
});
$scope.project_local_paths = opts;
$scope.local_path = $scope.project_local_paths[0];
$scope.base_dir = i18n._('You do not have access to view this property');
$scope.$emit('pathsReady');
}
$scope.pathRequired = ($scope.scm_type.value === 'manual') ? true : false; $scope.pathRequired = ($scope.scm_type.value === 'manual') ? true : false;
$scope.scmRequired = ($scope.scm_type.value !== 'manual') ? true : false; $scope.scmRequired = ($scope.scm_type.value !== 'manual') ? true : false;

View File

@@ -1,5 +1,5 @@
export default export default
function GetProjectPath(Alert, Rest, GetBasePath, ProcessErrors) { function GetProjectPath(i18n, Rest, GetBasePath, ProcessErrors) {
return function(params) { return function(params) {
var scope = params.scope, var scope = params.scope,
master = params.master; master = params.master;
@@ -53,7 +53,7 @@ export default
} }
} }
} }
scope.base_dir = data.project_base_dir; scope.base_dir = data.project_base_dir || i18n._('You do not have access to view this property');
master.local_path = scope.local_path; master.local_path = scope.local_path;
master.base_dir = scope.base_dir; // Keep in master object so that it doesn't get master.base_dir = scope.base_dir; // Keep in master object so that it doesn't get
// wiped out on form reset. // wiped out on form reset.
@@ -65,13 +65,13 @@ export default
}) })
.catch(({data, status}) => { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to access API config. GET status: ' + status }); msg: i18n._('Failed to access API config. GET status: ') + status });
}); });
}; };
} }
GetProjectPath.$inject = GetProjectPath.$inject =
[ 'Alert', [ 'i18n',
'Rest', 'Rest',
'GetBasePath', 'GetBasePath',
'ProcessErrors' 'ProcessErrors'