steambird/boecie/forms.py
def StudyCourseForm(has_course_field: bool = False):
    """
    Function which returns a modelform for usage in a page. The function is used to create a form to
    link information between studies anc courses.

    E.g.
        form_class = StudyCourseForm(True)

        Will return a form with Course field and Study-year visible, study-field is hidden input.

    While:
        form_class = StudyCourseForm(False)

        Will return  a form with Study field and Study-year visible, Course-field is hidden input.

    :param has_course_field: bool
    :return: ModelForm with either Study or Course field
    """

    class _cls(forms.ModelForm):
        class Meta:
            model = CourseStudy
            fields = [
                'study_year',
                ] + (['course'] if has_course_field else ['study'])

            if has_course_field:
                widgets = {
                    'course': AddAnotherWidgetWrapper(ModelSelect2Widget(
                        model=Course,
                        search_fields=[
                            'name__icontains',
                            'course_code__icontains'
                        ]
                    ), reverse_lazy('boecie:index')),

                    'study': HiddenInput(),
                }
            else:
                widgets = {
                    'study': AddAnotherWidgetWrapper(ModelSelect2Widget(
                        model=Study,
                        search_fields=[
                            'name__icontains',
                            'slug__icontains'
                        ]
                    ), reverse_lazy('boecie:index')),

                    'course': HiddenInput(),
                }

    return _cls

    Function which returns a modelform for usage in a page. The function is used to create a form to
    link information between studies anc courses.

    E.g.
        form_class = StudyCourseForm(True)

        Will return a form with Course field and Study-year visible, study-field is hidden input.

    While:
        form_class = StudyCourseForm(False)

        Will return  a form with Study field and Study-year visible, Course-field is hidden input.

    :param has_course_field: bool
    :return: ModelForm with either Study or Course field
    
Function which returns a modelform for usage in a page. The function is used to create a form to
link information between studies anc courses.



Will return a form with Course field and Study-year visible, study-field is hidden input.



Will return  a form with Study field and Study-year visible, Course-field is hidden input.
Function which returns a modelform for usage in a page . The function is used to create a form to link information between studies anc courses . Will return a form with Course field and Study - year visible study - field is hidden input . Will return a form with Study field and Study - year visible Course - field is hidden input .
def StudyCourseForm(has_course_field: bool = False):
    class _cls(forms.ModelForm):
        class Meta:
            model = CourseStudy
            fields = [
                'study_year',
                ] + (['course'] if has_course_field else ['study'])
            if has_course_field:
                widgets = {
                    'course': AddAnotherWidgetWrapper(ModelSelect2Widget(
                        model=Course,
                        search_fields=[
                            'name__icontains',
                            'course_code__icontains'
                        ]
                    ), reverse_lazy('boecie:index')),
                    'study': HiddenInput(),
                }
            else:
                widgets = {
                    'study': AddAnotherWidgetWrapper(ModelSelect2Widget(
                        model=Study,
                        search_fields=[
                            'name__icontains',
                            'slug__icontains'
                        ]
                    ), reverse_lazy('boecie:index')),
                    'course': HiddenInput(),
                }
    return _cls
def StudyCourseForm ( has_course_field : bool = False ) : class _cls ( forms . ModelForm ) : class Meta : model = CourseStudy fields = [ 'study_year' , ] + ( [ 'course' ] if has_course_field else [ 'study' ] ) if has_course_field : widgets = { 'course' : AddAnotherWidgetWrapper ( ModelSelect2Widget ( model = Course , search_fields = [ 'name__icontains' , 'course_code__icontains' ] ) , reverse_lazy ( 'boecie:index' ) ) , 'study' : HiddenInput ( ) , } else : widgets = { 'study' : AddAnotherWidgetWrapper ( ModelSelect2Widget ( model = Study , search_fields = [ 'name__icontains' , 'slug__icontains' ] ) , reverse_lazy ( 'boecie:index' ) ) , 'course' : HiddenInput ( ) , } return _cls
Function which returns a modelform for usage in a page.
Function which returns a modelform for usage in a page .
"""
    Function which returns a modelform for usage in a page. The function is used to create a form to
    link information between studies anc courses.

    E.g.
        form_class = StudyCourseForm(True)

        Will return a form with Course field and Study-year visible, study-field is hidden input.

    While:
        form_class = StudyCourseForm(False)

        Will return  a form with Study field and Study-year visible, Course-field is hidden input.

    :param has_course_field: bool
    :return: ModelForm with either Study or Course field
    """
ModelForm with either Study or Course field
ModelForm with either Study or Course field
has_course_field
bool
None