Esempio n. 1
0
def updateInstructorCalendars(event):
    """Add section's calendar to instructors overlaid calendars."""

    if event.rel_type != URIInstruction:
        return

    person = event[URIInstructor]
    section = event[URISection]
    calendar = ISchoolToolCalendar(section)
    if IRelationshipAddedEvent.providedBy(event):
        if calendar not in person.overlaid_calendars:
            person.overlaid_calendars.add(calendar)
    elif IRelationshipRemovedEvent.providedBy(event):
        if calendar in person.overlaid_calendars:
            person.overlaid_calendars.remove(calendar)
def updateInstructorCalendars(event):
    """Add section's calendar to instructors overlaid calendars."""

    if event.rel_type != URIInstruction:
        return

    person = event[URIInstructor]
    section = event[URISection]
    calendar = ISchoolToolCalendar(section)
    if IRelationshipAddedEvent.providedBy(event):
        if calendar not in person.overlaid_calendars:
            person.overlaid_calendars.add(calendar)
    elif IRelationshipRemovedEvent.providedBy(event):
        if calendar in person.overlaid_calendars:
            person.overlaid_calendars.remove(calendar)
Esempio 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)
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)