diff --git a/django/cantusdb_project/main_app/admin/__init__.py b/django/cantusdb_project/main_app/admin/__init__.py index 994faadaa..6c0fac619 100644 --- a/django/cantusdb_project/main_app/admin/__init__.py +++ b/django/cantusdb_project/main_app/admin/__init__.py @@ -11,3 +11,4 @@ from main_app.admin.source import SourceAdmin from main_app.admin.institution import InstitutionAdmin from main_app.admin.institution_identifier import InstitutionIdentifierAdmin +from main_app.admin.project import ProjectAdmin diff --git a/django/cantusdb_project/main_app/admin/project.py b/django/cantusdb_project/main_app/admin/project.py new file mode 100644 index 000000000..1bb98cb0b --- /dev/null +++ b/django/cantusdb_project/main_app/admin/project.py @@ -0,0 +1,9 @@ +from django.contrib import admin + +from main_app.admin.base_admin import BaseModelAdmin +from main_app.models import Project + + +@admin.register(Project) +class ProjectAdmin(BaseModelAdmin): + search_fields = ("name",) diff --git a/django/cantusdb_project/main_app/forms.py b/django/cantusdb_project/main_app/forms.py index 4b7222c7a..3c366d35f 100644 --- a/django/cantusdb_project/main_app/forms.py +++ b/django/cantusdb_project/main_app/forms.py @@ -8,6 +8,7 @@ Feast, Source, Segment, + Project, Provenance, Century, Sequence, @@ -82,14 +83,13 @@ class Meta: "content_structure", "indexing_notes", "addendum", - # See issue #1521: Temporarily commenting out segment-related functions on Chant - # "segment", - # "liturgical_function", - # "polyphony", - # "cm_melody_id", - # "incipit_of_refrain", - # "later_addition", - # "rubrics", + "project", + "liturgical_function", + "polyphony", + "cm_melody_id", + "incipit_of_refrain", + "later_addition", + "rubrics", ] # the widgets dictionary is ignored for a model field with a non-empty # choices attribute. In this case, you must override the form field to @@ -148,14 +148,12 @@ class Meta: "Mass Alleluias. Punctuation is omitted.", ) - # See issue #1521: Temporarily commenting out segment-related functions on Chant - # segment = SelectWidgetNameModelChoiceField( - # queryset=Segment.objects.all().order_by("id"), - # required=True, - # initial=Segment.objects.get(id=4063), # Default to the "Cantus" segment - # help_text="Select the Database segment that the chant belongs to. " - # "In most cases, this will be the CANTUS segment.", - # ) + project = SelectWidgetNameModelChoiceField( + queryset=Project.objects.all().order_by("id"), + initial=None, + required=False, + help_text="Select the project (if any) that the chant belongs to.", + ) # automatically computed fields # source and incipit are mandatory fields in model, @@ -280,14 +278,13 @@ class Meta: "manuscript_full_text_proofread", "volpiano_proofread", "proofread_by", - # See issue #1521: Temporarily commenting out segment-related functions on Chant - # "segment", - # "liturgical_function", - # "polyphony", - # "cm_melody_id", - # "incipit_of_refrain", - # "later_addition", - # "rubrics", + "project", + "liturgical_function", + "polyphony", + "cm_melody_id", + "incipit_of_refrain", + "later_addition", + "rubrics", ] widgets = { # manuscript_full_text_std_spelling: defined below (required) @@ -317,13 +314,12 @@ class Meta: "proofread_by": autocomplete.ModelSelect2Multiple( url="proofread-by-autocomplete" ), - # See issue #1521: Temporarily commenting out segment-related functions on Chant - # "polyphony": SelectWidget(), - # "liturgical_function": SelectWidget(), - # "cm_melody_id": TextInputWidget(), - # "incipit_of_refrain": TextInputWidget(), - # "later_addition": TextInputWidget(), - # "rubrics": TextInputWidget(), + "polyphony": SelectWidget(), + "liturgical_function": SelectWidget(), + "cm_melody_id": TextInputWidget(), + "incipit_of_refrain": TextInputWidget(), + "later_addition": TextInputWidget(), + "rubrics": TextInputWidget(), } manuscript_full_text_std_spelling = forms.CharField( @@ -348,13 +344,11 @@ class Meta: help_text="Each folio starts with '1'.", ) - # See issue #1521: Temporarily commenting out segment-related functions on Chant - # segment = SelectWidgetNameModelChoiceField( - # queryset=Segment.objects.all().order_by("id"), - # required=True, - # help_text="Select the Database segment that the chant belongs to. " - # "In most cases, this will be the CANTUS segment.", - # ) + project = SelectWidgetNameModelChoiceField( + queryset=Project.objects.all().order_by("id"), + help_text="Select the project (if any) that the chant belongs to.", + required = False, + ) class SourceEditForm(forms.ModelForm): diff --git a/django/cantusdb_project/main_app/management/commands/assign_chants_to_segments.py b/django/cantusdb_project/main_app/management/commands/assign_chants_to_segments.py deleted file mode 100644 index e5e056329..000000000 --- a/django/cantusdb_project/main_app/management/commands/assign_chants_to_segments.py +++ /dev/null @@ -1,44 +0,0 @@ -""" -This command is meant to be used one time toward solving issue -1420: Chants should belong to segments. - -This command iterates through all the sources in database and assigns -all chants in the database to the segment of the source they belong to. -""" - -from django.core.management.base import BaseCommand -from main_app.models import Source, Chant, Segment, Sequence - - -class Command(BaseCommand): - help = "Assigns all chants in the database to the segment of the source they belong to." - - def handle(self, *args, **options): - sources = Source.objects.all() - for source in sources: - segment = Segment.objects.get(id=source.segment_id) - chants = Chant.objects.filter(source=source) - sequences = Sequence.objects.filter(source=source) - chants_count = chants.count() - sequences_count = sequences.count() - if chants_count != 0 and sequences_count != 0: - self.stdout.write( - self.style.ERROR( - f"Source {source.id} has {chants_count} chants and {sequences_count} sequences." - ) - ) - continue - if chants_count > 0: - chants.update(segment=segment) - self.stdout.write( - self.style.SUCCESS( - f"Assigned {chants_count} chants in source {source.id} to segment {segment.id}." - ) - ) - else: - sequences.update(segment=segment) - self.stdout.write( - self.style.SUCCESS( - f"Assigned {sequences_count} sequences in source {source.id} to segment {segment.id}." - ) - ) diff --git a/django/cantusdb_project/main_app/management/commands/assign_sequences_to_bower_project.py b/django/cantusdb_project/main_app/management/commands/assign_sequences_to_bower_project.py new file mode 100644 index 000000000..dc59dc76c --- /dev/null +++ b/django/cantusdb_project/main_app/management/commands/assign_sequences_to_bower_project.py @@ -0,0 +1,40 @@ +""" +This command is meant to be used one time toward solving issue +1542, assigning chants and sequences, where necessary, to their appropriate +"project". + +This command assigns sequences to the Bower project. Chants +(in non-Bower sources) currently have +project. + +Note: This command can only be run *after* the Bower project has been created +in the database through the Admin interface. + +Note: This command is designed to be run once in order to complete the necessary +data migrations with the introduction of the Project model. It is not intended +for multiple runs. +""" + +from django.core.management.base import BaseCommand +from main_app.models import Project, Sequence + + +class Command(BaseCommand): + help = "Assigns all sequences to the Bower project." + + def handle(self, *args, **options): + sequences = Sequence.objects.all() + bower_project = Project.objects.get(name="Clavis Sequentiarum") + if not bower_project: + self.stdout.write( + self.style.ERROR( + "The Bower project does not exist. Please create it in the Admin interface." + ) + ) + return + sequences.update(project=bower_project) + self.stdout.write( + self.style.SUCCESS( + f"All sequences have been assigned to the {bower_project} project." + ) + ) diff --git a/django/cantusdb_project/main_app/migrations/0020_remove_chant_segment_remove_sequence_segment_project_and_more.py b/django/cantusdb_project/main_app/migrations/0020_remove_chant_segment_remove_sequence_segment_project_and_more.py new file mode 100644 index 000000000..bedd0e86b --- /dev/null +++ b/django/cantusdb_project/main_app/migrations/0020_remove_chant_segment_remove_sequence_segment_project_and_more.py @@ -0,0 +1,96 @@ +# Generated by Django 4.2.11 on 2024-06-18 13:04 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ("main_app", "0019_remove_source_rism_siglum_delete_rismsiglum"), + ] + + operations = [ + migrations.RemoveField( + model_name="chant", + name="segment", + ), + migrations.RemoveField( + model_name="sequence", + name="segment", + ), + migrations.CreateModel( + name="Project", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "date_created", + models.DateTimeField( + auto_now_add=True, help_text="The date this entry was created" + ), + ), + ( + "date_updated", + models.DateTimeField( + auto_now=True, help_text="The date this entry was updated" + ), + ), + ("name", models.CharField(max_length=63)), + ( + "created_by", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="%(class)s_created_by_user", + to=settings.AUTH_USER_MODEL, + ), + ), + ( + "last_updated_by", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="%(class)s_last_updated_by_user", + to=settings.AUTH_USER_MODEL, + ), + ), + ], + options={ + "abstract": False, + }, + ), + migrations.AddField( + model_name="chant", + name="project", + field=models.ForeignKey( + blank=True, + help_text="The project this chant belongs to. If left blank,this chant is considered part of the Cantus (default) project.", + null=True, + on_delete=django.db.models.deletion.PROTECT, + to="main_app.project", + ), + ), + migrations.AddField( + model_name="sequence", + name="project", + field=models.ForeignKey( + blank=True, + help_text="The project this chant belongs to. If left blank,this chant is considered part of the Cantus (default) project.", + null=True, + on_delete=django.db.models.deletion.PROTECT, + to="main_app.project", + ), + ), + ] diff --git a/django/cantusdb_project/main_app/models/__init__.py b/django/cantusdb_project/main_app/models/__init__.py index 35e764e0c..ef755c898 100644 --- a/django/cantusdb_project/main_app/models/__init__.py +++ b/django/cantusdb_project/main_app/models/__init__.py @@ -12,3 +12,4 @@ from main_app.models.source import Source from main_app.models.institution import Institution from main_app.models.institution_identifier import InstitutionIdentifier +from main_app.models.project import Project diff --git a/django/cantusdb_project/main_app/models/base_chant.py b/django/cantusdb_project/main_app/models/base_chant.py index 2419185e0..7885f538a 100644 --- a/django/cantusdb_project/main_app/models/base_chant.py +++ b/django/cantusdb_project/main_app/models/base_chant.py @@ -176,12 +176,15 @@ class Meta: # this field, populated by the populate_is_last_chant_in_feast script, exists in order to optimize .get_suggested_feasts() on the chant-create page is_last_chant_in_feast = models.BooleanField(blank=True, null=True) - segment = models.ForeignKey( - "Segment", + project = models.ForeignKey( + "Project", on_delete=models.PROTECT, null=True, blank=True, - help_text="The segment of the manuscript that contains this chant", + help_text=( + "The project this chant belongs to. If left blank," + "this chant is considered part of the Cantus (default) project." + ), ) # fragmentarium_id = models.CharField(blank=True, null=True, max_length=64) # # Digital Analysis of Chant Transmission diff --git a/django/cantusdb_project/main_app/models/project.py b/django/cantusdb_project/main_app/models/project.py new file mode 100644 index 000000000..bba9ca3e0 --- /dev/null +++ b/django/cantusdb_project/main_app/models/project.py @@ -0,0 +1,16 @@ +from main_app.models import BaseModel +from django.db import models + + +class Project(BaseModel): + """ + Chants can be tagged with the Project if their inventories are collected + as part of a particular project or initiative. Tagging a chant with a + project allows for the collection of project-specific chant data during + the inventory process and enables filtering by project during search. + """ + + name = models.CharField(max_length=63) + + def __str__(self): + return f"{self.name} ({self.id})" diff --git a/django/cantusdb_project/main_app/templates/chant_create.html b/django/cantusdb_project/main_app/templates/chant_create.html index 95f335c97..69082d3a4 100644 --- a/django/cantusdb_project/main_app/templates/chant_create.html +++ b/django/cantusdb_project/main_app/templates/chant_create.html @@ -90,16 +90,16 @@

Create Chant

{{ form.cantus_id }} - - +
@@ -147,11 +147,10 @@

Create Chant

{{ form.extra }}
- - +
@@ -187,9 +186,8 @@

Create Chant

- - - + --> +
diff --git a/django/cantusdb_project/main_app/templates/chant_edit.html b/django/cantusdb_project/main_app/templates/chant_edit.html index 8196d0d4b..97f6bd648 100644 --- a/django/cantusdb_project/main_app/templates/chant_edit.html +++ b/django/cantusdb_project/main_app/templates/chant_edit.html @@ -102,16 +102,15 @@ {{ form.melody_id }}
- - +
@@ -131,11 +130,10 @@ {{ form.extra.label_tag }} {{ form.extra }}
- - +
@@ -164,9 +162,8 @@ {% endif %}
- - - + --> +
{% if suggested_fulltext %}
diff --git a/django/cantusdb_project/main_app/tests/make_fakes.py b/django/cantusdb_project/main_app/tests/make_fakes.py index 931e347e8..15b9eb6eb 100644 --- a/django/cantusdb_project/main_app/tests/make_fakes.py +++ b/django/cantusdb_project/main_app/tests/make_fakes.py @@ -9,6 +9,7 @@ from main_app.models import Genre from main_app.models import Notation from main_app.models import Office +from main_app.models import Project from main_app.models import Provenance from main_app.models import Segment from main_app.models import Sequence @@ -151,7 +152,7 @@ def make_fake_chant( manuscript_syllabized_full_text=None, next_chant=None, differentia=None, - segment=None, + project=None, ) -> Chant: """Generates a fake Chant object.""" if source is None: @@ -189,8 +190,8 @@ def make_fake_chant( manuscript_syllabized_full_text = faker.sentence(20) if differentia is None: differentia = make_random_string(2) - if segment is None: - segment = make_fake_segment() + if project is None: + project = make_fake_project() chant = Chant.objects.create( source=source, @@ -225,7 +226,7 @@ def make_fake_chant( indexing_notes=faker.sentence(), json_info=None, next_chant=next_chant, - segment=segment, + project=project, ) chant.refresh_from_db() # several fields (e.g., incipit) are calculated automatically # upon chant save. By refreshing from db before returning, we ensure all the chant's fields @@ -303,6 +304,16 @@ def make_fake_segment(name: str = None, id: int = None) -> Segment: return segment +def make_fake_project(name: str = None, id: int = None) -> Project: + if name is None: + name = faker.sentence(nb_words=2) + if id is None: + project = Project.objects.create(name=name) + return project + project = Project.objects.create(name=name, id=id) + return project + + def make_fake_sequence(source=None, title=None, cantus_id=None) -> Sequence: """Generates a fake Sequence object.""" if source is None: diff --git a/django/cantusdb_project/main_app/tests/test_assign_chants_to_segments.py b/django/cantusdb_project/main_app/tests/test_assign_chants_to_segments.py deleted file mode 100644 index 6a66daa1e..000000000 --- a/django/cantusdb_project/main_app/tests/test_assign_chants_to_segments.py +++ /dev/null @@ -1,37 +0,0 @@ -from django.test import TestCase -from django.core.management import call_command - -from main_app.models import Chant, Sequence - -from main_app.tests.make_fakes import make_fake_source, make_fake_segment - - -class AssignChantsToSegmentsTest(TestCase): - def test_assign_chants_to_segments(self): - segment_1 = make_fake_segment() - segment_2 = make_fake_segment() - source_1 = make_fake_source(segment=segment_1) - source_2 = make_fake_source(segment=segment_2) - sequence_source = make_fake_source(segment=segment_2) - for _ in range(5): - Chant.objects.create(source=source_1) - for _ in range(3): - Chant.objects.create(source=source_2) - for _ in range(4): - Sequence.objects.create(source=sequence_source) - all_chants = Chant.objects.all() - for chant in all_chants: - self.assertIsNone(chant.segment_id) - all_sequences = Sequence.objects.all() - for sequence in all_sequences: - self.assertIsNone(sequence.segment_id) - call_command("assign_chants_to_segments") - source_1_chants = Chant.objects.filter(source=source_1) - source_2_chants = Chant.objects.filter(source=source_2) - sequence_source_sequences = Sequence.objects.filter() - for chant in source_1_chants: - self.assertEqual(chant.segment_id, segment_1.id) - for chant in source_2_chants: - self.assertEqual(chant.segment_id, segment_2.id) - for sequence in sequence_source_sequences: - self.assertEqual(sequence.segment_id, segment_2.id) diff --git a/django/cantusdb_project/main_app/tests/test_assign_sequences_to_bower_project.py b/django/cantusdb_project/main_app/tests/test_assign_sequences_to_bower_project.py new file mode 100644 index 000000000..cb28960b8 --- /dev/null +++ b/django/cantusdb_project/main_app/tests/test_assign_sequences_to_bower_project.py @@ -0,0 +1,30 @@ +from django.test import TestCase +from django.core.management import call_command + +from main_app.models import Chant, Sequence, Project + +from main_app.tests.make_fakes import make_fake_source + + +class AssignSequencesToBowerProjectTest(TestCase): + def test_assign_sequences_to_bower_project(self): + project = Project.objects.create(name="Clavis Sequentiarum") + chant_source = make_fake_source() + sequence_source = make_fake_source() + for _ in range(5): + Chant.objects.create(source=chant_source) + for _ in range(4): + Sequence.objects.create(source=sequence_source) + all_chants = Chant.objects.all() + for chant in all_chants: + self.assertIsNone(chant.project_id) + all_sequences = Sequence.objects.all() + for sequence in all_sequences: + self.assertIsNone(sequence.project_id) + call_command("assign_sequences_to_bower_project") + all_chants = Chant.objects.all() + all_sequences = Sequence.objects.all() + for chant in all_chants: + self.assertIsNone(chant.project_id) + for sequence in all_sequences: + self.assertEqual(sequence.project_id, project.id) diff --git a/django/cantusdb_project/main_app/tests/test_views.py b/django/cantusdb_project/main_app/tests/test_views.py index 701679ccc..5ddfc1c87 100644 --- a/django/cantusdb_project/main_app/tests/test_views.py +++ b/django/cantusdb_project/main_app/tests/test_views.py @@ -3148,14 +3148,12 @@ def test_url_and_templates(self): def test_create_chant(self): source = make_fake_source() - segment = make_fake_segment() response = self.client.post( reverse("chant-create", args=[source.id]), { "manuscript_full_text_std_spelling": "initial", "folio": "001r", "c_sequence": "1", - "segment": segment.id, }, ) self.assertEqual(response.status_code, 302) @@ -3207,14 +3205,12 @@ def test_repeated_seq(self): TEST_FOLIO = "001r" # create some chants in the test source source = make_fake_source() - segment = make_fake_segment() for i in range(1, 5): Chant.objects.create( source=source, manuscript_full_text=faker.text(10), folio=TEST_FOLIO, c_sequence=i, - segment=segment, ) # post a chant with the same folio and seq url = reverse("chant-create", args=[source.id]) @@ -3225,7 +3221,6 @@ def test_repeated_seq(self): "manuscript_full_text_std_spelling": fake_text, "folio": TEST_FOLIO, "c_sequence": random.randint(1, 4), - "segment": segment.id, }, follow=True, ) @@ -3254,7 +3249,6 @@ def test_template_used(self): def test_volpiano_signal(self): source = make_fake_source() - segment = make_fake_segment() self.client.post( reverse("chant-create", args=[source.id]), { @@ -3266,7 +3260,6 @@ def test_volpiano_signal(self): "volpiano": "9abcdefg)A-B1C2D3E4F5G67?. yiz", # ^ ^ ^ ^ ^ ^ ^^^^^^^^ # clefs, accidentals, etc., to be deleted - "segment": segment.id, }, ) with patch("requests.get", mock_requests_get): @@ -3282,7 +3275,6 @@ def test_volpiano_signal(self): "folio": "001r", "c_sequence": "2", "volpiano": "abacadaeafagahaja", - "segment": segment.id, }, ) with patch("requests.get", mock_requests_get): @@ -3300,7 +3292,6 @@ def test_initial_values(self): feast: Feast = make_fake_feast() office: Office = make_fake_office() image_link: str = "https://www.youtube.com/watch?v=9bZkp7q19f0" - segment = make_fake_segment() self.client.post( reverse("chant-create", args=[source.id]), { @@ -3310,7 +3301,6 @@ def test_initial_values(self): "feast": feast.id, "office": office.id, "image_link": image_link, - "segment": segment.id, }, ) with patch("requests.get", mock_requests_get): @@ -3528,7 +3518,6 @@ def test_update_chant(self): folio = chant.folio c_sequence = chant.c_sequence - segment_id = chant.segment_id response = self.client.post( reverse("source-edit-chants", args=[source.id]), { @@ -3536,7 +3525,6 @@ def test_update_chant(self): "pk": chant.id, "folio": folio, "c_sequence": c_sequence, - "segment": segment_id, }, ) self.assertEqual(response.status_code, 302) @@ -3546,14 +3534,12 @@ def test_update_chant(self): self.assertEqual(chant.manuscript_full_text_std_spelling, "test") def test_volpiano_signal(self): - segment = make_fake_segment() source = make_fake_source() chant_1 = make_fake_chant( manuscript_full_text_std_spelling="ut queant lactose", source=source, folio="001r", c_sequence=1, - segment=segment, ) self.client.post( reverse("source-edit-chants", args=[source.id]), @@ -3566,7 +3552,6 @@ def test_volpiano_signal(self): "volpiano": "9abcdefg)A-B1C2D3E4F5G67?. yiz", # ^ ^ ^ ^ ^ ^ ^^^^^^^^ # clefs, accidentals, etc., to be deleted - "segment": segment.id, }, ) chant_1 = Chant.objects.get( @@ -3580,7 +3565,6 @@ def test_volpiano_signal(self): source=source, folio="001r", c_sequence=2, - segment=segment, ) expected_volpiano: str = "abacadaeafagahaja" expected_intervals: str = "1-12-23-34-45-56-67-78-8" @@ -3591,7 +3575,6 @@ def test_volpiano_signal(self): "folio": "001r", "c_sequence": "2", "volpiano": "abacadaeafagahaja", - "segment": segment.id, }, ) with patch("requests.get", mock_requests_get): @@ -3645,7 +3628,6 @@ def test_proofread_chant(self): "folio": folio, "c_sequence": c_sequence, "manuscript_full_text_std_spelling": ms_std, - "segment": chant.segment_id, }, ) self.assertEqual(response.status_code, 302) # 302 Found diff --git a/django/cantusdb_project/main_app/widgets.py b/django/cantusdb_project/main_app/widgets.py index 36df85145..152b66aaa 100644 --- a/django/cantusdb_project/main_app/widgets.py +++ b/django/cantusdb_project/main_app/widgets.py @@ -1,5 +1,4 @@ from django.forms.widgets import TextInput, Select, Textarea, CheckboxInput -from django.utils.safestring import mark_safe class TextInputWidget(TextInput): diff --git a/django/cantusdb_project/static/js/chant_create.js b/django/cantusdb_project/static/js/chant_create.js index def18978e..fc3ee7027 100644 --- a/django/cantusdb_project/static/js/chant_create.js +++ b/django/cantusdb_project/static/js/chant_create.js @@ -7,18 +7,18 @@ window.addEventListener("load", function () { const standardText = document.getElementById('id_manuscript_full_text_std_spelling').value; document.getElementById('id_manuscript_full_text').value = standardText; } - // Add an event listener to the segment select field. + // Add an event listener to the segment project field. // If the user selects "Benedicamus Domino", show the additional fields - // in the "benedicamus-domino-segment-fields" div. By default, these + // in the "benedicamus-domino-project-fields" div. By default, these // are hidden. - const segmentSelectElem = document.getElementById("id_segment"); - segmentSelectElem.addEventListener("change", function () { - const benedicamusDominoSegmentFields = document.getElementById("benedicamus-domino-segment-fields"); - const selectedElemText = segmentSelectElem.options[segmentSelectElem.selectedIndex].text; + const projectSelectElem = document.getElementById("id_project"); + projectSelectElem.addEventListener("change", function () { + const benedicamusDominoProjectFields = document.getElementById("benedicamus-domino-project-fields"); + const selectedElemText = projectSelectElem.options[projectSelectElem.selectedIndex].text; if (selectedElemText === "Benedicamus Domino") { - benedicamusDominoSegmentFields.hidden = false; + benedicamusDominoProjectFields.hidden = false; } else { - benedicamusDominoSegmentFields.hidden = true; + benedicamusDominoProjectFields.hidden = true; } }); }) diff --git a/django/cantusdb_project/static/js/chant_edit.js b/django/cantusdb_project/static/js/chant_edit.js index b0687b043..0c355bbbe 100644 --- a/django/cantusdb_project/static/js/chant_edit.js +++ b/django/cantusdb_project/static/js/chant_edit.js @@ -47,21 +47,21 @@ window.addEventListener("load", function () { window.location.assign(url); } - // Add an event listener to the segment select field. + // Add an event listener to the project select field. // If the user selects "Benedicamus Domino", show the additional fields - // in the "benedicamus-domino-segment-fields" div. By default, these + // in the "benedicamus-domino-project-fields" div. By default, these // are hidden. - const segmentSelectElem = document.getElementById("id_segment"); - segmentSelectElem.addEventListener("change", function () { - const benedicamusDominoSegmentFields = document.getElementById("benedicamus-domino-segment-fields"); - const selectedElemText = segmentSelectElem.options[segmentSelectElem.selectedIndex].text; + const projectSelectElem = document.getElementById("id_project"); + projectSelectElem.addEventListener("change", function () { + const benedicamusDominoProjectFields = document.getElementById("benedicamus-domino-project-fields"); + const selectedElemText = projectSelectElem.options[projectSelectElem.selectedIndex].text; if (selectedElemText === "Benedicamus Domino") { - benedicamusDominoSegmentFields.hidden = false; + benedicamusDominoProjectFields.hidden = false; } else { - benedicamusDominoSegmentFields.hidden = true; + benedicamusDominoProjectFields.hidden = true; } }); - segmentSelectElem.dispatchEvent(new Event('change')); + projectSelectElem.dispatchEvent(new Event('change')); // ensures that the event listener is called on page load }) function autoFillSuggestedFullText(fullText) { diff --git a/django/cantusdb_project/templates/base.html b/django/cantusdb_project/templates/base.html index 5a34c789e..e31558382 100644 --- a/django/cantusdb_project/templates/base.html +++ b/django/cantusdb_project/templates/base.html @@ -203,7 +203,7 @@ @@ -217,7 +217,7 @@