From 4ab7478d1191e9ca01b6fcefe64240f80211fd3f Mon Sep 17 00:00:00 2001 From: Dylan Hillerbrand Date: Tue, 15 Oct 2024 09:32:55 -0400 Subject: [PATCH 1/9] fix(sources): modify source_completeness and complete_inventory display Adjust options for Source.source_completeness field to "Full source", "Fragment", and "Reconstruction". Adjust display for Source.complete_inventory boolean to `True` = "Full inventory" and `False` = "Partial inventory". --- django/cantusdb_project/main_app/forms.py | 13 +++++-------- django/cantusdb_project/main_app/models/source.py | 6 +++--- .../main_app/templates/source_create.html | 2 +- .../main_app/templates/source_detail.html | 6 +++--- .../main_app/templates/source_edit.html | 2 +- .../main_app/templates/source_list.html | 2 +- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/django/cantusdb_project/main_app/forms.py b/django/cantusdb_project/main_app/forms.py index bea4213e8..076bb9dec 100644 --- a/django/cantusdb_project/main_app/forms.py +++ b/django/cantusdb_project/main_app/forms.py @@ -73,7 +73,6 @@ def label_from_instance(self, obj): widget = CheckboxSelectMultiple() - class CantusDBLatinField(forms.CharField): """ A custom CharField for chant text fields. Validates that the text @@ -107,6 +106,7 @@ def validate(self, value): except ValueError as exc: raise forms.ValidationError("Invalid characters in text.") from exc + class StyledChoiceField(forms.ChoiceField): """ A custom ChoiceField that uses the custom SelectWidget defined in widgets.py @@ -116,7 +116,6 @@ class StyledChoiceField(forms.ChoiceField): widget = SelectWidget() - class ChantCreateForm(forms.ModelForm): class Meta: model = Chant @@ -314,7 +313,7 @@ class Meta: required=False, ) - TRUE_FALSE_CHOICES_INVEN = ((True, "Complete"), (False, "Incomplete")) + TRUE_FALSE_CHOICES_INVEN = ((True, "Full inventory"), (False, "Partial inventory")) complete_inventory = StyledChoiceField( choices=TRUE_FALSE_CHOICES_INVEN, required=False @@ -510,8 +509,8 @@ class Meta: ) CHOICES_COMPLETE_INV = ( - (True, "complete inventory"), - (False, "partial inventory"), + (True, "Full inventory"), + (False, "Partial inventory"), ) complete_inventory = StyledChoiceField(choices=CHOICES_COMPLETE_INV, required=False) @@ -763,7 +762,6 @@ class Meta: # help_text="RISM-style siglum + Shelf-mark (e.g. GB-Ob 202).", # ) - shelfmark = forms.CharField( required=True, widget=TextInputWidget, @@ -771,7 +769,6 @@ class Meta: name = forms.CharField(required=False, widget=TextInputWidget) - holding_institution = forms.ModelChoiceField( queryset=Institution.objects.all().order_by("city", "name"), required=False, @@ -841,7 +838,7 @@ class Meta: widget=FilteredSelectMultiple(verbose_name="other editors", is_stacked=False), ) - TRUE_FALSE_CHOICES_INVEN = ((True, "Complete"), (False, "Incomplete")) + TRUE_FALSE_CHOICES_INVEN = ((True, "Full inventory"), (False, "Partial inventory")) complete_inventory = forms.ChoiceField( choices=TRUE_FALSE_CHOICES_INVEN, required=False diff --git a/django/cantusdb_project/main_app/models/source.py b/django/cantusdb_project/main_app/models/source.py index 2887b95f6..05fe45a03 100644 --- a/django/cantusdb_project/main_app/models/source.py +++ b/django/cantusdb_project/main_app/models/source.py @@ -78,14 +78,14 @@ class Source(BaseModel): ) class SourceCompletenessChoices(models.IntegerChoices): - FULL_SOURCE = 1, "Full source" - FRAGMENT = 2, "Fragment/Fragmented" + FULL_SOURCE = 1, "Complete source" + FRAGMENT = 2, "Fragment" RECONSTRUCTION = 3, "Reconstruction" source_completeness = models.IntegerField( choices=SourceCompletenessChoices.choices, default=SourceCompletenessChoices.FULL_SOURCE, - verbose_name="Full Source/Fragment", + verbose_name="Complete Source/Fragment", ) full_source = models.BooleanField(blank=True, null=True) diff --git a/django/cantusdb_project/main_app/templates/source_create.html b/django/cantusdb_project/main_app/templates/source_create.html index 395a373fa..99d769cff 100644 --- a/django/cantusdb_project/main_app/templates/source_create.html +++ b/django/cantusdb_project/main_app/templates/source_create.html @@ -162,7 +162,7 @@

Create Source

{{ form.complete_inventory }}
diff --git a/django/cantusdb_project/main_app/templates/source_detail.html b/django/cantusdb_project/main_app/templates/source_detail.html index 60e84a39d..996a1e50d 100644 --- a/django/cantusdb_project/main_app/templates/source_detail.html +++ b/django/cantusdb_project/main_app/templates/source_detail.html @@ -113,11 +113,11 @@

{{ source.heading }}

{% endif %} {% if source.complete_inventory is not None %} -
Complete/Partial Inventory
-
{{ source.complete_inventory|yesno:"Complete Inventory,Partial Inventory" }}
+
Full/Partial Inventory
+
{{ source.complete_inventory|yesno:"Full Inventory,Partial Inventory" }}
{% endif %} -
Full Source/Fragment
+
Complete Source/Fragment
{{ source.get_source_completeness_display }}
{% if user.is_authenticated %} diff --git a/django/cantusdb_project/main_app/templates/source_edit.html b/django/cantusdb_project/main_app/templates/source_edit.html index 385ebc1e9..b953367b5 100644 --- a/django/cantusdb_project/main_app/templates/source_edit.html +++ b/django/cantusdb_project/main_app/templates/source_edit.html @@ -170,7 +170,7 @@

{{ form.complete_inventory }}
diff --git a/django/cantusdb_project/main_app/templates/source_list.html b/django/cantusdb_project/main_app/templates/source_list.html index 330f48e82..37d47722b 100644 --- a/django/cantusdb_project/main_app/templates/source_list.html +++ b/django/cantusdb_project/main_app/templates/source_list.html @@ -70,7 +70,7 @@

Browse Sources

- +