def find_times_post(request): find_times_form = FindTimesForm(request.POST) if find_times_form.is_valid(): required_interviewers, optional_interviewers = get_interviewers( *find_times_form.requisition_and_custom_interviewers ) calendar_response = calendar_client.get_calendars( required_interviewers | optional_interviewers, find_times_form.time_period, ) return render( request, 'find_times.html', dict( find_times_form=find_times_form, calendar_response=calendar_response, START_DATE=find_times_form.time_period.start_time.isoformat(), START_HOUR=START_HOUR, HOURS_PER_DAY=HOURS_PER_DAY, CHUNKS_PER_HOUR=CHUNKS_PER_HOUR, ) ) return render( request, 'find_times.html', dict( find_times_form=find_times_form, ) )
def scheduler_post(request): requisition_formset = RequisitionScheduleFormset(request.POST) scheduler_form = SuggestScheduleForm(request.POST) valid_submission = scheduler_form.is_valid() and requisition_formset.is_valid() schedules = [] if not valid_submission: return render( request, 'scheduler.html', dict( requisition_formset=requisition_formset, scheduler_form=scheduler_form, valid_submission=valid_submission, schedules=schedules, ) ) interviewer_groups = get_interviewer_groups( requisition_formset, also_include=scheduler_form.cleaned_data['also_include'], dont_include=scheduler_form.cleaned_data['dont_include'], ) calendar_responses = [ calendar_client.get_calendars( interviewer_group.interviewers, scheduler_form.time_period) for interviewer_group in interviewer_groups if interviewer_group.num_required ] interviewer_groups_with_calendars = [ schedule_calculator.InterviewerGroup( interviewers=calendar_response.interview_calendars, num_required=interviewer_group.num_required, ) for calendar_response, interviewer_group in zip(calendar_responses, interviewer_groups) ] schedules = schedule_calculator.calculate_schedules( interviewer_groups_with_calendars, time_period=scheduler_form.time_period, possible_break=scheduler_form.possible_break, ) return render( request, 'scheduler.html', dict( requisition_formset=requisition_formset, scheduler_form=scheduler_form, valid_submission=valid_submission, schedules=schedules, ) )
def get_preferences(interviewers, time_period): preferences = calendar_client.get_calendars( [ models.InterviewerStruct( external_id=interviewer.interviewer.preferences_address, address=interviewer.interviewer.address ) for interviewer in interviewers ], time_period, ) return preferences
def new_scheduler_post(request): form_data = request.POST candidate_name = form_data['candidate_name'] interview_template_id = int(form_data['interview_template']) # error checking for request.POST form_is_valid, error_fields = error_check_scheduler_form_post(form_data) if not form_is_valid: return HttpResponse(simplejson.dumps({'form_is_valid': form_is_valid, 'error_fields': error_fields})) interview_template = models.InterviewTemplate.objects.get(id=interview_template_id) interviewer_groups = get_interview_groups_with_requirements( interview_template.interviewtemplaterequisition_set.values() ) time_period = get_time_period( form_data['start_time'], form_data['end_time'], form_data['date'], ) calendar_responses = [ calendar_client.get_calendars( interviewer_group.interviewers, time_period) for interviewer_group in interviewer_groups if interviewer_group.num_required ] interviewer_groups_with_calendars = [ schedule_calculator.InterviewerGroup( interviewers=calendar_response.interview_calendars, num_required=interviewer_group.num_required, ) for calendar_response, interviewer_group in zip(calendar_responses, interviewer_groups) ] possible_break = determine_break_from_interview_time( time_period, interview_template.type, ) schedules = schedule_calculator.calculate_schedules( interviewer_groups_with_calendars, time_period=time_period, interview_type=interview_template.type, possible_break=possible_break, ) if not schedules: return HttpResponse(simplejson.dumps({'form_is_valid': False, 'error_fields': ['no result found']})) scheduler_post_result = { 'form_is_valid': form_is_valid, 'data': _dump_schedules_into_json(schedules), 'interview_type': interview_template.type, 'candidate_name': candidate_name, 'interview_template_name': interview_template.template_name, } return HttpResponse( simplejson.dumps(scheduler_post_result), mimetype='application/json', )
def get_all_rooms(time_period): room_id = getattr(secret, 'room_id', None) if room_id is None: return None all_rooms = models.Requisition.objects.get(id=room_id).interviewers.all() return calendar_client.get_calendars(all_rooms, time_period).interview_calendars
def get_all_rooms(time_period): all_rooms = models.Room.objects.all() return calendar_client.get_calendars(all_rooms, time_period).interview_calendars