コード例 #1
0
def process_update_account_form(request, teacher, old_anchor):
    update_account_form = TeacherEditAccountForm(request.user, request.POST)
    changing_email = False
    new_email = ""
    if update_account_form.is_valid():
        data = update_account_form.cleaned_data

        # check not default value for CharField
        check_update_password(update_account_form, teacher.new_user, request,
                              data)

        teacher.title = data["title"]
        teacher.new_user.first_name = data["first_name"]
        teacher.new_user.last_name = data["last_name"]

        changing_email, new_email = update_email(teacher.new_user, request,
                                                 data)

        teacher.save()
        teacher.new_user.save()

        anchor = "#"

        messages.success(
            request, "Your account details have been successfully changed.")
    else:
        anchor = old_anchor

    return changing_email, new_email, anchor
コード例 #2
0
    def process_student_edit_account_form(self, form, student, request):
        data = form.cleaned_data
        # check not default value for CharField
        check_update_password(form, student.new_user, request, data)

        messages.success(
            request, "Your account details have been changed successfully.")
コード例 #3
0
    def process_independent_student_edit_account_form(self, form, student, request):
        data = form.cleaned_data

        # check not default value for CharField
        check_update_password(form, student.new_user, request, data)

        # allow individual students to update more
        self.changing_email, new_email = update_email(student.new_user, request, data)

        self.update_name(student, data)

        messages.success(
            request, "Your account details have been changed successfully."
        )

        if self.changing_email:
            logout(request)