def get(self, request, *args, **kwargs):
        self.groundwork(request, args, kwargs)
        schedules = []

        for person in self.profiles:
            response = get_schedule(person.user_object,
                                    labels=[self.conference.conference_slug])
            if len(response.schedule_items) > 0 or len(self.profiles) == 1:
                ticket_items, role_items = get_checklist_items(
                    person, self.conference)
                schedules += [{
                    'person': person,
                    'bookings': response.schedule_items,
                    'ticket_items': ticket_items,
                    'role_items': role_items
                }]

        sorted_sched = sorted(
            schedules,
            key=lambda schedule: schedule['person'].get_badge_name())
        return render(
            request, 'gbe/report/printable_schedules.tmpl', {
                'schedules': sorted_sched,
                'conference_slugs': conference_slugs(),
                'conference': self.conference
            })
Exemple #2
0
    def process_inputs(self, request, args, kwargs):
        context = {}
        self.calendar_type = None
        self.conference = None
        self.this_day = None
        self.can_edit_show = False
        if "calendar_type" in kwargs:
            self.calendar_type = kwargs['calendar_type']
            if self.calendar_type not in list(calendar_type_options.values()):
                raise Http404

        if "day" in self.request.GET:
            try:
                self.this_day = get_object_or_404(
                    ConferenceDay,
                    day=datetime.strptime(self.request.GET.get('day', None),
                                          URL_DATE))
            except ValueError:
                raise Http404
            self.conference = self.this_day.conference

        elif "conference" in self.request.GET:
            self.conference = get_conference_by_slug(
                self.request.GET.get('conference', None))
        else:
            self.conference = get_current_conference()

        if not self.this_day:
            self.this_day = get_conference_days(
                self.conference, open_to_public=True).order_by("day").first()

        context = {
            'calendar_type': self.calendar_type,
            'conference': self.conference,
            'conference_slugs': conference_slugs(),
            'this_day': self.this_day,
        }
        if self.calendar_type == "General" and validate_perms(
                request, self.show_editors, require=False):
            self.can_edit_show = True

        if self.this_day:
            open_to_public = [True]
            if self.calendar_type == "Volunteer":
                open_to_public = [True, False]
            if ConferenceDay.objects.filter(
                    day=self.this_day.day + timedelta(days=1),
                    open_to_public__in=open_to_public).exists():
                context['next_date'] = (self.this_day.day +
                                        timedelta(days=1)).strftime(URL_DATE)
            if ConferenceDay.objects.filter(
                    day=self.this_day.day - timedelta(days=1),
                    open_to_public__in=open_to_public).exists():
                context['prev_date'] = (self.this_day.day -
                                        timedelta(days=1)).strftime(URL_DATE)

        return context
    def process_inputs(self, request, args, kwargs):
        context = {}
        self.calendar_type = None
        self.conference = None
        self.this_day = None

        if "calendar_type" in kwargs:
            self.calendar_type = kwargs['calendar_type']
            if self.calendar_type not in calendar_type_options.values():
                raise Http404

        if "day" in self.request.GET:
            try:
                self.this_day = get_object_or_404(
                    ConferenceDay,
                    day=datetime.strptime(self.request.GET.get('day', None),
                                          URL_DATE))
            except ValueError:
                raise Http404
            self.conference = self.this_day.conference

        elif "conference" in self.request.GET:
            self.conference = get_conference_by_slug(
                self.request.GET.get('conference', None))
        else:
            self.conference = get_current_conference()

        if not self.this_day:
            self.this_day = get_conference_days(
                self.conference,
                open_to_public=True).order_by("day").first()

        context = {
            'calendar_type': self.calendar_type,
            'conference': self.conference,
            'conference_slugs': conference_slugs(),
            'this_day': self.this_day,
        }
        if self.this_day:
            open_to_public = [True]
            if self.calendar_type == "Volunteer":
                open_to_public = [True, False]
            if ConferenceDay.objects.filter(
                    day=self.this_day.day+timedelta(days=1),
                    open_to_public__in=open_to_public).exists():
                context['next_date'] = (self.this_day.day+timedelta(days=1)
                                        ).strftime(URL_DATE)
            if ConferenceDay.objects.filter(
                    day=self.this_day.day-timedelta(days=1),
                    open_to_public__in=open_to_public).exists():
                context['prev_date'] = (self.this_day.day-timedelta(days=1)
                                        ).strftime(URL_DATE)

        return context
def all_volunteer_view(request):
    '''
    Generates a staff area report: volunteer opportunities scheduled,
    volunteers scheduled, sorted by time/day
    See ticket #250
    '''
    viewer_profile = validate_perms(request, 'any', require=True)
    roles = []
    if request.GET and request.GET.get('conf_slug'):
        conference = get_conference_by_slug(request.GET['conf_slug'])
    else:
        conference = get_current_conference()

    for role, commit in list(role_commit_map.items()):
        if commit[0] > 0 and commit[0] < 4:
            roles += [role]

    opps_response = None
    opps = []
    opps_response = get_occurrences(
        labels=[conference.conference_slug, "Volunteer"])

    if opps_response:
        show_general_status(request, opps_response, "staff_area")
        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]

    return render(request,
                  'gbe/report/flat_volunteer_review.tmpl',
                  {'opps': opps,
                   'conference': conference,
                   'conference_slugs': conference_slugs(),
                   'role_commit_map': role_commit_map,
                   'visible_roles': roles,
                   'columns': ['Event',
                               'Parent',
                               'Area',
                               'Date/Time',
                               'Location',
                               'Max',
                               'Current',
                               'Volunteers']
                   })
Exemple #5
0
def list_reports(request):
    '''
      Shows listing of all reports in this area
    '''
    viewer_profile = validate_perms(request, 'any', require=True)
    if request.GET and request.GET.get('conf_slug'):
        conference = get_conference_by_slug(request.GET['conf_slug'])
    else:
        conference = get_current_conference()
    return render(request,
                  'gbe/report/report_list.tmpl', {
                      'conference_slugs': conference_slugs(),
                      'conference': conference,
                      'return_link': reverse('report_list',
                                             urlconf='gbe.reporting.urls')})
Exemple #6
0
def review_staff_area_view(request):
    '''
      Shows listing of staff area stuff for drill down
    '''
    viewer_profile = validate_perms(request, 'any', require=True)
    if request.GET and request.GET.get('conf_slug'):
        conference = Conference.by_slug(request.GET['conf_slug'])
    else:
        conference = Conference.current_conf()

    header = ['Area', 'Leaders', 'Check Staffing']

    return render(
        request, 'gbe/report/staff_areas.tmpl', {
            'header': header,
            'areas': StaffArea.objects.filter(conference=conference),
            'conference_slugs': conference_slugs(),
            'conference': conference
        })
Exemple #7
0
def view_techinfo(request):
    '''
    Show the list of act tech info for all acts in a given show for a given
    tech area.
    export specifies the type of export, csv or view.  area is the tech area
    of the information being exported, audio, lighting, stage_mgmt, or all.
    '''

    validate_perms(request, ('Tech Crew', ))
    area = request.GET.get('area', 'all')
    show_id = request.GET.get('show_id', None)
    area = request.GET.get('area', 'all')
    show, acts, conference, scheduling_link = prep_act_tech_info(
        request, show_id)

    if show_id:
        logger.info(area + ', ' + show_id)
        header, techinfo = build_techinfo(show_id, area=area)
        logger.info(techinfo)
        logger.info(header)
    else:
        logger.info(area)
        header = None
        techinfo = None

    return render(
        request, 'gbe/report/view_techinfo.tmpl', {
            'this_show': show,
            'area': area,
            'area_options': ['all', 'audio', 'stage_mgmt', 'lighting'],
            'all_shows': Show.objects.filter(e_conference=conference),
            'techinfo': techinfo,
            'header': header,
            'conference_slugs': conference_slugs(),
            'conference': conference,
            'scheduling_link': scheduling_link,
            'return_link': reverse(
                'view_techinfo',
                urlconf='gbe.reporting.urls',
            )
        })
def review_staff_area_view(request):
    '''
      Shows listing of staff area stuff for drill down
    '''
    viewer_profile = validate_perms(request, 'any', require=True)
    if request.GET and request.GET.get('conf_slug'):
        conference = Conference.by_slug(request.GET['conf_slug'])
    else:
        conference = Conference.current_conf()

    header = ['Area', 'Leaders', 'Check Staffing']

    return render(
        request,
        'gbe/report/staff_areas.tmpl',
        {'header': header,
         'areas': StaffArea.objects.filter(conference=conference),
         'shows': Show.objects.filter(e_conference=conference),
         'volunteer_types': AvailableInterest.objects.filter(visible=True),
         'conference_slugs': conference_slugs(),
         'conference': conference})
Exemple #9
0
def view_techinfo(request):
    '''
    Show the list of act tech info for all acts in a given show for a given
    tech area.
    export specifies the type of export, csv or view.  area is the tech area
    of the information being exported, audio, lighting, stage_mgmt, or all.
    '''

    validate_perms(request, ('Tech Crew',))
    area = request.GET.get('area', 'all')
    show_id = request.GET.get('show_id', None)
    area = request.GET.get('area', 'all')
    show, acts, conference, scheduling_link = prep_act_tech_info(
        request, show_id)

    if show_id:
        logger.info(area+', '+show_id)
        header, techinfo = build_techinfo(show_id, area=area)
        logger.info(techinfo)
        logger.info(header)
    else:
        logger.info(area)
        header = None
        techinfo = None

    return render(request,
                  'gbe/report/view_techinfo.tmpl',
                  {'this_show': show,
                   'area': area,
                   'area_options': ['all', 'audio', 'stage_mgmt', 'lighting'],
                   'all_shows': Show.objects.filter(
                       e_conference=conference),
                   'techinfo': techinfo,
                   'header': header,
                   'conference_slugs': conference_slugs(),
                   'conference': conference,
                   'scheduling_link': scheduling_link,
                   'return_link': reverse('view_techinfo',
                                          urlconf='gbe.reporting.urls',)})
Exemple #10
0
def review_act_techinfo(request, show_id=None):
    '''
    Show the list of act tech info for all acts in a given show
    '''
    validate_perms(request, ('Tech Crew',))
    # using try not get_or_404 to cover the case where the show is there
    # but does not have any scheduled events.
    # I can still show a list of shows this way.

    show, acts, conference, scheduling_link = prep_act_tech_info(
        request, show_id)
    return render(request,
                  'gbe/report/act_tech_review.tmpl',
                  {'this_show': show,
                   'acts': acts,
                   'all_shows': conf.Show.objects.filter(
                       e_conference=conference),
                   'conference_slugs': conference_slugs(),
                   'conference': conference,
                   'scheduling_link': scheduling_link,
                   'return_link': reverse('act_techinfo_review',
                                          urlconf='gbe.reporting.urls',)})
    def get(self, request, *args, **kwargs):
        self.groundwork(request, args, kwargs)
        schedules = []

        for person in self.profiles:
            response = get_schedule(
                person.user_object,
                labels=[self.conference.conference_slug])
            if len(response.schedule_items) > 0 or len(self.profiles) == 1:
                ticket_items, role_items = get_checklist_items(person,
                                                               self.conference)
                schedules += [{'person': person,
                               'bookings': response.schedule_items,
                               'ticket_items': ticket_items,
                               'role_items': role_items}]

        sorted_sched = sorted(
            schedules,
            key=lambda schedule: schedule['person'].get_badge_name())
        return render(request,
                      'gbe/report/printable_schedules.tmpl',
                      {'schedules': sorted_sched,
                       'conference_slugs': conference_slugs(),
                       'conference': self.conference})
Exemple #12
0
    def setup(self, request, args, kwargs):
        context = {}

        if "event_type" in kwargs:
            self.event_type = kwargs['event_type']
            if self.event_type.lower() not in list_titles:
                raise Http404

        if "conference" in self.request.GET:
            self.conference = get_conference_by_slug(
                self.request.GET.get('conference', None))
        else:
            self.conference = get_current_conference()
        if not self.conference:
            raise Http404

        context = {
            'conf_slug': self.conference.conference_slug,
            'conference_slugs': conference_slugs(),
            'title': list_titles.get(self.event_type.lower(), ""),
            'view_header_text': list_text.get(self.event_type.lower(), ""),
        }

        return context
Exemple #13
0
    def setup(self, request, args, kwargs):
        context = {}

        if "event_type" in kwargs:
            self.event_type = kwargs['event_type']
            if self.event_type.lower() not in list_titles:
                raise Http404

        if "conference" in self.request.GET:
            self.conference = get_conference_by_slug(
                self.request.GET.get('conference', None))
        else:
            self.conference = get_current_conference()
        if not self.conference:
            raise Http404

        context = {
            'conf_slug': self.conference.conference_slug,
            'conference_slugs': conference_slugs(),
            'title': list_titles.get(self.event_type.lower(), ""),
            'view_header_text': list_text.get(self.event_type.lower(), ""),
        }

        return context
Exemple #14
0
def eval_view(request, occurrence_id=None):
    details = None
    reviewer = validate_perms(request, ('Class Coordinator', ))
    if request.GET and request.GET.get('conf_slug'):
        conference = get_conference_by_slug(request.GET['conf_slug'])
    else:
        conference = get_current_conference()
    if occurrence_id:
        detail_response = get_eval_info(occurrence_id=int(occurrence_id))
        show_general_status(request, detail_response, "EvaluationDetailView")
        if detail_response.occurrences and len(
                detail_response.occurrences) > 0:
            detail_response.answers.sort(
                key=lambda answer: (answer.profile.profile.display_name,
                                    answer.question.order))
            details = {
                'occurrence': detail_response.occurrences[0],
                'title': detail_response.occurrences[
                    0].eventitem.event.e_title,
                'description': detail_response.occurrences[
                    0].eventitem.event.e_description,
                'questions': detail_response.questions,
                'evaluations': detail_response.answers,
            }

    response = get_eval_summary(
        labels=[conference.conference_slug, "Conference"])
    header = ['Class',
              'Teacher(s)',
              'Time',
              '# Interested',
              '# Evaluations']
    for question in response.questions:
        header += [question.question]
    header += ['Actions']

    display_list = []
    summary_view_data = {}
    events = Class.objects.filter(e_conference=conference)
    for occurrence in response.occurrences:
        class_event = events.get(
                eventitem_id=occurrence.eventitem.eventitem_id)
        teachers = []
        interested = []
        for person in occurrence.people:
            if person.role == "Interested":
                interested += [person]
            elif person.role in ("Teacher", "Moderator"):
                teachers += [Performer.objects.get(pk=person.public_id)]

        display_item = {
            'id': occurrence.id,
            'eventitem_id': class_event.eventitem_id,
            'sort_start': occurrence.start_time,
            'start':  occurrence.start_time.strftime(DATETIME_FORMAT),
            'title': class_event.e_title,
            'teachers': teachers,
            'interested': len(interested),
            'eval_count': response.count.get(occurrence.pk, 0),
            'detail_link': reverse(
                'evaluation_detail',
                urlconf='gbe.reporting.urls',
                args=[occurrence.id])}
        display_list += [display_item]
        summary_view_data[int(occurrence.id)] = {}
    for question in response.questions:
        for item in response.summaries[question.pk]:
            summary_view_data[int(item['event'])][int(question.pk)] = item[
                'summary']

    display_list.sort(key=lambda k: k['sort_start'])
    user_message = UserMessage.objects.get_or_create(
        view="InterestView",
        code="ABOUT_EVAL_REPORT",
        defaults={
            'summary': "About Evaluation Report",
            'description': eval_report_explain_msg})
    return render(request,
                  'gbe/report/evals.tmpl',
                  {'header': header,
                   'classes': display_list,
                   'questions': response.questions,
                   'summaries': summary_view_data,
                   'conference_slugs': conference_slugs(),
                   'conference': conference,
                   'about': user_message[0].description,
                   'details': details})
Exemple #15
0
def interest_view(request):
    viewer_profile = validate_perms(request, 'any', require=True)

    if request.GET and request.GET.get('conf_slug'):
        conference = get_conference_by_slug(request.GET['conf_slug'])
    else:
        conference = get_current_conference()

    response = get_occurrences(
        labels=[conference.conference_slug, "Conference"])
    header = ['Class',
              'Teacher',
              'Location',
              'Max attendees',
              'Style',
              'Interested',
              'Action']

    display_list = []
    events = Class.objects.filter(e_conference=conference)
    for occurrence in response.occurrences:
        class_event = events.get(
                eventitem_id=occurrence.eventitem.eventitem_id)
        teachers = []
        interested = []
        for person in occurrence.people:
            if person.role == "Interested":
                interested += [person]
            elif person.role in ("Teacher", "Moderator"):
                teachers += [Performer.objects.get(pk=person.public_id)]

        display_item = {
            'id': occurrence.id,
            'sort_start': occurrence.start_time,
            'start':  occurrence.start_time.strftime(DATETIME_FORMAT),
            'title': class_event.e_title,
            'location': occurrence.location,
            'teachers': teachers,
            'eventitem_id': class_event.eventitem_id,
            'interested': interested,
            'type': class_event.type,
            'maximum_enrollment': class_event.maximum_enrollment,
            'detail_link': reverse(
                'detail_view',
                urlconf='gbe.scheduling.urls',
                args=[class_event.eventitem_id])}
        display_list += [display_item]

    display_list.sort(key=lambda k: k['sort_start'])
    user_message = UserMessage.objects.get_or_create(
        view="InterestView",
        code="ABOUT_INTERESTED",
        defaults={
            'summary': "About Interested Attendee Report",
            'description': interested_report_explain_msg})
    return render(request,
                  'gbe/report/interest.tmpl',
                  {'header': header,
                   'classes': display_list,
                   'conference_slugs': conference_slugs(),
                   'conference': conference,
                   'about': user_message[0].description})
def interest_view(request):
    viewer_profile = validate_perms(request, 'any', require=True)

    if request.GET and request.GET.get('conf_slug'):
        conference = get_conference_by_slug(request.GET['conf_slug'])
    else:
        conference = get_current_conference()

    response = get_occurrences(
        labels=[conference.conference_slug, "Conference"])
    header = [
        'Class', 'Teacher', 'Location', 'Max attendees', 'Style', 'Interested',
        'Action'
    ]

    display_list = []
    events = Class.objects.filter(e_conference=conference)
    for occurrence in response.occurrences:
        class_event = events.get(
            eventitem_id=occurrence.eventitem.eventitem_id)
        teachers = []
        interested = []
        for person in occurrence.people:
            if person.role == "Interested":
                interested += [person]
            elif person.role in ("Teacher", "Moderator"):
                teachers += [Performer.objects.get(pk=person.public_id)]

        display_item = {
            'id':
            occurrence.id,
            'title':
            class_event.e_title,
            'location':
            occurrence.location,
            'teachers':
            teachers,
            'eventitem_id':
            class_event.eventitem_id,
            'interested':
            interested,
            'type':
            class_event.type,
            'maximum_enrollment':
            class_event.maximum_enrollment,
            'detail_link':
            reverse('detail_view',
                    urlconf='gbe.scheduling.urls',
                    args=[class_event.eventitem_id])
        }
        display_list += [display_item]

    user_message = UserMessage.objects.get_or_create(
        view="InterestView",
        code="ABOUT_INTERESTED",
        defaults={
            'summary': "About Interested Attendee Report",
            'description': interested_report_explain_msg
        })
    return render(
        request, 'gbe/report/interest.tmpl', {
            'columns': header,
            'classes': display_list,
            'conference_slugs': conference_slugs(),
            'conference': conference,
            'about': user_message[0].description
        })
def eval_view(request, occurrence_id=None):
    details = None
    reviewer = validate_perms(request, ('Class Coordinator', ))
    conference = None
    if request.GET and request.GET.get('conf_slug'):
        conference = get_conference_by_slug(request.GET['conf_slug'])
    if occurrence_id and not conference:
        detail_response = get_eval_info(occurrence_id=int(occurrence_id))
        show_general_status(request, detail_response, "EvaluationDetailView")
        if detail_response.occurrences and len(
                detail_response.occurrences) > 0:
            detail_response.answers.sort(key=lambda answer: (
                answer.profile.profile.display_name, answer.question.order))
            details = {
                'occurrence': detail_response.occurrences[0],
                'title':
                detail_response.occurrences[0].eventitem.event.e_title,
                'description':
                detail_response.occurrences[0].eventitem.event.e_description,
                'questions': detail_response.questions,
                'evaluations': detail_response.answers,
            }
            if not conference:
                conference = detail_response.occurrences[
                    0].eventitem.event.e_conference
    if not conference:
        conference = get_current_conference()

    response = get_eval_summary(
        labels=[conference.conference_slug, "Conference"])

    display_list = []
    summary_view_data = {}
    events = Class.objects.filter(e_conference=conference)
    for occurrence in response.occurrences:
        class_event = events.get(
            eventitem_id=occurrence.eventitem.eventitem_id)
        teachers = []
        interested = []
        for person in occurrence.people:
            if person.role == "Interested":
                interested += [person]
            elif person.role in ("Teacher", "Moderator"):
                teachers += [Performer.objects.get(pk=person.public_id)]

        display_item = {
            'id':
            occurrence.id,
            'eventitem_id':
            class_event.eventitem_id,
            'start':
            occurrence.start_time.strftime(GBE_TABLE_FORMAT),
            'title':
            class_event.e_title,
            'teachers':
            teachers,
            'interested':
            len(interested),
            'eval_count':
            response.count.get(occurrence.pk, 0),
            'detail_link':
            reverse('evaluation_detail',
                    urlconf='gbe.reporting.urls',
                    args=[occurrence.id])
        }
        display_list += [display_item]
        summary_view_data[int(occurrence.id)] = {}
    for question in response.questions:
        for item in response.summaries[question.pk]:
            summary_view_data[int(item['event'])][int(
                question.pk)] = item['summary']

    user_message = UserMessage.objects.get_or_create(
        view="InterestView",
        code="ABOUT_EVAL_REPORT",
        defaults={
            'summary': "About Evaluation Report",
            'description': eval_report_explain_msg
        })
    return render(
        request, 'gbe/report/evals.tmpl', {
            'columns':
            ['Class', 'Teacher(s)', 'Time', '# Interested', '# Evaluations'],
            'vertical_columns':
            response.questions.values_list('question', flat=True),
            'last_columns': ['Actions'],
            'classes':
            display_list,
            'questions':
            response.questions,
            'summaries':
            summary_view_data,
            'conference_slugs':
            conference_slugs(),
            'conference':
            conference,
            'about':
            user_message[0].description,
            'details':
            details
        })
def ticket_items(request, conference_choice=None):
    '''
    Represents the view for working with ticket items.  This will have a
    list of current ticket items, and the ability to synch them.
    '''
    validate_perms(request, ('Ticketing - Admin', ))

    if 'Import' in request.POST:
        msgs = import_ticket_items()
        for msg, is_success in msgs:
            if is_success:
                messages.success(request, msg)
            else:
                messages.error(request, msg)

    conference_choice = request.GET.get('conference', None)
    if conference_choice:
        events = TicketingEvents.objects.filter(
            conference__conference_slug=conference_choice).order_by('title')
        conference = get_conference_by_slug(conference_choice)
    else:
        events = TicketingEvents.objects.exclude(
            conference__status='completed').order_by('title')
        conference = get_current_conference()
        if conference:
            conference_choice = conference.conference_slug
    intro = UserMessage.objects.get_or_create(view="ViewTicketItems",
                                              code="INTRO_MESSAGE",
                                              defaults={
                                                  'summary':
                                                  "Introduction Message",
                                                  'description':
                                                  intro_ticket_message
                                              })
    check_intro = UserMessage.objects.get_or_create(
        view="CheckTicketEventItems",
        code="INTRO_MESSAGE",
        defaults={
            'summary': "Introduction Message",
            'description': intro_ticket_assign_message
        })
    gbe_events = get_ticketable_gbe_events(conference_choice)
    context = {
        'intro':
        intro[0].description,
        'act_pay_form':
        get_ticket_form("Act", conference),
        'vendor_pay_form':
        get_ticket_form("Vendor", conference),
        'act_fees':
        events.filter(act_submission_event=True),
        'vendor_fees':
        events.filter(vendor_submission_event=True),
        'open_panel':
        request.GET.get('open_panel', ""),
        'updated_tickets':
        eval(request.GET.get('updated_tickets', '[]')),
        'updated_events':
        eval(request.GET.get('updated_events', '[]')),
        'events':
        events.filter(act_submission_event=False,
                      vendor_submission_event=False),
        'conference_slugs':
        conference_slugs(),
        'conference':
        conference,
        'check_intro':
        check_intro[0].description,
        'gbe_events':
        gbe_events
    }
    return render(request, r'ticketing/ticket_items.tmpl', context)
Exemple #19
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'
            ]
        }
def transactions(request):
    '''
    Represents the view for working with ticket items.  This will have a
    list of current ticket items, and the ability to synch them.
    '''
    validate_perms(request, ('Ticketing - Transactions', ))
    conference_choice = request.GET.get('conference', None)
    if conference_choice:
        conference = get_conference_by_slug(conference_choice)
    else:
        conference = get_current_conference()

    view_format = request.GET.get('format', 'ticket')
    changed_id = int(request.GET.get('changed_id', -1))

    intro = UserMessage.objects.get_or_create(view="ViewTransactions",
                                              code="INTRO_MESSAGE",
                                              defaults={
                                                  'summary':
                                                  "Introduction Message",
                                                  'description':
                                                  intro_transaction_message
                                              })
    count = -1
    error = ''

    if ('Sync' in request.POST):
        msgs = process_eb_purchases()
        for msg, is_success in msgs:
            if is_success:
                messages.success(request, msg)
            else:
                messages.error(request, msg)
        count = process_bpt_order_list()
        success_msg = UserMessage.objects.get_or_create(
            view="ViewTransactions",
            code="IMPORT_MESSAGE",
            defaults={
                'summary': "Import BPT Transactions Message",
                'description': import_transaction_message
            })
        messages.success(
            request, "%s   Transactions imported: %s - BPT" %
            (success_msg[0].description, count))

    user_editor = validate_perms(request, ('Registrar', ), require=False)
    context = {
        'conference_slugs': conference_slugs(),
        'conference': conference,
        'changed_id': changed_id,
        'error': error,
        'intro': intro[0].description,
        'can_edit': user_editor,
        'view_format': view_format
    }
    if view_format == "ticket":
        context['transactions'] = Transaction.objects.filter(
            ticket_item__ticketing_event__conference=conference).order_by(
                'ticket_item__ticketing_event', 'ticket_item__title',
                'purchaser')
    else:
        context['users'] = User.objects.filter(
            purchaser__transaction__ticket_item__ticketing_event__conference=
            conference).distinct().order_by('email')
    return render(request, r'ticketing/transactions.tmpl', context)