def get_people(parent_event_ids=[],
               foreign_event_ids=[],
               labels=[],
               label_sets=[],
               roles=[]):
    if len(labels) > 0 and len(label_sets) > 0:
        return PeopleResponse(errors=[
            Error(code="INVALID_REQUEST",
                  details="labels and label_sets are not compatible"),
        ])
    people = []
    bookings = ResourceAllocation.objects.all()
    if len(labels) > 0:
        bookings = bookings.filter(event__eventlabel__text__in=labels)
    for label_set in label_sets:
        bookings = bookings.filter(event__eventlabel__text__in=label_set)
    if len(parent_event_ids) > 0:
        bookings = bookings.filter(
            Q(event__container_event__parent_event__eventitem__eventitem_id__in
              =(parent_event_ids))
            | Q(event__eventitem__eventitem_id__in=parent_event_ids))
    if len(foreign_event_ids) > 0:
        bookings = bookings.filter(
            event__eventitem__eventitem_id__in=foreign_event_ids)
    if len(roles) > 0:
        bookings = bookings.filter(resource__worker__role__in=roles)
    for booking in bookings:
        if booking.resource.as_subtype.__class__.__name__ == "Worker":
            person = Person(booking=booking)
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]

    return PeopleResponse(people=people)
Beispiel #2
0
def get_people(parent_event_ids=[], labels=[], label_sets=[], roles=[]):
    if len(labels) > 0 and len(label_sets) > 0:
        return PeopleResponse(
            errors=[Error(
                code="INVALID_REQUEST",
                details="labels and label_sets are not compatible"), ])
    people = []
    bookings = ResourceAllocation.objects.all()
    act_bookings = []
    if len(labels) > 0:
        bookings = bookings.filter(event__eventlabel__text__in=labels)
    for label_set in label_sets:
        bookings = bookings.filter(event__eventlabel__text__in=label_set)
    if len(parent_event_ids) > 0:
        bookings = bookings.filter(Q(
            event__container_event__parent_event__eventitem__eventitem_id__in=(
                parent_event_ids)) |
            Q(event__eventitem__eventitem_id__in=parent_event_ids))
    if "Performer" in roles:
        act_bookings = bookings.filter(resource__actresource__pk__gt=0)
    if len(roles) > 0:
        bookings = bookings.filter(resource__worker__role__in=roles)
    for booking in bookings:
        if booking.resource.as_subtype.__class__.__name__ == "Worker":
            person = Person(
                booking_id=booking.pk,
                worker=booking.resource.worker,
                role=booking.resource.worker.role,
                )
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    for booking in act_bookings:
        if booking.resource.as_subtype.__class__.__name__ == "ActResource":
            performer = booking.resource.actresource.item.as_subtype.performer
            person = Person(
                booking_id=booking.pk,
                user=performer.user_object,
                role="Performer",
                public_class=performer.__class__.__name__,
                public_id=performer.pk
                )
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    return PeopleResponse(people=people)
 def people(self):
     people = []
     for booking in self.resources_allocated.all():
         if booking.resource.as_subtype.__class__.__name__ == "Worker":
             person = Person(booking=booking)
             if hasattr(booking, 'label'):
                 person.label = booking.label.text
             people += [person]
     return people
Beispiel #4
0
def get_people(parent_event_ids=[], labels=[], label_sets=[], roles=[]):
    if len(labels) > 0 and len(label_sets) > 0:
        return PeopleResponse(errors=[
            Error(code="INVALID_REQUEST",
                  details="labels and label_sets are not compatible"),
        ])
    people = []
    bookings = ResourceAllocation.objects.all()
    act_bookings = []
    if len(labels) > 0:
        bookings = bookings.filter(event__eventlabel__text__in=labels)
    for label_set in label_sets:
        bookings = bookings.filter(event__eventlabel__text__in=label_set)
    if len(parent_event_ids) > 0:
        bookings = bookings.filter(
            Q(event__container_event__parent_event__eventitem__eventitem_id__in
              =(parent_event_ids))
            | Q(event__eventitem__eventitem_id__in=parent_event_ids))
    if "Performer" in roles:
        act_bookings = bookings.filter(resource__actresource__pk__gt=0)
    if len(roles) > 0:
        bookings = bookings.filter(resource__worker__role__in=roles)
    for booking in bookings:
        if booking.resource.as_subtype.__class__.__name__ == "Worker":
            person = Person(
                booking_id=booking.pk,
                worker=booking.resource.worker,
                role=booking.resource.worker.role,
            )
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    for booking in act_bookings:
        if booking.resource.as_subtype.__class__.__name__ == "ActResource":
            performer = booking.resource.actresource.item.as_subtype.performer
            person = Person(booking_id=booking.pk,
                            user=performer.user_object,
                            role="Performer",
                            public_class=performer.__class__.__name__,
                            public_id=performer.pk)
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    return PeopleResponse(people=people)
Beispiel #5
0
 def people(self):
     people = []
     for booking in ResourceAllocation.objects.filter(event=self):
         if booking.resource.as_subtype.__class__.__name__ == "Worker":
             person = Person(booking_id=booking.pk,
                             worker=booking.resource.worker)
             if hasattr(booking, 'label'):
                 person.label = booking.label.text
             people += [person]
     return people
Beispiel #6
0
 def people(self):
     people = []
     for booking in ResourceAllocation.objects.filter(event=self):
         if booking.resource.as_subtype.__class__.__name__ == "Worker":
             person = Person(
                 booking_id=booking.pk,
                 worker=booking.resource.worker)
             if hasattr(booking, 'label'):
                 person.label = booking.label.text
             people += [person]
     return people
Beispiel #7
0
def get_all_container_bookings(occurrence_ids, roles=[]):
    people = []
    bookings = ResourceAllocation.objects.filter(
        Q(event__pk__in=occurrence_ids) |
        Q(event__contained_events__child_event__pk__in=occurrence_ids)
        ).distinct()
    if len(roles) > 0:
        bookings = bookings.filter(resource__worker__role__in=roles)
    for booking in bookings:
        if booking.resource.as_subtype.__class__.__name__ == "Worker":
            person = Person(booking=booking)
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    return PeopleResponse(people=people)
Beispiel #8
0
def get_bookings(occurrence_ids, roles=[]):
    people = []
    bookings = ResourceAllocation.objects.filter(event__pk__in=occurrence_ids)
    if len(roles) > 0:
        bookings = bookings.filter(resource__worker__role__in=roles)
    for booking in bookings:
        if booking.resource.as_subtype.__class__.__name__ == "Worker":
            person = Person(
                booking_id=booking.pk,
                worker=booking.resource.worker,
                role=booking.resource.worker.role,
            )
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    return PeopleResponse(people=people)
Beispiel #9
0
def get_bookings(occurrence_ids, roles=[]):
    people = []
    bookings = ResourceAllocation.objects.filter(event__pk__in=occurrence_ids)
    if len(roles) > 0:
        bookings = bookings.filter(resource__worker__role__in=roles)
    for booking in bookings:
        if booking.resource.as_subtype.__class__.__name__ == "Worker":
            person = Person(
                booking_id=booking.pk,
                worker=booking.resource.worker,
                role=booking.resource.worker.role,
                )
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    return PeopleResponse(people=people)