Fixing issue with creating roles

This commit is contained in:
kevgliss 2015-08-17 22:51:29 -07:00
parent 95ac5245e1
commit f09f5eb0f1
5 changed files with 26 additions and 7 deletions

View File

@ -23,9 +23,10 @@ CertificateOwnerNeed = partial(CertificateOwner, 'certificateView')
class ViewKeyPermission(Permission):
def __init__(self, role_id, certificate_id):
def __init__(self, certificate_id, owner_id):
c_need = CertificateCreatorNeed(str(certificate_id))
o_need = CertificateOwnerNeed(str(role_id))
o_need = CertificateOwnerNeed(str(owner_id))
super(ViewKeyPermission, self).__init__(o_need, c_need, RoleNeed('admin'))

View File

@ -140,7 +140,7 @@ class RolesList(AuthenticatedResource):
self.reqparse.add_argument('description', type=str, location='json')
self.reqparse.add_argument('username', type=str, location='json')
self.reqparse.add_argument('password', type=str, location='json')
self.reqparse.add_argument('users', type=dict, location='json')
self.reqparse.add_argument('users', type=list, location='json')
args = self.reqparse.parse_args()
return service.create(args['name'], args.get('password'), args.get('description'), args.get('username'),

View File

@ -18,6 +18,12 @@ angular.module('lemur')
$modalInstance.dismiss('cancel');
};
$scope.userPage = 1;
$scope.loadMoreRoles = function () {
$scope.userPage += 1;
RoleService.loadMoreUsers($scope.role, $scope.userPage);
};
$scope.userService = UserService;
$scope.roleService = RoleService;
})

View File

@ -27,7 +27,7 @@
Username
</label>
<div class="col-sm-10">
<input ng-show="!role.fromServer" name="username" ng-model="role.username" placeholder="Username" class="form-control" required/>
<input ng-show="!role.fromServer" name="username" ng-model="role.username" placeholder="Username" class="form-control"/>
<div class="well">
<span ng-show="role.password">
{{ role.username }}
@ -43,7 +43,7 @@
Password
</label>
<div class="col-sm-10">
<input ng-show="!role.fromServer" type="password" name="password" ng-model="role.password" placeholder="hunter2" class="form-control" required/>
<input ng-show="!role.fromServer" type="password" name="password" ng-model="role.password" placeholder="hunter2" class="form-control"/>
<p ng-show="createForm.password.$invalid && !createForm.password.$pristine" class="help-block">You must enter an password</p>
<div class="well">
<span ng-show="role.password">
@ -61,7 +61,7 @@
<input tooltip="You can attach any user to this role, once attached they will have access as defined by this role"
typeahead="user.username for user in userService.findUserByName($viewValue)" typeahead-loading="loadingUsers"
typeahead-min-wait="100" typeahead-on-select="role.addUser($item)"
type="text" name="user" ng-model="role.selectedUser" placeholder="Username..." class="form-control" required/>
type="text" name="user" ng-model="role.selectedUser" placeholder="Username..." class="form-control"/>
<table ng-show="role.users" class="table">
<tr ng-repeat="user in role.users track by $index">
<td>{{ user.username }}</td>
@ -69,6 +69,10 @@
<button type="button" ng-click="role.removeUser($index)" class="btn btn-danger btn-sm pull-right">Remove</button>
</td>
</tr>
<tr>
<td></td>
<td><a class="pull-right" ng-click="loadMoreUsers()"><strong>More</strong></a></td>
</tr>
</table>
</div>
</div>

View File

@ -34,11 +34,19 @@ angular.module('lemur')
};
RoleService.getUsers = function (role) {
role.customGET('users').then(function (users) {
return role.getList('users').then(function (users) {
role.users = users;
});
};
RoleService.loadMoreUsers = function (role, page) {
role.getList('users', {page: page}).then(function (users) {
_.each(users, function (user) {
role.users.push(user);
});
});
};
RoleService.create = function (role) {
return RoleApi.post(role).then(
function () {