def make_context(self): context = super(ReviewClassView, self).make_context() context['class'] = self.object context['scheduling_info'] = get_scheduling_info(self.object) context['performer'] = self.performer context['display_contact_info'] = True return context
def make_context(self, request, errorcontext=None): context = super(EditEventView, self).make_context(request, errorcontext) context, initial_form_info = setup_event_management_form( self.item.e_conference, self.item, self.occurrence, context) context['edit_title'] = self.title context['scheduling_info'] = get_scheduling_info(self.item) if 'worker_formset' not in context: context['worker_formset'] = self.make_formset( event_settings[self.item.type.lower()]['roles']) if validate_perms(request, ('Volunteer Coordinator',), require=False): volunteer_initial_info = initial_form_info.copy() volunteer_initial_info.pop('occurrence_id') context.update(self.get_manage_opportunity_forms( volunteer_initial_info, self.manage_vol_url, self.conference, request, errorcontext=errorcontext, occurrence_id=self.occurrence.pk)) else: context['start_open'] = True return context
def make_context(self): context = { 'performer': self.bid.teacher, 'class': self.bid, 'scheduling_info': get_scheduling_info(self.bid), 'display_contact_info': True } return context
def make_context(self): context = super(ReviewClassView, self).make_context() context['class'] = self.object context['scheduling_info'] = get_scheduling_info(self.object) context['performer'] = self.performer context['display_contact_info'] = True if self.can_schedule: context['extra_button'] = "Schedule >>" return context
def setup_third_form(self, working_class=None): context = {} if working_class is not None: context['third_title'] = "Book Class: %s" % ( working_class.e_title) context['third_form'] = ClassBookingForm(instance=working_class) duration = working_class.duration.total_seconds() / timedelta( hours=1).total_seconds() context['scheduling_info'] = get_scheduling_info(working_class) else: context['third_form'] = ClassBookingForm() duration = 1 context['scheduling_form'] = ScheduleOccurrenceForm( conference=self.conference, open_to_public=True, initial={ 'duration': duration, }) context['scheduling_form'].fields[ 'max_volunteer'].widget = HiddenInput() context['worker_formset'] = self.make_formset(working_class) return context
def post(self, request, *args, **kwargs): working_class = None context = self.groundwork(request, args, kwargs) context['second_form'] = PickClassForm( request.POST, initial={'conference': self.conference}) context['third_title'] = "Make New Class" if 'pick_class' in request.POST.keys() and context[ 'second_form'].is_valid(): if context['second_form'].cleaned_data[ 'accepted_class']: working_class = context['second_form'].cleaned_data[ 'accepted_class'] context['third_title'] = "Book Class: %s" % ( working_class.e_title) context['third_form'] = ClassBookingForm( instance=working_class) duration = working_class.duration.hours() + float( working_class.duration.minutes())/60 context['scheduling_info'] = get_scheduling_info(working_class) else: context['third_form'] = ClassBookingForm() duration = 1 context['scheduling_form'] = ScheduleOccurrenceForm( conference=self.conference, open_to_public=True, initial={'duration': duration, }) context['scheduling_form'].fields[ 'max_volunteer'].widget = HiddenInput() context['worker_formset'] = self.make_formset(working_class) elif 'set_class' in request.POST.keys( ) and 'eventitem_id' in request.POST.keys(): if request.POST['eventitem_id']: working_class = get_object_or_404( Class, eventitem_id=request.POST['eventitem_id']) context['third_title'] = "Book Class: %s" % ( working_class.e_title) context['third_form'] = ClassBookingForm( request.POST, instance=working_class) context['scheduling_info'] = get_scheduling_info(working_class) else: context['third_form'] = ClassBookingForm(request.POST) context['second_form'] = PickClassForm( initial={'conference': self.conference, 'accepted_class': working_class}) context['scheduling_form'] = ScheduleOccurrenceForm( request.POST, conference=self.conference) context['scheduling_form'].fields[ 'max_volunteer'].widget = HiddenInput() context['worker_formset'] = self.make_formset(working_class, post=request.POST) if context['third_form'].is_valid( ) and context['scheduling_form'].is_valid( ) and self.is_formset_valid(context['worker_formset']): working_class = context['third_form'].save(commit=False) working_class.duration = Duration( minutes=context['scheduling_form'].cleaned_data[ 'duration']*60) if not hasattr(working_class, 'teacher'): teacher = None for form in context['worker_formset']: if form.cleaned_data['worker']: teacher = form.cleaned_data['worker'] break if teacher: working_class.teacher = teacher else: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="NEED_LEADER", defaults={ 'summary': "Need Leader for Class", 'description': "You must select at least " + "one person to run this class."}) messages.error( request, user_message[0].description) return render(request, self.template, context) working_class.e_conference = self.conference working_class.b_conference = self.conference working_class.save() response = self.book_event(context['scheduling_form'], context['worker_formset'], working_class) success = self.finish_booking( request, response, context['scheduling_form'].cleaned_data['day'].pk) if success: return success return render(request, self.template, context)
def post(self, request, *args, **kwargs): working_class = None context = self.groundwork(request, args, kwargs) context['second_form'] = PickClassForm( request.POST, initial={'conference': self.conference}) context['third_title'] = "Make New Class" if 'pick_class' in request.POST.keys( ) and context['second_form'].is_valid(): if context['second_form'].cleaned_data['accepted_class']: working_class = context['second_form'].cleaned_data[ 'accepted_class'] context['third_title'] = "Book Class: %s" % ( working_class.e_title) context['third_form'] = ClassBookingForm( instance=working_class) duration = working_class.duration.hours() + float( working_class.duration.minutes()) / 60 context['scheduling_info'] = get_scheduling_info(working_class) else: context['third_form'] = ClassBookingForm() duration = 1 context['scheduling_form'] = ScheduleOccurrenceForm( conference=self.conference, open_to_public=True, initial={ 'duration': duration, }) context['scheduling_form'].fields[ 'max_volunteer'].widget = HiddenInput() context['worker_formset'] = self.make_formset(working_class) elif 'set_class' in request.POST.keys( ) and 'eventitem_id' in request.POST.keys(): if request.POST['eventitem_id']: working_class = get_object_or_404( Class, eventitem_id=request.POST['eventitem_id']) context['third_title'] = "Book Class: %s" % ( working_class.e_title) context['third_form'] = ClassBookingForm( request.POST, instance=working_class) context['scheduling_info'] = get_scheduling_info(working_class) else: context['third_form'] = ClassBookingForm(request.POST) context['second_form'] = PickClassForm( initial={ 'conference': self.conference, 'accepted_class': working_class }) context['scheduling_form'] = ScheduleOccurrenceForm( request.POST, conference=self.conference) context['scheduling_form'].fields[ 'max_volunteer'].widget = HiddenInput() context['worker_formset'] = self.make_formset(working_class, post=request.POST) if context['third_form'].is_valid() and context[ 'scheduling_form'].is_valid() and self.is_formset_valid( context['worker_formset']): working_class = context['third_form'].save(commit=False) working_class.duration = Duration( minutes=context['scheduling_form'].cleaned_data['duration'] * 60) if not hasattr(working_class, 'teacher'): teacher = None for form in context['worker_formset']: if form.cleaned_data['worker']: teacher = form.cleaned_data['worker'] break if teacher: working_class.teacher = teacher else: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="NEED_LEADER", defaults={ 'summary': "Need Leader for Class", 'description': "You must select at least " + "one person to run this class." }) messages.error(request, user_message[0].description) return render(request, self.template, context) working_class.e_conference = self.conference working_class.b_conference = self.conference working_class.save() response = self.book_event(context['scheduling_form'], context['worker_formset'], working_class) success = self.finish_booking( request, response, context['scheduling_form'].cleaned_data['day'].pk) if success: return success return render(request, self.template, context)
def make_context(self): context = {'performer': self.bid.teacher, 'class': self.bid, 'scheduling_info': get_scheduling_info(self.bid), 'display_contact_info': True} return context