Пример #1
0
def recruit_education_page_post(recruit_instance, request):  # TeamRome
    arr_edu = pars_edu_request(request.POST,
                               request.FILES)  # list of dictionaries

    if any(arr_edu):
        RecruitEducation.objects.filter(recruit_edu=recruit_instance).delete()
        for edus in arr_edu:
            if any(edus.values()):

                education = RecruitEducation(
                    recruit_edu=recruit_instance,
                    institution=edus['institution'],
                    subject_area=edus['subject_area'],
                    specialization=edus['specialization'],
                    qualification=edus['qualification'],
                    date_start=edus['date_start'],
                    date_end=edus['date_end'],
                )
                education.save()

                if edus['certificate']:
                    for c in edus['certificate']:  # array of tuples
                        certificate = RecruitCertificate(
                            education=education,
                            img=c[1],
                            link=c[0],
                        )
                        certificate.save()

                # print("\tEducation Form - OK:\n\t", institution, subject_area, specialization, qualification,
                #       date_start, date_end, cert_arr)
            else:
                print('\tEducation Form is Empty')
    else:
        print('\tEducation Parser is Empty')
Пример #2
0
def education_page_post(client_instance, request):  # TeamRome
    """" views.py ClientEditEducation(TemplateView) POST method.  """
    arr_edu = pars_edu_request(request.POST,
                               request.FILES)  # list of dictionaries

    if any(arr_edu):
        Education.objects.filter(client_edu=client_instance).delete()
        for edus in arr_edu:
            if any(edus.values()):

                institution = edus['institution']
                subject_area = edus['subject_area']
                specialization = edus['specialization']
                qualification = edus['qualification']
                date_start = edus['date_start']
                date_end = edus['date_end']
                cert_arr = edus['certificate']

                education = Education(
                    client_edu=client_instance,
                    institution=institution,
                    subject_area=subject_area,
                    specialization=specialization,
                    qualification=qualification,
                    date_start=date_start,
                    date_end=date_end,
                )
                education.save()

                for c in cert_arr:  # array of tuples
                    certificate = Certificate(
                        education=education,
                        img=c[1],
                        link=c[0],
                    )
                    certificate.save()

                # print("\tEducation Form - OK:\n\t", institution, subject_area, specialization, qualification,
                #       date_start, date_end, cert_arr)
            else:
                print('\tEducation Form is Empty')
    else:
        print('\tEducation Parser is Empty')
Пример #3
0
def education_page_post(client_instance, request):
    """" views.py ClientEditEducation(TemplateView) POST method.  """
    print("education_page_post()")
    time_0 = perf_counter()
    arr_edu = pars_edu_request(request.POST,
                               request.FILES)  # list of dictionaries

    if any(arr_edu):
        Education.objects.all().delete()

        for edus in arr_edu:
            institution = edus['institution']
            subject_area = edus['subject_area']
            specialization = edus['specialization']
            qualification = edus['qualification']
            date_start = edus['date_start']
            date_end = edus['date_end']
            link = edus['certificate_url']
            img = edus['certificate_img']

            if any(edus.values()):
                education = Education(
                    client_edu=client_instance,
                    institution=institution,
                    subject_area=subject_area,
                    specialization=specialization,
                    qualification=qualification,
                    date_start=date_start if date_start else None,
                    date_end=date_end if date_end else None)
                education.save()

                certificate = Certificate(education=education,
                                          img=img,
                                          link=link)
                certificate.save()

                # print("Education Form - OK\n", institution, subject_area, specialization, qualification,
                #       date_start if date_start else None, date_end if date_end else None, img, link)
            else:
                print('Education Form is Empty')
    print('education_page_post() - OK; TIME: %s' % (perf_counter() - time_0))