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

Merge staging into production, 2023 Nov 10 edition #1146

Merged
merged 100 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
ee2a0f5
build(deps): bump urllib3 in /django/cantusdb_project
dependabot[bot] Oct 3, 2023
df9c671
Merge pull request #1083 from DDMAL/dependabot/pip/django/cantusdb_pr…
jacobdgm Oct 3, 2023
c011e91
update update_differentia_new command to raise DeprecationWarning
jacobdgm Oct 3, 2023
2a3393e
rename differentia_new to differentiae_database
jacobdgm Oct 3, 2023
236a2b4
renaming differentia_new to differentiae_database: create migrations
jacobdgm Oct 3, 2023
417031b
Source Detail: ensure line breaks are preserved when displaying sever…
jacobdgm Oct 3, 2023
8a6d070
Merge pull request #1086 from jacobdgm/issue-1084
jacobdgm Oct 3, 2023
124dc91
create remap_user_ids management command
jacobdgm Oct 3, 2023
11868a6
Merge pull request #1087 from jacobdgm/issue-1085
jacobdgm Oct 5, 2023
705f6fa
remap_user_ids command: update command to actually modify objects, an…
jacobdgm Oct 12, 2023
9de8e14
remap_user_ids command: replace print with stdout.write
jacobdgm Oct 12, 2023
d240e4f
base chant: add diff_db field
lucasmarchd01 Oct 12, 2023
b3bf606
models: add differentia model
lucasmarchd01 Oct 12, 2023
7898659
add differentia model to init
lucasmarchd01 Oct 12, 2023
2bb432a
add sync script for differentiae
lucasmarchd01 Oct 12, 2023
6010f59
admin: add differentia model
lucasmarchd01 Oct 12, 2023
1f68c78
base chant: update diff_db foreignkey
lucasmarchd01 Oct 12, 2023
8f5532d
init: fix import statement for differentia
lucasmarchd01 Oct 12, 2023
38ff7dd
apply migration to add diff_db field
lucasmarchd01 Oct 12, 2023
8a695c3
build(deps): bump urllib3 in /django/cantusdb_project
dependabot[bot] Oct 18, 2023
ffc7252
add updated google analytics tag to base.html
jacobdgm Oct 19, 2023
11f6745
add differentia data to sync
lucasmarchd01 Oct 26, 2023
6b6b97c
update add_differentiae sync script
lucasmarchd01 Oct 26, 2023
34bf036
chant detail: use diff_db field to show volpiano snippets
lucasmarchd01 Oct 26, 2023
95bf439
chant admin: hide old differentia_database field
lucasmarchd01 Oct 26, 2023
ad193c6
chant detail: formatting changes to diff_db field
lucasmarchd01 Oct 26, 2023
5435b2f
add diff_db field to chant edit and chant create forms
lucasmarchd01 Oct 26, 2023
ee45933
chant create: add diff_db field
lucasmarchd01 Oct 26, 2023
fe44b94
chant edit: add diff_db field
lucasmarchd01 Oct 26, 2023
076addf
csv export: export diff_db instead of old differentiae_database
lucasmarchd01 Oct 26, 2023
7acd399
Merge pull request #1093 from jacobdgm/analytics
jacobdgm Oct 26, 2023
c4dcefc
remove unused variables in remap_user_ids.py
jacobdgm Oct 26, 2023
3a14faf
add_differentiae: add type annotations
lucasmarchd01 Oct 26, 2023
32a9e59
remap_user_ids command: add type annotations
jacobdgm Oct 26, 2023
e4997cf
remap_user_ids command: replace if statements with try/excepts
jacobdgm Oct 26, 2023
744a29b
remap_user_ids command: fix bug where a chant's updated user was not …
jacobdgm Oct 26, 2023
299b823
Merge pull request #1104 from lucasmarchd01/sync_differentiae_db
lucasmarchd01 Oct 27, 2023
12812ac
remap_user_ids: ensure ids that don't need to be remapped don't get m…
jacobdgm Oct 27, 2023
91504e3
remap_user_ids: add message upon success
jacobdgm Oct 27, 2023
014318a
add_differentiae command: fix Differentia.DoesNotExist error
jacobdgm Oct 27, 2023
d33aa59
add type annotations
jacobdgm Oct 27, 2023
35e54e7
Merge pull request #1113 from jacobdgm/differentiae_fix
jacobdgm Oct 27, 2023
58d2e69
Merge pull request #1111 from jacobdgm/issue-1000
jacobdgm Oct 27, 2023
3705f12
full_index.html: add DD column
jacobdgm Oct 27, 2023
842cb5e
add test_views.ChantIndexViewTest.test_dd_column
jacobdgm Oct 27, 2023
647877f
Merge pull request #1114 from jacobdgm/issue-693
jacobdgm Oct 31, 2023
516fa0f
Merge pull request #1090 from DDMAL/dependabot/pip/django/cantusdb_pr…
jacobdgm Oct 31, 2023
634f7cf
Source admin: hide source status field
lucasmarchd01 Nov 2, 2023
31273a1
Merge pull request #1116 from lucasmarchd01/issue-1107
lucasmarchd01 Nov 2, 2023
37116cd
chant detail: change viewing permissions for proofread fields
lucasmarchd01 Nov 2, 2023
b364fda
chant detail: change viewing permissions for proofread fields
lucasmarchd01 Nov 2, 2023
3867218
change email icon in footer to send email to Debra's email address
jacobdgm Nov 2, 2023
196766a
footer: update copyright date from 2022 to 2023
jacobdgm Nov 2, 2023
7fa52bb
refactor parse_json_from_api -> parse_json_from_ci_api
jacobdgm Nov 2, 2023
d776ea9
remove _refresh_json_con_api and touch_ci_json_con_api
jacobdgm Nov 2, 2023
17de58a
source edit: add autocomplete for provenance
lucasmarchd01 Nov 2, 2023
7812fa6
Stop wrap of staff overflow
dchiller Nov 3, 2023
c60bbe3
Recalculate draw bounds on window resize
dchiller Nov 3, 2023
e37c236
Use relative position references to add melody search notes:
dchiller Nov 3, 2023
244b630
Change drawArea coordinates on resize wo deleting current search
dchiller Nov 3, 2023
51cc445
Merge pull request #1123 from jacobdgm/issue-1122
jacobdgm Nov 3, 2023
7c931a6
add autocomplete widgets for office, genre, and diff_db fields
lucasmarchd01 Nov 3, 2023
766d2a0
source create: add provenance autocomplete
lucasmarchd01 Nov 3, 2023
f592f05
Merge pull request #1121 from lucasmarchd01/issue-1100
lucasmarchd01 Nov 3, 2023
d0c4556
Merge pull request #1130 from dchiller/i-1127-melody-search-bugs
jacobdgm Nov 3, 2023
206e85a
Chant Detail View: remove code related to the display of concordances
jacobdgm Nov 9, 2023
567e2c0
autocomplete: change result label for genre and office
lucasmarchd01 Nov 9, 2023
cb5c7b1
Merge pull request #1131 from lucasmarchd01/issue-1126
lucasmarchd01 Nov 9, 2023
f4c1c1f
chant_detail.html: remove concordances and concordances summary
jacobdgm Nov 9, 2023
6dd1ae3
parsejson_from_ci_api: fix error message that had been incorrect
jacobdgm Nov 9, 2023
a598e41
reformat several lines of comment/docstring which were too long
jacobdgm Nov 9, 2023
f5d05ac
views/chant.py: remove several unused import statements
jacobdgm Nov 9, 2023
92fa045
Chant Create: remove Chant Suggestion feature
jacobdgm Nov 9, 2023
7b18c99
remove CISearchView
jacobdgm Nov 9, 2023
10b3bd3
Edit Chants: remove suggested_fulltext functionality
jacobdgm Nov 9, 2023
edf527d
main_app/urls.py: remove import statement for CISearchView
jacobdgm Nov 9, 2023
34e82b9
main_app/views: remove import statements from __init.py__
jacobdgm Nov 9, 2023
49a1978
remove CISearchViewTest
jacobdgm Nov 9, 2023
7a94dea
test_views: remove unused import statement
jacobdgm Nov 9, 2023
fc188e9
ChantCreateViewTest: delete test_no_suggest test
jacobdgm Nov 9, 2023
1947b2c
remove SourceEditChantsViewTest.test_provide_suggested_fulltext
jacobdgm Nov 9, 2023
d65f424
ChantCreateViewTest: remove test_suggest_one_folio
jacobdgm Nov 9, 2023
1f3fbd7
views/chant.py: improve type annotation
jacobdgm Nov 10, 2023
a211c20
views/chant.py: improve/add type annotations to functions and constants
jacobdgm Nov 10, 2023
ddc228d
Merge pull request #1142 from jacobdgm/issue-1119
jacobdgm Nov 10, 2023
ba702ec
Merge pull request #1145 from DDMAL/develop
jacobdgm Nov 10, 2023
bac09f6
Chant Search: remove option to search for chants without melodies
jacobdgm Nov 10, 2023
871ef9e
Merge pull request #1150 from jacobdgm/1149-chants-wo-melodies
jacobdgm Nov 14, 2023
9abef5c
Revert "chant detail: change viewing permissions for proofread fields"
jacobdgm Nov 14, 2023
acec77f
Merge pull request #1151 from jacobdgm/revert-1121
jacobdgm Nov 15, 2023
be5e33b
Merge pull request #1154 from DDMAL/develop
jacobdgm Nov 15, 2023
10a491f
autocomplete: change genre, office, feast to use icontains search
lucasmarchd01 Nov 16, 2023
a21a816
feast autocomplete: remove search by feast code
lucasmarchd01 Nov 17, 2023
f3a7815
Merge pull request #1156 from lucasmarchd01/issue-1155
jacobdgm Nov 21, 2023
e2d9f62
Chant Create: in sidebar, re-add link to source
jacobdgm Nov 21, 2023
b9de8c9
Merge pull request #1162 from jacobdgm/1161-sidebar
jacobdgm Nov 21, 2023
5e8dd28
Merge pull request #1163 from DDMAL/develop
jacobdgm Nov 21, 2023
eb063fd
disable remap_user_ids command
jacobdgm Nov 23, 2023
355fc59
Merge pull request #1167 from jacobdgm/1166-disable-remap
jacobdgm Nov 23, 2023
5bb070e
Merge pull request #1169 from DDMAL/develop
jacobdgm Nov 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1,273 changes: 1,273 additions & 0 deletions django/cantusdb_project/differentia_data.txt

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions django/cantusdb_project/main_app/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def get_source_siglum(self, obj):
"volpiano_notes",
"volpiano_intervals",
"title",
"differentiae_database",
)
form = AdminChantForm
raw_id_fields = (
Expand All @@ -88,6 +89,13 @@ def get_source_siglum(self, obj):
ordering = ("source__siglum",)


class DifferentiaAdmin(BaseModelAdmin):
search_fields = (
"differentia_id",
"id",
)


class FeastAdmin(BaseModelAdmin):
search_fields = (
"name",
Expand Down Expand Up @@ -164,6 +172,8 @@ def get_source_siglum(self, obj):


class SourceAdmin(BaseModelAdmin):
exclude = ("source_status",)

# These search fields are also available on the user-source inline relationship in the user admin page
search_fields = (
"siglum",
Expand Down Expand Up @@ -211,6 +221,7 @@ class SourceAdmin(BaseModelAdmin):

admin.site.register(Century, CenturyAdmin)
admin.site.register(Chant, ChantAdmin)
admin.site.register(Differentia, DifferentiaAdmin)
admin.site.register(Feast, FeastAdmin)
admin.site.register(Genre, GenreAdmin)
admin.site.register(Notation, NotationAdmin)
Expand Down
65 changes: 11 additions & 54 deletions django/cantusdb_project/main_app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Provenance,
Century,
Sequence,
Differentia,
)
from .widgets import (
TextInputWidget,
Expand Down Expand Up @@ -82,7 +83,7 @@ class Meta:
"feast",
"mode",
"differentia",
"differentia_new",
"diff_db",
"finalis",
"extra",
"chant_range",
Expand All @@ -103,14 +104,14 @@ class Meta:
"marginalia": TextInputWidget(),
# folio: defined below (required)
# c_sequence: defined below (required)
# office: defined below (foreignkey)
# genre: defined below (foreignkey)
"office": autocomplete.ModelSelect2(url="office-autocomplete"),
"genre": autocomplete.ModelSelect2(url="genre-autocomplete"),
"position": TextInputWidget(),
"cantus_id": TextInputWidget(),
"feast": autocomplete.ModelSelect2(url="feast-autocomplete"),
"mode": TextInputWidget(),
"differentia": TextInputWidget(),
"differentia_new": TextInputWidget(),
"diff_db": autocomplete.ModelSelect2(url="differentia-autocomplete"),
"finalis": TextInputWidget(),
"extra": TextInputWidget(),
"chant_range": VolpianoInputWidget(),
Expand All @@ -136,22 +137,6 @@ class Meta:
help_text="Each folio starts with '1'.",
)

# We use NameModelChoiceField here so the dropdown list of office/mass displays the name
# instead of [name] + description
office = NameModelChoiceField(
queryset=Office.objects.all().order_by("name"),
required=False,
)
office.widget.attrs.update({"class": "form-control custom-select custom-select-sm"})

# We use NameModelChoiceField here so the dropdown list of genres displays the name
# instead of [name] + description
genre = NameModelChoiceField(
queryset=Genre.objects.all().order_by("name"),
required=False,
)
genre.widget.attrs.update({"class": "form-control custom-select custom-select-sm"})

manuscript_full_text_std_spelling = forms.CharField(
required=True,
widget=TextAreaWidget,
Expand Down Expand Up @@ -206,6 +191,7 @@ class Meta:
widgets = {
"title": TextInputWidget(),
"siglum": TextInputWidget(),
"provenance": autocomplete.ModelSelect2(url="provenance-autocomplete"),
"provenance_notes": TextInputWidget(),
"date": TextInputWidget(),
"cursus": SelectWidget(),
Expand Down Expand Up @@ -238,13 +224,6 @@ class Meta:
),
}

provenance = forms.ModelChoiceField(
queryset=Provenance.objects.all().order_by("name"), required=False
)
provenance.widget.attrs.update(
{"class": "form-control custom-select custom-select-sm"}
)

TRUE_FALSE_CHOICES_SOURCE = (
(True, "Full source"),
(False, "Fragment or Fragmented"),
Expand Down Expand Up @@ -283,7 +262,7 @@ class Meta:
"mode",
"finalis",
"differentia",
"differentia_new",
"diff_db",
"extra",
"image_link",
"indexing_notes",
Expand All @@ -302,15 +281,15 @@ class Meta:
# folio: defined below (required)
# c_sequence: defined below (required)
"feast": autocomplete.ModelSelect2(url="feast-autocomplete"),
# office: defined below (foreignkey)
# genre: defined below (foreignkey)
"office": autocomplete.ModelSelect2(url="office-autocomplete"),
"genre": autocomplete.ModelSelect2(url="genre-autocomplete"),
"position": TextInputWidget(),
"cantus_id": TextInputWidget(),
"melody_id": TextInputWidget(),
"mode": TextInputWidget(),
"finalis": TextInputWidget(),
"differentia": TextInputWidget(),
"differentia_new": TextInputWidget(),
"diff_db": autocomplete.ModelSelect2(url="differentia-autocomplete"),
"extra": TextInputWidget(),
"image_link": TextInputWidget(),
"indexing_notes": TextAreaWidget(),
Expand Down Expand Up @@ -346,22 +325,6 @@ class Meta:
help_text="Each folio starts with '1'.",
)

# We use NameModelChoiceField here so the dropdown list of office/mass displays the name
# instead of [name] + description
office = NameModelChoiceField(
queryset=Office.objects.all().order_by("name"),
required=False,
)
office.widget.attrs.update({"class": "form-control custom-select custom-select-sm"})

# We use NameModelChoiceField here so the dropdown list of genres displays the name
# instead of [name] + description
genre = NameModelChoiceField(
queryset=Genre.objects.all().order_by("name"),
required=False,
)
genre.widget.attrs.update({"class": "form-control custom-select custom-select-sm"})


class SourceEditForm(forms.ModelForm):
class Meta:
Expand Down Expand Up @@ -396,6 +359,7 @@ class Meta:
"title": TextInputWidget(),
"rism_siglum": autocomplete.ModelSelect2(url="rismsiglum-autocomplete"),
"siglum": TextInputWidget(),
"provenance": autocomplete.ModelSelect2(url="provenance-autocomplete"),
"provenance_notes": TextInputWidget(),
"date": TextInputWidget(),
"summary": TextAreaWidget(),
Expand Down Expand Up @@ -427,13 +391,6 @@ class Meta:
),
}

provenance = forms.ModelChoiceField(
queryset=Provenance.objects.all().order_by("name"), required=False
)
provenance.widget.attrs.update(
{"class": "form-control custom-select custom-select-sm"}
) # adds styling

CHOICES_FULL_SOURCE = (
(None, "None"),
(True, "Full source"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
from main_app.models import Chant, Differentia
from django.core.management.base import BaseCommand
from typing import List, Optional
from django.db.models.query import QuerySet


# Python script to sync the differentia database with CantusDB. Previously, we had a CharField that represented
# the differentia ID. Now, we change this field to a ForeignKey that points to the new Differentia model that contains
# the ID, melodic transcription, and mode.


DIFFERENTIA_DATA = "differentia_data.txt"


class Command(BaseCommand):
def handle(self, *args, **options):
differentia_database: List[List[str]] = get_differentia_data(DIFFERENTIA_DATA)
total: int = len(differentia_database)
count: int = 0
for item in differentia_database:
differentia_id: str
melodic_transcription: str
mode: str
differentia_id, melodic_transcription, mode, _ = item
differentia: Optional[Differentia] = None
try:
differentia = Differentia.objects.get(differentia_id=differentia_id)
except Differentia.DoesNotExist:
pass

if differentia:
differentia.melodic_transcription = melodic_transcription
differentia.mode = mode
differentia.save()
else:
differentia = Differentia(
differentia_id=differentia_id,
melodic_transcription=melodic_transcription,
mode=mode,
)
differentia.save()
if count % 100 == 0:
print(
f"------------------- {count} of {total} differentia created -------------------"
)
count += 1

CHUNK_SIZE = 1_000
chants: QuerySet[Chant] = Chant.objects.all()
chants_count: int = chants.count()
start_index: int = 0
count: int = 0
while start_index <= chants_count:
print("processing chunk with start_index of", start_index)
chunk: QuerySet[Chant] = chants[start_index : start_index + CHUNK_SIZE]

# Update Chant model to use foreign key
for chant in chunk:
try:
differentia_id: Optional[str] = chant.differentiae_database
if not differentia_id is None:
differentia = Differentia.objects.filter(
differentia_id=differentia_id
).first()

if differentia:
chant.diff_db = differentia
else:
# If the Differentia doesn't exist, create a new one
differentia: Differentia = Differentia(
differentia_id=differentia_id,
)
differentia.save()
chant.diff_db = differentia

chant.save()
if count % 100 == 0:
print(
f"------------------- {count} of {chants_count} chants updated -------------------"
)
except Differentia.DoesNotExist:
print(f"Differentia not found for chant: {chant}")
count += 1
del chunk # make sure we don't use too much RAM
start_index += CHUNK_SIZE


def get_differentia_data(filename) -> List[List[str]]:
differentia_list: List = []
with open(filename, "r") as file:
for line in file:
line: str = line.strip()
values: tuple = tuple(line.split(","))
differentia_list.append(values)
return differentia_list