diff --git a/django/cantusdb_project/main_app/forms.py b/django/cantusdb_project/main_app/forms.py index bea4213e8..8ec2597c7 100644 --- a/django/cantusdb_project/main_app/forms.py +++ b/django/cantusdb_project/main_app/forms.py @@ -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): """ @@ -73,7 +80,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 +113,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 +123,6 @@ class StyledChoiceField(forms.ChoiceField): widget = SelectWidget() - class ChantCreateForm(forms.ModelForm): class Meta: model = Chant @@ -314,10 +320,8 @@ class Meta: required=False, ) - TRUE_FALSE_CHOICES_INVEN = ((True, "Complete"), (False, "Incomplete")) - complete_inventory = StyledChoiceField( - choices=TRUE_FALSE_CHOICES_INVEN, required=False + choices=COMPLETE_INVENTORY_FORM_CHOICES, required=False ) @@ -509,11 +513,9 @@ class Meta: required=False, ) - CHOICES_COMPLETE_INV = ( - (True, "complete 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): @@ -763,7 +765,6 @@ class Meta: # help_text="RISM-style siglum + Shelf-mark (e.g. GB-Ob 202).", # ) - shelfmark = forms.CharField( required=True, widget=TextInputWidget, @@ -771,7 +772,6 @@ class Meta: name = forms.CharField(required=False, widget=TextInputWidget) - holding_institution = forms.ModelChoiceField( queryset=Institution.objects.all().order_by("city", "name"), required=False, @@ -781,12 +781,6 @@ class Meta: queryset=Provenance.objects.all().order_by("name"), required=False, ) - TRUE_FALSE_CHOICES_SOURCE = ( - (True, "Full source"), - (False, "Fragment or Fragmented"), - ) - - full_source = forms.ChoiceField(choices=TRUE_FALSE_CHOICES_SOURCE, required=False) century = forms.ModelMultipleChoiceField( queryset=Century.objects.all().order_by("name"), @@ -841,10 +835,8 @@ class Meta: widget=FilteredSelectMultiple(verbose_name="other editors", is_stacked=False), ) - TRUE_FALSE_CHOICES_INVEN = ((True, "Complete"), (False, "Incomplete")) - complete_inventory = forms.ChoiceField( - choices=TRUE_FALSE_CHOICES_INVEN, required=False + choices=COMPLETE_INVENTORY_FORM_CHOICES, required=False ) diff --git a/django/cantusdb_project/main_app/management/commands/migrate_records.py b/django/cantusdb_project/main_app/management/commands/migrate_records.py index bc3f26325..fca35a564 100644 --- a/django/cantusdb_project/main_app/management/commands/migrate_records.py +++ b/django/cantusdb_project/main_app/management/commands/migrate_records.py @@ -71,6 +71,7 @@ "HR": "Croatia", "I": "Italy", "IRL": "Ireland", + "N": "Norway", "NL": "Netherlands", "NZ": "New Zealand", "P": "Portugal", diff --git a/django/cantusdb_project/main_app/management/commands/populate_source_completeness.py b/django/cantusdb_project/main_app/management/commands/populate_source_completeness.py index fe7d9e279..7a16fa6f5 100644 --- a/django/cantusdb_project/main_app/management/commands/populate_source_completeness.py +++ b/django/cantusdb_project/main_app/management/commands/populate_source_completeness.py @@ -12,7 +12,7 @@ class Command(BaseCommand): def handle(self, *args, **options): sources = Source.objects.all() for source in sources: - if source.full_source: + if source.full_source or source.full_source is None: source.source_completeness = ( source.SourceCompletenessChoices.FULL_SOURCE ) diff --git a/django/cantusdb_project/main_app/migrations/0032_alter_source_source_completeness.py b/django/cantusdb_project/main_app/migrations/0032_alter_source_source_completeness.py new file mode 100644 index 000000000..9809b8d03 --- /dev/null +++ b/django/cantusdb_project/main_app/migrations/0032_alter_source_source_completeness.py @@ -0,0 +1,26 @@ +# Generated by Django 4.2.14 on 2024-10-15 14:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("main_app", "0031_source_name_source_production_method_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="source", + name="source_completeness", + field=models.IntegerField( + choices=[ + (1, "Complete source"), + (2, "Fragment"), + (3, "Reconstruction"), + ], + default=1, + verbose_name="Complete Source/Fragment", + ), + ), + ] 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/institution_detail.html b/django/cantusdb_project/main_app/templates/institution_detail.html index c862ae679..b22ba9bbb 100644 --- a/django/cantusdb_project/main_app/templates/institution_detail.html +++ b/django/cantusdb_project/main_app/templates/institution_detail.html @@ -10,7 +10,7 @@ {% include "global_search_bar.html" %}

{{ institution.name }} {% if institution.siglum %}({{ institution.siglum }}){% endif %}

-

{{ institution.city }}, {{ institution.country }}

+

{% if institution.city %}{{ institution.city }}{% else %}[No City]{% endif %}, {{ institution.country }}

{% if institution_authorities %}
@@ -29,14 +29,14 @@
Cantus Database
- + {% for source in cantus_sources %} {% endfor %} @@ -47,18 +47,18 @@
Cantus Database
{% if num_bower_sources > 0 %}
-
Bower Sequence Database
+
Clavis Sequentiarum (Sequence Database by Calvin Bower)
ShelfmarkSources
- {{ source.shelfmark }} + {{ source.shelfmark }}{% if source.name %} ("{{ source.name }}"){% endif %}
- + {% for source in bower_sources %} {% endfor %} diff --git a/django/cantusdb_project/main_app/templates/institution_list.html b/django/cantusdb_project/main_app/templates/institution_list.html index 0bc32c6f3..b4fa0c1a7 100644 --- a/django/cantusdb_project/main_app/templates/institution_list.html +++ b/django/cantusdb_project/main_app/templates/institution_list.html @@ -27,7 +27,11 @@

Institutions

{{ institution.country }}
ShelfmarkSources
- {{ source.shelfmark }} + {{ source.shelfmark }}{% if source.name %} ("{{ source.name }}"){% endif %}
- {{ institution.city }} + {% if institution.city %} + {{ institution.city }} + {% else %} + [No City] + {% endif %} 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

- +