本文整理匯總了Python中enroll.models.Student.get_by_id方法的典型用法代碼示例。如果您正苦於以下問題:Python Student.get_by_id方法的具體用法?Python Student.get_by_id怎麽用?Python Student.get_by_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類enroll.models.Student
的用法示例。
在下文中一共展示了Student.get_by_id方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _obs_send_enroll_no_email
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_id [as 別名]
def _obs_send_enroll_no_email(request):
logging.info(request.POST)
student_id = request.POST['student_id']
student = Student.get_by_id(int(student_id))
if student is None:
raise Http404
course = student.get_course()
(subject,body) = mail.prepare_enroll_no_email_text(student,course)
sender = cfg.getConfigString('ENROLL_EMAIL',None)
if sender is None:
logging.info('no sender, skip')
return HttpResponse('ok')
recipient = student.email.__str__()
logging.info('sending from "%s", to "%s", subject "%s", body "%s"'%(sender,recipient,subject,body))
gmail.send_mail(sender, recipient, subject,body)
logging.info('send ok')
return HttpResponse('ok')
示例2: hide_student
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_id [as 別名]
def hide_student(owner, student_id):
student = Student.get_by_id(int(student_id))
if student is None:
return
student.hidden = True
student.save()
cdbsync.plan_cdb_put(student)
示例3: mark_cardout
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_id [as 別名]
def mark_cardout(owner, student_id):
student = Student.get_by_id(int(student_id))
if student is None:
return
student.card_out=True
student.save()
cdbsync.plan_cdb_put(student)
示例4: prepare_card
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_id [as 別名]
def prepare_card(owner, student_id, season_name, course_code, info_line_1, info_line_2):
student = Student.get_by_id(int(student_id))
if student is None:
return
card = Card()
card.init(owner=owner,name=student.name, surname=student.surname, season_name=season_name, course_code=course_code, info_line_1=info_line_1, info_line_2=info_line_2)
card.save()
logging.info('card=%s'%card)
示例5: send_enroll_form_to_admin
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_id [as 別名]
def send_enroll_form_to_admin(request,test_id=None):
logging.info(request.POST)
if not cfg.getConfigBool('ENROLL_FORM_EMAIL_ON',False):
logging.info('ENROLL_FORM_EMAIL_ON is OFF!')
return HttpResponse('ok - disabled')
if test_id is None:
student_id = request.POST['student_id']
else:
student_id = test_id
student = Student.get_by_id(int(student_id))
if student is None:
raise Http404
logging.info('student=%s'%student)
course = student.get_course()
partner = student.get_partner()
logging.info('course=%s'%(course))
sender = cfg.getConfigString('ENROLL_FORM_EMAIL_SENDER',None)
to = cfg.getConfigString('ENROLL_FORM_EMAIL_TO',None)
if sender is None:
logging.info('no sender')
return HttpResponse('ok - no sender, ignore')
if to is None:
logging.info('no to')
return HttpResponse('ok - no to, ignore')
logging.info('prepare text')
(subject,body) = mail.prepare_email_text('ENROLL_FORM_REPORT', student,course,partner)
logging.info('prepare text done')
# subject = "online prihlaska" #cfg.getConfigString('ENROLL_FORM_EMAIL_SUBJECT',None)
# body = "online prihlaska je v priloze" #cfg.getConfigString('ENROLL_FORM_EMAIL_SUBJECT',None)
filename = "prihlaska.pdf"
out = cStringIO.StringIO()
from utils.pdf import students_enroll
students_enroll(out,[student],with_partner=True)
data=out.getvalue()
gmail.send_mail(sender=sender, to=to,subject=subject,body=body,attachments=[(filename,data)])
logging.info('send ok')
return HttpResponse('ok')
示例6: makecopy_student
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_id [as 別名]
def makecopy_student(student_id, course):
logging.info('makecopy student %d'%student_id)
student = Student.get_by_id(student_id)
if student is None:
return
new = student.clone()
logging.info('clone ok')
new.set_course_key(str(course.key()))
new.save()
cdbsync.plan_cdb_put(new)
return (student.ref_key,new)
示例7: transfer_student
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_id [as 別名]
def transfer_student(student_id, course):
logging.info('transfer student %d'%student_id)
student = Student.get_by_id(student_id)
if student is None:
return
student.set_course_key(str(course.key()))
student.save()
cdbsync.plan_cdb_put(student)
try:
plan_send_student_email('ENROLL_TRANSFER', student)
except:
logging.info('email problem...')
示例8: prepare_invitation
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_id [as 別名]
def prepare_invitation(owner, student_id, mode, addressing_parents, addressing_p, addressing_s, addressing_d):
student = Student.get_by_id(int(student_id))
if student is None:
return
logging.info('student: %s'%student)
addressing=''
iname = None
isurname = None
if mode=='parents':
addressing=addressing_parents
sex=student.get_sex()
if not student.name is None:
iname = inflector.do_inflect('name',sex,student.name)
if not student.surname is None:
isurname = inflector.do_inflect('surname',sex,student.surname)
elif mode=='direct':
if student.addressing =='p':
addressing=addressing_p
elif student.addressing =='s':
addressing=addressing_s
elif student.addressing =='d':
addressing=addressing_d
logging.info('addressing:%s'%addressing)
invitation = Invitation()
invitation.init(owner=owner,mode=mode, addressing=addressing, name=student.name, surname=student.surname, sex=student.get_sex(), street=student.street,
street_no=student.street_no, city=student.city, post_code=student.post_code
)
if not iname is None:
invitation.name_inflected = iname
if not isurname is None:
invitation.surname_inflected = isurname
logging.info('pre save invitation=%s'%invitation)
invitation.save()
logging.info('invitation=%s'%invitation)
示例9: prepare_qcard
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_id [as 別名]
def prepare_qcard(owner, student_id):
student = Student.get_by_id(int(student_id))
if student is None:
return
course = student.get_course()
season = course.get_season()
logging.info("creating QR card for student %s" % (student))
logging.info("creating QR card for course %s" % (course))
logging.info("creating QR card for season %s" % (season))
qcard = QCard()
season_name = season.public_name
course_code = course.code
info_line_1=course.card_line_1
info_line_2=course.card_line_2
qrcode = calc_qrcode_for_student(student,course,season)
qcard.init(owner=owner,ref_gid=student.ref_gid, name=student.name, surname=student.surname, season_name=season_name, course_code=course_code, info_line_1=info_line_1, info_line_2=info_line_2, qrcode=qrcode)
qcard.save()
logging.info('qcard=%s'%qcard)
示例10: send_student_email
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_id [as 別名]
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')