Beispiel #1
0
def setup_event_management_form(conference, item, occurrence, context):
    duration = float(item.duration.total_minutes()) / 60
    initial_form_info = {
        'duration':
        duration,
        'max_volunteer':
        occurrence.max_volunteer,
        'day':
        get_conference_day(conference=conference,
                           date=occurrence.starttime.date()),
        'time':
        occurrence.starttime.strftime("%H:%M:%S"),
        'location':
        occurrence.location,
        'occurrence_id':
        occurrence.pk,
    }
    context['event_id'] = occurrence.pk
    context['eventitem_id'] = item.eventitem_id

    # if there was an error in the edit form
    if 'event_form' not in context:
        context['event_form'] = EventBookingForm(instance=item)
    if 'scheduling_form' not in context:
        context['scheduling_form'] = ScheduleOccurrenceForm(
            conference=conference,
            open_to_public=True,
            initial=initial_form_info)
    return (context, initial_form_info)
Beispiel #2
0
 def make_context(self, request, errorcontext=None):
     context = super(EditShowView,
                     self).make_context(request, errorcontext=errorcontext)
     initial_rehearsal_info = {
             'type':  "Rehearsal Slot",
             'duration': 1.0,
             'max_volunteer': 10,
             'day': get_conference_day(
                 conference=self.conference,
                 date=self.occurrence.starttime.date()),
             'time': (self.occurrence.starttime - timedelta(hours=4)
                      ).strftime("%H:%M:%S"),
             'location': self.occurrence.location,
             'occurrence_id': self.occurrence.pk, }
     context.update(self.get_rehearsal_forms(
             initial_rehearsal_info,
             self.manage_vol_url,
             self.conference,
             request,
             errorcontext=errorcontext,
             occurrence_id=self.occurrence.pk))
     return context
Beispiel #3
0
def setup_event_management_form(conference, item, occurrence, context):
    duration = float(item.duration.total_minutes())/60
    initial_form_info = {
        'duration': duration,
        'max_volunteer': occurrence.max_volunteer,
        'day': get_conference_day(
            conference=conference,
            date=occurrence.starttime.date()),
        'time': occurrence.starttime.strftime("%H:%M:%S"),
        'location': occurrence.location,
        'occurrence_id': occurrence.pk, }
    context['event_id'] = occurrence.pk
    context['eventitem_id'] = item.eventitem_id

    # if there was an error in the edit form
    if 'event_form' not in context:
        context['event_form'] = EventBookingForm(instance=item)
    if 'scheduling_form' not in context:
        context['scheduling_form'] = ScheduleOccurrenceForm(
            conference=conference,
            open_to_public=True,
            initial=initial_form_info)
    return (context, initial_form_info)
Beispiel #4
0
    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
Beispiel #5
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
    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