コード例 #1
0
def agreement_input_view(request):
    form = AgreementForm(request.POST or None)
    print(request.POST)

    if '_next' in request.POST and form.is_valid():
        post = form.save(commit=False)
        post.agreement_date = request.POST['agreement_date']
        post.effected_date_as_actual = request.POST['effected_date_as_actual']
        post.effected_date_as_per_agreement = request.POST[
            'effected_date_as_per_agreement']
        post.agreement_cat_type = request.POST['agreement_cat_type']
        post.notice_period = request.POST['notice_period']
        post.file_no = request.POST['file_no']
        post.serial_no = request.POST['serial_no']
        post.agreement_advance_amount = request.POST[
            'agreement_advance_amount']
        post.agreement_security_amount = request.POST[
            'agreement_security_amount']
        site1 = form['main_site'].value()
        print(site1)
        print(" test begin")
        print(post.properties.type)
        print("test end")
        post.properties.type = 'not available'
        print(post.properties.type)
        post.properties.save()
        post.agrm_id = create_id_for_agreement(post.main_site, post.file_no,
                                               post.serial_no)
        post.save()
        return redirect(agreement_detail_view, pk=post.id)
    else:
        print(form.errors)

    if '_save' in request.POST and form.is_valid():
        post = form.save(commit=False)
        post = form.save(commit=False)
        post.agreement_date = request.POST['agreement_date']
        post.effected_date_as_actual = request.POST['effected_date_as_actual']
        post.effected_date_as_per_agreement = request.POST[
            'effected_date_as_per_agreement']
        post.agreement_cat_type = request.POST['agreement_cat_type']
        post.notice_period = request.POST['notice_period']
        post.file_no = request.POST['file_no']
        post.serial_no = request.POST['serial_no']
        post.agreement_advance_amount = request.POST[
            'agreement_advance_amount']
        post.agreement_security_amount = request.POST[
            'agreement_security_amount']
        site1 = form['main_site'].value()

        post.agrm_id = create_id_for_agreement(post.main_site, post.file_no,
                                               post.serial_no)
        post.save()
        return redirect(agreement_view)
    else:
        print(form.errors)

    return render(request, 'agreement/agreement.html', {'form': form})