Skip to content

Commit

Permalink
fix: added Bootstrap widgets to study related forms
Browse files Browse the repository at this point in the history
  • Loading branch information
EdoStorm96 committed May 30, 2024
1 parent a11f008 commit 16f3978
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 35 deletions.
16 changes: 10 additions & 6 deletions interventions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from main.utils import YES_NO
from .models import Intervention

from cdh.core.forms import (
BootstrapCheckboxSelectMultiple,
BootstrapRadioSelect,
)

class InterventionForm(SoftValidationMixin, ConditionalModelForm):
class Meta:
Expand All @@ -25,12 +29,12 @@ class Meta:
"extra_task",
]
widgets = {
"setting": forms.CheckboxSelectMultiple(),
"supervision": forms.RadioSelect(choices=YES_NO),
"multiple_sessions": forms.RadioSelect(choices=YES_NO),
"leader_has_coc": forms.RadioSelect(choices=YES_NO),
"has_controls": forms.RadioSelect(choices=YES_NO),
"extra_task": forms.RadioSelect(choices=YES_NO),
"setting": BootstrapCheckboxSelectMultiple(),
"supervision": BootstrapRadioSelect(choices=YES_NO),
"multiple_sessions": BootstrapRadioSelect(choices=YES_NO),
"leader_has_coc": BootstrapRadioSelect(choices=YES_NO),
"has_controls": BootstrapRadioSelect(choices=YES_NO),
"extra_task": BootstrapRadioSelect(choices=YES_NO),
}

def __init__(self, *args, **kwargs):
Expand Down
23 changes: 13 additions & 10 deletions observations/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
from main.utils import YES_NO
from .models import Observation


from cdh.core.forms import (
BootstrapRadioSelect,
BootstrapCheckboxSelectMultiple,
)
class ObservationForm(SoftValidationMixin, ConditionalModelForm):
class Meta:
model = Observation
Expand All @@ -33,15 +36,15 @@ class Meta:
"registrations_details",
]
widgets = {
"setting": forms.CheckboxSelectMultiple(),
"supervision": forms.RadioSelect(choices=YES_NO),
"leader_has_coc": forms.RadioSelect(choices=YES_NO),
"is_anonymous": forms.RadioSelect(choices=YES_NO),
"is_in_target_group": forms.RadioSelect(choices=YES_NO),
"is_nonpublic_space": forms.RadioSelect(choices=YES_NO),
"has_advanced_consent": forms.RadioSelect(choices=YES_NO),
"needs_approval": forms.RadioSelect(choices=YES_NO),
"registrations": forms.CheckboxSelectMultiple(),
"setting": BootstrapCheckboxSelectMultiple(),
"supervision": BootstrapRadioSelect(choices=YES_NO),
"leader_has_coc": BootstrapRadioSelect(choices=YES_NO),
"is_anonymous": BootstrapRadioSelect(choices=YES_NO),
"is_in_target_group": BootstrapRadioSelect(choices=YES_NO),
"is_nonpublic_space": BootstrapRadioSelect(choices=YES_NO),
"has_advanced_consent": BootstrapRadioSelect(choices=YES_NO),
"needs_approval": BootstrapRadioSelect(choices=YES_NO),
"registrations": BootstrapCheckboxSelectMultiple(),
}

def __init__(self, *args, **kwargs):
Expand Down
30 changes: 17 additions & 13 deletions studies/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
from .models import AgeGroup, Documents, Study
from .utils import check_necessity_required

from cdh.core.forms import (
BootstrapRadioSelect,
BootstrapCheckboxSelectMultiple,
)

class StudyForm(SoftValidationMixin, ConditionalModelForm):
class Meta:
Expand All @@ -33,15 +37,15 @@ class Meta:
"hierarchy_details",
]
widgets = {
"age_groups": forms.CheckboxSelectMultiple(),
"legally_incapable": forms.RadioSelect(choices=YES_NO),
"has_special_details": forms.RadioSelect(choices=YES_NO),
"hierarchy": forms.RadioSelect(choices=YES_NO),
"special_details": forms.CheckboxSelectMultiple(),
"traits": forms.CheckboxSelectMultiple(),
"necessity": forms.RadioSelect(),
"recruitment": forms.CheckboxSelectMultiple(),
"compensation": forms.RadioSelect(),
"age_groups": BootstrapCheckboxSelectMultiple(),
"legally_incapable": BootstrapRadioSelect(choices=YES_NO),
"has_special_details": BootstrapRadioSelect(choices=YES_NO),
"hierarchy": BootstrapRadioSelect(choices=YES_NO),
"special_details": BootstrapCheckboxSelectMultiple(),
"traits": BootstrapCheckboxSelectMultiple(),
"necessity": BootstrapRadioSelect(),
"recruitment": BootstrapCheckboxSelectMultiple(),
"compensation": BootstrapRadioSelect(),
}
mark_safe_lazy = lazy(mark_safe, SafeString)
labels = {
Expand Down Expand Up @@ -191,10 +195,10 @@ class Meta:
"risk_details",
]
widgets = {
"deception": forms.RadioSelect(),
"negativity": forms.RadioSelect(),
"stressful": forms.RadioSelect(),
"risk": forms.RadioSelect(),
"deception": BootstrapRadioSelect(),
"negativity": BootstrapRadioSelect(),
"stressful": BootstrapRadioSelect(),
"risk": BootstrapRadioSelect(),
}

_soft_validation_fields = [
Expand Down
17 changes: 11 additions & 6 deletions tasks/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
from django.utils.safestring import mark_safe, SafeString
from django.utils.functional import lazy

from cdh.core.forms import (
BootstrapRadioSelect,
BootstrapCheckboxSelectMultiple,
)

mark_safe_lazy = lazy(mark_safe, SafeString)


Expand All @@ -27,9 +32,9 @@ class Meta:
"leader_has_coc",
]
widgets = {
"setting": forms.CheckboxSelectMultiple(),
"supervision": forms.RadioSelect(choices=YES_NO),
"leader_has_coc": forms.RadioSelect(choices=YES_NO),
"setting": BootstrapCheckboxSelectMultiple(),
"supervision": BootstrapRadioSelect(choices=YES_NO),
"leader_has_coc": BootstrapRadioSelect(choices=YES_NO),
}

_soft_validation_fields = [
Expand Down Expand Up @@ -105,9 +110,9 @@ class Meta:
),
}
widgets = {
"registrations": forms.CheckboxSelectMultiple(),
"registration_kinds": forms.CheckboxSelectMultiple(),
"feedback": forms.RadioSelect(choices=YES_NO),
"registrations": BootstrapCheckboxSelectMultiple(),
"registration_kinds": BootstrapCheckboxSelectMultiple(),
"feedback": BootstrapRadioSelect(choices=YES_NO),
}

def __init__(self, *args, **kwargs):
Expand Down

0 comments on commit 16f3978

Please sign in to comment.