예제 #1
0
 def schedule_instance(self, starttime=None, room=None, teacher=None):
     room = room or self.room
     teacher = teacher or self.teacher
     if starttime:
         sched_event = SchedEventFactory(eventitem=self.bid.eventitem_ptr,
                                         starttime=starttime)
     elif self.sched_event:
         one_day = timedelta(1)
         sched_event = SchedEventFactory(
             eventitem=self.bid.eventitem_ptr,
             starttime=self.sched_event.starttime + one_day)
     else:
         sched_event = SchedEventFactory(eventitem=self.bid.eventitem_ptr,
                                         starttime=noon(self.days[0]))
     ResourceAllocationFactory(
         event=sched_event,
         resource=LocationFactory(_item=room.locationitem_ptr))
     ResourceAllocationFactory(event=sched_event,
                               resource=WorkerFactory(
                                   _item=teacher.workeritem_ptr,
                                   role='Teacher'))
     EventLabelFactory(event=sched_event,
                       text=self.conference.conference_slug)
     EventLabelFactory(event=sched_event, text="Conference")
     return sched_event
예제 #2
0
    def __init__(self,
                 performer=None,
                 act=None,
                 show=None,
                 sched_event=None,
                 conference=None,
                 room_name=None,
                 schedule_rehearsal=False,
                 act_role="Regular Act",
                 set_waitlist=False):
        if conference:
            self.show = show or ShowFactory(e_conference=conference)
        else:
            self.show = show or ShowFactory()
        self.conference = conference or self.show.e_conference
        self.performer = performer or PersonaFactory()
        self.act = act or ActFactory(performer=self.performer,
                                     b_conference=self.conference,
                                     accepted=3,
                                     submitted=True)
        role = "Performer"
        if set_waitlist:
            self.act.accepted = 2
            self.act.save()
            act_role = "Waitlisted"
            role = "Waitlisted"
        self.tech = self.act.tech

        # schedule the show
        if sched_event:
            self.sched_event = sched_event
        else:
            self.sched_event = SchedEventFactory(
                eventitem=self.show.eventitem_ptr)
            EventLabelFactory(event=self.sched_event,
                              text=self.conference.conference_slug)
        room_name = room_name or "Dining Room"
        self.room = RoomFactory(name=room_name)
        self.room.conferences.add(self.conference)
        if not sched_event:
            ResourceAllocationFactory(
                event=self.sched_event,
                resource=LocationFactory(_item=self.room.locationitem_ptr))
        # schedule the act into the show
        self.booking = ResourceAllocationFactory(event=self.sched_event,
                                                 resource=WorkerFactory(
                                                     _item=self.act.performer,
                                                     role=role))
        self.order = OrderingFactory(allocation=self.booking,
                                     class_id=self.act.pk,
                                     class_name="Act",
                                     role=act_role)
        if schedule_rehearsal:
            self.rehearsal = self._schedule_rehearsal(self.sched_event,
                                                      self.act)
예제 #3
0
    def __init__(self,
                 profile=None,
                 bid=None,
                 event=None,
                 opportunity=None,
                 role=None):
        if not event:
            self.window = VolunteerWindowFactory()
            self.conference = self.window.day.conference
        else:
            self.conference = event.e_conference
            if not VolunteerWindow.objects.filter(
                    day__conference=self.conference).exists():
                self.window = VolunteerWindowFactory(
                    day__conference=self.conference)
            else:
                self.window = VolunteerWindow.objects.all().first()
        self.conf_day = self.window.day
        self.profile = profile or ProfileFactory()
        if not hasattr(self.profile, 'preferences'):
            ProfilePreferencesFactory(profile=self.profile)

        if bid is False:
            self.bid = None
        elif bid:
            self.bid = bid
            self.profile = self.bid.profile
        else:
            self.bid = VolunteerFactory(
                b_conference=self.conference,
                profile=self.profile)
        self.interest = VolunteerInterestFactory(
            volunteer=self.bid)
        self.event = event or ShowFactory(
            e_conference=self.conference)
        self.role = role or "Volunteer"
        self.room = RoomFactory()
        self.sched_event = SchedEventFactory(
            eventitem=self.event.eventitem_ptr,
            starttime=datetime.combine(self.window.day.day,
                                       self.window.start))
        ResourceAllocationFactory(
            event=self.sched_event,
            resource=LocationFactory(_item=self.room))
        EventLabelFactory(event=self.sched_event,
                          text="General")
        EventLabelFactory(event=self.sched_event,
                          text=self.conference.conference_slug)
        self.worker = WorkerFactory(_item=self.profile.workeritem,
                                    role=self.role)
        self.opportunity, self.opp_event = self.add_opportunity(opportunity)
        self.allocation = ResourceAllocationFactory(resource=self.worker,
                                                    event=self.opp_event)
예제 #4
0
    def add_volunteer_opp(self, volunteer_sched_event=None, room=None):
        if not self.conference.conferenceday_set.exists():
            if volunteer_sched_event:
                self.conf_day = ConferenceDayFactory(
                    day=volunteer_sched_event.starttime.date(),
                    conference=self.conference)
            else:
                self.conf_day = ConferenceDayFactory(
                    conference=self.conference)
        else:
            self.conf_day = self.conference.conferenceday_set.first()
        if not volunteer_sched_event:
            vol_event = GenericEventFactory(e_conference=self.conference,
                                            type="Volunteer")
            volunteer_sched_event = SchedEventFactory(
                eventitem=vol_event,
                max_volunteer=self.area.default_volunteers,
                starttime=noon(self.conf_day))
        if not room:
            room = RoomFactory()

        ResourceAllocationFactory(event=volunteer_sched_event,
                                  resource=LocationFactory(_item=room))
        EventLabelFactory(event=volunteer_sched_event, text=self.area.slug)
        EventLabelFactory(event=volunteer_sched_event,
                          text=self.conference.conference_slug)
        EventLabelFactory(event=volunteer_sched_event, text="Volunteer")
        return volunteer_sched_event
예제 #5
0
 def book_act(self, act=None, act_role=''):
     act = act or ActFactory(
         b_conference=self.conference, accepted=3, submitted=True)
     booking = ResourceAllocationFactory(event=self.sched_event,
                                         resource=ActResourceFactory(
                                             _item=act, role=act_role))
     return (act, booking)
예제 #6
0
 def set_staff_lead(self, staff_lead=None):
     staff_lead = staff_lead or ProfileFactory()
     ResourceAllocationFactory(event=self.sched_event,
                               resource=WorkerFactory(
                                 _item=staff_lead,
                                 role="Staff Lead"))
     return staff_lead
예제 #7
0
 def add_panelist(self, panelist=None):
     panelist = panelist or PersonaFactory()
     ResourceAllocationFactory(event=self.sched_event,
                               resource=WorkerFactory(
                                   _item=panelist.workeritem_ptr,
                                   role='Panelist'))
     return panelist
    def test_review_volunteer_has_old_commitments(self):
        ''' when a volunteer is booked in old conference, it should not show'''
        past_conference = ConferenceFactory(accepting_bids=False,
                                            status='completed')
        past_opportunity = GenericEventFactory(
            e_conference=past_conference,
            volunteer_type=AvailableInterestFactory(interest='Security/usher'),
            type='Volunteer')
        past_opportunity.save()
        booked_sched = sEvent(
            eventitem=past_opportunity,
            starttime=datetime(2016, 2, 6, 9, 0, 0, 0, pytz.utc),
            max_volunteer=1)
        booked_sched.save()
        worker = Worker(_item=self.volunteer.profile, role='Volunteer')
        worker.save()
        volunteer_assignment = ResourceAllocationFactory(
            event=booked_sched,
            resource=worker
        )
        login_as(self.privileged_user, self)
        response = self.client.get(
            self.url,
            {'conf_slug': self.volunteer.b_conference.conference_slug})

        nt.assert_equal(response.status_code, 200)
        nt.assert_true('Bid Information' in response.content)
        nt.assert_false(str(past_opportunity) in response.content,
                        msg="The commitment %s is showing up" % (
                            str(past_opportunity)))
 def test_get_allocation_eventitem_no_resource(self):
     allocation = ResourceAllocationFactory(resource=ResourceFactory())
     response = self.client.get('/admin/scheduler/resourceallocation/',
                                follow=True)
     self.assertContains(response,
                         "Error in resource allocation, no resource")
     self.assertContains(response, "Resource (no child)")
 def test_get_allocation_eventitem_no_child_workeritem_no_child(self):
     allocation = ResourceAllocationFactory(
         event__eventitem=EventItemFactory())
     response = self.client.get('/admin/scheduler/resourceallocation/',
                                follow=True)
     self.assertContains(response, "no child")
     self.assertContains(response, "Worker Item (no child_event)")
 def set_interest(self, interested_profile=None):
     interested_profile = interested_profile or ProfileFactory()
     ResourceAllocationFactory(event=self.sched_event,
                               resource=WorkerFactory(
                                   _item=interested_profile,
                                   role="Interested"))
     return interested_profile
예제 #12
0
def book_act_item_for_show(actitem, eventitem):
        booking = ResourceAllocationFactory.create(
            event=SchedEventFactory.create(
                eventitem=eventitem),
            resource=ActResourceFactory.create(
                _item=actitem))
        return booking
예제 #13
0
 def test_repeated_lead_shows_once(self):
     show = ShowFactory()
     sched_events = [
         SchedEventFactory.create(eventitem=show.eventitem_ptr)
         for i in range(2)
     ]
     staff_lead = ProfileFactory()
     lead_worker = WorkerFactory(_item=staff_lead.workeritem_ptr,
                                 role="Staff Lead")
     for se in sched_events:
         ResourceAllocationFactory.create(event=se, resource=lead_worker)
     response = self.client.get(
         reverse(self.view_name,
                 urlconf="gbe.scheduling.urls",
                 args=[show.eventitem_id]))
     self.assertEqual(200, response.status_code)
     self.assertEqual(1, response.content.count(staff_lead.display_name))
예제 #14
0
def book_act_item_for_show(actitem, eventitem):
    booking = ResourceAllocationFactory.create(
        event=SchedEventFactory.create(eventitem=eventitem),
        resource=ActResourceFactory.create(_item=actitem))
    EventLabelFactory(event=booking.event,
                      text=eventitem.e_conference.conference_slug)
    EventLabelFactory(event=booking.event, text=eventitem.calendar_type)
    return booking
예제 #15
0
def book_worker_item_for_role(workeritem, role, eventitem=None):
    worker = WorkerFactory.create(_item=workeritem, role=role)
    if eventitem:
        event = SchedEventFactory.create(eventitem=eventitem)
    else:
        event = SchedEventFactory.create()

    booking = ResourceAllocationFactory.create(event=event, resource=worker)
    return booking
예제 #16
0
 def test_show_interest_duplicate(self):
     ResourceAllocationFactory(event=self.context.sched_event,
                               resource=WorkerFactory(_item=self.profile,
                                                      role="Interested"))
     login_as(self.profile, self)
     response = self.client.get(self.url, follow=True)
     redirect_url = reverse('home', urlconf='gbe.urls')
     self.assertRedirects(response, redirect_url)
     self.assertContains(response, self.context.bid.e_title)
     self.assertNotContains(response, set_favorite_msg)
예제 #17
0
    def __init__(self,
                 profile=None,
                 event=None,
                 sched_event=None,
                 opportunity=None,
                 role=None,
                 conference=None):
        if not event:
            self.conference = conference or ConferenceFactory()
        else:
            self.conference = event.e_conference

        if ConferenceDay.objects.filter(conference=self.conference).exists():
            self.conf_day = ConferenceDay.objects.filter(
                conference=self.conference).first()
        else:
            self.conf_day = ConferenceDayFactory(conference=self.conference)
        self.profile = profile or ProfileFactory()
        if not hasattr(self.profile, 'preferences'):
            ProfilePreferencesFactory(profile=self.profile)

        self.role = role or "Volunteer"
        self.room = RoomFactory()
        self.room.conferences.add(self.conference)
        self.event = event or ShowFactory(e_conference=self.conference)

        if not sched_event:
            self.sched_event = SchedEventFactory(
                eventitem=self.event.eventitem_ptr,
                starttime=datetime.combine(self.conf_day.day, time(12, 0, 0)))
            ResourceAllocationFactory(
                event=self.sched_event,
                resource=LocationFactory(_item=self.room))
            EventLabelFactory(event=self.sched_event, text="General")
            EventLabelFactory(event=self.sched_event,
                              text=self.conference.conference_slug)
        else:
            self.sched_event = sched_event
        self.worker = WorkerFactory(_item=self.profile.workeritem,
                                    role=self.role)
        self.opportunity, self.opp_event = self.add_opportunity(opportunity)
        self.allocation = ResourceAllocationFactory(resource=self.worker,
                                                    event=self.opp_event)
예제 #18
0
 def book_act(self, act=None, act_role='Regular Act'):
     act = act or ActFactory(
         b_conference=self.conference, accepted=3, submitted=True)
     role = "Performer"
     booking = ResourceAllocationFactory(
         event=self.sched_event,
         resource=WorkerFactory(_item=act.performer, role=role))
     order = OrderingFactory(allocation=booking,
                             class_id=act.pk,
                             class_name="Act",
                             role=act_role)
     return (act, booking)
예제 #19
0
 def book_volunteer(self,
                    volunteer_sched_event=None,
                    volunteer=None,
                    role="Volunteer"):
     if not volunteer_sched_event:
         volunteer_sched_event = self.add_volunteer_opp()
     if not volunteer:
         volunteer = ProfileFactory()
     booking = ResourceAllocationFactory(event=volunteer_sched_event,
                                         resource=WorkerFactory(
                                             _item=volunteer, role=role))
     return (volunteer, booking)
예제 #20
0
 def schedule_instance(self, starttime=None, room=None, moderator=None):
     room = room or self.room
     moderator = moderator or self.moderator
     if starttime:
         sched_event = SchedEventFactory(eventitem=self.bid.eventitem_ptr,
                                         starttime=starttime)
     elif self.sched_event:
         one_day = timedelta(1)
         sched_event = SchedEventFactory(
             eventitem=self.bid.eventitem_ptr,
             starttime=self.sched_event.starttime + one_day)
     else:
         sched_event = SchedEventFactory(eventitem=self.bid.eventitem_ptr)
     ResourceAllocationFactory(
         event=sched_event,
         resource=LocationFactory(_item=room.locationitem_ptr))
     ResourceAllocationFactory(event=sched_event,
                               resource=WorkerFactory(
                                   _item=moderator.workeritem_ptr,
                                   role='Moderator'))
     return sched_event
def book_act_item_for_show(actitem, eventitem):
    booking = ResourceAllocationFactory.create(
        event=SchedEventFactory.create(eventitem=eventitem),
        resource=WorkerFactory.create(_item=actitem.performer,
                                      role="Performer"))
    order = OrderingFactory(allocation=booking,
                            class_id=actitem.pk,
                            class_name="Act")
    EventLabelFactory(event=booking.event,
                      text=eventitem.e_conference.conference_slug)
    EventLabelFactory(event=booking.event, text=eventitem.calendar_type)
    return booking
def book_worker_item_for_role(workeritem, role, eventitem=None):
    worker = WorkerFactory.create(_item=workeritem, role=role)
    if eventitem:
        event = SchedEventFactory.create(eventitem=eventitem)
    else:
        event = SchedEventFactory.create()

    EventLabelFactory(event=event,
                      text=event.eventitem.e_conference.conference_slug)
    EventLabelFactory(event=event, text=event.eventitem.calendar_type)
    booking = ResourceAllocationFactory.create(event=event, resource=worker)
    return booking
예제 #23
0
 def __init__(self,
              performer=None,
              act=None,
              show=None,
              sched_event=None,
              conference=None,
              room_name=None,
              cue_count=1,
              schedule_rehearsal=False,
              act_role=""):
     self.show = show or ShowFactory()
     self.conference = conference or self.show.e_conference
     self.performer = performer or PersonaFactory()
     self.act = act or ActFactory(performer=self.performer,
                                  b_conference=self.conference,
                                  accepted=3,
                                  submitted=True)
     self.tech = self.act.tech
     self.audio = self.tech.audio
     self.lighting = self.tech.lighting
     self.stage = self.tech.stage
     for i in range(cue_count):
         CueInfoFactory.create(techinfo=self.tech, cue_sequence=i)
     # schedule the show
     self.sched_event = sched_event or SchedEventFactory(
         eventitem=self.show.eventitem_ptr)
     room_name = room_name or "Dining Room"
     self.room = RoomFactory(name=room_name)
     if not sched_event:
         ResourceAllocationFactory(
             event=self.sched_event,
             resource=LocationFactory(_item=self.room.locationitem_ptr))
     # schedule the act into the show
     ResourceAllocationFactory(event=self.sched_event,
                               resource=ActResourceFactory(
                                   _item=self.act.actitem_ptr,
                                   role=act_role))
     if schedule_rehearsal:
         self.rehearsal = self._schedule_rehearsal(self.sched_event,
                                                   self.act)
예제 #24
0
 def test_remove_interest(self):
     self.url = reverse(self.view_name,
                        args=[self.context.sched_event.pk, "off"],
                        urlconf="gbe.scheduling.urls")
     ResourceAllocationFactory(event=self.context.sched_event,
                               resource=WorkerFactory(_item=self.profile,
                                                      role="Interested"))
     login_as(self.profile, self)
     response = self.client.get(self.url, follow=True)
     redirect_url = reverse('home', urlconf='gbe.urls')
     self.assertRedirects(response, redirect_url)
     self.assertNotContains(response, self.context.bid.e_title)
     assert_alert_exists(response, 'success', 'Success', unset_favorite_msg)
예제 #25
0
 def test_act_changestate_book_act_with_conflict(self):
     grant_privilege(self.privileged_user, 'Act Reviewers')
     conflict = SchedEventFactory(
         starttime=self.context.sched_event.starttime)
     ResourceAllocationFactory(
         event=conflict,
         resource=WorkerFactory(
             _item=self.context.performer.performer_profile))
     url = reverse(self.view_name,
                   args=[self.context.act.pk],
                   urlconf='gbe.urls')
     login_as(self.privileged_user, self)
     response = self.client.post(url, data=self.data, follow=True)
     self.assertContains(response, "is booked for")
예제 #26
0
def _create_scheduled_show_with_acts(conference=None, qty=6):
    if not conference:
        conference = ConferenceFactory()
    conf_day = ConferenceDayFactory(conference=conference)

    show = ShowFactory(e_conference=conference)
    sEvent = SchedEventFactory(eventitem=show.eventitem_ptr,
                               starttime=utc.localize(
                                   datetime.combine(conf_day.day, time(20,
                                                                       0))))
    acts = [ActFactory(accepted=3) for i in range(qty)]
    for act in acts:
        ar = ActResourceFactory(_item=act.actitem_ptr)
        ResourceAllocationFactory(event=sEvent, resource=ar)
    return show, sEvent, acts
예제 #27
0
 def schedule_instance(self, starttime=None, room=None):
     room = room or self.room
     if starttime:
         sched_event = SchedEventFactory(eventitem=self.show.eventitem_ptr,
                                         starttime=starttime)
     else:
         sched_event = SchedEventFactory(eventitem=self.show.eventitem_ptr,
                                         starttime=noon(self.days[0]))
     EventLabelFactory(event=sched_event,
                       text=self.conference.conference_slug)
     EventLabelFactory(event=sched_event, text="General")
     ResourceAllocationFactory(
         event=sched_event,
         resource=LocationFactory(_item=room.locationitem_ptr))
     return sched_event
예제 #28
0
def book_worker_item_for_role(workeritem, role, eventitem=None):
        worker = WorkerFactory.create(
            _item=workeritem,
            role=role)
        if eventitem:
            event = SchedEventFactory.create(
                eventitem=eventitem)
        else:
            event = SchedEventFactory.create()

        booking = ResourceAllocationFactory.create(
            event=event,
            resource=worker
        )
        return booking
예제 #29
0
 def test_volunteer_has_earlier_conflict(self):
     opportunity, opp_event = self.context.add_opportunity(
         start_time=self.context.opp_event.start_time -
         timedelta(minutes=30))
     conflict = ResourceAllocationFactory(resource=self.context.worker,
                                          event=opp_event)
     login_as(self.privileged_profile, self)
     response = self.client.get(self.url, follow=True)
     assert ("no available volunteers" not in response.content)
     assert_link(
         response,
         reverse(
             self.view_name,
             args=[self.context.conference.conference_slug, opp_event.pk],
             urlconf="gbe.scheduling.urls"))
예제 #30
0
def book_act_item_for_show(actitem, eventitem):
    booking = ResourceAllocationFactory.create(
        event=SchedEventFactory.create(
            eventitem=eventitem),
        resource=ActResourceFactory.create(
            _item=actitem))
    EventLabelFactory(
        event=booking.event,
        text=eventitem.e_conference.conference_slug
    )
    EventLabelFactory(
        event=booking.event,
        text=eventitem.calendar_type
    )
    return booking
예제 #31
0
    def make_rehearsal(self, room=True):
        rehearsal = GenericEventFactory(e_conference=self.conference,
                                        type='Rehearsal Slot')
        start_time = datetime.combine(self.days[0].day,
                                      (self.sched_event.start_time -
                                       timedelta(hours=4)).time())

        slot = SchedEventFactory(eventitem=rehearsal.eventitem_ptr,
                                 starttime=start_time,
                                 max_volunteer=10)
        if room:
            ResourceAllocationFactory(
                event=slot, resource=LocationFactory(_item=self.room))
        EventContainerFactory(parent_event=self.sched_event, child_event=slot)
        EventLabelFactory(event=slot, text=self.conference.conference_slug)
        return rehearsal, slot
예제 #32
0
 def _schedule_rehearsal(self, s_event, act=None):
     rehearsal = GenericEventFactory(type="Rehearsal Slot",
                                     e_conference=self.conference)
     rehearsal_event = SchedEventFactory(
         eventitem=rehearsal.eventitem_ptr,
         max_volunteer=10,
         starttime=self.sched_event.starttime)
     event_container = EventContainerFactory(child_event=rehearsal_event,
                                             parent_event=s_event)
     EventLabelFactory(event=rehearsal_event,
                       text=self.conference.conference_slug)
     if act:
         ResourceAllocationFactory(
             resource=ActResourceFactory(_item=act.actitem_ptr),
             event=rehearsal_event)
     return rehearsal_event
예제 #33
0
    def test_personal_schedule_interest_booking(self):
        '''a teacher booked into a class, with an active role condition
           should have a booking
        '''
        role_condition = RoleEligibilityConditionFactory()
        context = ClassContext()
        profile = ProfileFactory()
        booking = ResourceAllocationFactory(resource=WorkerFactory(
            _item=profile, role="Interested"),
                                            event=context.sched_event)

        login_as(self.priv_profile, self)
        response = self.client.get(
            self.url, data={"conf_slug": context.conference.conference_slug})
        self.assertContains(response, str(profile))
        self.assertContains(response, context.bid.e_title, 2)
        self.assertContains(response, "interested-sched")
예제 #34
0
def book_worker_item_for_role(workeritem, role, eventitem=None):
    worker = WorkerFactory.create(
        _item=workeritem,
        role=role)
    if eventitem:
        event = SchedEventFactory.create(
            eventitem=eventitem)
    else:
        event = SchedEventFactory.create()

    EventLabelFactory(
        event=event,
        text=event.eventitem.e_conference.conference_slug
    )
    EventLabelFactory(
        event=event,
        text=event.eventitem.calendar_type
    )
    booking = ResourceAllocationFactory.create(
        event=event,
        resource=worker
    )
    return booking