コード例 #1
0
    def get_filtered_occurrences(self, request, select_form):
        occurrences = []
        label_set = [[self.conference.conference_slug]]

        if len(select_form.cleaned_data['calendar_type']) > 0:
            cal_types = []
            for cal_type in select_form.cleaned_data['calendar_type']:
                cal_types += [calendar_type_options[int(cal_type)]]
            label_set += [cal_types]
        if len(select_form.cleaned_data['staff_area']) > 0:
            staff_areas = []
            for staff_area in select_form.cleaned_data['staff_area']:
                staff_areas += [staff_area.slug]
            label_set += [staff_areas]
        if len(select_form.cleaned_data['day']) > 0:
            for day_id in select_form.cleaned_data['day']:
                day = ConferenceDay.objects.get(pk=day_id)
                response = get_occurrences(label_sets=label_set, day=day.day)
                occurrences += response.occurrences
        else:
            response = get_occurrences(label_sets=label_set)
            occurrences += response.occurrences
        if len(select_form.cleaned_data['volunteer_type']) > 0:
            volunteer_event_ids = GenericEvent.objects.filter(
                e_conference=self.conference,
                volunteer_type__in=select_form.cleaned_data['volunteer_type']
            ).values_list('eventitem_id', flat=True)
            occurrences = [
                occurrence for occurrence in occurrences
                if occurrence.eventitem.eventitem_id in volunteer_event_ids
            ]
        return self.build_occurrence_display(occurrences)
コード例 #2
0
ファイル: staff_area_view.py プロジェクト: bethlakshmi/GBE2
def staff_area_view(request, area_id):
    '''
    Generates a staff area report: volunteer opportunities scheduled,
    volunteers scheduled, sorted by time/day
    See ticket #250
    '''
    show_style = False
    viewer_profile = validate_perms(request, 'any', require=True)
    if 'area' in request.GET.keys():
        show_style = (request.GET['area'] == "Show")

    opps_response = None
    area = None
    opps = None

    if show_style:
        parent_response = get_occurrences(foreign_event_ids=[area_id])
        if parent_response.occurrences:
            area = parent_response.occurrences[0]
            opps_response = get_occurrences(
                parent_event_id=parent_response.occurrences[0].pk)
    else:
        area = get_object_or_404(StaffArea, pk=area_id)
        opps_response = get_occurrences(labels=[
            area.conference.conference_slug,
            area.slug])
    if opps_response:
        show_general_status(request, opps_response, "staff_area")
        opps = opps_response.occurrences

    return render(request,
                  'gbe/report/staff_area_schedule.tmpl',
                  {'opps': opps,
                   'area': area})
コード例 #3
0
    def get_filtered_occurrences(self, request, select_form):
        occurrences = []
        label_set = [[self.conference.conference_slug]]

        if len(select_form.cleaned_data['calendar_type']) > 0:
            cal_types = []
            for cal_type in select_form.cleaned_data['calendar_type']:
                cal_types += [calendar_type_options[int(cal_type)]]
            label_set += [cal_types]
        if len(select_form.cleaned_data['staff_area']) > 0:
            staff_areas = []
            for staff_area in select_form.cleaned_data['staff_area']:
                staff_areas += [staff_area.slug]
            label_set += [staff_areas]
        if len(select_form.cleaned_data['day']) > 0:
            for day_id in select_form.cleaned_data['day']:
                day = ConferenceDay.objects.get(pk=day_id)
                response = get_occurrences(label_sets=label_set,
                                           day=day.day)
                occurrences += response.occurrences
        else:
            response = get_occurrences(
                label_sets=label_set)
            occurrences += response.occurrences
        if len(select_form.cleaned_data['volunteer_type']) > 0:
            volunteer_event_ids = GenericEvent.objects.filter(
                e_conference=self.conference,
                volunteer_type__in=select_form.cleaned_data['volunteer_type']
                ).values_list('eventitem_id', flat=True)
            occurrences = [
                occurrence for occurrence in occurrences
                if occurrence.eventitem.eventitem_id in volunteer_event_ids]
        return self.build_occurrence_display(occurrences)
コード例 #4
0
 def get(self, request, *args, **kwargs):
     context = self.process_inputs(request, args, kwargs)
     personal_schedule = []
     eval_occurrences = []
     if not self.conference or not self.this_day or not self.calendar_type:
         return render(request, self.template, context)
     response = get_occurrences(
         labels=[self.calendar_type, self.conference.conference_slug],
         day=self.this_day.day)
     show_general_status(request, response, self.__class__.__name__)
     if len(response.occurrences) > 0:
         if request.user.is_authenticated() and hasattr(
                 request.user, 'profile'):
             sched_response = get_schedule(
                 request.user,
                 labels=[
                     self.calendar_type, self.conference.conference_slug
                 ])
             personal_schedule = sched_response.schedule_items
             person = Person(user=request.user,
                             public_id=request.user.profile.pk,
                             public_class="Profile")
             eval_response = get_eval_info(person=person)
             if len(eval_response.questions) > 0:
                 eval_occurrences = eval_response.occurrences
             else:
                 eval_occurrences = None
         max_block_size, context[
             'occurrences'] = self.build_occurrence_display(
                 response.occurrences, personal_schedule, eval_occurrences)
         grid_size = 2
         if max_block_size < 6:
             grid_size = self.grid_map[max_block_size]
         context['grid_size'] = grid_size
     return render(request, self.template, context)
コード例 #5
0
 def __init__(self, *args, **kwargs):
     event_type = None
     choices = []
     events = None
     if 'event_type' in kwargs:
         event_type = kwargs.pop('event_type')
     super(CopyEventPickModeForm, self).__init__(*args, **kwargs)
     if event_type == "Show":
         events = Show.objects.exclude(e_conference__status="completed")
     elif event_type == "Class":
         events = Class.objects.exclude(e_conference__status="completed")
     elif event_type != "Staff":
         events = GenericEvent.objects.exclude(
             e_conference__status="completed").filter(type=event_type)
     if events:
         response = get_occurrences(foreign_event_ids=events.values_list(
             'eventitem_id', flat=True))
         if response.occurrences:
             for occurrence in response.occurrences:
                 choices += [
                     (occurrence.pk, "%s - %s" %
                      (str(occurrence),
                       occurrence.start_time.strftime(DATETIME_FORMAT)))
                 ]
     else:
         areas = StaffArea.objects.exclude(conference__status="completed")
         for area in areas:
             choices += [(area.pk, area.title)]
     self.fields['target_event'].choices = BLANK_CHOICE_DASH + choices
コード例 #6
0
 def __init__(self, *args, **kwargs):
     event_type = None
     choices = []
     events = None
     if 'event_type' in kwargs:
         event_type = kwargs.pop('event_type')
     super(CopyEventPickModeForm, self).__init__(*args, **kwargs)
     if event_type == "Show":
         events = Show.objects.exclude(
             e_conference__status="completed")
     elif event_type == "Class":
         events = Class.objects.exclude(
             e_conference__status="completed")
     elif event_type != "Staff":
         events = GenericEvent.objects.exclude(
             e_conference__status="completed").filter(type=event_type)
     if events:
         response = get_occurrences(
             foreign_event_ids=events.values_list('eventitem_id',
                                                  flat=True))
         if response.occurrences:
             for occurrence in response.occurrences:
                 choices += [(occurrence.pk, "%s - %s" % (
                     str(occurrence),
                     occurrence.start_time.strftime(DATETIME_FORMAT)))]
     else:
         areas = StaffArea.objects.exclude(
             conference__status="completed")
         for area in areas:
             choices += [(area.pk, area.title)]
     self.fields['target_event'].choices = BLANK_CHOICE_DASH + choices
コード例 #7
0
    def get(self, request, *args, **kwargs):
        error_url = self.groundwork(request, args, kwargs)
        if error_url:
            return error_url

        title = str(self.occurrence)
        start_time = self.occurrence.start_time
        gbe_event = self.occurrence.eventitem

        result = delete_occurrence(self.occurrence.pk)
        show_general_status(request, result, self.__class__.__name__)

        if len(result.errors) == 0:
            result = get_occurrences(
                foreign_event_ids=[self.occurrence.foreign_event_id])
            if len(result.occurrences) == 0:
                gbe_event.visible = False
                gbe_event.save()

            user_message = UserMessage.objects.get_or_create(
                view=self.__class__.__name__,
                code="DELETE_SUCCESS",
                defaults={
                    'summary': "Occurrence Deletion Completed",
                    'description': "This event has been deleted."
                })
            messages.success(
                request, '%s<br>Title: %s,<br> Start Time: %s' %
                (user_message[0].description, title,
                 start_time.strftime(GBE_DATETIME_FORMAT)))
        return HttpResponseRedirect(self.redirect_to)
コード例 #8
0
    def groundwork(self, request, args, kwargs):
        self.profile = validate_perms(request, self.permissions)
        self.area = get_object_or_404(StaffArea,
                                      id=int(kwargs['staff_id']))
        if self.area.conference.conferenceday_set.count() > 0:
            self.start_day = self.area.conference.conferenceday_set.order_by(
                "day").first().day
        else:
            user_message = UserMessage.objects.get_or_create(
                view=self.__class__.__name__,
                code="NO_CONF_DAYS",
                defaults={
                    'summary': "No Conference Days in Conference",
                    'description': no_conf_day_msg})
            messages.error(
                request,
                user_message[0].description)
            return HttpResponseRedirect(reverse(
                'manage_event_list',
                urlconf='gbe.scheduling.urls',
                args=[self.area.conference.conference_slug]))

        response = get_occurrences(labels=[
            self.area.slug,
            self.area.conference.conference_slug])
        self.children = response.occurrences
        show_general_status(request, response, self.__class__.__name__)
コード例 #9
0
def get_eval_summary(labels, visible=True):
    summaries = {}
    response = get_occurrences(labels=labels)

    if visible:
        base = EventEvalQuestion.objects.filter(visible=visible)
    else:
        base = EventEvalQuestion.objects.all()

    questions = base.filter(answer_type="grade").order_by('order')

    for question in questions:
        summaries[question.pk] = EventEvalGrade.objects.filter(
            event__in=response.occurrences,
            question=question).values('event').annotate(summary=Avg('answer'))

    count_question = EventEvalQuestion.objects.filter(
        visible=True, answer_type="grade").first()
    count = {}
    for item in EventEvalGrade.objects.filter(
            event__in=response.occurrences,
            question=count_question).values('event').annotate(
                eval_count=Count('event')):
        count[item['event']] = item['eval_count']
    return EvalSummaryResponse(occurrences=response.occurrences,
                               questions=questions,
                               summaries=summaries,
                               count=count)
コード例 #10
0
def staff_area_view(request, target):
    '''
    Generates a staff area report: volunteer opportunities scheduled,
    volunteers scheduled, sorted by time/day
    See ticket #250
    '''
    viewer_profile = validate_perms(request, (
        'Act Coordinator',
        'Class Coordinator',
        'Costume Coordinator',
        'Vendor Coordinator',
        'Volunteer Coordinator',
        'Tech Crew',
        'Scheduling Mavens',
        'Staff Lead',
        'Ticketing - Admin',
        'Registrar',
    ),
                                    require=True)
    other = "Potential"
    roles = []
    if 'filter' in list(request.GET.keys()) and (request.GET['filter']
                                                 == "Potential"):
        other = "Committed"
    for role, commit in list(role_commit_map.items()):
        if commit[0] == 1 or (commit[0] > 0 and commit[0] < 4
                              and other == "Committed"):
            roles += [role]
    opps_response = None
    area = None
    opps = None
    conference = None
    edit_link = None
    area = get_object_or_404(StaffArea, pk=target)
    opps_response = get_occurrences(
        labels=[area.conference.conference_slug, area.slug])
    conference = area.conference
    if area.conference.status != 'completed':
        edit_link = reverse("edit_staff",
                            urlconf='gbe.scheduling.urls',
                            args=[area.pk])
    if opps_response:
        show_general_status(request, opps_response, "staff_area")
        opps = opps_response.occurrences

    return render(
        request, 'gbe/report/staff_area_schedule.tmpl', {
            'opps': opps,
            'area': area,
            'conference': conference,
            'role_commit_map': role_commit_map,
            'visible_roles': roles,
            'other_option': other,
            'edit_link': edit_link,
        })
コード例 #11
0
 def groundwork(self, request, args, kwargs):
     self.occurrence_id = int(kwargs['occurrence_id'])
     self.profile = validate_perms(request, self.permissions)
     response = get_occurrence(self.occurrence_id)
     show_general_status(request, response, self.__class__.__name__)
     if not response.occurrence:
         raise Http404
     self.occurrence = response.occurrence
     self.start_day = self.occurrence.starttime.date()
     response = get_occurrences(parent_event_id=self.occurrence_id)
     self.children = response.occurrences
     show_general_status(request, response, self.__class__.__name__)
コード例 #12
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)
        response = get_occurrences(foreign_event_ids=[eventitem_id])
    except Event.DoesNotExist:
        raise Http404
    bio_grid_list = []
    featured_grid_list = []
    occurrence_ids = []
    for sched_event in response.occurrences:
        occurrence_ids += [sched_event.pk]
        for casting in sched_event.casting_list:
            if len(casting.role):
                featured_grid_list += [{
                    'bio': casting._item.bio,
                    'role': casting.role,
                }]
            else:
                bio_grid_list += [casting._item.bio]
    booking_response = get_bookings(
        occurrence_ids,
        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': response.occurrences,
        'bio_grid_list': bio_grid_list,
        'featured_grid_list': featured_grid_list,
        'people': people,
    }
    return eventitem_view
コード例 #13
0
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']
                   })
コード例 #14
0
 def prep_bid(self, request, args, kwargs):
     super(ActChangeStateView, self).prep_bid(request, args, kwargs)
     if 'next' in request.POST:
         self.next_page = request.POST['next']
     elif 'next' in request.GET:
         self.next_page = request.GET['next']
     if self.act_accepted(request):
         response = get_occurrences(
             foreign_event_ids=[request.POST['show']])
         show_general_status(request, response, self.__class__.__name__)
         if response.occurrences.count() > 0:
             self.new_show = response.occurrences.first()
         else:
             raise Http404
コード例 #15
0
 def groundwork(self, request, args, kwargs):
     self.occurrence_id = int(kwargs['occurrence_id'])
     self.profile = validate_perms(request, self.permissions)
     response = get_occurrence(self.occurrence_id)
     show_general_status(request, response, self.__class__.__name__)
     if not response.occurrence:
         raise Http404
     self.occurrence = response.occurrence
     if self.occurrence.as_subtype.__class__.__name__ == "Class":
         return HttpResponseForbidden("Class copy is not yet available")
     self.start_day = self.occurrence.starttime.date()
     response = get_occurrences(parent_event_id=self.occurrence_id)
     self.children = response.occurrences
     show_general_status(request, response, self.__class__.__name__)
コード例 #16
0
ファイル: functions.py プロジェクト: bethlakshmi/GBE2
def get_event_display_info(eventitem_id):
    '''
    Helper for displaying a single of event.
    '''
    try:
        item = Event.objects.get_subclass(eventitem_id=eventitem_id)
        response = get_occurrences(foreign_event_ids=[eventitem_id])
    except Event.DoesNotExist:
        raise Http404
    bio_grid_list = []
    featured_grid_list = []
    occurrence_ids = []
    for sched_event in response.occurrences:
        occurrence_ids += [sched_event.pk]
        for casting in sched_event.casting_list:
            if len(casting.role):
                featured_grid_list += [{
                    'bio': casting._item.bio,
                    'role': casting.role,
                    }]
            else:
                bio_grid_list += [casting._item.bio]
    booking_response = get_bookings(
        occurrence_ids,
        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': response.occurrences,
                      'bio_grid_list': bio_grid_list,
                      'featured_grid_list': featured_grid_list,
                      'people': people,
                      }
    return eventitem_view
コード例 #17
0
    def get_filtered_occurrences(self, request, select_form):
        occurrences = []
        label_set = [[self.conference.conference_slug]]

        if len(select_form.cleaned_data['calendar_type']) > 0:
            cal_types = []
            for cal_type in select_form.cleaned_data['calendar_type']:
                cal_types += [calendar_type_options[int(cal_type)]]
            label_set += [cal_types]
        if len(select_form.cleaned_data['staff_area']) > 0:
            staff_areas = []
            for staff_area in select_form.cleaned_data['staff_area']:
                staff_areas += [staff_area.slug]
            label_set += [staff_areas]
        if len(select_form.cleaned_data['day']) > 0:
            for day_id in select_form.cleaned_data['day']:
                day = ConferenceDay.objects.get(pk=day_id)
                response = get_occurrences(label_sets=label_set, day=day.day)
                occurrences += response.occurrences
        else:
            response = get_occurrences(label_sets=label_set)
            occurrences += response.occurrences

        return self.build_occurrence_display(occurrences)
コード例 #18
0
 def groundwork(self, request, args, kwargs):
     groundwork_data = shared_groundwork(request, kwargs, self.view_perm)
     if groundwork_data is None:
         error_url = reverse('home', urlconf='gbe.urls')
         return HttpResponseRedirect(error_url)
     else:
         (self.profile, self.occurrence, self.item) = groundwork_data
     self.can_schedule_acts = validate_perms(request,
                                             self.schedule_act_perm,
                                             require=False)
     self.can_change_techinfo = validate_perms(request,
                                               self.change_tech_perm,
                                               require=False)
     self.can_rebook = validate_perms(request,
                                      self.rebook_perm,
                                      require=False)
     self.can_approve_vol = validate_perms(request,
                                           self.approve_volunteers,
                                           require=False)
     self.can_assign_act = request.user.has_perm(
         'gbe.assign_act') or validate_perms(
             request, self.assign_act_perm, require=False)
     self.show_scope = []
     if validate_perms(request, self.cross_show_scope, require=False):
         self.show_scope = get_occurrences(
             foreign_event_ids=Show.objects.filter(
                 e_conference=self.item.e_conference).values_list(
                     'eventitem_id', flat=True)).occurrences
     else:
         check_scope = False
         for item in get_schedule(user=self.profile.user_object,
                                  roles=self.view_perm).schedule_items:
             self.show_scope += [item.event]
             if item.event == self.occurrence:
                 check_scope = True
         if not check_scope:
             messages.error(
                 request,
                 UserMessage.objects.get_or_create(
                     view=self.__class__.__name__,
                     code="NO_SHOW_SCOPE_PRIVILEGE",
                     defaults={
                         'summary':
                         "User is accesing show they don't manage",
                         'description': no_scope_error
                     })[0].description)
             error_url = reverse('home', urlconf='gbe.urls')
             return HttpResponseRedirect(error_url)
コード例 #19
0
def make_show_casting_form(conference, base_form, start, casting):
    choices = []
    response = get_occurrences(
        foreign_event_ids=Show.objects.filter(
            e_conference=conference).values_list('eventitem_id', flat=True))
    for occurrence in response.occurrences:
        choices += [(occurrence.eventitem.pk, str(occurrence))]
    base_form.fields['show'] = ChoiceField(
        choices=choices,
        label='Pick a Show',
        initial=start)
    base_form.fields['casting'] = ChoiceField(
        choices=get_act_casting(),
        required=False,
        label=act_casting_label,
        initial=casting)
    return base_form
 def __init__(self, *args, **kwargs):
     event_type = None
     choices = []
     events = None
     super(EventAssociationForm, self).__init__(*args, **kwargs)
     shows = Show.objects.exclude(e_conference__status="completed")
     specials = GenericEvent.objects.exclude(
             e_conference__status="completed").filter(type="Special")
     response = get_occurrences(
         foreign_event_ids=list(
             shows.values_list('eventitem_id', flat=True)) +
         list(specials.values_list('eventitem_id', flat=True)))
     if response.occurrences:
         for occurrence in response.occurrences:
             choices += [(occurrence.pk, "%s - %s" % (
                 str(occurrence),
                 occurrence.start_time.strftime(GBE_DATETIME_FORMAT)))]
     self.fields['parent_event'].choices = BLANK_CHOICE_DASH + choices
コード例 #21
0
    def set_rehearsal_forms(self, request=None):
        rehearsal_forms = []
        possible_rehearsals = GenericEvent.objects.filter(
            type='Rehearsal Slot',
            e_conference=self.act.b_conference).values_list('eventitem_id')
        for show in self.shows:
            response = get_occurrences(
                labels=[self.act.b_conference.conference_slug],
                foreign_event_ids=possible_rehearsals,
                parent_event_id=show.pk)
            choices = [(-1, "No rehearsal needed")]
            initial = None
            for event in response.occurrences:
                if (show.pk in self.rehearsals) and (
                        event == self.rehearsals[show.pk].event):
                    choices += [(event.pk,
                                 date_format(event.starttime, "TIME_FORMAT"))]
                    initial = {
                        'rehearsal': event.pk,
                        'booking_id': self.rehearsals[show.pk].booking_id
                    }
                elif event.has_commitment_space("Act"):
                    choices += [(event.pk,
                                 date_format(event.starttime, "TIME_FORMAT"))]
            if initial is None:
                if self.act.tech.confirm_no_rehearsal:
                    initial = {'rehearsal': choices[0][0]}
                elif len(choices) > 1:
                    initial = {'rehearsal': choices[1][0]}

            if request:
                rehearsal_form = BasicRehearsalForm(request.POST,
                                                    prefix=str(show.pk))
            else:
                rehearsal_form = BasicRehearsalForm(prefix=str(show.pk),
                                                    initial=initial)

            rehearsal_form.fields['rehearsal'].choices = choices
            rehearsal_form.fields['rehearsal'].label = \
                "Rehearsal for %s" % str(show.eventitem)
            rehearsal_forms += [rehearsal_form]

        return rehearsal_forms
コード例 #22
0
ファイル: pick_show_form.py プロジェクト: bethlakshmi/GBE2
 def __init__(self, *args, **kwargs):
     super(PickShowForm, self).__init__(*args, **kwargs)
     if 'initial' in kwargs and 'conference' in kwargs['initial']:
         initial = kwargs.pop('initial')
         choices = []
         show_pks = Show.objects.filter(
             e_conference=initial['conference']
             ).order_by('e_title').values_list('eventitem_id', flat=True)
         if len(show_pks) > 0:
             response = get_occurrences(foreign_event_ids=show_pks)
             for occurrence in response.occurrences:
                 event = Show.objects.get(
                     eventitem_id=occurrence.foreign_event_id)
                 choices += [
                     (occurrence.pk, "%s - %s" % (
                         event.e_title,
                         occurrence.start_time.strftime(DATETIME_FORMAT)))]
         choices += [("", "Make New Show")]
         self.fields['show'].choices = choices
コード例 #23
0
def volunteer_type_view(request, conference_choice, volunteer_type_id):
    '''
    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)
    vol_type = get_object_or_404(AvailableInterest, pk=volunteer_type_id)
    eventitem_id_list = GenericEvent.objects.filter(
        e_conference__conference_slug=conference_choice,
        volunteer_type=vol_type).values_list('eventitem_id', flat=True)
    collection = get_occurrences(labels=[conference_choice, 'Volunteer'],
                                 foreign_event_ids=eventitem_id_list)
    show_general_status(request, collection, "volunteer_type")

    return render(request, 'gbe/report/staff_area_schedule.tmpl', {
        'opps': collection.occurrences,
        'vol_type': vol_type
    })
コード例 #24
0
    def get(self, request, *args, **kwargs):
        context = self.process_inputs(request, args, kwargs)
        personal_schedule = []
        if not self.conference or not self.this_day:
            return render(request, self.template, context)
        response = get_occurrences(
            labels=["Volunteer", self.conference.conference_slug],
            day=self.this_day.day,
            max_volunteer=1)
        show_general_status(request, response, self.__class__.__name__)
        if len(response.occurrences) > 0:
            if request.user.is_authenticated and hasattr(
                    request.user, 'profile'):
                all_roles = []
                for n, m in role_options:
                    all_roles += [m]
                sched_response = get_schedule(
                    request.user,
                    labels=["Volunteer", self.conference.conference_slug],
                    roles=all_roles)
                personal_schedule = sched_response.schedule_items
                person = Person(user=request.user,
                                public_id=request.user.profile.pk,
                                public_class="Profile")
                eval_response = get_eval_info(person=person)
            context['occurrences'] = self.build_occurrence_display(
                response.occurrences, personal_schedule)
            context['col_per_hour'] = self.col_per_hour
            context['grid_list'] = self.make_time_range(
                self.start_grid_hour * 60, self.end_grid_hour * 60,
                int(60 / self.col_per_hour))
            if self.next_day_end:
                # hack to roll around the clock
                context['grid_list'] += self.make_time_range(
                    self.end_grid_hour * 60, (self.end_grid_hour + 1) * 60,
                    int(60 / self.col_per_hour))
                context['grid_list'] += self.make_time_range(
                    0, self.next_day_end * 60, int(60 / self.col_per_hour),
                    True)
            context['col_fraction'] = 100.0 / len(context['grid_list'])

        return render(request, self.template, context)
コード例 #25
0
 def __init__(self, *args, **kwargs):
     super(PickShowForm, self).__init__(*args, **kwargs)
     if 'initial' in kwargs and 'conference' in kwargs['initial']:
         initial = kwargs.pop('initial')
         choices = []
         show_pks = Show.objects.filter(
             e_conference=initial['conference']).order_by(
                 'e_title').values_list('eventitem_id', flat=True)
         if len(show_pks) > 0:
             response = get_occurrences(foreign_event_ids=show_pks)
             for occurrence in response.occurrences:
                 event = Show.objects.get(
                     eventitem_id=occurrence.foreign_event_id)
                 choices += [
                     (occurrence.pk, "%s - %s" %
                      (event.e_title,
                       occurrence.start_time.strftime(GBE_DATETIME_FORMAT)))
                 ]
         choices += [("", "Make New Show")]
         self.fields['show'].choices = choices
コード例 #26
0
def volunteer_type_view(request, conference_choice, volunteer_type_id):
    '''
    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)
    vol_type = get_object_or_404(AvailableInterest, pk=volunteer_type_id)
    eventitem_id_list = GenericEvent.objects.filter(
        e_conference__conference_slug=conference_choice,
        volunteer_type=vol_type).values_list('eventitem_id', flat=True)
    collection = get_occurrences(
        labels=[conference_choice, 'Volunteer'],
        foreign_event_ids=eventitem_id_list)
    show_general_status(request, collection, "volunteer_type")

    return render(request,
                  'gbe/report/staff_area_schedule.tmpl',
                  {'opps': collection.occurrences,
                   'vol_type': vol_type})
コード例 #27
0
 def get(self, request, *args, **kwargs):
     context = self.process_inputs(request, args, kwargs)
     personal_schedule = []
     eval_occurrences = []
     if not self.conference or not self.this_day or not self.calendar_type:
         return render(request, self.template, context)
     response = get_occurrences(
         labels=[self.calendar_type, self.conference.conference_slug],
         day=self.this_day.day)
     show_general_status(
         request, response, self.__class__.__name__)
     if len(response.occurrences) > 0:
         if request.user.is_authenticated() and hasattr(
                 request.user,
                 'profile'):
             sched_response = get_schedule(
                 request.user,
                 labels=[self.calendar_type,
                         self.conference.conference_slug])
             personal_schedule = sched_response.schedule_items
             person = Person(
                 user=request.user,
                 public_id=request.user.profile.pk,
                 public_class="Profile")
             eval_response = get_eval_info(person=person)
             if len(eval_response.questions) > 0:
                 eval_occurrences = eval_response.occurrences
             else:
                 eval_occurrences = None
         max_block_size, context[
             'occurrences'] = self.build_occurrence_display(
             response.occurrences,
             personal_schedule,
             eval_occurrences)
         grid_size = 2
         if max_block_size < 6:
             grid_size = self.grid_map[max_block_size]
         context['grid_size'] = grid_size
     return render(request, self.template, context)
コード例 #28
0
    def __init__(self, *args, **kwargs):
        super(PickVolunteerTopicForm, self).__init__(*args, **kwargs)
        if 'initial' in kwargs and 'conference' in kwargs['initial']:
            initial = kwargs.pop('initial')
            complete_choices = []
            event_choices = {
                'Show': [],
                'Special': [],
            }
            staff_choices = []

            response = get_occurrences(labels=[
                initial['conference'].conference_slug,
                "General"])
            for item in response.occurrences:
                event = Event.objects.get_subclass(
                    eventitem_id=item.foreign_event_id)
                if event.event_type in event_choices.keys():
                    event_choices[event.event_type] += [
                        (item.pk, "%s - %s" % (
                            event.e_title,
                            item.start_time.strftime(DATETIME_FORMAT)))]
            if len(event_choices['Show']) > 0:
                complete_choices += [('Shows', event_choices['Show'])]
            if len(event_choices['Special']) > 0:
                complete_choices += [('Special Events',
                                      event_choices['Special'])]
            for item in StaffArea.objects.filter(
                    conference=initial['conference']):
                staff_choices += [("staff_%d" % item.pk,
                                   item.title)]
            if len(staff_choices) > 0:
                complete_choices += [('Staff Areas', staff_choices)]
            complete_choices += [(
                'Standalone',
                [("", "Make a Volunteer Opportunity with no topic"), ])]
            self.fields['volunteer_topic'].choices = complete_choices
コード例 #29
0
    def groundwork(self, request, args, kwargs):
        self.profile = validate_perms(request, self.permissions)
        self.area = get_object_or_404(StaffArea, id=int(kwargs['staff_id']))
        if self.area.conference.conferenceday_set.count() > 0:
            self.start_day = self.area.conference.conferenceday_set.order_by(
                "day").first().day
        else:
            user_message = UserMessage.objects.get_or_create(
                view=self.__class__.__name__,
                code="NO_CONF_DAYS",
                defaults={
                    'summary': "No Conference Days in Conference",
                    'description': no_conf_day_msg
                })
            messages.error(request, user_message[0].description)
            return HttpResponseRedirect(
                reverse('manage_event_list',
                        urlconf='gbe.scheduling.urls',
                        args=[self.area.conference.conference_slug]))

        response = get_occurrences(
            labels=[self.area.slug, self.area.conference.conference_slug])
        self.children = response.occurrences
        show_general_status(request, response, self.__class__.__name__)
    def __init__(self, *args, **kwargs):
        super(PickVolunteerTopicForm, self).__init__(*args, **kwargs)
        if 'initial' in kwargs and 'conference' in kwargs['initial']:
            initial = kwargs.pop('initial')
            complete_choices = []
            event_choices = {
                'Show': [],
                'Special': [],
            }
            staff_choices = []

            response = get_occurrences(
                labels=[initial['conference'].conference_slug, "General"])
            for item in response.occurrences:
                event = Event.objects.get_subclass(
                    eventitem_id=item.foreign_event_id)
                if event.event_type in list(event_choices.keys()):
                    event_choices[event.event_type] += [
                        (item.pk, "%s - %s" %
                         (event.e_title,
                          item.start_time.strftime(GBE_DATETIME_FORMAT)))
                    ]
            if len(event_choices['Show']) > 0:
                complete_choices += [('Shows', event_choices['Show'])]
            if len(event_choices['Special']) > 0:
                complete_choices += [('Special Events',
                                      event_choices['Special'])]
            for item in StaffArea.objects.filter(
                    conference=initial['conference']):
                staff_choices += [("staff_%d" % item.pk, item.title)]
            if len(staff_choices) > 0:
                complete_choices += [('Staff Areas', staff_choices)]
            complete_choices += [('Standalone', [
                ("", "Make a Volunteer Opportunity with no topic"),
            ])]
            self.fields['volunteer_topic'].choices = complete_choices
コード例 #31
0
    def get(self, request, *args, **kwargs):
        context = self.setup(request, args, kwargs)
        items = self.get_events_list_by_type()
        events = []
        eval_occurrences = []
        if request.user.is_authenticated() and hasattr(request.user,
                                                       'profile'):
            person = Person(user=request.user,
                            public_id=request.user.profile.pk,
                            public_class="Profile")
            eval_response = get_eval_info(person=person)
            if len(eval_response.questions) > 0:
                eval_occurrences = eval_response.occurrences
            else:
                eval_occurrences = None
        for item in items:
            scheduled_events = []
            presenters = []
            response = get_occurrences(foreign_event_ids=[item.eventitem_id])
            for occurrence in response.occurrences:
                evaluate = None
                people_response = get_bookings([occurrence.pk])
                highlight = None
                role = None
                favorite_link = reverse('set_favorite',
                                        args=[occurrence.pk, 'on'],
                                        urlconf='gbe.scheduling.urls')
                for person in people_response.people:
                    if request.user == person.user:
                        role = person.role
                        highlight = person.role.lower()
                        if person.role == "Interested":
                            favorite_link = reverse(
                                'set_favorite',
                                args=[occurrence.pk, 'off'],
                                urlconf='gbe.scheduling.urls')
                        else:
                            favorite_link = "disabled"
                    if person.role in ("Teacher", "Moderator", "Panelist"
                                       ) and person.public_class != "Profile":
                        presenter = Performer.objects.get(pk=person.public_id)
                        if presenter not in presenters:
                            presenters += [presenter]
                if self.conference.status == "completed" or (item.calendar_type
                                                             == 'Volunteer'):
                    favorite_link = None
                if (self.event_type == 'Class') and (
                        occurrence.start_time <
                    (datetime.now(tz=pytz.timezone('America/New_York')) -
                     timedelta(hours=settings.EVALUATION_WINDOW))) and (
                         role not in ("Teacher", "Performer",
                                      "Moderator")) and (eval_occurrences
                                                         is not None):
                    if occurrence in eval_occurrences:
                        evaluate = "disabled"
                    else:
                        evaluate = reverse('eval_event',
                                           args=[
                                               occurrence.pk,
                                           ],
                                           urlconf='gbe.scheduling.urls')
                scheduled_events += [{
                    'occurrence': occurrence,
                    'favorite_link': favorite_link,
                    'highlight': highlight,
                    'evaluate': evaluate,
                }]
            if len(presenters) == 0 and item.calendar_type == "Conference":
                presenters += [item.teacher]

            events += [{
                'eventitem':
                item,
                'scheduled_events':
                scheduled_events,
                'presenters':
                presenters,
                'detail':
                reverse('detail_view',
                        urlconf='gbe.scheduling.urls',
                        args=[item.eventitem_id])
            }]
        context['events'] = events
        return render(request, self.template, context)
コード例 #32
0
def AssignVolunteerView(request, volunteer_id):
    '''
    Show a bid  which needs to be assigned to shifts by the coordinator.
    To show: display useful information about the bid,
    If user is not a coordinator, politely decline to show anything.
    '''
    reviewer = validate_perms(request, ('Volunteer Coordinator',))

    if int(volunteer_id) == 0 and request.method == 'POST':
        volunteer_id = int(request.POST['volunteer'])
    volunteer = get_object_or_404(
        Volunteer,
        id=volunteer_id,
    )
    if not volunteer.is_current:
        return HttpResponseRedirect(reverse(
            'volunteer_view', urlconf='gbe.urls', args=[volunteer_id]))
    conference, old_bid = get_conf(volunteer)

    actionURL = reverse('volunteer_changestate',
                        urlconf='gbe.urls',
                        args=[volunteer_id])

    response = get_occurrences(
        labels=[volunteer.b_conference.conference_slug],
        max_volunteer=1)
    show_general_status(request, response, "AssignVolunteerView")
    rehearsals = GenericEvent.objects.filter(
        type='Rehearsal Slot', e_conference=volunteer.b_conference
        ).values_list('eventitem_id', flat=True)

    sched_response = get_schedule(
            user=volunteer.profile.user_object,
            labels=[volunteer.b_conference.conference_slug, ],
            roles=['Volunteer', ])
    show_general_status(request, sched_response, "AssignVolunteerView")
    booking_ids = []
    for schedule_item in sched_response.schedule_items:
        booking_ids += [schedule_item.event.pk]

    conf_windows = conference.windows()
    volunteer_event_windows = []
    volunteer_events = Event.objects.filter(
        e_conference=volunteer.b_conference)

    for event in response.occurrences:
        if event.foreign_event_id not in rehearsals:
            window = {
                'occurrence': event,
                'window': conf_windows.filter(
                    day__day=event.starttime.date(),
                    start__lte=event.starttime.time(),
                    end__gt=event.starttime.time()).first(),
                'booked': event.pk in booking_ids,
                'eventitem': event.eventitem,
                'staff_areas': StaffArea.objects.filter(
                    conference=conference,
                    slug__in=event.labels.values_list('text', flat=True))
            }
            if hasattr(event, 'container_event'):
                window['parent_event'] = event.container_event.parent_event
            volunteer_event_windows += [window]

    return render(
        request,
        'gbe/assign_volunteer.tmpl',
        {'volunteer': volunteer,
         'interests': volunteer.interest_list,
         'volunteer_event_windows': volunteer_event_windows,
         'actionURL': actionURL,
         'conference': conference,
         'old_bid': old_bid})
コード例 #33
0
ファイル: interest_view.py プロジェクト: bethlakshmi/GBE2
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})
コード例 #34
0
    def get_manage_opportunity_forms(self,
                                     initial,
                                     manage_vol_info,
                                     conference,
                                     request,
                                     report_data,
                                     errorcontext=None,
                                     occurrence_id=None,
                                     labels=[]):
        '''
        Generate the forms to allocate, edit, or delete volunteer
        opportunities associated with a scheduler event.
        '''
        actionform = []
        context = {}
        if occurrence_id is not None or len(labels) > 0:
            response = get_occurrences(parent_event_id=occurrence_id,
                                       labels=labels)
        else:
            return None

        if request.GET.get('changed_id', None):
            context['changed_id'] = int(
                self.request.GET.get('changed_id', None))

        for vol_occurence in response.occurrences:
            try:
                vol_event = GenericEvent.objects.get(
                    eventitem_id=vol_occurence.foreign_event_id,
                    type="Volunteer")
                if (errorcontext and 'error_opp_form' in errorcontext and
                        errorcontext['error_opp_form'].instance == vol_event):
                    actionform.append(errorcontext['error_opp_form'])
                else:
                    num_volunteers = vol_occurence.max_volunteer
                    date = vol_occurence.start_time.date()

                    time = vol_occurence.start_time.time
                    day = get_conference_day(conference=vol_event.e_conference,
                                             date=date)
                    location = vol_occurence.location
                    if location:
                        room = location.room
                    elif self.occurrence.location:
                        room = self.occurrence.location.room

                    actionform.append(
                        VolunteerOpportunityForm(
                            instance=vol_event,
                            initial={
                                'opp_event_id': vol_event.event_id,
                                'opp_sched_id': vol_occurence.pk,
                                'max_volunteer': num_volunteers,
                                'day': day,
                                'time': time,
                                'location': room,
                                'type': "Volunteer",
                                'approval': vol_occurence.approval_needed,
                            },
                        ))
            except:
                pass
        context['actionform'] = actionform
        if len(actionform) > 0:
            context['report_url'] = reverse('staff_area',
                                            urlconf='gbe.reporting.urls',
                                            args=report_data)

        if errorcontext and 'createform' in errorcontext:
            createform = errorcontext['createform']
        else:
            createform = VolunteerOpportunityForm(prefix='new_opp',
                                                  initial=initial,
                                                  conference=conference)

        actionheaders = [
            'Title', '#', 'Approve', 'Duration', 'Day', 'Time', 'Location'
        ]
        context.update({
            'createform': createform,
            'actionheaders': actionheaders,
            'manage_vol_url': manage_vol_info
        }),
        return context
コード例 #35
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,
            '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
        })
コード例 #36
0
    def get(self, request, *args, **kwargs):
        context = self.groundwork(request, args, kwargs)
        items = self.get_events_list_by_type()
        events = []
        eval_occurrences = []
        all_roles = []
        personal_schedule_items = []
        if request.user.is_authenticated and hasattr(request.user, 'profile'):
            person = Person(user=request.user,
                            public_id=request.user.profile.pk,
                            public_class="Profile")
            for n, m in role_options:
                all_roles += [m]
            personal_schedule_items = get_schedule(
                request.user,
                labels=[self.conference.conference_slug],
                roles=all_roles,
            ).schedule_items

            eval_response = get_eval_info(person=person)
            if len(eval_response.questions) > 0:
                eval_occurrences = eval_response.occurrences
            else:
                eval_occurrences = None
        for item in items:
            scheduled_events = []
            presenters = []
            response = get_occurrences(foreign_event_ids=[item.eventitem_id])
            for occurrence in response.occurrences:
                (favorite_link, volunteer_link, evaluate,
                 highlight, vol_disable_msg) = build_icon_links(
                     occurrence, eval_occurrences, item.calendar_type,
                     (self.conference.status == "completed"),
                     personal_schedule_items)
                scheduled_events += [{
                    'occurrence':
                    occurrence,
                    'favorite_link':
                    favorite_link,
                    'volunteer_link':
                    volunteer_link,
                    'highlight':
                    highlight,
                    'evaluate':
                    evaluate,
                    'vol_disable_msg':
                    vol_disable_msg,
                    'approval_needed':
                    occurrence.approval_needed,
                }]
                people_response = get_bookings(
                    [occurrence.pk],
                    roles=["Teacher", "Moderator", "Panelist"])
                for person in people_response.people:
                    if person.public_class != "Profile":
                        presenter = Performer.objects.get(pk=person.public_id)
                        if presenter not in presenters:
                            presenters += [presenter]
            if len(presenters) == 0 and item.calendar_type == "Conference":
                presenters += [item.teacher]

            events += [{
                'eventitem':
                item,
                'scheduled_events':
                scheduled_events,
                'presenters':
                presenters,
                'detail':
                reverse('detail_view',
                        urlconf='gbe.scheduling.urls',
                        args=[item.eventitem_id])
            }]
        context['events'] = events
        return render(request, self.template, context)
コード例 #37
0
ファイル: list_events_view.py プロジェクト: bethlakshmi/GBE2
    def get(self, request, *args, **kwargs):
        context = self.setup(request, args, kwargs)
        items = self.get_events_list_by_type()
        events = []
        eval_occurrences = []
        if request.user.is_authenticated() and hasattr(request.user,
                                                       'profile'):
            person = Person(
                user=request.user,
                public_id=request.user.profile.pk,
                public_class="Profile")
            eval_response = get_eval_info(person=person)
            if len(eval_response.questions) > 0:
                eval_occurrences = eval_response.occurrences
            else:
                eval_occurrences = None
        for item in items:
            scheduled_events = []
            presenters = []
            response = get_occurrences(
                foreign_event_ids=[item.eventitem_id])
            for occurrence in response.occurrences:
                evaluate = None
                people_response = get_bookings([occurrence.pk])
                highlight = None
                role = None
                favorite_link = reverse(
                    'set_favorite',
                    args=[occurrence.pk, 'on'],
                    urlconf='gbe.scheduling.urls')
                for person in people_response.people:
                    if request.user == person.user:
                        role = person.role
                        highlight = person.role.lower()
                        if person.role == "Interested":
                            favorite_link = reverse(
                                'set_favorite',
                                args=[occurrence.pk, 'off'],
                                urlconf='gbe.scheduling.urls')
                        else:
                            favorite_link = "disabled"
                    if person.role in (
                            "Teacher",
                            "Moderator",
                            "Panelist") and person.public_class != "Profile":
                        presenter = Performer.objects.get(pk=person.public_id)
                        if presenter not in presenters:
                            presenters += [presenter]
                if self.conference.status == "completed" or (
                        item.calendar_type == 'Volunteer'):
                    favorite_link = None
                if (self.event_type == 'Class') and (
                        occurrence.start_time < (datetime.now(
                            tz=pytz.timezone('America/New_York')
                            ) - timedelta(hours=settings.EVALUATION_WINDOW))
                        ) and (
                        role not in ("Teacher", "Performer", "Moderator")
                        ) and (
                        eval_occurrences is not None):
                    if occurrence in eval_occurrences:
                        evaluate = "disabled"
                    else:
                        evaluate = reverse(
                            'eval_event',
                            args=[occurrence.pk, ],
                            urlconf='gbe.scheduling.urls')
                scheduled_events += [{
                    'occurrence': occurrence,
                    'favorite_link': favorite_link,
                    'highlight': highlight,
                    'evaluate': evaluate,
                }]
            if len(presenters) == 0 and item.calendar_type == "Conference":
                presenters += [item.teacher]

            events += [{
                'eventitem': item,
                'scheduled_events': scheduled_events,
                'presenters': presenters,
                'detail': reverse('detail_view',
                                  urlconf='gbe.scheduling.urls',
                                  args=[item.eventitem_id])}]
        context['events'] = events
        return render(request, self.template, context)
コード例 #38
0
    def post(self, request, *args, **kwargs):
        intro_message = self.groundwork(request, args, kwargs)
        if "day_id" in kwargs:
            day = get_object_or_404(ConferenceDay, pk=kwargs.get("day_id"))
        else:
            raise Http404
        all_valid = True
        forms = []
        the_form = None
        for conference in Conference.objects.filter(
                status__in=('upcoming', 'ongoing')):
            first_day = ConferenceDay.objects.filter(
                conference=conference).order_by('day').first()
            if first_day is not None:
                form = ConferenceStartChangeForm(request.POST,
                                                 instance=first_day,
                                                 prefix=first_day.pk)
                if first_day == day:
                    form.fields['day'].required = True
                    the_form = form
                all_valid = all_valid and form.is_valid()
                forms += [(first_day, form)]

        if the_form is None:
            messages.error(request, UserMessage.objects.get_or_create(
                view=self.__class__.__name__,
                code="NO_CONF_DAY_FORM",
                defaults={
                   'summary': "Conference Day Form Not Loaded",
                   'description': missing_day_form_note})[0].description)
            all_valid = False

        if not all_valid:
            return render(
                request,
                'gbe/scheduling/manage_conference.tmpl',
                {'forms': forms,
                 'intro': intro_message,
                 'title': self.title,
                 'button': self.button,
                 'header': self.header})
        conf_change = the_form.cleaned_data['day'] - day.day

        # update each conference day so form selection offers right choices
        for each_day in day.conference.conferenceday_set.all():
            each_day.day = each_day.day + conf_change
            each_day.save()
        messages.success(
            request,
            "Moved Conference %s by %d days, change %d conference days" % (
                day.conference.conference_slug,
                conf_change.days,
                day.conference.conferenceday_set.count()))

        # update all scheduled events
        event_count = 0
        response = get_occurrences(
            labels=[day.conference.conference_slug])
        for occurrence in response.occurrences:
            occ_response = update_occurrence(
                occurrence.pk,
                start_time=occurrence.starttime + conf_change)
            show_general_status(request, occ_response, self.__class__.__name__)
            if occ_response and occ_response.occurrence:
                event_count = event_count + 1
        messages.success(
            request,
            "Moved %d scheduled events by %d days" % (
                event_count,
                conf_change.days))
        general_calendar_links = ""
        class_calendar_links = ""
        volunteer_calendar_links = ""
        for each_day in day.conference.conferenceday_set.filter(
                open_to_public=True).order_by('day'):
            general_calendar_links = "%s<li>%s - %s?day=%s" % (
                general_calendar_links,
                each_day.day.strftime("%A"),
                reverse("calendar",
                        urlconf='gbe.scheduling.urls',
                        args=['General']),
                each_day.day.strftime(URL_DATE))
            class_calendar_links = "%s<li>%s - %s?day=%s" % (
                class_calendar_links,
                each_day.day.strftime("%A"),
                reverse("calendar",
                        urlconf='gbe.scheduling.urls',
                        args=['Conference']),
                each_day.day.strftime(URL_DATE))
            volunteer_calendar_links = "%s<li>%s - %s?day=%s" % (
                volunteer_calendar_links,
                each_day.day.strftime("%A"),
                reverse("calendar",
                        urlconf='gbe.scheduling.urls',
                        args=['Volunteer']),
                each_day.day.strftime(URL_DATE))
        messages.warning(
            request,
            ("REMINDER: Don't forget to change the calendar links: <ul>" +
             "<li>Special Events</li><ul>%s</ul><li>Conference Events</li>" +
             "<ul>%s</ul><li>Volunteer Events</li><ul>%s</ul></ul>") % (
                general_calendar_links,
                class_calendar_links,
                volunteer_calendar_links))

        return HttpResponseRedirect(
            ("%s?%s-calendar_type=0&%s-calendar_type=1&%s-calendar_type=2" +
             "&filter=Filter") % (
             reverse('manage_event_list', urlconf='gbe.scheduling.urls'),
             day.conference.conference_slug,
             day.conference.conference_slug,
             day.conference.conference_slug))
コード例 #39
0
 def test_get_labels_and_label_sets(self):
     response = get_occurrences(
         labels=["foo"],
         label_sets=["bar"],
     )
     self.assertEqual(response.errors[0].code, "INVALID_REQUEST")
コード例 #40
0
ファイル: edit_show_view.py プロジェクト: bethlakshmi/GBE2
    def get_rehearsal_forms(self,
                            initial,
                            manage_slot_info,
                            conference,
                            request,
                            errorcontext,
                            occurrence_id):
        '''
        Generate the forms to allocate, edit, or delete volunteer
        opportunities associated with a scheduler event.
        '''
        actionform = []
        context = {}
        response = get_occurrences(parent_event_id=occurrence_id)

        for rehearsal_slot in response.occurrences:
            rehearsal = None
            try:
                rehearsal = GenericEvent.objects.get(
                        eventitem_id=rehearsal_slot.foreign_event_id,
                        type="Rehearsal Slot")
            except:
                pass
            if rehearsal is not None:
                if (errorcontext and 'error_slot_form' in errorcontext and
                        errorcontext['error_slot_occurrence_id'
                                     ] == int(rehearsal_slot.pk)):
                    actionform.append(errorcontext['error_slot_form'])
                else:
                    num_volunteers = rehearsal_slot.max_volunteer
                    date = rehearsal_slot.start_time.date()

                    time = rehearsal_slot.start_time.time
                    day = get_conference_day(
                        conference=rehearsal.e_conference,
                        date=date)
                    location = rehearsal_slot.location
                    if location:
                        room = location.room
                    elif self.occurrence.location:
                        room = self.occurrence.location.room
                    response = get_acts(rehearsal_slot.pk)

                    actionform.append(
                        RehearsalSlotForm(
                            instance=rehearsal,
                            initial={'opp_event_id': rehearsal.event_id,
                                     'opp_sched_id': rehearsal_slot.pk,
                                     'current_acts': len(response.castings),
                                     'max_volunteer': num_volunteers,
                                     'day': day,
                                     'time': time,
                                     'location': room,
                                     },
                            )
                        )
        context['slotactionform'] = actionform
        if errorcontext and 'createslotform' in errorcontext:
            createform = errorcontext['createslotform']
        else:
            createform = RehearsalSlotForm(
                prefix='new_slot',
                initial=initial,
                conference=conference)

        actionheaders = ['Title',
                         'Booked/',
                         'Available',
                         'Duration',
                         'Day',
                         'Time',
                         'Location']
        context.update({'createslotform': createform,
                        'slotactionheaders': actionheaders,
                        'manage_slot_url': manage_slot_info}),
        return context
コード例 #41
0
    def get_manage_opportunity_forms(self,
                                     initial,
                                     manage_vol_info,
                                     conference,
                                     request,
                                     errorcontext=None,
                                     occurrence_id=None,
                                     labels=[]):
        '''
        Generate the forms to allocate, edit, or delete volunteer
        opportunities associated with a scheduler event.
        '''
        actionform = []
        context = {}
        if occurrence_id is not None or len(labels) > 0:
            response = get_occurrences(parent_event_id=occurrence_id,
                                       labels=labels)
        else:
            return None

        if request.GET.get('changed_id', None):
            context['changed_id'] = int(
                self.request.GET.get('changed_id', None))

        for vol_occurence in response.occurrences:
            try:
                vol_event = GenericEvent.objects.get(
                        eventitem_id=vol_occurence.foreign_event_id,
                        type="Volunteer")
                if (errorcontext and
                        'error_opp_form' in errorcontext and
                        errorcontext['error_opp_form'].instance == vol_event):
                    actionform.append(errorcontext['error_opp_form'])
                else:
                    num_volunteers = vol_occurence.max_volunteer
                    date = vol_occurence.start_time.date()

                    time = vol_occurence.start_time.time
                    day = get_conference_day(
                        conference=vol_event.e_conference,
                        date=date)
                    location = vol_occurence.location
                    if location:
                        room = location.room
                    elif self.occurrence.location:
                        room = self.occurrence.location.room

                    actionform.append(
                        VolunteerOpportunityForm(
                            instance=vol_event,
                            initial={'opp_event_id': vol_event.event_id,
                                     'opp_sched_id': vol_occurence.pk,
                                     'max_volunteer': num_volunteers,
                                     'day': day,
                                     'time': time,
                                     'location': room,
                                     'type': "Volunteer"
                                     },
                            )
                        )
            except:
                pass
        context['actionform'] = actionform
        if errorcontext and 'createform' in errorcontext:
            createform = errorcontext['createform']
        else:
            createform = VolunteerOpportunityForm(
                prefix='new_opp',
                initial=initial,
                conference=conference)

        actionheaders = ['Title',
                         'Volunteer Type',
                         '#',
                         'Duration',
                         'Day',
                         'Time',
                         'Location']
        context.update({'createform': createform,
                        'actionheaders': actionheaders,
                        'manage_vol_url': manage_vol_info}),
        return context
コード例 #42
0
 def test_get_labels_and_label_sets(self):
     response = get_occurrences(labels=["foo"], label_sets=["bar"],)
     self.assertEqual(response.errors[0].code, "INVALID_REQUEST")
コード例 #43
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'
            ]
        }