Exemple #1
0
def plan_send_student_email(template_key, student, course=None):

    if student.no_email_notification:
        logging.info('info emails disabled for this student, ignore request') 
        return

    if not mail.valid_email(student.email):
        logging.info('no valid email <%s>'%student.email)
        return

    if not template_key in mail.MAIL_TEMPLATE_KEYS:
        logging.info('plan_send_student_email - invalid template - "%s"'%template_key)
        raise Http404

    if student is None:
        logging.info('plan_send_student_email - student is None!')
        raise Http404

    taskqueue.add(url='/task/send_student_email/', params={'template_key':template_key,'student_id':student.key().id()})
Exemple #2
0
def import_student2(course,row):
    logging.info('import student2 data=%s'%(row))
    
    try:
        s = row[0].lower()
        if not (s in ['p','s','d','?']):
            logging.info('skip, no p/s/d/? at first col')
            return None
    except:
        logging.info('skip, no p/s/d/? at first col')
        return None
    
    
    st = Student()
    
    st.status = 'e'
    st.course_key=str(course.key())
    st.init_reg()
    st.init_ref_base()
    s = row[0].lower()
    if s in ['p','s','d']:
        st.addressing = s
    
    st.surname = row[2]
    st.name = row[1]

    try:
        st.course_cost = int(row[3])
    except:
        st.course_cost = 0

    try:
        st.paid = int(row[4])
    except:
        st.paid = 0

       
        
    st.discount = row[5]
    
    st.pay_info = row[6]
    
    st.email = row[7]
    st.phone = row[8]


    st.street = row[9]
    st.street_no = row[10]
    st.city = row[11]
    st.post_code = row[12]



    st.school = row[13]
    st.school_class = row[14]


    st.comment = row[15]

    st.no_email_notification = True
    st.no_email_info = not valid_email(st.email)
    st.no_email_ad = st.no_email_info
   
   
    st.student = True
    st.student_check = False

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

 
    return st
Exemple #3
0
def send_student_email(request):
    logging.info(request.POST)
    student_id = request.POST['student_id']
    student = Student.get_by_id(int(student_id))
    if student is None:
        logging.info('student is None')
        raise Http404
    logging.info('student=%s'%(student))

    course = student.get_course()
    partner = student.get_partner()

    logging.info('course=%s'%(course))

    template_key = request.POST['template_key']
    if template_key is None:
        logging.info('template_key is None')
        raise Http404 

    logging.info('template_key=%s'%(template_key))

    if not template_key in mail.MAIL_TEMPLATE_KEYS:
        logging.info('template_key is not valid')
        raise Http404

    logging.info('key ok')

    sender = cfg.getConfigString('ENROLL_EMAIL',None)
    reply_to = cfg.getConfigString('ENROLL_REPLY_TO',None)
    bcc = cfg.getConfigString('ENROLL_BCC',None)


    if sender is None:
        logging.info('no sender, skip')
        return HttpResponse('ok')
        
    if reply_to is None:
        logging.info('no reply to !, skip')
        return HttpResponse('ok')


    if not mail.valid_email(student.email):
        logging.info('no valid student email')
        return HttpResponse('ok')

    recipient = student.email.__str__()

    logging.info('prepare text') 
    (subject,body) = mail.prepare_email_text(template_key, student,course,partner)
    logging.info('prepare text done') 


#    sss=unicode(body,'utf-8')
#    logging.info(type(subject))
#    logging.info(sss)
#    logging.info(body.encode('utf8'))


    logging.info('sender [%s]'%(sender))
    logging.info('reply_to [%s]'%(sender))
    logging.info('recipient [%s]'%(recipient))
    if not (bcc is None):
        logging.info('bcc [%s]'%(bcc))

    if bcc is None:
        logging.info('no bcc !, ignore bcc header')
        gmail.send_mail(sender=sender, reply_to=reply_to, to=recipient, subject=subject,body=body) 
    else:
        gmail.send_mail(sender=sender, reply_to=reply_to, bcc=bcc, to=recipient, subject=subject,body=body) 
    
    logging.info('sent out !')

    return HttpResponse('ok')
Exemple #4
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