Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make shelfmark a required field on source create and edit forms #1606

Merged
merged 9 commits into from
Aug 30, 2024
17 changes: 15 additions & 2 deletions django/cantusdb_project/main_app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ class Meta:
"holding_institution": autocomplete.ModelSelect2(
url="holding-autocomplete"
),
"shelfmark": TextInputWidget(),
"provenance": autocomplete.ModelSelect2(url="provenance-autocomplete"),
"provenance_notes": TextInputWidget(),
"date": TextInputWidget(),
Expand Down Expand Up @@ -254,6 +253,11 @@ class Meta:
"segment_m2m": CheckboxNameModelMultipleChoiceField,
}

shelfmark = forms.CharField(
required=True,
widget=TextInputWidget,
)

TRUE_FALSE_CHOICES_SOURCE = (
(True, "Full source"),
(False, "Fragment or Fragmented"),
Expand Down Expand Up @@ -410,7 +414,6 @@ class Meta:
"holding_institution": autocomplete.ModelSelect2(
url="holding-autocomplete"
),
"shelfmark": TextInputWidget(),
"segment_m2m": CheckboxSelectMultiple(),
"provenance": autocomplete.ModelSelect2(url="provenance-autocomplete"),
"provenance_notes": TextInputWidget(),
Expand Down Expand Up @@ -447,6 +450,11 @@ class Meta:
"segment_m2m": CheckboxNameModelMultipleChoiceField,
}

shelfmark = forms.CharField(
required=True,
widget=TextInputWidget,
)

CHOICES_FULL_SOURCE = (
(None, "None"),
(True, "Full source"),
Expand Down Expand Up @@ -718,6 +726,11 @@ class Meta:
help_text="RISM-style siglum + Shelf-mark (e.g. GB-Ob 202).",
)

shelfmark = forms.CharField(
required=True,
widget=TextInputWidget,
)

provenance = forms.ModelChoiceField(
queryset=Provenance.objects.all().order_by("name"),
required=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h3>Create Source</h3>
<div class="form-row">
<div class="form-group m-1 col-lg-3">
<label for="{{ form.shelfmark.id_for_label }}">
<small>Shelfmark:</small>
<small>Shelfmark:</small><span class="text-danger" title="This field is required">*</span></small>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See: #1550

Better would be to add the .small class to the <label> element.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've fixes the ones for these fields by using class='form-control-sm on the <label> element. But there's many more of these cases we'll want to fix in the future.

</label>
<br>{{ form.shelfmark }}
<p class=text-muted>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ <h3>
<div class="form-row">
<div class="form-group m-1 col-lg-3">
<label for="{{ form.shelfmark.id_for_label }}">
<small>Shelfmark:</small>
<small>Shelfmark:</small><span class="text-danger" title="This field is required">*</span></small>
</label>
<br>{{ form.shelfmark }}
<p class=text-muted>
Expand Down
Loading