def test_copy_only_area(self): area_context = StaffAreaContext() conf_day = ConferenceDayFactory(conference=area_context.conference) another_day = ConferenceDayFactory() another_room = RoomFactory() another_room.conferences.add(another_day.conference) data = { 'pick_mode': "Next", 'copy_to_day': another_day.pk, 'room': another_room.room.pk, } self.url = reverse(self.view_name, args=[area_context.area.pk], urlconf='gbe.scheduling.urls') login_as(self.privileged_user, self) response = self.client.post(self.url, data=data, follow=True) redirect_url = "%s?%s-day=%d&filter=Filter&new=%s" % ( reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[another_day.conference.conference_slug ]), another_day.conference.conference_slug, another_day.pk, str([area_context.area.pk + 1])) self.assertRedirects(response, redirect_url) assert_alert_exists( response, 'success', 'Success', 'A new Staff Area was created.<br>Staff Area: %s' % (area_context.area.title))
def __init__(self, bid=None, teacher=None, conference=None, room=None, starttime=None): self.teacher = teacher or PersonaFactory() self.conference = conference or ConferenceFactory() if not self.conference.conferenceday_set.exists(): day = ConferenceDayFactory(conference=self.conference) if starttime: day.day = starttime.date() day.save() self.days = self.conference.conferenceday_set.all() self.starttime = starttime or noon(self.days[0]) self.bid = bid or ClassFactory(b_conference=self.conference, e_conference=self.conference, accepted=3, teacher=self.teacher, submitted=True) self.room = room or RoomFactory() self.sched_event = None self.sched_event = self.schedule_instance(room=self.room, starttime=starttime)
def test_room_setup_by_conference_with_permission(self): '''room_setup view should load for privileged users, and fail for others ''' Conference.objects.all().delete() context = ClassContext() one_day = timedelta(1) ConferenceDayFactory(conference=context.conference, day=context.sched_event.starttime.date()) ConferenceDayFactory(conference=context.conference, day=context.sched_event.starttime.date() + one_day) context.schedule_instance(starttime=context.sched_event.starttime + one_day) current_conference = context.conference ConferenceDayFactory(conference=context.conference, day=context.sched_event.starttime.date()) current_conference = ConferenceFactory() grant_privilege(self.profile, 'Act Reviewers') login_as(self.profile, self) response = self.client.get( reverse('room_setup', urlconf='gbe.reporting.urls'), data={'conf_slug': context.conference.conference_slug}) self.assertEqual(response.status_code, 200) self.assertContains(response, context.bid.e_title, 2)
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
def __init__(self, bid=None, teacher=None, conference=None, room=None, starttime=None): self.teacher = teacher or PersonaFactory() self.conference = conference or ConferenceFactory() if not self.conference.conferenceday_set.exists(): day = ConferenceDayFactory(conference=self.conference) if starttime: day.day = starttime.date() day.save() self.days = self.conference.conferenceday_set.all() self.starttime = starttime or noon(self.days[0]) self.bid = bid or ClassFactory(b_conference=self.conference, e_conference=self.conference, accepted=3, teacher=self.teacher, submitted=True) self.room = room or RoomFactory() self.room.conferences.add(self.conference) self.sched_event = None self.sched_event = self.schedule_instance(room=self.room, starttime=starttime)
def __init__(self, act=None, performer=None, conference=None, room=None, starttime=None, act_role=''): self.performer = performer or PersonaFactory() self.conference = conference or ConferenceFactory() if not self.conference.conferenceday_set.exists(): day = ConferenceDayFactory(conference=self.conference) if starttime: day.day = starttime.date() day.save() self.days = self.conference.conferenceday_set.all() act = act or ActFactory(b_conference=self.conference, performer=self.performer, accepted=3, submitted=True) self.acts = [act] self.show = ShowFactory(e_conference=self.conference) self.room = room or RoomFactory() self.sched_event = None self.sched_event = self.schedule_instance(room=self.room, starttime=starttime) self.book_act(act, act_role)
def __init__(self, act=None, performer=None, conference=None, room=None, starttime=None, act_role=''): self.performer = performer or PersonaFactory() self.conference = conference or ConferenceFactory() if not self.conference.conferenceday_set.exists(): day = ConferenceDayFactory(conference=self.conference) if starttime: day.day = starttime.date() day.save() self.days = self.conference.conferenceday_set.all() act = act or ActFactory(b_conference=self.conference, performer=self.performer, accepted=3, submitted=True) self.acts = [act] self.show = ShowFactory(e_conference=self.conference) self.room = room or RoomFactory() self.sched_event = None self.sched_event = self.schedule_instance(room=self.room, starttime=starttime) self.book_act(act, act_role)
def test_other_days(self): earlier_day = ConferenceDayFactory( conference=self.staffcontext.conference, day=date(2016, 0o2, 0o5)) later_day = ConferenceDayFactory( conference=self.staffcontext.conference, day=date(2016, 0o2, 0o7)) login_as(self.profile, self) response = self.client.get("%s?day=02-06-2016" % self.url) self.assertContains(response, "?day=02-05-2016") self.assertContains(response, "?day=02-07-2016")
def test_calendar_conference_w_default_conf_public_days(self): conference_day = ConferenceDayFactory( conference=self.staffcontext.conference, day=date(2016, 2, 5), open_to_public=False) conference_day = ConferenceDayFactory( conference=self.staffcontext.conference, day=date(2016, 2, 7), open_to_public=False) url = reverse('calendar', urlconf="gbe.scheduling.urls", args=['Conference']) response = self.client.get(url) self.assertContains(response, "btn disabled", 2) self.assertContains(response, "Feb. 6, 2016", 1)
def test_calendar_volunteer_w_default_conf_public_days(self): conference_day = ConferenceDayFactory( conference=self.staffcontext.conference, day=date(2016, 2, 5), open_to_public=False) conference_day = ConferenceDayFactory( conference=self.staffcontext.conference, day=date(2016, 2, 7), open_to_public=False) url = reverse('calendar', urlconf="gbe.scheduling.urls", args=['Volunteer']) data = {'day': "02-06-2016"} response = self.client.get(url, data=data) self.assertNotContains(response, "btn disabled")
def test_copy_child_parent_events(self): another_day = ConferenceDayFactory() data = { 'copy_mode': 'include_parent', 'copy_to_day': another_day.pk, 'copied_event': self.vol_opp.pk, 'pick_event': "Finish", } login_as(self.privileged_user, self) max_pk = Event.objects.latest('pk').pk response = self.client.post(self.url, data=data, follow=True) new_occurrences = [] for occurrence in Event.objects.filter(pk__gt=max_pk): new_occurrences += [occurrence.pk] redirect_url = "%s?%s-day=%d&filter=Filter&new=%s&alt_id=%s" % ( reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[another_day.conference.conference_slug ]), another_day.conference.conference_slug, another_day.pk, replace(str(new_occurrences), " ", "%20"), self.context.area.pk + 1) self.assertRedirects(response, redirect_url) assert_alert_exists( response, 'success', 'Success', 'A new Staff Area was created.<br>Staff Area: %s' % (self.context.area.title)) assert_alert_exists( response, 'success', 'Success', 'Occurrence has been updated.<br>%s, Start Time: %s' % (self.vol_opp.eventitem.e_title, datetime.combine( another_day.day, self.vol_opp.starttime.time()).strftime(DATETIME_FORMAT)))
def test_copy_child_event(self): target_context = StaffAreaContext() target_day = ConferenceDayFactory(conference=target_context.conference, day=self.context.conf_day.day + timedelta(days=340)) data = { 'copy_mode': 'copy_children_only', 'target_event': target_context.area.pk, 'copied_event': self.vol_opp.pk, 'pick_event': "Finish", } login_as(self.privileged_user, self) response = self.client.post(self.url, data=data, follow=True) max_pk = Event.objects.latest('pk').pk redirect_url = "%s?%s-day=%d&filter=Filter&new=%s" % ( reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[target_context.conference.conference_slug]), target_context.conference.conference_slug, target_day.pk, str([max_pk]), ) self.assertRedirects(response, redirect_url) assert_alert_exists( response, 'success', 'Success', 'Occurrence has been updated.<br>%s, Start Time: %s' % (self.vol_opp.eventitem.e_title, datetime.combine( target_day.day, self.vol_opp.starttime.time()).strftime(DATETIME_FORMAT)))
def test_authorized_user_pick_mode_only_children(self): target_context = StaffAreaContext() delta = timedelta(days=340) target_day = ConferenceDayFactory(conference=target_context.conference, day=self.context.conf_day.day + delta) data = { 'copy_mode': 'copy_children_only', 'target_event': target_context.area.pk, 'pick_mode': "Next", } login_as(self.privileged_user, self) response = self.client.post(self.url, data=data, follow=True) self.assertContains( response, '<input checked="checked" id="id_copy_mode_0" name="copy_mode" ' + 'type="radio" value="copy_children_only" />') self.assertContains( response, '<option value="%d" selected="selected">' % (target_context.area.pk)) self.assertContains(response, "Choose Sub-Events to be copied") self.assertContains( response, "%s - %s" % (self.vol_opp.eventitem.e_title, (self.vol_opp.start_time + delta).strftime( self.copy_date_format)))
def test_copy_only_parent_event(self): another_day = ConferenceDayFactory() another_room = RoomFactory() another_room.conferences.add(another_day.conference) data = { 'copy_mode': 'include_parent', 'copy_to_day': another_day.pk, 'room': another_room.pk, 'pick_event': "Finish", } login_as(self.privileged_user, self) response = self.client.post(self.url, data=data, follow=True) max_area = StaffArea.objects.latest('pk') redirect_url = "%s?%s-day=%d&filter=Filter&alt_id=%s" % ( reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[another_day.conference.conference_slug]), another_day.conference.conference_slug, another_day.pk, max_area.pk, ) self.assertRedirects(response, redirect_url) self.assertRedirects(response, redirect_url) self.assertFalse(max_area.default_location) assert_alert_exists( response, 'success', 'Success', 'A new Staff Area was created.<br>Staff Area: %s' % (max_area.title))
def test_copy_child_event(self): target_context = StaffAreaContext() target_day = ConferenceDayFactory(conference=target_context.conference, day=self.context.conf_day.day + timedelta(days=340)) new_room = target_context.get_room() data = { 'copy_mode': 'copy_children_only', 'target_event': target_context.area.pk, 'copied_event': self.vol_opp.pk, 'room': new_room.pk, 'pick_event': "Finish", } login_as(self.privileged_user, self) response = self.client.post(self.url, data=data, follow=True) max_pk = Event.objects.latest('pk').pk redirect_url = "%s?%s-day=%d&filter=Filter&new=%s" % ( reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[target_context.conference.conference_slug]), target_context.conference.conference_slug, target_day.pk, str([max_pk]), ) self.assertRedirects(response, redirect_url) self.assertContains(response, new_room)
def test_authorized_user_pick_mode_only_children(self): target_context = StaffAreaContext() delta = timedelta(days=340) target_day = ConferenceDayFactory(conference=target_context.conference, day=self.context.conf_day.day + delta) new_room = target_context.get_room() data = { 'copy_mode': 'copy_children_only', 'target_event': target_context.area.pk, 'room': new_room.pk, 'pick_mode': "Next", } login_as(self.privileged_user, self) response = self.client.post(self.url, data=data, follow=True) self.assertContains(response, self.copy_children_only_checked, html=True) self.assertContains( response, '<option value="%d" selected>' % (target_context.area.pk)) self.assertContains(response, "Choose Sub-Events to be copied") self.assertContains( response, "%s - %s" % (self.vol_opp.eventitem.e_title, (self.vol_opp.start_time + delta).strftime( self.copy_date_format))) self.assert_hidden_value(response, "id_room", "room", new_room.pk)
def test_copy_only_parent_event(self): another_day = ConferenceDayFactory() show_context = VolunteerContext() url = reverse( self.view_name, args=[show_context.sched_event.pk], urlconf='gbe.scheduling.urls') data = { 'copy_mode': 'include_parent', 'copy_to_day': another_day.pk, 'room': self.context.room.pk, 'pick_event': "Finish", } login_as(self.privileged_user, self) response = self.client.post(url, data=data, follow=True) max_pk = Event.objects.latest('pk').pk redirect_url = "%s?%s-day=%d&filter=Filter&new=[%s]" % ( reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[another_day.conference.conference_slug]), another_day.conference.conference_slug, another_day.pk, str(max_pk),) self.assertRedirects(response, redirect_url) assert_alert_exists( response, 'success', 'Success', 'Occurrence has been updated.<br>%s, Start Time: %s' % ( show_context.event.e_title, datetime.combine( another_day.day, show_context.sched_event.starttime.time()).strftime( GBE_DATETIME_FORMAT))) self.assertContains(response, "Occurrence has been updated.<br>", 1)
def test_authorized_user_pick_mode_include_parent(self): another_day = ConferenceDayFactory(conference=self.context.conference) show_context = VolunteerContext() url = reverse( self.view_name, args=[show_context.sched_event.pk], urlconf='gbe.scheduling.urls') data = { 'copy_mode': 'include_parent', 'copy_to_day': another_day.pk, 'pick_mode': "Next", } delta = another_day.day - show_context.sched_event.starttime.date() login_as(self.privileged_user, self) response = self.client.post(url, data=data, follow=True) self.assertContains( response, '<input checked="checked" id="id_copy_mode_1" name="copy_mode" ' + 'type="radio" value="include_parent" />') self.assertContains( response, '<option value="%d" selected="selected">' % another_day.pk) self.assertContains(response, "Choose Sub-Events to be copied") self.assertContains(response, "%s - %s" % ( show_context.opportunity.e_title, (show_context.opp_event.start_time + delta).strftime( self.copy_date_format)))
def test_copy_single_event(self): another_day = ConferenceDayFactory( conference=self.context.conference, day=self.context.conf_day.day + timedelta(days=1)) data = { 'copy_to_day': another_day.pk, 'pick_mode': "Next", } login_as(self.privileged_user, self) self.url = reverse( self.view_name, args=[self.context.opp_event.pk], urlconf='gbe.scheduling.urls') response = self.client.post(self.url, data=data, follow=True) max_pk = Event.objects.latest('pk').pk redirect_url = "%s?%s-day=%d&filter=Filter&new=%s" % ( reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[another_day.conference.conference_slug]), another_day.conference.conference_slug, another_day.pk, str([max_pk]),) self.assertRedirects(response, redirect_url) assert_alert_exists( response, 'success', 'Success', 'Occurrence has been updated.<br>%s, Start Time: %s' % ( self.context.opportunity.e_title, datetime.combine( another_day.day, self.context.opp_event.starttime.time()).strftime( DATETIME_FORMAT)))
def test_copy_area_duplicate_name(self): dup_area_context = StaffAreaContext() dup_area_context.area.title = self.context.area.title dup_area_context.area.save() conf_day = ConferenceDayFactory(conference=dup_area_context.conference) self.url = reverse(self.view_name, args=[dup_area_context.area.pk], urlconf='gbe.scheduling.urls') data = { 'copy_to_day': self.context.conf_day.pk, 'room': self.vol_opp.location.pk, 'pick_mode': "Next", } login_as(self.privileged_user, self) response = self.client.post(self.url, data=data, follow=True) redirect_url = "%s?%s-day=%d&filter=Filter&new=%s" % ( reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[self.context.conference.conference_slug ]), self.context.conference.conference_slug, self.context.conf_day.pk, str([dup_area_context.area.pk + 1])) self.assertRedirects(response, redirect_url) max_area = StaffArea.objects.latest('pk') assert_alert_exists( response, 'success', 'Success', 'A new Staff Area was created.<br>Staff Area: %s' % (max_area.title))
def test_good_user_get_success_pick_conf(self): old_conf_day = ConferenceDayFactory( conference__status="completed", day=self.day.day + timedelta(3)) login_as(self.privileged_profile, self) url = reverse(self.view_name, urlconf="gbe.scheduling.urls", args=[old_conf_day.conference.conference_slug]) response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertContains( response, self.conf_tab % ( url, '-active', old_conf_day.conference.conference_slug), html=True) self.assertContains( response, self.conf_tab % ( reverse(self.view_name, urlconf="gbe.scheduling.urls", args=[self.day.conference.conference_slug]), '', self.day.conference.conference_slug), html=True) self.assertContains( response, old_conf_day.day.strftime(GBE_DATE_FORMAT)) self.assertNotContains( response, self.day.day.strftime(GBE_DATE_FORMAT))
def test_good_user_get_success_pick_conf(self): old_conf_day = ConferenceDayFactory( conference__status="completed", day=self.day.day + timedelta(3)) login_as(self.privileged_profile, self) url = reverse(self.view_name, urlconf="gbe.scheduling.urls", args=[old_conf_day.conference.conference_slug]) response = self.client.get(url) self.assertEqual(response.status_code, 200) s = '<li role="presentation" class="active">\n' + \ ' <a href = "%s?">%s</a></li>' self.assertContains( response, s % (url, old_conf_day.conference.conference_slug)) s = '<li role="presentation" >\n <a href = "%s?">%s</a></li>' self.assertContains( response, s % (reverse(self.view_name, urlconf="gbe.scheduling.urls", args=[self.day.conference.conference_slug]), self.day.conference.conference_slug)) self.assertContains( response, old_conf_day.day.strftime(DATE_FORMAT)) self.assertNotContains( response, self.day.day.strftime(DATE_FORMAT))
def test_no_events(self): earlier_day = ConferenceDayFactory( conference=self.staffcontext.conference, day=date(2016, 0o2, 0o5)) login_as(self.profile, self) response = self.client.get("%s?day=02-05-2016" % self.url) self.assertContains( response, "There are no volunteer events scheduled for this day.")
def setUp(self): self.client = Client() clear_conferences() conference = ConferenceFactory() save_the_date = datetime(2016, 02, 06, 12, 00, 00) day = ConferenceDayFactory(conference=conference, day=date(2016, 02, 06)) self.staffcontext = StaffAreaContext(conference=conference, starttime=save_the_date) self.showcontext = ShowContext(conference=conference, starttime=save_the_date) self.other_conference = ConferenceFactory(status='completed') self.other_conf_day = ConferenceDayFactory( conference=self.other_conference, day=date(2015, 02, 06)) self.other_show = ShowContext(conference=self.other_conference) self.classcontext = ClassContext(conference=conference, starttime=save_the_date) self.volunteeropp = self.staffcontext.add_volunteer_opp()
def make_three_day_spread(self): conference_events = [ self.showcontext.sched_event, self.classcontext.sched_event ] two_day = timedelta(2) ConferenceDayFactory(conference=self.conference, day=date(2016, 2, 6)) ConferenceDayFactory(conference=self.conference, day=date(2016, 2, 7)) conference_events += [self.showcontext.schedule_instance()] conference_events += [ self.showcontext.schedule_instance( starttime=self.showcontext.sched_event.starttime + two_day) ] conference_events += [self.classcontext.schedule_instance()] conference_events += [ self.classcontext.schedule_instance( starttime=self.classcontext.sched_event.starttime + two_day) ] return conference_events
def setUp(self): self.client = Client() password = '******' self.privileged_user = User.objects.create_superuser( 'myuser', '*****@*****.**', password) self.profile = ProfileFactory(user_object=self.privileged_user) grant_privilege(self.profile, 'Admins') self.day = ConferenceDayFactory() self.url = reverse(self.view_name, urlconf="gbe.scheduling.urls")
def setUp(self): self.factory = RequestFactory() self.client = Client() self.profile = ProfileFactory() Conference.objects.all().delete() UserMessage.objects.all().delete() AvailableInterest.objects.all().delete() self.conference = ConferenceFactory(accepting_bids=True) days = ConferenceDayFactory.create_batch(3, conference=self.conference) [VolunteerWindowFactory(day=day) for day in days] self.interest = AvailableInterestFactory()
def test_authorized_user_get_no_children(self): alt_context = StaffAreaContext() ConferenceDayFactory(conference=alt_context.conference) login_as(self.privileged_user, self) self.url = reverse(self.view_name, args=[alt_context.area.pk], urlconf='gbe.scheduling.urls') response = self.client.get(self.url, follow=True) self.assertEqual(response.status_code, 200) self.assertContains(response, self.context.conf_day.day.strftime(DATE_FORMAT)) self.assertNotContains(response, copy_mode_choices[0][1])
def setUp(self): self.url = reverse('volunteer_signup', urlconf="gbe.scheduling.urls") self.client = Client() self.profile = ProfileFactory() clear_conferences() conference = ConferenceFactory() save_the_date = datetime(2016, 2, 6, 12, 0, 0) day = ConferenceDayFactory(conference=conference, day=date(2016, 0o2, 0o6)) self.staffcontext = StaffAreaContext(conference=conference, starttime=save_the_date) self.volunteeropp = self.staffcontext.add_volunteer_opp()
def get_solo_data(self): another_day = ConferenceDayFactory( conference=self.context.conference, day=self.context.conf_day.day + timedelta(days=1)) other_room = RoomFactory() other_room.conferences.add(another_day.conference) data = { 'copy_to_day': another_day.pk, 'room': other_room.pk, 'copy_mode': ['choose_day'], 'pick_mode': "Next", } return data, another_day, other_room
def test_room_schedule_succeed(self): '''room_schedule view should load for privileged users, and fail for others ''' Conference.objects.all().delete() context = ClassContext() one_day = timedelta(1) ConferenceDayFactory(conference=context.conference, day=context.sched_event.starttime.date()) ConferenceDayFactory(conference=context.conference, day=context.sched_event.starttime.date() + one_day) context.schedule_instance(starttime=context.sched_event.starttime + one_day) current_conference = context.conference grant_privilege(self.profile, 'Act Reviewers') login_as(self.profile, self) response = self.client.get( reverse('room_schedule', urlconf='gbe.reporting.urls', args=[context.room.pk])) self.assertEqual(response.status_code, 200)
def test_two_upcoming_conf(self): second_conference = ConferenceFactory() save_the_date = datetime(2017, 2, 6, 12, 0, 0) second_day = ConferenceDayFactory(conference=second_conference, day=date(2017, 0o2, 0o6)) staffcontext = StaffAreaContext(conference=second_conference, starttime=save_the_date) volunteeropp = staffcontext.add_volunteer_opp() login_as(self.profile, self) response = self.client.get( "%s?conference=%s" % (self.url, second_conference.conference_slug)) self.assertContains(response, staffcontext.conference.conference_name) self.assertContains(response, volunteeropp.eventitem.e_title)