diff --git a/django/cantusdb_project/main_app/forms.py b/django/cantusdb_project/main_app/forms.py index ad150622b..322a70870 100644 --- a/django/cantusdb_project/main_app/forms.py +++ b/django/cantusdb_project/main_app/forms.py @@ -42,6 +42,15 @@ (False, "Partial inventory"), ) +# Define choices for Chant model's +# various proofreading fields: manuscript_full_text_std_proofread, +# manuscript_full_text_proofread, volpiano_proofread +PROOFREAD_CHOICES = [ + (None, "Any"), + (True, "Yes"), + (False, "No"), +] + class NameModelChoiceField(forms.ModelChoiceField): """ @@ -520,6 +529,28 @@ class Meta: ) +class SourceBrowseChantsProofreadForm(forms.Form): + manuscript_full_text_std_proofread = forms.ChoiceField( + label="Full text as in Source (standardized spelling) proofread", + choices=PROOFREAD_CHOICES, + widget=forms.RadioSelect, + required=False, + ) + manuscript_full_text_proofread = forms.ChoiceField( + label="Full text as in Source (source spelling) proofread", + choices=PROOFREAD_CHOICES, + widget=forms.RadioSelect, + required=False, + ) + + volpiano_proofread = forms.ChoiceField( + label="Volpiano proofread", + choices=PROOFREAD_CHOICES, + widget=forms.RadioSelect, + required=False, + ) + + class SequenceEditForm(forms.ModelForm): class Meta: model = Sequence diff --git a/django/cantusdb_project/main_app/permissions.py b/django/cantusdb_project/main_app/permissions.py index c5c647485..4bbd65d82 100644 --- a/django/cantusdb_project/main_app/permissions.py +++ b/django/cantusdb_project/main_app/permissions.py @@ -54,14 +54,29 @@ def user_can_proofread_chant(user: User, chant: Chant) -> bool: if user.is_anonymous: return False - source_id = chant.source.id - user_is_assigned_to_source = user.sources_user_can_edit.filter( # type: ignore[attr-defined] + source = chant.source + return user_can_proofread_source(user, source) + + +def user_can_proofread_source(user: User, source: Source) -> bool: + """ + Checks if the user can access the proofreading page of a given Source. + Used in SourceBrowseChantsView. + """ + if user.is_superuser: + return True + + if user.is_anonymous: + return False + + source_id = source.id + user_is_assigned_to_source: bool = user.sources_user_can_edit.filter( # type: ignore[attr-defined] id=source_id ).exists() user_groups = user.groups.all().values_list("name", flat=True) - user_is_pm = "project manager" in user_groups - user_is_editor = "editor" in user_groups + user_is_pm: bool = "project manager" in user_groups + user_is_editor: bool = "editor" in user_groups return user_is_pm or (user_is_editor and user_is_assigned_to_source) diff --git a/django/cantusdb_project/main_app/templates/browse_chants.html b/django/cantusdb_project/main_app/templates/browse_chants.html index c06f3125a..8ac640490 100644 --- a/django/cantusdb_project/main_app/templates/browse_chants.html +++ b/django/cantusdb_project/main_app/templates/browse_chants.html @@ -58,6 +58,21 @@
View | Edit
{% endif %} - -{{ chant.diff_db.melodic_transcription }}
++ {{ chant.diff_db.melodic_transcription }} +
{% endif %} - + {{ chant.diff_db }} -{{ chant.chant_range }}
++ {{ chant.chant_range }} +
{{ chant.volpiano }}
++ {{ chant.volpiano }} +
Syllabification is based on saved syllabized text.
++ Syllabification is based on saved syllabized text. +
{% endif %}{{ syl_text }}
{{ syl_text }}+
- For concordances, please consult the - Cantus Index entry for Cantus ID - {{ chant.cantus_id }}. -
- -