Skip to content

Commit

Permalink
refactor(forms): define complete_inventory choices once in forms.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dchiller committed Oct 15, 2024
1 parent 55162dd commit a167fc7
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions django/cantusdb_project/main_app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
# ModelForm allows to build a form directly from a model
# see https://docs.djangoproject.com/en/3.0/topics/forms/modelforms/

# Define choices for the Source model's
# complete_inventory BooleanField
COMPLETE_INVENTORY_FORM_CHOICES = (
(True, "Full inventory"),
(False, "Partial inventory"),
)


class NameModelChoiceField(forms.ModelChoiceField):
"""
Expand Down Expand Up @@ -313,10 +320,8 @@ class Meta:
required=False,
)

TRUE_FALSE_CHOICES_INVEN = ((True, "Full inventory"), (False, "Partial inventory"))

complete_inventory = StyledChoiceField(
choices=TRUE_FALSE_CHOICES_INVEN, required=False
choices=COMPLETE_INVENTORY_FORM_CHOICES, required=False
)


Expand Down Expand Up @@ -508,11 +513,9 @@ class Meta:
required=False,
)

CHOICES_COMPLETE_INV = (
(True, "Full inventory"),
(False, "Partial inventory"),
complete_inventory = StyledChoiceField(
choices=COMPLETE_INVENTORY_FORM_CHOICES, required=False
)
complete_inventory = StyledChoiceField(choices=CHOICES_COMPLETE_INV, required=False)


class SequenceEditForm(forms.ModelForm):
Expand Down Expand Up @@ -832,10 +835,8 @@ class Meta:
widget=FilteredSelectMultiple(verbose_name="other editors", is_stacked=False),
)

TRUE_FALSE_CHOICES_INVEN = ((True, "Full inventory"), (False, "Partial inventory"))

complete_inventory = forms.ChoiceField(
choices=TRUE_FALSE_CHOICES_INVEN, required=False
choices=COMPLETE_INVENTORY_FORM_CHOICES, required=False
)


Expand Down

0 comments on commit a167fc7

Please sign in to comment.