steambird/boecie/views.py
def form_valid(self, form: Form) -> HttpResponseRedirect:
        """
        Checks if the Form is valid. Redirects to the 'edit' page of the same teacher

        :param form: Django Form object
        :return: Django HttpResponseRedirect
        """

        teacherinfo = form.save(commit=False)
        lastname = str()
        if teacherinfo.surname_prefix is not None:
            lastname += teacherinfo.surname_prefix
        lastname += teacherinfo.last_name

        # Create a Django User object, so we can then create a Authcode and Teacher object to
        # link it to.
        user = User()
        user.first_name = teacherinfo.first_name
        user.last_name = lastname
        user.username = teacherinfo.initials.replace('.', '') + teacherinfo.last_name
        user.password = 'AC0mpl3t3lyRandomPasSwORDThatSh08dNevahbeUsed'
        user.set_unusable_password()
        user.save()

        # Create an AuthToken that can be used for the Teacher
        authcode = AuthToken()
        authcode.user = user
        authcode.save()

        # Create
        teacher = form.save(commit=False)
        teacher.user = user

        teacher.save()
        teacher_pk = teacher.pk
        return redirect(
            reverse('boecie:teacher.detail', kwargs={'pk': teacher_pk}))

        Checks if the Form is valid. Redirects to the 'edit' page of the same teacher

        :param form: Django Form object
        :return: Django HttpResponseRedirect
        
Checks if the Form is valid. Redirects to the 'edit' page of the same teacher
Checks if the Form is valid . Redirects to the ' edit ' page of the same teacher
def form_valid(self, form: Form) -> HttpResponseRedirect:
        teacherinfo = form.save(commit=False)
        lastname = str()
        if teacherinfo.surname_prefix is not None:
            lastname += teacherinfo.surname_prefix
        lastname += teacherinfo.last_name
        user = User()
        user.first_name = teacherinfo.first_name
        user.last_name = lastname
        user.username = teacherinfo.initials.replace('.', '') + teacherinfo.last_name
        user.password = 'AC0mpl3t3lyRandomPasSwORDThatSh08dNevahbeUsed'
        user.set_unusable_password()
        user.save()
        authcode = AuthToken()
        authcode.user = user
        authcode.save()
        teacher = form.save(commit=False)
        teacher.user = user
        teacher.save()
        teacher_pk = teacher.pk
        return redirect(
            reverse('boecie:teacher.detail', kwargs={'pk': teacher_pk}))
def form_valid ( self , form : Form ) -> HttpResponseRedirect : teacherinfo = form . save ( commit = False ) lastname = str ( ) if teacherinfo . surname_prefix is not None : lastname += teacherinfo . surname_prefix lastname += teacherinfo . last_name user = User ( ) user . first_name = teacherinfo . first_name user . last_name = lastname user . username = teacherinfo . initials . replace ( '.' , '' ) + teacherinfo . last_name user . password = 'AC0mpl3t3lyRandomPasSwORDThatSh08dNevahbeUsed' user . set_unusable_password ( ) user . save ( ) authcode = AuthToken ( ) authcode . user = user authcode . save ( ) teacher = form . save ( commit = False ) teacher . user = user teacher . save ( ) teacher_pk = teacher . pk return redirect ( reverse ( 'boecie:teacher.detail' , kwargs = { 'pk' : teacher_pk } ) )
Checks if the Form is valid.
Checks if the Form is valid .
"""
        Checks if the Form is valid. Redirects to the 'edit' page of the same teacher

        :param form: Django Form object
        :return: Django HttpResponseRedirect
        """ # Create a Django User object, so we can then create a Authcode and Teacher object to # link it to. # Create an AuthToken that can be used for the Teacher # Create
None
self
form
Form
Django Form object
Django Form object