use of org.activityinfo.shared.dto.UserPermissionDTO in project activityinfo by bedatadriven.
the class UpdateUserPermissionsHandlerTest method testVerifyAuthorityForViewPermissions.
/**
* Asserts that someone with ManageUsersPermission will be permitted to
* grant some one edit rights.
*/
@Test
public void testVerifyAuthorityForViewPermissions() throws IllegalAccessCommandException {
UserPermission executingUserPermissions = new UserPermission();
executingUserPermissions.setPartner(NRC);
executingUserPermissions.setAllowManageUsers(true);
UserPermissionDTO dto = new UserPermissionDTO();
dto.setPartner(NRC_DTO);
dto.setAllowView(true);
UpdateUserPermissions cmd = new UpdateUserPermissions(1, dto);
UpdateUserPermissionsHandler.verifyAuthority(cmd, executingUserPermissions);
}
use of org.activityinfo.shared.dto.UserPermissionDTO in project activityinfo by bedatadriven.
the class UpdateUserPermissionsHandlerTest method testFailingVerifyAuthorityForView.
@Test(expected = IllegalAccessCommandException.class)
public void testFailingVerifyAuthorityForView() throws IllegalAccessCommandException {
UserPermission executingUserPermissions = new UserPermission();
executingUserPermissions.setPartner(IRC);
executingUserPermissions.setAllowManageUsers(true);
UserPermissionDTO dto = new UserPermissionDTO();
dto.setPartner(NRC_DTO);
dto.setAllowView(true);
dto.setAllowEdit(true);
UpdateUserPermissions cmd = new UpdateUserPermissions(1, dto);
UpdateUserPermissionsHandler.verifyAuthority(cmd, executingUserPermissions);
}
use of org.activityinfo.shared.dto.UserPermissionDTO in project activityinfo by bedatadriven.
the class UpdateUserPermissionsHandlerTest method testVerifyAuthorityForViewByOtherPartner.
@Test
public void testVerifyAuthorityForViewByOtherPartner() throws IllegalAccessCommandException {
UserPermission executingUserPermissions = new UserPermission();
executingUserPermissions.setPartner(IRC);
executingUserPermissions.setAllowManageUsers(true);
executingUserPermissions.setAllowManageAllUsers(true);
UserPermissionDTO dto = new UserPermissionDTO();
dto.setPartner(NRC_DTO);
dto.setAllowView(true);
dto.setAllowEdit(true);
UpdateUserPermissions cmd = new UpdateUserPermissions(1, dto);
UpdateUserPermissionsHandler.verifyAuthority(cmd, executingUserPermissions);
}
use of org.activityinfo.shared.dto.UserPermissionDTO in project activityinfo by bedatadriven.
the class DbUserEditor method createGrid.
private void createGrid() {
loader = new BasePagingLoader<UserResult>(new UserProxy());
store = new ListStore<UserPermissionDTO>(loader);
store.setKeyProvider(new ModelKeyProvider<UserPermissionDTO>() {
@Override
public String getKey(UserPermissionDTO model) {
return model.getEmail();
}
});
store.addListener(Store.Update, new Listener<StoreEvent<UserPermissionDTO>>() {
@Override
public void handleEvent(StoreEvent<UserPermissionDTO> event) {
toolBar.setDirty(!store.getModifiedRecords().isEmpty());
}
});
final List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("name", I18N.CONSTANTS.name(), 100));
columns.add(new ColumnConfig("email", I18N.CONSTANTS.email(), 150));
columns.add(new ColumnConfig("partner", I18N.CONSTANTS.partner(), 150));
PermissionCheckConfig allowView = new PermissionCheckConfig("allowViewSimple", I18N.CONSTANTS.allowView(), 75);
allowView.setDataIndex("allowView");
allowView.setToolTip(I18N.CONSTANTS.allowViewLong());
columns.add(allowView);
PermissionCheckConfig allowEdit = new PermissionCheckConfig("allowEditSimple", I18N.CONSTANTS.allowEdit(), 75);
allowEdit.setDataIndex("allowEdit");
allowEdit.setToolTip(I18N.CONSTANTS.allowEditLong());
columns.add(allowEdit);
PermissionCheckConfig allowViewAll = new PermissionCheckConfig("allowViewAll", I18N.CONSTANTS.allowViewAll(), 75);
allowViewAll.setToolTip(I18N.CONSTANTS.allowViewAllLong());
columns.add(allowViewAll);
PermissionCheckConfig allowEditAll = new PermissionCheckConfig("allowEditAll", I18N.CONSTANTS.allowEditAll(), 75);
allowEditAll.setToolTip(I18N.CONSTANTS.allowEditAllLong());
columns.add(allowEditAll);
PermissionCheckConfig allowManageUsers = null;
allowManageUsers = new PermissionCheckConfig("allowManageUsers", I18N.CONSTANTS.allowManageUsers(), 150);
columns.add(allowManageUsers);
PermissionCheckConfig allowManageAllUsers = new PermissionCheckConfig("allowManageAllUsers", I18N.CONSTANTS.manageAllUsers(), 150);
columns.add(allowManageAllUsers);
// only users with the right to design them selves can change the design
// attribute
PermissionCheckConfig allowDesign = new PermissionCheckConfig("allowDesign", I18N.CONSTANTS.allowDesign(), 75);
allowDesign.setToolTip(I18N.CONSTANTS.allowDesignLong());
columns.add(allowDesign);
grid = new Grid<UserPermissionDTO>(store, new ColumnModel(columns));
grid.setLoadMask(true);
grid.setSelectionModel(new GridSelectionModel<UserPermissionDTO>());
grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<UserPermissionDTO>() {
@Override
public void selectionChanged(SelectionChangedEvent<UserPermissionDTO> se) {
onSelectionChanged(se.getSelectedItem());
}
});
grid.addPlugin(allowEdit);
grid.addPlugin(allowViewAll);
grid.addPlugin(allowEditAll);
grid.addPlugin(allowManageUsers);
grid.addPlugin(allowManageAllUsers);
grid.addPlugin(allowDesign);
add(grid);
}
use of org.activityinfo.shared.dto.UserPermissionDTO in project activityinfo by bedatadriven.
the class DbUserEditor method delete.
private void delete() {
final UserPermissionDTO model = grid.getSelectionModel().getSelectedItem();
model.setAllowView(false);
model.setAllowViewAll(false);
model.setAllowEdit(false);
model.setAllowEditAll(false);
model.setAllowDesign(false);
model.setAllowManageAllUsers(false);
model.setAllowManageUsers(false);
dispatcher.execute(new UpdateUserPermissions(db.getId(), model), new MaskingAsyncMonitor(this, I18N.CONSTANTS.deleting()), new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(VoidResult result) {
store.remove(model);
}
});
}
Aggregations