def getGroup(self, group_principal_id): prefix = PersonContainerAuthenticationPlugin.group_prefix if not group_principal_id.startswith(prefix): return None groups = IGroupContainer(ISchoolToolApplication(None), None) if groups is None: return None group_id = group_principal_id[len(prefix):] return groups.get(group_id, None)
def evolvePerson(app, schoolyear, person): groups = IGroupContainer(schoolyear) admin_names = ('manager', 'administrators', 'clerks') admin_groups = [groups.get(name) for name in admin_names if name in groups] person_groups = [group for group in Membership.query(member=person) if group.__parent__.__name__ == groups.__name__] if any([group in admin_groups for group in person_groups]): for group in admin_groups: if group not in person_groups: Membership(group=group, member=person)
def makeManager(app, schoolyear, person): groups = IGroupContainer(schoolyear) default_admin_names = ('manager', 'clerks') admin_groups = [groups.get(name) for name in default_admin_names if name in groups] person_groups = [group for group in Membership.query(member=person) if group.__parent__.__name__ == groups.__name__] for group in admin_groups: if group not in person_groups: Membership(group=group, member=person)