Пример #1
0
    def get_list(self, request):
        pending = get_people(
            roles=["Pending Volunteer", "Waitlisted", "Rejected"],
            labels=[self.conference.conference_slug])
        show_general_status(request, pending, self.__class__.__name__)
        rows = []
        action = ""

        for pending_person in pending.people:
            action_links = {
                'email':
                reverse('mail_to_individual',
                        urlconf='gbe.email.urls',
                        args=[pending_person.public_id])
            }
            for action in ['approve', 'reject', 'waitlist']:
                if action in volunteer_action_map and (
                        volunteer_action_map[action]['role']
                        == (pending_person.role)):
                    action_links[action] = None
                else:
                    action_links[action] = reverse(
                        self.review_list_view_name,
                        urlconf='gbe.scheduling.urls',
                        args=[
                            action, pending_person.public_id,
                            pending_person.booking_id
                        ])
            row = {
                'volunteer':
                pending_person.user.profile,
                'occurrence':
                pending_person.occurrence,
                'staff_areas':
                StaffArea.objects.filter(
                    conference=self.conference,
                    slug__in=pending_person.occurrence.labels),
                'state':
                pending_person.role.split(' ', 1)[0],
                'status':
                "",
                'label':
                pending_person.label,
                'action_links':
                action_links
            }
            if hasattr(pending_person.occurrence, 'container_event'):
                container = pending_person.occurrence.container_event
                row['parent_event'] = container.parent_event
            if pending_person.booking_id == self.changed_id:
                row['status'] = 'gbe-table-success'
            elif not row['volunteer'].is_active:
                row['status'] = "gbe-table-danger"
            elif pending_person.occurrence.role_count("Volunteer") >= (
                    pending_person.occurrence.max_volunteer):
                row['status'] = "gbe-table-warning"
            elif pending_person.role == "Pending Volunteer":
                row['status'] = "gbe-table-info"
            rows.append(row)
        return rows
Пример #2
0
 def test_get_act_w_label(self):
     context = ShowContext()
     act, booking = context.book_act()
     label = LabelFactory(allocation=booking)
     response = get_people(labels=[context.conference.conference_slug],
                           roles=["Performer"])
     self.assertEqual(response.people[1].label, label.text)
Пример #3
0
 def test_get_act_w_label(self):
     context = ShowContext()
     act, booking = context.book_act()
     label = LabelFactory(allocation=booking)
     response = get_people(labels=[context.conference.conference_slug],
                           roles=["Performer"])
     self.assertEqual(response.people[1].label, label.text)
Пример #4
0
 def get_acts(self):
     acts = []
     response = get_people(parent_event_ids=[self.eventitem_id],
                           roles=["Performer"])
     for performer in response.people:
         act = Act.objects.get(pk=performer.commitment.class_id)
         acts += [act]
     return acts
 def test_get_act_w_label(self):
     context = ShowContext()
     act, booking = context.book_act()
     label = LabelFactory(allocation=booking)
     response = get_people(labels=[context.conference.conference_slug],
                           roles=["Performer"])
     target_person = None
     for person in response.people:
         if act.performer.user_object == person.user:
             target_person = person
         else:
             self.assertNotEqual(person.label, label.text)
     self.assertIsNotNone(target_person)
     self.assertEqual(target_person.label, label.text)
 def test_get_volunteer_w_label(self):
     context = VolunteerContext()
     label = LabelFactory(allocation=context.allocation)
     response = get_people(labels=[context.conference.conference_slug],
                           roles=["Volunteer"])
     self.assertEqual(response.people[0].label, label.text)
 def test_get_labels_and_label_sets(self):
     response = get_people(
         labels=["foo"],
         label_sets=["bar"],
     )
     self.assertEqual(response.errors[0].code, "INVALID_REQUEST")
    def get(self, request):
        conference = get_current_conference()
        badged_usernames = []

        badged_purchases = Transaction.objects.filter(
            ticket_item__ticketing_event__conference=conference).exclude(
            ticket_item__ticketingeligibilitycondition__checklistitem__badge_title__isnull=True
            ).order_by('ticket_item')

        header = ['First',
                  'Last',
                  'username',
                  'Badge Name',
                  'Badge Type',
                  'Ticket Purchased',
                  'Date']

        badge_info = []
        # now build content - the order of loops is specific here,
        # we need ALL transactions, if they are limbo, then the purchaser
        # should have a BPT first/last name
        for badge in badged_purchases:
            buyer = badge.purchaser.matched_to_user
            badged_usernames += [buyer.username]
            if hasattr(buyer, 'profile') and len(
                    buyer.profile.get_badge_name()) > 0:
                badge_name = buyer.profile.get_badge_name()
            else:
                badge_name = badge.purchaser.first_name
            for condition in badge.ticket_item.ticketingeligibilitycondition_set.exclude(
                    checklistitem__badge_title__isnull=True):
                badge_info.append(
                    [badge.purchaser.first_name,
                     badge.purchaser.last_name,
                     buyer.username,
                     str(badge_name),
                     condition.checklistitem.badge_title,
                     badge.ticket_item.title,
                     badge.import_date])

        role_conditions = RoleEligibilityCondition.objects.exclude(
            checklistitem__badge_title__isnull=True)
        title_to_badge = {}
        if role_conditions.count() > 0:
            for role_cond in role_conditions:
                title_to_badge[
                    role_cond.role] = role_cond.checklistitem.badge_title
            roles = role_conditions.values_list('role', flat=True).distinct()
            response = get_people(labels=[conference.conference_slug],
                                  roles=roles)

            for person in response.people:
                if person.user.username not in badged_usernames:
                    badge_info.append(
                        [person.user.first_name,
                         person.user.last_name,
                         person.user.username,
                         person.user.profile.get_badge_name(),
                         title_to_badge[person.role],
                         "Role Condition: %s" % person.role,
                         "N/A"])
                    badged_usernames += [person.user.username]

        response = HttpResponse(content_type='text/csv')
        response['Content-Disposition'] = 'attachment; filename=print_badges.csv'
        writer = csv.writer(response)
        writer.writerow(header)
        for row in badge_info:
            writer.writerow(row)
        return response
Пример #9
0
 def test_get_volunteer_w_label(self):
     context = VolunteerContext()
     label = LabelFactory(allocation=context.allocation)
     response = get_people(labels=[context.conference.conference_slug],
                           roles=["Volunteer"])
     self.assertEqual(response.people[0].label, label.text)
Пример #10
0
 def test_get_labels_and_label_sets(self):
     response = get_people(labels=["foo"], label_sets=["bar"],)
     self.assertEqual(response.errors[0].code, "INVALID_REQUEST")
Пример #11
0
 def get_to_list(self):
     to_list = []
     slugs = []
     people = []
     limits = None
     for conference in self.select_form.cleaned_data['conference']:
         slugs += [conference.conference_slug]
     if self.specify_event_form:
         limits = self.create_occurrence_limits()
     if self.user.user_object.is_superuser or len(
             [i for i in ["Schedule Mavens",
                          "Registrar",
                          "Volunteer Coordinator"] if i in self.priv_list]
             ) > 0:
         if limits:
             if len(limits['parent_ids']) > 0:
                 response = get_people(
                     parent_event_ids=limits['parent_ids'],
                     labels=slugs,
                     roles=self.select_form.cleaned_data['roles'])
                 people += response.people
             if len(limits['labels']) > 0:
                 response = get_people(
                     label_sets=[slugs, limits['labels']],
                     roles=self.select_form.cleaned_data['roles'])
                 people += response.people
         else:
             response = get_people(
                 labels=slugs,
                 roles=self.select_form.cleaned_data['roles'])
             people += response.people
     else:
         if len([i for i in ['Producer',
                             'Technical Director',
                             'Act Coordinator',
                             'Staff Lead'] if i in self.priv_list]) > 0:
             response = None
             if limits:
                 if len(limits['parent_ids']) > 0:
                     response = get_people(
                         parent_event_ids=limits['parent_ids'],
                         labels=slugs,
                         roles=self.select_form.cleaned_data['roles'])
             else:
                 # this should be doable from a values_list, isn't
                 parent_items = []
                 for item in self.event_queryset:
                     parent_items += [item.eventitem_id]
                 response = get_people(
                     parent_event_ids=parent_items,
                     labels=slugs,
                     roles=self.select_form.cleaned_data['roles'])
             if response:
                 people += response.people
         if "Class Coordinator" in self.priv_list:
             if limits is None or "Conference" in limits['labels']:
                 response = get_people(
                     label_sets=[slugs, ["Conference", ]],
                     roles=self.select_form.cleaned_data['roles'])
                 people += response.people
         if "Staff Lead" in self.priv_list:
             if limits:
                 if len(limits['labels']) > 0:
                     response = get_people(
                         label_sets=[slugs, limits['labels']],
                         roles=self.select_form.cleaned_data['roles'])
             else:
                 allowed_labels = ["Volunteer", ]
                 for area in self.staff_queryset:
                     allowed_labels += [area.slug]
                 response = get_people(
                     label_sets=[slugs, allowed_labels],
                     roles=self.select_form.cleaned_data['roles'])
             people += response.people
     for person in people:
         person_contact = (person.user.email,
                           person.user.profile.display_name)
         if person.user.is_active and person_contact not in to_list:
             to_list += [person_contact]
     return sorted(to_list, key=lambda s: s[1].lower())
Пример #12
0
    def get_context_data(self, request):
        acts = []
        all_valid = True
        scheduling_link = ''
        columns = [
            'Order', 'Tech Done', 'Act', 'Performer', 'Rehearsal', 'Music',
            'Action'
        ]
        conference = self.item.e_conference

        # Setup act pane
        response = get_people(foreign_event_ids=[self.item.eventitem_id],
                              roles=["Performer"])
        show_general_status(request, response, self.__class__.__name__)
        for performer in response.people:
            rehearsals = []
            order = -1
            act = get_object_or_404(Act, pk=performer.commitment.class_id)
            sched_response = get_schedule(
                labels=[act.b_conference.conference_slug], commitment=act)
            show_general_status(request, sched_response,
                                self.__class__.__name__)
            for item in sched_response.schedule_items:
                if item.event not in rehearsals and (
                        GenericEvent.objects.filter(
                            eventitem_id=item.event.eventitem.eventitem_id,
                            type='Rehearsal Slot').exists()):
                    rehearsals += [item.event]
                elif Show.objects.filter(eventitem_id=item.event.eventitem.
                                         eventitem_id).exists():
                    order = item.commitment.order
            if request.POST:
                form = ActScheduleBasics(request.POST,
                                         prefix=performer.booking_id)
                all_valid = all_valid and form.is_valid()
            else:
                form = ActScheduleBasics(
                    prefix=performer.booking_id,
                    initial={'order': performer.commitment.order})
            rebook_form = Form()
            rebook_form.fields['accepted'] = ChoiceField(choices=((3, 3), ),
                                                         initial=3,
                                                         widget=HiddenInput())
            rebook_form = make_show_casting_form(conference, rebook_form,
                                                 self.item.eventitem_id,
                                                 performer.commitment.role)
            acts += [{
                'act': act,
                'rehearsals': rehearsals,
                'order': order,
                'rebook_form': rebook_form,
                'form': form
            }]

        # Setup Volunteer pane
        opps = []
        roles = []
        for role, commit in list(role_commit_map.items()):
            if commit[0] > 0 and commit[0] < 4:
                roles += [role]
        opps_response = get_occurrences(
            labels=[conference.conference_slug, "Volunteer"],
            parent_event_id=self.occurrence.pk)

        if opps_response:
            show_general_status(request, opps_response,
                                self.__class__.__name__)
            for opp in opps_response.occurrences:
                item = {
                    'event': opp,
                    'areas': [],
                }
                for area in StaffArea.objects.filter(slug__in=opp.labels,
                                                     conference=conference):
                    item['areas'] += [area]
                opps += [item]
        vol_msg = UserMessage.objects.get_or_create(
            view=self.__class__.__name__,
            code="VOLUNTEER_PANEL_INSTRUCTIONS",
            defaults={
                'summary': "Instructions at top of Volunteer Panel",
                'description': volunteer_panel_instr
            })
        return {
            'this_show':
            self.item,
            'email_forms':
            self.setup_email_forms(),
            'this_occurrence':
            self.occurrence,
            'acts':
            acts,
            'all_valid':
            all_valid,
            'columns':
            columns,
            'other_shows':
            self.show_scope,
            'conference_slugs':
            conference_slugs(),
            'conference':
            conference,
            'can_schedule':
            self.can_schedule_acts,
            'can_rebook':
            self.can_rebook,
            'can_approve_vol':
            self.can_approve_vol,
            'can_assign_act':
            self.can_assign_act,
            'change_acts':
            self.can_change_techinfo,
            'opps':
            opps,
            'role_commit_map':
            role_commit_map,
            'visible_roles':
            roles,
            'act_panel_instructions':
            UserMessage.objects.get_or_create(
                view=self.__class__.__name__,
                code="ACT_PANEL_INSTRUCTIONS",
                defaults={
                    'summary': "Instructions at top of Act Panel",
                    'description': act_panel_instr
                })[0].description,
            'volunteer_panel_instructions':
            vol_msg[0].description,
            'vol_columns': [
                'Event', 'Area', 'Date/Time', 'Location', 'Max', 'Current',
                'Volunteers'
            ]
        }
Пример #13
0
 def get_to_list(self):
     to_list = []
     slugs = []
     people = []
     limits = None
     for conference in self.select_form.cleaned_data['conference']:
         slugs += [conference.conference_slug]
     if self.specify_event_form:
         limits = self.create_occurrence_limits()
     if self.user.user_object.is_superuser or len([
             i for i in
         ["Schedule Mavens", "Registrar", "Volunteer Coordinator"]
             if i in self.priv_list
     ]) > 0:
         if limits:
             if len(limits['parent_ids']) > 0:
                 response = get_people(
                     parent_event_ids=limits['parent_ids'],
                     labels=slugs,
                     roles=self.select_form.cleaned_data['roles'])
                 people += response.people
             if len(limits['labels']) > 0:
                 response = get_people(
                     label_sets=[slugs, limits['labels']],
                     roles=self.select_form.cleaned_data['roles'])
                 people += response.people
         else:
             response = get_people(
                 labels=slugs, roles=self.select_form.cleaned_data['roles'])
             people += response.people
     else:
         if len([
                 i for i in [
                     'Producer', 'Technical Director', 'Act Coordinator',
                     'Staff Lead'
                 ] if i in self.priv_list
         ]) > 0:
             response = None
             if limits:
                 if len(limits['parent_ids']) > 0:
                     response = get_people(
                         parent_event_ids=limits['parent_ids'],
                         labels=slugs,
                         roles=self.select_form.cleaned_data['roles'])
             else:
                 # this should be doable from a values_list, isn't
                 parent_items = []
                 for item in self.event_queryset:
                     parent_items += [item.eventitem_id]
                 response = get_people(
                     parent_event_ids=parent_items,
                     labels=slugs,
                     roles=self.select_form.cleaned_data['roles'])
             if response:
                 people += response.people
         if "Class Coordinator" in self.priv_list:
             if limits is None or "Conference" in limits['labels']:
                 response = get_people(
                     label_sets=[slugs, [
                         "Conference",
                     ]],
                     roles=self.select_form.cleaned_data['roles'])
                 people += response.people
         if "Staff Lead" in self.priv_list:
             if limits:
                 if len(limits['labels']) > 0:
                     response = get_people(
                         label_sets=[slugs, limits['labels']],
                         roles=self.select_form.cleaned_data['roles'])
             else:
                 allowed_labels = [
                     "Volunteer",
                 ]
                 for area in self.staff_queryset:
                     allowed_labels += [area.slug]
                 response = get_people(
                     label_sets=[slugs, allowed_labels],
                     roles=self.select_form.cleaned_data['roles'])
             people += response.people
     for person in people:
         person_contact = (person.user.email,
                           person.user.profile.display_name)
         if person.user.is_active and person_contact not in to_list:
             to_list += [person_contact]
     return sorted(to_list, key=lambda s: s[1].lower())
    def get(self, request, *args, **kwargs):
        error_url = self.groundwork(request, args, kwargs)
        if error_url:
            return error_url

        header = [
            'Order', 'Performer', 'Title', 'Duration (HH:MM:SS)',
            'Starting Position', 'Prop Setup', 'Pronouns',
            'Read Intro Exactly', 'Intro Text', 'Costume Colors',
            'Starting Lights', 'Follow Spot', 'Wash Color', 'Background Color',
            'Cue for light change', 'Lighting at End', 'Track Title',
            'Track Artist', 'Mic Options'
        ]
        tech_info = []
        response = get_people(foreign_event_ids=[self.item.eventitem_id],
                              roles=["Performer"])
        show_general_status(request, response, self.__class__.__name__)

        for performer in response.people:
            read_exact = "No"
            light_start = "Lights On"
            light_end = "Lights On"
            prop_setup_list = ""
            follow_spot = "OFF"
            wash = "No selection made"
            background = "No selection made"
            cue = "NONE"
            order = -1
            act = get_object_or_404(Act, pk=performer.commitment.class_id)
            sched_response = get_schedule(
                labels=[act.b_conference.conference_slug], commitment=act)
            show_general_status(request, sched_response,
                                self.__class__.__name__)
            for item in sched_response.schedule_items:
                if Show.objects.filter(eventitem_id=item.event.eventitem.
                                       eventitem_id).exists():
                    order = item.commitment.order
            if act.tech.prop_setup:
                for item in act.tech.prop_setup_list:
                    if len(prop_setup_list) == 0:
                        prop_setup_list = item
                    else:
                        prop_setup_list = "%s, %s" % (prop_setup_list, item)
                prop_setup_list = "%s\n%s" % (prop_setup_list,
                                              act.tech.crew_instruct)
            else:
                prop_setup_list = act.tech.crew_instruct
            if act.tech.read_exact:
                read_exact = "Yes"
            if act.tech.start_blackout:
                light_start = "Blackout"
            if act.tech.end_blackout:
                light_end = "Blackout"
            if act.tech.follow_spot_color:
                follow_spot = act.tech.follow_spot_color
            if act.tech.wash_color:
                wash = act.tech.wash_color
            if act.tech.background_color:
                background = act.tech.background_color
            if act.tech.special_lighting_cue:
                cue = act.tech.special_lighting_cue
            if act.tech.confirm_no_music:
                title = "no music"
                artist = ""
            else:
                title = act.tech.track_title
                artist = act.tech.track_artist
            tech_info.append([
                order,
                str(act.performer),
                act.b_title,
                act.tech.duration,
                act.tech.starting_position,
                prop_setup_list,
                act.tech.pronouns,
                read_exact,
                act.tech.introduction_text,
                "Primary: %s\nSecondary: %s" %
                (act.tech.primary_color, act.tech.secondary_color),
                light_start,
                follow_spot,
                wash,
                background,
                cue,
                light_end,
                title,
                artist,
                act.tech.mic_choice,
            ])

        response = HttpResponse(content_type='text/csv')
        response[
            'Content-Disposition'] = 'attachment; filename=%s_tech.csv' % (str(
                self.item))
        writer = csv.writer(response)
        writer.writerow(header)
        for row in tech_info:
            writer.writerow(row)
        return response
Пример #15
0
def get_event_display_info(eventitem_id):
    '''
    Helper for displaying a single of event.
    '''
    try:
        item = Event.objects.get_subclass(eventitem_id=eventitem_id)
    except Event.DoesNotExist:
        raise Http404
    bio_grid_list = {}
    featured_grid_list = []
    response = get_people(foreign_event_ids=[eventitem_id],
                          roles=["Performer"])
    regular_roles = {}
    special_roles = {}
    for casting in ActCastingOption.objects.filter():
        if casting.show_as_special:
            special_roles[casting.casting] = casting.display_header
        else:
            regular_roles[casting.casting] = casting.display_header
    for casting in response.people:
        performer = eval(casting.public_class).objects.get(
            pk=casting.public_id)
        if len(casting.commitment.role) > 0 and (
                casting.commitment.role in special_roles):
            featured_grid_list += [{
                'bio': performer,
                'role': special_roles[casting.commitment.role]}]
        else:
            if len(casting.commitment.role) > 0 and (
                    casting.commitment.role in regular_roles):
                header = regular_roles[casting.commitment.role]
            else:
                header = "Fabulous Performers"

            if header in bio_grid_list:
                bio_grid_list[header] += [performer]
            else:
                bio_grid_list[header] = [performer]
    featured_grid_list.sort(key=lambda p: p['bio'].name)
    for header, perf_list in bio_grid_list.items():
        perf_list.sort(key=lambda p: p.name)

    booking_response = get_people(
        foreign_event_ids=[eventitem_id],
        roles=['Teacher', 'Panelist', 'Moderator', 'Staff Lead'])
    people = []
    if len(booking_response.people) == 0 and (
            item.__class__.__name__ == "Class"):
        people = [{
            'role': "Presenter",
            'person': item.teacher, }]
    else:
        id_set = []
        for person in booking_response.people:
            if person.public_id not in id_set:
                id_set += [person.public_id]
                people += [{
                    'role': person.role,
                    'person': eval(person.public_class).objects.get(
                        pk=person.public_id),
                }]

    eventitem_view = {
        'event': item,
        'scheduled_events': get_occurrences(
            foreign_event_ids=[eventitem_id]).occurrences,
        'bio_grid_list': bio_grid_list,
        'featured_grid_list': featured_grid_list,
        'people': people}
    return eventitem_view