Example #1
0
def update_major_single_choice(request):
    applicant = request.applicant

    if request.method == 'POST':

        if 'cancel' not in request.POST:
            form = SingleMajorPreferenceForm(request.POST)
            if form.is_valid():
                assign_major_pref_to_applicant(
                    applicant, [form.cleaned_data['major'].number])
                request.session['notice'] = 'การแก้ไขอันดับสาขาวิชาเรียบร้อย'
                return HttpResponseRedirect(reverse('status-index'))
        else:
            request.session['notice'] = 'อันดับสาขาวิชาไม่ถูกแก้ไข'
            return HttpResponseRedirect(reverse('status-index'))

    else:
        if applicant.has_major_preference():
            pref = applicant.preference.majors
            if len(pref) == 0:
                prev_major = None
            else:
                majors = dict([(int(m.number), m)
                               for m in Major.get_all_majors()])
                prev_major = majors[pref[0]]
        form = SingleMajorPreferenceForm(initial={'major': prev_major.id})

    # add step info
    form_data = {}
    form_data['step_name'] = 'แก้ไขอันดับสาขาวิชา'
    form_data['can_log_out'] = True
    form_data['form'] = form
    return render_to_response('application/update/majors_single.html',
                              form_data)
def applicant_major_single_choice(request):
    applicant = request.applicant

    if (request.method == 'POST') and ('cancel' not in request.POST):

        form = SingleMajorPreferenceForm(request.POST)
        if form.is_valid():
            assign_major_pref_to_applicant(applicant,
                                           [form.cleaned_data['major'].number])
            return HttpResponseRedirect(reverse('apply-doc-menu'))
    else:
        prev_major = None
        if applicant.has_major_preference():
            pref = applicant.preference.majors
            if len(pref)==0:
                prev_major = None
            else:
                majors = dict([(int(m.number), m) for m in Major.get_all_majors()])
                prev_major = majors[pref[0]]
        if prev_major!=None:
            form = SingleMajorPreferenceForm(initial={'major': prev_major.id})
        else:
            form = SingleMajorPreferenceForm()

    # add step info
    form_data = {}
    form_step_info = build_form_step_info(3, applicant)
    form_data['form_step_info'] = form_step_info
    form_data['form'] = form
    return render_to_response('application/majors_single.html',
                              form_data)
Example #3
0
def update_major_single_choice(request):
    applicant = request.applicant

    if request.method == 'POST':

        if 'cancel' not in request.POST:
            form = SingleMajorPreferenceForm(request.POST)
            if form.is_valid():
                assign_major_pref_to_applicant(applicant,
                                               [form.cleaned_data['major'].number])
                request.session['notice'] = 'การแก้ไขอันดับสาขาวิชาเรียบร้อย'
                return HttpResponseRedirect(reverse('status-index'))
        else:
            request.session['notice'] = 'อันดับสาขาวิชาไม่ถูกแก้ไข'
            return HttpResponseRedirect(reverse('status-index'))

    else:
        if applicant.has_major_preference():
            pref = applicant.preference.majors
            if len(pref)==0:
                prev_major = None
            else:
                majors = dict([(int(m.number), m) for m in Major.get_all_majors()])
                prev_major = majors[pref[0]]
        form = SingleMajorPreferenceForm(initial={'major': prev_major.id})

    # add step info
    form_data = {}
    form_data['step_name'] = 'แก้ไขอันดับสาขาวิชา'
    form_data['can_log_out'] = True
    form_data['form'] = form
    return render_to_response('application/update/majors_single.html',
                              form_data)
Example #4
0
def applicant_major_single_choice(request):
    applicant = request.applicant

    if (request.method == 'POST') and ('cancel' not in request.POST):

        form = SingleMajorPreferenceForm(request.POST)
        if form.is_valid():
            assign_major_pref_to_applicant(applicant,
                                           [form.cleaned_data['major'].number])
            return HttpResponseRedirect(reverse('apply-doc-menu'))
    else:
        prev_major = None
        if applicant.has_major_preference():
            pref = applicant.preference.majors
            if len(pref) == 0:
                prev_major = None
            else:
                majors = dict([(int(m.number), m)
                               for m in Major.get_all_majors()])
                prev_major = majors[pref[0]]
        if prev_major != None:
            form = SingleMajorPreferenceForm(initial={'major': prev_major.id})
        else:
            form = SingleMajorPreferenceForm()

    # add step info
    form_data = {}
    form_step_info = build_form_step_info(3, applicant)
    form_data['form_step_info'] = form_step_info
    form_data['form'] = form
    return render_to_response('application/majors_single.html', form_data)