steambird/boecie/views.py
def form_valid(self, request: HttpRequest, form: Form, form_name: str) -> HttpResponseRedirect:
        """
        Method which checks if the form is valid. Has a bit more complexity than most form_valid
        due to the M2M fields like teachers and MSP's. We also need to check which form has been
        submitted. Save's valid forms content and fills in any leftover hidden fields

        :param request: Django HtppRequest object
        :param form: Django Form object
        :param form_name: form name, see forms dict of the class
        :return: HttpResponseRedirect object
        """

        if form_name == 'course_form':
            form.instance.id = self.kwargs['pk']
            form.save()
            next_course = Course.objects.filter(studies__id=self.kwargs['study'],
                                                updated_associations=False).first()
            if next_course is None:
                return redirect(reverse('boecie:study.list',
                                        kwargs={'pk': self.kwargs['study']}))
            return redirect(reverse('boecie:course.detail',
                                    kwargs={'study': self.kwargs['study'],
                                            'pk': next_course.pk}))
        # elif form == 'studycourse_form'
        form.instance.course = Course.objects.get(pk=self.kwargs['pk'])
        form.save()
        return redirect(reverse('boecie:course.detail',
                                kwargs={'study': self.kwargs['study'],
                                        'pk': self.kwargs['pk']}))

        Method which checks if the form is valid. Has a bit more complexity than most form_valid
        due to the M2M fields like teachers and MSP's. We also need to check which form has been
        submitted. Save's valid forms content and fills in any leftover hidden fields

        :param request: Django HtppRequest object
        :param form: Django Form object
        :param form_name: form name, see forms dict of the class
        :return: HttpResponseRedirect object
        
Method which checks if the form is valid. Has a bit more complexity than most form_valid
due to the M2M fields like teachers and MSP's. We also need to check which form has been
submitted. Save's valid forms content and fills in any leftover hidden fields
Method which checks if the form is valid . Has a bit more complexity than most form_valid due to the M2M fields like teachers and MSP ' s . We also need to check which form has been submitted . Save ' s valid forms content and fills in any leftover hidden fields
def form_valid(self, request: HttpRequest, form: Form, form_name: str) -> HttpResponseRedirect:
        if form_name == 'course_form':
            form.instance.id = self.kwargs['pk']
            form.save()
            next_course = Course.objects.filter(studies__id=self.kwargs['study'],
                                                updated_associations=False).first()
            if next_course is None:
                return redirect(reverse('boecie:study.list',
                                        kwargs={'pk': self.kwargs['study']}))
            return redirect(reverse('boecie:course.detail',
                                    kwargs={'study': self.kwargs['study'],
                                            'pk': next_course.pk}))
        form.instance.course = Course.objects.get(pk=self.kwargs['pk'])
        form.save()
        return redirect(reverse('boecie:course.detail',
                                kwargs={'study': self.kwargs['study'],
                                        'pk': self.kwargs['pk']}))
def form_valid ( self , request : HttpRequest , form : Form , form_name : str ) -> HttpResponseRedirect : if form_name == 'course_form' : form . instance . id = self . kwargs [ 'pk' ] form . save ( ) next_course = Course . objects . filter ( studies__id = self . kwargs [ 'study' ] , updated_associations = False ) . first ( ) if next_course is None : return redirect ( reverse ( 'boecie:study.list' , kwargs = { 'pk' : self . kwargs [ 'study' ] } ) ) return redirect ( reverse ( 'boecie:course.detail' , kwargs = { 'study' : self . kwargs [ 'study' ] , 'pk' : next_course . pk } ) ) form . instance . course = Course . objects . get ( pk = self . kwargs [ 'pk' ] ) form . save ( ) return redirect ( reverse ( 'boecie:course.detail' , kwargs = { 'study' : self . kwargs [ 'study' ] , 'pk' : self . kwargs [ 'pk' ] } ) )
Method which checks if the form is valid.
Method which checks if the form is valid .
"""
        Method which checks if the form is valid. Has a bit more complexity than most form_valid
        due to the M2M fields like teachers and MSP's. We also need to check which form has been
        submitted. Save's valid forms content and fills in any leftover hidden fields

        :param request: Django HtppRequest object
        :param form: Django Form object
        :param form_name: form name, see forms dict of the class
        :return: HttpResponseRedirect object
        """ # elif form == 'studycourse_form'
None
self
request
HttpRequest
Django HtppRequest object
Django HtppRequest object
form
Form
Django Form object
Django Form object
form_name
str
form name, see forms dict of the class
form name see forms dict of the class