def assign_major_pref_to_applicant(applicant, pref_list): if applicant.has_major_preference(): preference = applicant.preference else: preference = MajorPreference() preference.majors = [int(m.number) for m in pref_list] preference.applicant = applicant preference.save() applicant.add_related_model('major_preference', save=True, smart=True)
def assign_major_pref_to_applicant(applicant, major_ranks): if applicant.has_major_preference(): preference = applicant.preference else: preference = MajorPreference() preference.majors = major_ranks preference.applicant = applicant preference.save() applicant.add_related_model('major_preference', save=True, smart=True)
def applicant_major_as_major_lists(request): """ WARNINGS: Unused in the current version. This is for the case when the number of choices is small. """ if settings.MAX_MAJOR_RANK == 1: return applicant_major_single_choice(request) applicant = request.applicant if (request.method == 'POST') and ('cancel' not in request.POST): result, major_list, errors = handle_major_form(request) if result: return HttpResponseRedirect(reverse('apply-confirm')) pref_ranks = MajorPreference.major_list_to_major_rank_list(major_list) form_data = prepare_major_form(applicant, pref_ranks, errors) else: if applicant.has_major_preference(): pref_ranks = applicant.preference.to_major_rank_list() else: pref_ranks = None form_data = prepare_major_form(applicant, pref_ranks) # add step info form_step_info = build_form_step_info(3, applicant) form_data['form_step_info'] = form_step_info return render_to_response('application/major_select_by_majors.html', form_data)
def applicant_major(request): if settings.MAX_MAJOR_RANK == 1: return applicant_major_single_choice(request) applicant = request.applicant if (request.method == 'POST') and ('cancel' not in request.POST): result, major_list, errors = handle_major_form(request) if result: return HttpResponseRedirect(reverse('apply-confirm')) pref_ranks = MajorPreference.major_list_to_major_rank_list(major_list) form_data = prepare_major_form(applicant, pref_ranks, errors) else: if applicant.has_major_preference(): pref_ranks = applicant.preference.to_major_rank_list() else: pref_ranks = None form_data = prepare_major_form(applicant, pref_ranks) # add step info form_step_info = build_form_step_info(3, applicant) form_data['form_step_info'] = form_step_info return render_to_response('application/majors.html', form_data)
def major_form(request, applicant_id): applicant = get_object_or_404(Applicant,pk=applicant_id) if applicant.is_submitted: return HttpResponseForbidden() if (request.method == 'POST') and ('cancel' not in request.POST): result, major_list, errors = handle_major_form(request, applicant=applicant) if result: return HttpResponseRedirect(reverse('manual-confirm', args=[applicant.id])) pref_ranks = MajorPreference.major_list_to_major_rank_list(major_list) form_data = prepare_major_form(applicant, pref_ranks, errors) else: if applicant.has_major_preference(): pref_ranks = applicant.preference.to_major_rank_list() else: pref_ranks = None form_data = prepare_major_form(applicant, pref_ranks) # add step info form_data['applicant'] = applicant form_data['show_navigation'] = True form_data['hide_description'] = True return render_to_response('manual/majors.html', form_data)
def update_majors_as_major_lists(request): """ WARNINGS: Unused in the current version. This is for the case when the number of choices is small. """ if settings.MAX_MAJOR_RANK == 1: return update_major_single_choice(request) applicant = request.applicant if request.method == 'POST': if 'cancel' not in request.POST: result, major_list, errors = handle_major_form(request) if result: request.session['notice'] = 'การแก้ไขอันดับสาขาวิชาเรียบร้อย' return HttpResponseRedirect(reverse('status-index')) else: request.session['notice'] = 'อันดับสาขาวิชาไม่ถูกแก้ไข' return HttpResponseRedirect(reverse('status-index')) pref_ranks = MajorPreference.major_list_to_major_rank_list(major_list) form_data = prepare_major_form(applicant, pref_ranks, errors) else: if applicant.has_major_preference(): pref_ranks = applicant.preference.to_major_rank_list() else: pref_ranks = [None] * len(majors) form_data = prepare_major_form(applicant, pref_ranks) # add step info form_data['step_name'] = 'แก้ไขอันดับสาขาวิชา' form_data['can_log_out'] = True return render_to_response('application/update/majors.html', form_data)