Esempio n. 1
0
def import_student(course,row):
    logging.info('import student data=%s'%(row))

    st = Student()
    st.status = 'e'
    st.course_key=str(course.key())
    st.init_reg()
    st.init_ref_base()
    s = row[2].lower()
    if s in ['p','s','d']:
        st.addressing = s
    
#    st.addressing = form.cleaned_data['addressing']
    st.name = row[4]
    st.surname = row[3]


    try:
        st.x_import_no_1 = int(row[0])
    except:
        pass
    try:
        st.x_import_no_2 = int(row[1])
    except:
        pass

# 5 6 7 - prachy

    try:
        paid = int(row[5])
    except:
        paid = 0
    try:
        to_pay = int(row[6])
    except:
        to_pay = 0
        
    st.course_cost = paid+to_pay
    st.paid = paid
        
    st.discount = row[7]
    logging.info('sleva: %s'%st.discount)    

# 8,9 skola  trida
    st.school = row[8]
    st.school_class = row[9]

    st.student = AnoNe2Bool(row[17])
    st.student_check = AnoNe2Bool(row[18])
    
#    st.long_period = form.cleaned_data['long_period']
#    st.year = form.cleaned_data['year']
    st.email = row[15]
    spam = AnoNe2Bool(row[16])
    if spam is True:
        st.no_email_ad = False
    else:
        st.no_email_ad = True

    st.no_email_notification = True
    st.no_email_info = not valid_email(st.email)
    if st.no_email_info:
        st.no_email_ad = True
    st.phone = row[14]
    st.street = row[10]
    st.street_no = row[11]
    st.city = row[12]
    st.post_code = row[13]

    st.comment = row[19]

    st.save()
    st.init_ref_codes()
    st.save()

    return st