Ejemplo n.º 1
0
    def __iter__(self):
        if IPerson.providedBy(self.context):
            groups = [group for group in self.context.groups
                      if IGroup.providedBy(group)]
        else:
            groups = list(IGroupContainer(ISchoolToolApplication(None), {}).values())

        for group in sorted(groups, key=lambda g: g.__name__):
            yield GroupTerm(group)
Ejemplo n.º 2
0
def updateStudentCalendars(event):
    """Add section's calendar to students overlaid calendars."""

    if event.rel_type != URIMembership:
        return

    section = event[URIGroup]

    # Only continue if we're working with Sections rather than generic groups
    if not ISection.providedBy(section):
        return

    member = event[URIMember]

    calendar = ISchoolToolCalendar(section)
    if IRelationshipAddedEvent.providedBy(event):
        if IPerson.providedBy(member) and \
                calendar not in member.overlaid_calendars:
            member.overlaid_calendars.add(calendar)

        elif IGroup.providedBy(member):
            for person in member.members:
                # we don't handle nested groups any more so there
                # shouldn't be more than one layer of groups
                if IPerson.providedBy(person) and \
                       calendar not in person.overlaid_calendars:
                    person.overlaid_calendars.add(calendar)

    elif IRelationshipRemovedEvent.providedBy(event):
        if IPerson.providedBy(member):
            if calendar in member.overlaid_calendars:
                for group in member.groups:
                    if group in section.members:
                        return
                member.overlaid_calendars.remove(calendar)

        elif IGroup.providedBy(member):
            for person in member.members:
                if IPerson.providedBy(person):
                    if calendar in person.overlaid_calendars:
                        if person not in section.members:
                            person.overlaid_calendars.remove(calendar)
Ejemplo n.º 3
0
def updateStudentCalendars(event):
    """Add section's calendar to students overlaid calendars."""

    if event.rel_type != URIMembership:
        return

    section = event[URIGroup]

    # Only continue if we're working with Sections rather than generic groups
    if not ISection.providedBy(section):
        return

    member = event[URIMember]

    calendar = ISchoolToolCalendar(section)
    if IRelationshipAddedEvent.providedBy(event):
        if IPerson.providedBy(member) and \
                calendar not in member.overlaid_calendars:
            member.overlaid_calendars.add(calendar)

        elif IGroup.providedBy(member):
            for person in member.members:
                # we don't handle nested groups any more so there
                # shouldn't be more than one layer of groups
                if IPerson.providedBy(person) and \
                       calendar not in person.overlaid_calendars:
                    person.overlaid_calendars.add(calendar)

    elif IRelationshipRemovedEvent.providedBy(event):
        if IPerson.providedBy(member):
            if calendar in member.overlaid_calendars:
                for group in member.groups:
                    if group in section.members:
                        return
                member.overlaid_calendars.remove(calendar)

        elif IGroup.providedBy(member):
            for person in member.members:
                if IPerson.providedBy(person):
                    if calendar in person.overlaid_calendars:
                        if person not in section.members:
                            person.overlaid_calendars.remove(calendar)
Ejemplo n.º 4
0
    def __iter__(self):
        if IPerson.providedBy(self.context):
            groups = [
                group for group in self.context.groups
                if IGroup.providedBy(group)
            ]
        else:
            groups = list(
                IGroupContainer(ISchoolToolApplication(None), {}).values())

        for group in sorted(groups, key=lambda g: g.__name__):
            yield GroupTerm(group)
Ejemplo n.º 5
0
def use_student_enrollment_states(other, collection):
    other = removeSecurityProxy(other)
    collection = removeSecurityProxy(collection)
    return (getattr(other, '__name__') == 'students'
            and collection.rel_type == URIMembership
            and IGroup.providedBy(other) and not ISection.providedBy(other))