本文整理汇总了Python中models.models.Student.add_new_student_for_current_user方法的典型用法代码示例。如果您正苦于以下问题:Python Student.add_new_student_for_current_user方法的具体用法?Python Student.add_new_student_for_current_user怎么用?Python Student.add_new_student_for_current_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.models.Student
的用法示例。
在下文中一共展示了Student.add_new_student_for_current_user方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import add_new_student_for_current_user [as 别名]
def post(self):
"""Handles POST requests."""
user = self.personalize_page_and_get_user()
if not user:
self.redirect(
users.create_login_url(self.request.uri), normalize=False)
return
if not self.assert_xsrf_token_or_fail(self.request, 'register-post'):
return
can_register = self.app_context.get_environ(
)['reg_form']['can_register']
if not can_register:
self.redirect('/course#registration_closed')
return
if 'name_from_profile' in self.request.POST.keys():
profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
name = profile.nick_name
else:
name = self.request.get('form01')
Student.add_new_student_for_current_user(
name, transforms.dumps(self.request.POST.items()))
# Render registration confirmation page
self.redirect('/course#registration_confirmation')
示例2: post
# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import add_new_student_for_current_user [as 别名]
def post(self):
"""Handles POST requests."""
user = self.personalize_page_and_get_user()
if not user:
self.redirect(users.create_login_url(self.request.uri), normalize=False)
return
if not self.assert_xsrf_token_or_fail(self.request, "register-post"):
return
can_register = self.app_context.get_environ()["reg_form"]["can_register"]
if not can_register:
self.redirect("/course#registration_closed")
return
if "name_from_profile" in self.request.POST.keys():
profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
name = profile.nick_name
else:
name = self.request.get("form01")
Student.add_new_student_for_current_user(name, transforms.dumps(self.request.POST.items()))
course = sites.get_course_for_current_request()
if course.get_slug().split("_")[-1] == "DFR":
self.redirect("/gDefier/register")
else:
self.redirect("/course#registration_confirmation")
示例3: post
# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import add_new_student_for_current_user [as 别名]
def post(self):
"""Handles POST requests."""
user = self.personalize_page_and_get_user()
if not user:
self.redirect(
users.create_login_url(self.request.uri), normalize=False)
return
if not self.assert_xsrf_token_or_fail(self.request, 'register-post'):
return
can_register = self.app_context.get_environ(
)['reg_form']['can_register']
if not can_register:
self.redirect('/course#registration_closed')
return
if 'name_from_profile' in self.request.POST.keys():
profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
name = profile.nick_name
else:
name = self.request.get('form01')
Student.add_new_student_for_current_user(
name, transforms.dumps(self.request.POST.items()))
# CGL-MOOC-Builder: Get user's Google App email and
# course title, email body from course setting page.
course = self.app_context.get_environ()['course']
if 'google_app_email' in course:
sender_email = course['google_app_email']
else:
sender_email = ''
if 'title' in course:
course_title = course['title']
else:
course_title = ''
if 'email_body' in course and course['email_body'] != '':
email_body = course['email_body']
else:
email_body = "<div style='background-color: #999999; color: #ffffff; padding: 0px 20px 20px 20px; font-family: 'Verdana', sans-serif;'> <div style='width: 500px; margin: 0 auto;'> <p style='background-color: #093359; height: 100px; margin: 0px; padding: 0px;'> <img src='http://cloudmooc.pti.indiana.edu:8080/assets/img/Logo.png'></img> </p> <div style='background-color: #CCC; color: black; padding: 15px;'> <p>Welcome " + name + ",</p> <p>Thank you for enrolling in this.</p> </div> <p style='background-color: #012256; height: 50px; margin: 0px; padding: 0px;'></p></div></div>"
# CGL-MOOC-Builder starts:
# Send an notification email after registration
sender_address = course_title + " <"+sender_email+">"
user_address = name + " <" + user.email() + ">"
subject = "Welcome "+name+" to "+course_title
body = "Welcome!"
html = email_body
mail.send_mail(sender_address, user_address, subject, body, html=html)
# CGL-MOOC-Builder ends
# Render registration confirmation page
self.redirect('/course#registration_confirmation')
示例4: post
# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import add_new_student_for_current_user [as 别名]
def post(self):
"""Handles POST requests."""
user = self.personalize_page_and_get_user()
if not user:
self.redirect(
users.create_login_url(self.request.uri), normalize=False)
return
if not self.assert_xsrf_token_or_fail(self.request, 'register-post'):
return
can_register = self.app_context.get_environ(
)['reg_form']['can_register']
if not can_register:
self.redirect('/course#registration_closed')
return
if 'name_from_profile' in self.request.POST.keys():
profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
name = profile.nick_name
else:
name = self.request.get('form01')
age = self.request.get('age') #Age
city = self.request.get('city') #City
state = self.request.get('state') #State
country = self.request.get('country') #Country
education = self.request.get('education') #Education
profession = self.request.get('profession') #Profession
organization = self.request.get('organization') #Organization
motivation = self.request.get('motivation') #Motivation
privacy = self.request.get('privacy') #Privacy
reference = self.request.get('reference') #Reference
Student.add_new_student_for_current_user(
name, age, city, state, country, education, profession, organization, motivation, privacy, reference, transforms.dumps(self.request.POST.items()))
# send a notification email
sender_address = "X-Informatics <[email protected]>"
user_address = name + " <" + user.email() + ">"
subject = "Welcome to the Big Data Applications and Analytics MOOC"
body = "Dear " + name + ", Example HTML content"
html = "<div style='background-color: #999999; color: #ffffff; padding: 0px 20px 20px 20px; font-family: 'Verdana', sans-serif;'> <div style='width: 500px; margin: 0 auto;'> <p style='background-color: #093359; height: 100px; margin: 0px; padding: 0px;'> <img src='http://cloudmooc.pti.indiana.edu:8080/assets/img/Logo.png'></img> </p> <div style='background-color: #CCC; color: black; padding: 15px;'> <p>Welcome " + name + ",</p> <p>Thank you for enrolling in <a href='https://bigdatacourse.appspot.com' title='Big Data Applications and Analytics MOOC' target='_blank' style='color: #003366; '>Big Data Applications and Analytics MOOC</a>. This MOOC will take you on a journey to learn great things about Big Data and its case studies.</p> <p>This course is open for everyone, so watch a unit or two whenever you get time. You can also review homework assignments of your peers and view your feedback!</p><p>You can download the entire <a href='http://tinyurl.com/bigdatasyllabus' title='Big Data MOOC Course Syllabus' target='_blank'>syllabus</a>, <a href='https://www.dropbox.com/s/2p2zj9jbywcb76u/Course_Slides.pdf' title='Big Data MOOC Course Slides' target='_blank'>slides</a>, and the entire <a href='https://www.dropbox.com/s/htvr0l9d6g2gl71/Big_Data_Course_Material.zip' title='Big Data MOOC Course Material Zip File' target='_blank'>course material</a> directly.</p><p>Get Ready!<br> Geoffrey Fox and the Big Data MOOC Team</p> <p>Go to the <a href='https://bigdatacourse.appspot.com' title='Big Data Applications and Analytics MOOC' target='_blank' style='color: #093359;'>Course</a></p> <p>Share this MOOC with your friends!</p> </div> <p style='background-color: #012256; height: 50px; margin: 0px; padding: 0px;'></p></div></div>"
mail.send_mail(sender_address, user_address, subject, body, html=html)
# Render registration confirmation page
self.redirect('/course#registration_confirmation')