Пример #1
0
def get_nickname_for(user_data):

    if not user_data:
        return None

    user_id = user_data.user_id
    email = user_data.email

    if not user_id or not email:
        return None
        
    if facebook_util.is_facebook_user_id(user_id):
        nickname = facebook_util.get_facebook_nickname(user_id)
    elif is_phantom_id(user_id):
        nickname =  "" # No nickname, results in "Login" in header
    else:
        nickname = email.split('@')[0]
    return to_unicode(nickname)
Пример #2
0
def get_nickname_for(user_data):

    if not user_data:
        return None

    user_id = user_data.user_id
    email = user_data.email

    if not user_id or not email:
        return None

    if facebook_util.is_facebook_user_id(user_id):
        nickname = facebook_util.get_facebook_nickname(user_id)
    elif is_phantom_id(user_id):
        nickname = ""  # No nickname, results in "Login" in header
    else:
        nickname = email.split('@')[0]
    return to_unicode(nickname)
Пример #3
0
    def authenticated_response(self):
        user_data = UserData.current()
        user_email = user_data.user_email
        nickname = ""
        if facebook_util.is_facebook_user_id(user_email):
            nickname = facebook_util.get_facebook_nickname(user_email)

        query = SummerStudent.all()
        query.filter('email = ', user_email)
        student = query.get()

        students = []
        is_parent = False

        if student is None:
            query = SummerParentData.all()
            query.filter('email = ', user_email)
            parent = query.get()
            if parent is None:
                return None

            is_parent = True
            number_of_students = 0
            for student_key in parent.students:
                student = SummerStudent.get(student_key)
                students.append(student)
                if student.accepted and not student.tuition_paid:
                    number_of_students += 1

        else:
            number_of_students = 1
            students.append(student)

        template_values = {
            "authenticated": True,
            "is_parent": is_parent,
            "students": students,
            "number_of_students": json.dumps(number_of_students),
            "student": students[0],
            "user_email": user_email,
            "nickname": nickname,
        }

        return template_values
Пример #4
0
    def authenticated_response(self):
        user_data = UserData.current()
        user_email = user_data.user_email
        nickname = ""
        if facebook_util.is_facebook_user_id(user_email):
            nickname = facebook_util.get_facebook_nickname(user_email)

        query = SummerStudent.all()
        query.filter("email = ", user_email)
        student = query.get()

        students = []
        is_parent = False

        if student is None:
            query = SummerParentData.all()
            query.filter("email = ", user_email)
            parent = query.get()
            if parent is None:
                return None

            is_parent = True
            number_of_students = 0
            for student_key in parent.students:
                student = SummerStudent.get(student_key)
                students.append(student)
                if student.accepted and not student.tuition_paid:
                    number_of_students += 1

        else:
            number_of_students = 1
            students.append(student)

        template_values = {
            "authenticated": True,
            "is_parent": is_parent,
            "students": students,
            "number_of_students": json.dumps(number_of_students),
            "student": students[0],
            "user_email": user_email,
            "nickname": nickname,
        }

        return template_values
Пример #5
0
def get_default_nickname_for(user_data):
    """ Gets the default nickname for a user if none is available locally.

    This will infer a nickname either from Facebook or a Google e-mail address.
    """

    if not user_data:
        return None

    user_id = user_data.user_id
    email = user_data.email

    if not user_id or not email:
        return None

    if facebook_util.is_facebook_user_id(user_id):
        nickname = facebook_util.get_facebook_nickname(user_id)
    elif is_phantom_id(user_id):
        nickname = ""  # No nickname, results in "Login" in header
    else:
        nickname = email.split("@")[0]
    return to_unicode(nickname)
Пример #6
0
def get_default_nickname_for(user_data):
    """ Gets the default nickname for a user if none is available locally.

    This will infer a nickname either from Facebook or a Google e-mail address.
    """

    if not user_data:
        return None

    user_id = user_data.user_id
    email = user_data.email

    if not user_id or not email:
        return None

    if facebook_util.is_facebook_user_id(user_id):
        nickname = facebook_util.get_facebook_nickname(user_id)
    elif is_phantom_id(user_id):
        nickname = ""  # No nickname, results in "Login" in header
    else:
        nickname = email.split('@')[0]
    return to_unicode(nickname)
Пример #7
0
def get_default_nickname_for(user_data):
    """ Gets the default nickname for a user if none is available locally.

    This will infer a nickname either from Facebook or a Google e-mail address.
    """

    if not user_data:
        return None

    user_id = user_data.user_id
    email = user_data.email

    if not user_id or not email:
        return None

    if facebook_util.is_facebook_user_id(user_id):
        nickname = facebook_util.get_facebook_nickname(user_id)
    elif is_phantom_id(user_id):
        # Users will be prompted to login and save progress all over the place
        nickname = "Unsaved user"
    else:
        nickname = email.split('@')[0]
    return to_unicode(nickname)
Пример #8
0
def get_default_nickname_for(user_data):
    """ Gets the default nickname for a user if none is available locally.

    This will infer a nickname either from Facebook or a Google e-mail address.
    """

    if not user_data:
        return None

    user_id = user_data.user_id
    email = user_data.email

    if not user_id or not email:
        return None

    if facebook_util.is_facebook_user_id(user_id):
        nickname = facebook_util.get_facebook_nickname(user_id)
    elif is_phantom_id(user_id):
        # Users will be prompted to login and save progress all over the place
        nickname = "Niet ingelogd!"
    else:
        nickname = email.split('@')[0]
    return to_unicode(nickname)
Пример #9
0
    def authenticated_response(self):
        user_data = UserData.current()
        user_email = user_data.user_email
        nickname = ""
        if facebook_util.is_facebook_user_id(user_email):
            nickname = facebook_util.get_facebook_nickname(user_email)

        query = SummerStudent.all()
        query.filter("email = ", user_email)
        student = query.get()

        students = []
        is_parent = False

        if student is None:
            query = SummerParentData.all()
            query.filter("email = ", user_email)
            parent = query.get()
            if parent is None:
                return None

            is_parent = True
            for student_key in parent.students:
                students.append(SummerStudent.get(student_key))

        else:
            students.append(student)

        template_values = {
            "authenticated": True,
            "is_parent": is_parent,
            "students": students,
            "user_email": user_email,
            "nickname": nickname,
        }

        return template_values
Пример #10
0
    def authenticated_response(self):
        user_data = UserData.current()
        user_email = user_data.user_email
        nickname = ""
        if facebook_util.is_facebook_user_id(user_email):
            nickname = facebook_util.get_facebook_nickname(user_email)

        query = SummerStudent.all()
        query.filter('email = ', user_email)
        student = query.get()

        students = []
        is_parent = False

        if student is None:
            query = SummerParentData.all()
            query.filter('email = ', user_email)
            parent = query.get()
            if parent is None:
                return None

            is_parent = True
            for student_key in parent.students:
                students.append(SummerStudent.get(student_key))

        else:
            students.append(student)

        template_values = {
            "authenticated": True,
            "is_parent": is_parent,
            "students": students,
            "user_email": user_email,
            "nickname": nickname,
        }

        return template_values
Пример #11
0
    def get(self):
        template_values = {}
        user_data = UserData.current()

        if user_data is not None:
            user_email = user_data.user_email
            nickname = ""
            if facebook_util.is_facebook_user_id(user_email):
                nickname = facebook_util.get_facebook_nickname(user_email)

            application_filled = self.request.get("application_filled")
            make_payment = self.request.get("make_payment")

            if make_payment:
                student_email = self.request.get("student_email")
                is_parent_str = self.request.get("is_parent")

                query = SummerStudent.all()
                query.filter("email = ", student_email)
                student = query.get()

                if student is None:
                    output_str = 'Please <a href="/summer/application">apply</a> first' % student_email
                    self.response.out.write(output_str)
                    return

                if student.processing_fee_paid:
                    self.redirect("/summer/application-status")
                    return

                query = SummerParentData.all()
                query.filter("email = ", student.parent_email)
                parent = query.get()

                if parent is None:
                    logging.error(
                        "Unexpected NULL parent for student <%s> with parent <%s>"
                        % (student_email, student.parent_email)
                    )

                if is_parent_str == "True":
                    is_parent = True
                else:
                    is_parent = False

                payee_phone_a = ""
                payee_phone_b = ""
                payee_phone_c = ""
                phone_parts = parent.phone.split("-")
                if phone_parts is not None:
                    payee_phone_a = phone_parts[0]
                    payee_phone_b = phone_parts[1]
                    payee_phone_c = phone_parts[2]

                template_values = {
                    "authenticated": True,
                    "make_payment": True,
                    "is_parent": is_parent,
                    "is_parent_js": json.dumps(is_parent),
                    "student": student,
                    "student_js": json.dumps(student.to_dict()),
                    "payee": parent,
                    "payee_phone_a": payee_phone_a,
                    "payee_phone_b": payee_phone_b,
                    "payee_phone_c": payee_phone_c,
                    "user_email": user_email,
                    "nickname": nickname,
                }

            elif not application_filled:
                template_values = self.authenticated_response()

            else:
                first_name = self.request.get("first_name")
                student_email = self.request.get("student_email")

                query = SummerStudent.all()
                query.filter("email = ", student_email)
                student = query.get()
                if student is None:
                    student = SummerStudent()
                    student.email = student_email
                    student.applier_email = user_email
                    student.processing_fee_paid = False
                    student.tuition_paid = False

                student.first_name = first_name
                student.last_name = self.request.get("last_name")

                student.date_of_birth = self.request.get("date_of_birth")

                if self.request.get("gender") == "Female":
                    student.is_female = True
                else:
                    student.is_female = False

                student.grade = self.request.get("grade")
                student.school = self.request.get("school")
                student.school_zipcode = self.request.get("school_zip")

                student.session_1 = self.request.get("session_1")
                student.session_2 = self.request.get("session_2")
                student.session_3 = self.request.get("session_3")

                session_choices = {"0": [], "1": [], "2": [], "3": []}
                session_choices[student.session_1].append("Session 1")
                session_choices[student.session_2].append("Session 2")
                session_choices[student.session_3].append("Session 3")

                student.no_choice = session_choices["0"]
                student.first_choice = session_choices["1"]
                student.second_choice = session_choices["2"]
                student.third_choice = session_choices["3"]

                student.answer_why = self.request.get("answer_why")
                student.answer_how = self.request.get("answer_how")

                student.processing_fee = self.request.get("fee")

                student.tuition = "TBD"

                student.application_year = "2012"
                student.application_status = "Processing"

                if user_email == student_email:
                    is_parent = False
                    student.self_applied = True
                else:
                    is_parent = True
                    student.self_applied = False

                student.parent_relation = self.request.get("relation")
                student.parent_email = self.request.get("parent_email")

                student.put()

                query = SummerParentData.all()
                query.filter("email = ", student.parent_email)
                parent = query.get()
                if parent is None:
                    parent = SummerParentData()
                    parent.email = student.parent_email

                parent.first_name = self.request.get("parent_first_name")
                parent.last_name = self.request.get("parent_last_name")
                parent.address_1 = self.request.get("parent_address_1")
                parent.address_2 = self.request.get("parent_address_2")
                parent.city = self.request.get("parent_city")
                parent.state = self.request.get("parent_state")
                parent.zipcode = self.request.get("parent_zip")
                parent.country = self.request.get("parent_country")
                parent.phone = self.request.get("parent_phone")
                parent.comments = self.request.get("parent_comments")

                if student.key() not in parent.students:
                    parent.students.append(student.key())

                parent.put()

                if student.processing_fee_paid:
                    self.redirect("/summer/application-status")
                    return

                payee_phone_a = ""
                payee_phone_b = ""
                payee_phone_c = ""
                phone_parts = parent.phone.split("-")
                if phone_parts is not None:
                    payee_phone_a = phone_parts[0]
                    payee_phone_b = phone_parts[1]
                    payee_phone_c = phone_parts[2]

                # Only send email if the user's email is a valid one
                if not facebook_util.is_facebook_user_id(parent.email):
                    mail.send_mail(
                        sender=FROM_EMAIL,
                        to=parent.email,
                        subject="Khan Academy Discovery Lab Application",
                        body="""Dear %s,
                
We have received your application for %s %s for the Khan Academy Discovery Lab 2012. Please ensure you have paid the $5.00 processing fee for the application.

We will notify you about the status of the application as soon as possible, no later than March 1st, 2012. You can always check the status of the application any time at http://www.khanacademy.org/summer/application-status.

Thank you!
Khan Academy Discovery Lab"""
                        % (parent.first_name, student.first_name, student.last_name),
                    )

                template_values = {
                    "authenticated": True,
                    "make_payment": True,
                    "is_parent": is_parent,
                    "is_parent_js": json.dumps(is_parent),
                    "student": student,
                    "student_js": json.dumps(student.to_dict()),
                    "parent": parent,
                    "parent_js": json.dumps(parent.to_dict()),
                    "payee": parent,
                    "payee_phone_a": payee_phone_a,
                    "payee_phone_b": payee_phone_b,
                    "payee_phone_c": payee_phone_c,
                    "user_email": user_email,
                    "nickname": nickname,
                }

        else:
            template_values = {"authenticated": False, "applied": False}

        self.add_global_template_values(template_values)
        self.render_jinja2_template("summer/summer.html", template_values)
Пример #12
0
    def authenticated_response(self):
        user_data = UserData.current()
        user_email = user_data.user_email
        nickname = ""
        if facebook_util.is_facebook_user_id(user_email):
            nickname = facebook_util.get_facebook_nickname(user_email)

        students = []
        is_parent = False
        query = SummerStudent.all()
        query.filter("email = ", user_email)
        student = query.get()

        if student is not None:
            students.append(student)
        else:
            query = SummerParentData.all()
            query.filter("email = ", user_email)
            parent = query.get()
            if parent is not None:
                is_parent = True
                for student_key in parent.students:
                    students.append(SummerStudent.get(student_key))

        if len(students) > 0:
            applied = True
            student_email = self.request.get("student_email")
            query = SummerStudent.all()
            query.filter("email = ", student_email)
            student = query.get()
            if student is None:
                logging.error("Student <%s> not expected to be NULL in datastore, but it is" % student_email)
                student = students[0]

            query = SummerParentData.all()
            query.filter("email = ", student.parent_email)
            parent = query.get()
            assert parent != None

            student_js = json.dumps(student.to_dict())
            parent_js = json.dumps(parent.to_dict())
        else:
            applied = False
            student = None
            parent = None
            student_js = json.dumps(student)
            parent_js = json.dumps(parent)

        template_values = {
            "authenticated": True,
            "applied": applied,
            "is_parent": is_parent,
            "is_parent_js": json.dumps(is_parent),
            "students": students,
            "student": student,
            "student_js": student_js,
            "parent": parent,
            "parent_js": parent_js,
            "user_email_js": json.dumps(user_email),
            "user_email": user_email,
            "nickname": nickname,
        }

        return template_values
Пример #13
0
    def get(self):
        template_values = {}
        user_data = UserData.current()

        if user_data is not None:
            user_email = user_data.user_email
            template_values = self.authenticated_response()
            if template_values is None:
                nickname = user_email
                if facebook_util.is_facebook_user_id(user_email):
                    nickname = facebook_util.get_facebook_nickname(user_email)

                response = (
                    "User "
                    + nickname
                    + " not registered for Discovery Lab. Please login to Khan Academy as another user"
                )
                self.response.out.write(response)
                return

            make_payment = self.request.get("make_payment")
            if make_payment:
                total_payment = self.request.get("total_payment")
                for student in template_values["students"]:
                    email_in_request = self.request.get(student.email)
                    if email_in_request != student.email:
                        logging.error("Email <%s> expected in requst but not found" % student.email)

                    student.tuition = str(int(total_payment) / int(template_values["number_of_students"]))
                    student.extended_care = False
                    if self.request.get("extended_care"):
                        student.extended_care = True

                    student.put()

                if template_values["is_parent"]:
                    parent = SummerParentData.all().filter("email =", user_email).get()
                else:
                    parent = SummerParentData.all().filter("email =", template_values["student"].parent_email).get()

                payee_phone_a = ""
                payee_phone_b = ""
                payee_phone_c = ""
                phone_parts = parent.phone.split("-")
                if phone_parts is not None:
                    payee_phone_a = phone_parts[0]
                    payee_phone_b = phone_parts[1]
                    payee_phone_c = phone_parts[2]

                template_values["total_payment"] = total_payment
                template_values["authenticated"] = True
                template_values["make_payment"] = True
                template_values["parent"] = parent
                template_values["payee"] = parent
                template_values["payee_phone_a"] = payee_phone_a
                template_values["payee_phone_b"] = payee_phone_b
                template_values["payee_phone_c"] = payee_phone_c

        else:
            template_values = {"authenticated": False}

        self.add_global_template_values(template_values)
        self.render_jinja2_template("summer/summer_tuition.html", template_values)
Пример #14
0
    def get(self):
        template_values = {}
        user_data = UserData.current()

        if user_data is not None:
            user_email = user_data.user_email
            template_values = self.authenticated_response()
            if template_values is None:
                nickname = user_email
                if facebook_util.is_facebook_user_id(user_email):
                    nickname = facebook_util.get_facebook_nickname(user_email)

                response = "User " + nickname + " not registered for Discovery Lab. Please login to Khan Academy as another user"
                self.response.out.write(response)
                return

            make_payment = self.request.get('make_payment')
            if make_payment:
                total_payment = self.request.get('total_payment')
                for student in template_values['students']:
                    email_in_request = self.request.get(student.email)
                    if email_in_request != student.email:
                        logging.error(
                            "Email <%s> expected in requst but not found" %
                            student.email)

                    student.tuition = str(
                        int(total_payment) /
                        int(template_values['number_of_students']))
                    student.extended_care = False
                    if self.request.get('extended_care'):
                        student.extended_care = True

                    student.put()

                if template_values['is_parent']:
                    parent = SummerParentData.all().filter(
                        'email =', user_email).get()
                else:
                    parent = SummerParentData.all().filter(
                        'email =',
                        template_values['student'].parent_email).get()

                payee_phone_a = ""
                payee_phone_b = ""
                payee_phone_c = ""
                phone_parts = parent.phone.split("-")
                if phone_parts is not None:
                    payee_phone_a = phone_parts[0]
                    payee_phone_b = phone_parts[1]
                    payee_phone_c = phone_parts[2]

                template_values['total_payment'] = total_payment
                template_values['authenticated'] = True
                template_values['make_payment'] = True
                template_values['parent'] = parent
                template_values['payee'] = parent
                template_values['payee_phone_a'] = payee_phone_a
                template_values['payee_phone_b'] = payee_phone_b
                template_values['payee_phone_c'] = payee_phone_c

        else:
            template_values = {
                "authenticated": False,
            }

        self.add_global_template_values(template_values)
        self.render_jinja2_template('summer/summer_tuition.html',
                                    template_values)
Пример #15
0
def get_nickname_for(user):
    if facebook_util.is_facebook_email(user.email()):
        return facebook_util.get_facebook_nickname(user)
    else:
        return user.nickname()
Пример #16
0
    def authenticated_response(self):
        user_data = UserData.current()
        user_email = user_data.user_email
        nickname = ""
        if facebook_util.is_facebook_user_id(user_email):
            nickname = facebook_util.get_facebook_nickname(user_email)

        students = []
        is_parent = False
        query = SummerStudent.all()
        query.filter('email = ', user_email)
        student = query.get()

        if student is not None:
            students.append(student)
        else:
            query = SummerParentData.all()
            query.filter('email = ', user_email)
            parent = query.get()
            if parent is not None:
                is_parent = True
                for student_key in parent.students:
                    students.append(SummerStudent.get(student_key))

        if len(students) > 0:
            applied = True
            student_email = self.request.get('student_email')
            query = SummerStudent.all()
            query.filter('email = ', student_email)
            student = query.get()
            if student is None:
                logging.error(
                    "Student <%s> not expected to be NULL in datastore, but it is"
                    % student_email)
                student = students[0]

            query = SummerParentData.all()
            query.filter('email = ', student.parent_email)
            parent = query.get()
            assert (parent != None)

            student_js = json.dumps(student.to_dict())
            parent_js = json.dumps(parent.to_dict())
        else:
            applied = False
            student = None
            parent = None
            student_js = json.dumps(student)
            parent_js = json.dumps(parent)

        template_values = {
            "authenticated": True,
            "applied": applied,
            "is_parent": is_parent,
            "is_parent_js": json.dumps(is_parent),
            "students": students,
            "student": student,
            "student_js": student_js,
            "parent": parent,
            "parent_js": parent_js,
            "user_email_js": json.dumps(user_email),
            "user_email": user_email,
            "nickname": nickname,
        }

        return template_values
Пример #17
0
    def get(self):
        template_values = {}
        user_data = UserData.current()

        if user_data is not None:
            user_email = user_data.user_email
            nickname = ""
            if facebook_util.is_facebook_user_id(user_email):
                nickname = facebook_util.get_facebook_nickname(user_email)

            application_filled = self.request.get('application_filled')
            make_payment = self.request.get('make_payment')

            if make_payment:
                student_email = self.request.get('student_email')
                is_parent_str = self.request.get('is_parent')

                query = SummerStudent.all()
                query.filter('email = ', student_email)
                student = query.get()

                if student is None:
                    output_str = 'Please <a href="/summer/application">apply</a> first' % student_email
                    self.response.out.write(output_str)
                    return

                if student.processing_fee_paid:
                    self.redirect("/summer/application-status")
                    return

                query = SummerParentData.all()
                query.filter('email = ', student.parent_email)
                parent = query.get()

                if parent is None:
                    logging.error(
                        "Unexpected NULL parent for student <%s> with parent <%s>"
                        % (student_email, student.parent_email))

                if is_parent_str == "True":
                    is_parent = True
                else:
                    is_parent = False

                payee_phone_a = ""
                payee_phone_b = ""
                payee_phone_c = ""
                phone_parts = parent.phone.split("-")
                if phone_parts is not None:
                    payee_phone_a = phone_parts[0]
                    payee_phone_b = phone_parts[1]
                    payee_phone_c = phone_parts[2]

                template_values = {
                    "authenticated": True,
                    "make_payment": True,
                    "is_parent": is_parent,
                    "is_parent_js": json.dumps(is_parent),
                    "student": student,
                    "student_js": json.dumps(student.to_dict()),
                    "payee": parent,
                    "payee_phone_a": payee_phone_a,
                    "payee_phone_b": payee_phone_b,
                    "payee_phone_c": payee_phone_c,
                    "user_email": user_email,
                    "nickname": nickname,
                }

            elif not application_filled:
                template_values = self.authenticated_response()

            else:
                first_name = self.request.get('first_name')
                student_email = self.request.get('student_email')

                query = SummerStudent.all()
                query.filter('email = ', student_email)
                student = query.get()
                if student is None:
                    student = SummerStudent()
                    student.email = student_email
                    student.applier_email = user_email
                    student.processing_fee_paid = False
                    student.tuition_paid = False

                student.first_name = first_name
                student.last_name = self.request.get('last_name')

                student.date_of_birth = self.request.get('date_of_birth')

                if self.request.get('gender') == "Female":
                    student.is_female = True
                else:
                    student.is_female = False

                student.grade = self.request.get('grade')
                student.school = self.request.get('school')
                student.school_zipcode = self.request.get('school_zip')

                student.session_1 = self.request.get('session_1')
                student.session_2 = self.request.get('session_2')
                student.session_3 = self.request.get('session_3')

                session_choices = {"0": [], "1": [], "2": [], "3": []}
                session_choices[student.session_1].append("Session 1")
                session_choices[student.session_2].append("Session 2")
                session_choices[student.session_3].append("Session 3")

                student.no_choice = session_choices["0"]
                student.first_choice = session_choices["1"]
                student.second_choice = session_choices["2"]
                student.third_choice = session_choices["3"]

                student.answer_why = self.request.get('answer_why')
                student.answer_how = self.request.get('answer_how')

                student.processing_fee = self.request.get('fee')

                student.tuition = 'TBD'

                student.application_year = '2012'
                student.application_status = 'Processing'

                if user_email == student_email:
                    is_parent = False
                    student.self_applied = True
                else:
                    is_parent = True
                    student.self_applied = False

                student.parent_relation = self.request.get('relation')
                student.parent_email = self.request.get('parent_email')

                student.put()

                query = SummerParentData.all()
                query.filter('email = ', student.parent_email)
                parent = query.get()
                if parent is None:
                    parent = SummerParentData()
                    parent.email = student.parent_email

                parent.first_name = self.request.get('parent_first_name')
                parent.last_name = self.request.get('parent_last_name')
                parent.address_1 = self.request.get('parent_address_1')
                parent.address_2 = self.request.get('parent_address_2')
                parent.city = self.request.get('parent_city')
                parent.state = self.request.get('parent_state')
                parent.zipcode = self.request.get('parent_zip')
                parent.country = self.request.get('parent_country')
                parent.phone = self.request.get('parent_phone')
                parent.comments = self.request.get('parent_comments')

                if student.key() not in parent.students:
                    parent.students.append(student.key())

                parent.put()

                if student.processing_fee_paid:
                    self.redirect("/summer/application-status")
                    return

                payee_phone_a = ""
                payee_phone_b = ""
                payee_phone_c = ""
                phone_parts = parent.phone.split("-")
                if phone_parts is not None:
                    payee_phone_a = phone_parts[0]
                    payee_phone_b = phone_parts[1]
                    payee_phone_c = phone_parts[2]

                # Only send email if the user's email is a valid one
                if not facebook_util.is_facebook_user_id(parent.email):
                    mail.send_mail( \
                        sender = FROM_EMAIL, \
                        to = parent.email, \
                        subject = "Khan Academy Discovery Lab Application", \
                        body = """Dear %s,
                
We have received your application for %s %s for the Khan Academy Discovery Lab 2012. Please ensure you have paid the $5.00 processing fee for the application.

We will notify you about the status of the application as soon as possible, no later than March 1st, 2012. You can always check the status of the application any time at http://www.khanacademy.org/summer/application-status.

Thank you!
Khan Academy Discovery Lab""" % (parent.first_name, student.first_name, student.last_name))

                template_values = {
                    "authenticated": True,
                    "make_payment": True,
                    "is_parent": is_parent,
                    "is_parent_js": json.dumps(is_parent),
                    "student": student,
                    "student_js": json.dumps(student.to_dict()),
                    "parent": parent,
                    "parent_js": json.dumps(parent.to_dict()),
                    "payee": parent,
                    "payee_phone_a": payee_phone_a,
                    "payee_phone_b": payee_phone_b,
                    "payee_phone_c": payee_phone_c,
                    "user_email": user_email,
                    "nickname": nickname,
                }

        else:
            template_values = {"authenticated": False, "applied": False}

        self.add_global_template_values(template_values)
        self.render_jinja2_template('summer/summer.html', template_values)