Skip to content
Snippets Groups Projects
Commit b4d60557 authored by srosse's avatar srosse
Browse files

OO-4048: send only to course coaches, not to coaches of other groups

parent 60e99667
No related branches found
No related tags found
No related merge requests found
......@@ -1092,7 +1092,7 @@ public class BusinessGroupServiceImpl implements BusinessGroupService {
if(coaches.isEmpty()) {
Collection<BusinessGroup> groups = Collections.singletonList(group);
List<RepositoryEntry> entries = businessGroupRelationDAO.findRepositoryEntries(groups, 0, -1);
coaches.addAll(repositoryService.getMembers(entries, RepositoryEntryRelationType.all, GroupRoles.coach.name()));
coaches.addAll(repositoryService.getMembers(entries, RepositoryEntryRelationType.defaultGroup, GroupRoles.coach.name()));
if(coaches.isEmpty()) {
//get system administrators of the user's organisations
......
......@@ -65,6 +65,7 @@ import org.olat.group.model.LeaveOption;
import org.olat.group.model.MembershipModification;
import org.olat.group.model.SearchBusinessGroupParams;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.manager.RepositoryEntryRelationDAO;
import org.olat.resource.accesscontrol.ACService;
import org.olat.resource.accesscontrol.ResourceReservation;
import org.olat.resource.accesscontrol.manager.ACReservationDAO;
......@@ -92,12 +93,14 @@ public class BusinessGroupServiceTest extends OlatTestCase {
@Autowired
private UserManager userManager;
@Autowired
private ACReservationDAO reservationDao;
@Autowired
private BaseSecurity securityManager;
@Autowired
private ACReservationDAO reservationDao;
@Autowired
private BusinessGroupRelationDAO businessGroupRelationDao;
@Autowired
private RepositoryEntryRelationDAO repositoryEntryRelationDao;
@Autowired
private BusinessGroupModule businessGroupModule;
@Autowired
private BusinessGroupService businessGroupService;
......@@ -1153,6 +1156,38 @@ public class BusinessGroupServiceTest extends OlatTestCase {
}
}
@Test
public void allowToLeavingBusinessGroup_withCourse_andGroups() {
//authors group
RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
Identity coachCourse = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-8-");
Identity coachGroup = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-8-");
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-8-");
BusinessGroup group1 = businessGroupService.createBusinessGroup(null, "Leaving group 8a", "But you cannot leave :-(", Integer.valueOf(0), Integer.valueOf(2), false, false, resource);
BusinessGroup group2 = businessGroupService.createBusinessGroup(null, "Leaving group 8b", "But you cannot leave :-(", Integer.valueOf(0), Integer.valueOf(2), false, false, resource);
repositoryEntryRelationDao.addRole(coachCourse, resource, GroupRoles.coach.name());
businessGroupRelationDao.addRole(coachGroup, group2, GroupRoles.coach.name());
businessGroupRelationDao.addRole(participant, group1, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
//set to not allowed to leave
group1 = businessGroupService.updateAllowToLeaveBusinessGroup(group1, false);
dbInstance.commitAndCloseSession();
//check the authors group leaving option
LeaveOption optionToLeave = businessGroupService.isAllowToLeaveBusinessGroup(participant, group1);
Assert.assertNotNull(optionToLeave);
Assert.assertFalse(optionToLeave.isAllowToLeave());
ContactList contacts = optionToLeave.getContacts();
Collection<Identity> contactList = contacts.getIdentiEmails().values();
Assert.assertNotNull(contactList);
Assert.assertFalse(contactList.isEmpty());
Assert.assertEquals(1, contactList.size());
Assert.assertTrue(contactList.contains(coachCourse));
Assert.assertFalse(contactList.contains(coachGroup));// coach of other group doesn't receive an email
}
@Test
public void allowToLeavingBusinessGroup_subOrganisation() {
// a special
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment