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-Sept-07 edition #1027

Merged
merged 26 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
57137e6
admin: allow search by id for chant/sequence
lucasmarchd01 Aug 21, 2023
3a7ab57
remove unnecessary print statements in views/redirect_documents
jacobdgm Aug 21, 2023
0cd9751
Merge pull request #1007 from lucasmarchd01/admin-id-search
lucasmarchd01 Aug 21, 2023
f9cd36b
Merge pull request #1008 from jacobdgm/remove-print-statements
jacobdgm Aug 21, 2023
3cc8a1d
chant edit: insert "add chant" link to volpiano edit page
lucasmarchd01 Aug 22, 2023
7623687
chant proofread: insert "add chant/source" links
lucasmarchd01 Aug 22, 2023
9d069dd
source foreignkey: make migrations to remove null=True, blank=True
lucasmarchd01 Aug 24, 2023
87c534d
test views: fix chants/sequences created without sources
lucasmarchd01 Aug 24, 2023
e5a6d80
test views: remove print statement
lucasmarchd01 Aug 24, 2023
a262c3e
Chant Detail: display differentia_new
jacobdgm Aug 29, 2023
410ce4f
Merge pull request #1015 from jacobdgm/issue-1014
jacobdgm Aug 29, 2023
aaa4459
make Short Video Intro open in new tab
jacobdgm Aug 29, 2023
c1665d3
chant edit: reformat div styling on links
lucasmarchd01 Aug 29, 2023
0579670
Merge pull request #1017 from jacobdgm/issue-1012b
jacobdgm Aug 29, 2023
ce2f7f3
Chant Create: add cid_clean to suggested_chant_dict
jacobdgm Aug 30, 2023
7f08715
Chant Create: add title attributes to various suggested-chant elements
jacobdgm Aug 30, 2023
449445b
Chant Create: rename variable: chant -> cantus_id
jacobdgm Aug 30, 2023
52c0b62
Chant Create: suggested_chants: ensure colons are removed from cid_clean
jacobdgm Aug 30, 2023
5e86f3b
apply styling changes to links on chant edit and chant proofread
lucasmarchd01 Aug 30, 2023
2bc874f
add management command to create unknown sources
lucasmarchd01 Aug 30, 2023
154185d
Merge pull request #1011 from lucasmarchd01/issue-1004
lucasmarchd01 Sep 7, 2023
066a9ec
management: separate if statements for chants and sequences sources
lucasmarchd01 Sep 7, 2023
ec30927
Merge pull request #1013 from lucasmarchd01/issue-996
lucasmarchd01 Sep 7, 2023
8e0a0af
Chant Create: ensure autofill function names will always be unique
jacobdgm Sep 7, 2023
7d46845
Merge pull request #1019 from jacobdgm/issue-998
jacobdgm Sep 7, 2023
d59c14b
Merge pull request #1026 from DDMAL/develop
jacobdgm Sep 7, 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
8 changes: 6 additions & 2 deletions django/cantusdb_project/main_app/admin.py
Expand Up @@ -43,7 +43,8 @@ class CenturyAdmin(BaseModelAdmin):
class ChantAdmin(BaseModelAdmin):
@admin.display(description="Source Siglum")
def get_source_siglum(self, obj):
return obj.source.siglum
if obj.source:
return obj.source.siglum

list_display = (
"incipit",
Expand All @@ -54,6 +55,7 @@ def get_source_siglum(self, obj):
"title",
"incipit",
"cantus_id",
"id",
)
list_filter = (
"genre",
Expand Down Expand Up @@ -124,12 +126,14 @@ class SegmentAdmin(BaseModelAdmin):
class SequenceAdmin(BaseModelAdmin):
@admin.display(description="Source Siglum")
def get_source_siglum(self, obj):
return obj.source.siglum
if obj.source:
return obj.source.siglum

search_fields = (
"title",
"incipit",
"cantus_id",
"id",
)
exclude = EXCLUDE + (
"c_sequence",
Expand Down
@@ -0,0 +1,32 @@
from django.core.management.base import BaseCommand
from main_app.models import Source, Sequence, Chant, Segment


class Command(BaseCommand):
def handle(self, *args, **options):
cantus_segment = Segment.objects.get(id=4063)
calvin_segment = Segment.objects.get(id=4064)
chants = Chant.objects.all().filter(source__isnull=True)
sequences = Sequence.objects.all().filter(source__isnull=True)

if len(chants) > 0:
unknown_source_chants = Source.objects.create(
segment=cantus_segment,
siglum="Unknown",
published=False,
title="Unknown Source (Chants)",
)
for c in chants:
c.source = unknown_source_chants
c.save()

if len(sequences) > 0:
unknown_source_sequences = Source.objects.create(
segment=calvin_segment,
siglum="Unknown",
published=False,
title="Unknown Source (Sequences)",
)
for s in sequences:
s.source = unknown_source_sequences
s.save()
@@ -0,0 +1,32 @@
# Generated by Django 4.2.3 on 2023-08-24 15:33

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("main_app", "0002_unaccent"),
]

operations = [
migrations.AlterField(
model_name="chant",
name="source",
field=models.ForeignKey(
default="",
on_delete=django.db.models.deletion.CASCADE,
to="main_app.source",
),
),
migrations.AlterField(
model_name="sequence",
name="source",
field=models.ForeignKey(
default="",
on_delete=django.db.models.deletion.CASCADE,
to="main_app.source",
),
),
]
@@ -0,0 +1,28 @@
# Generated by Django 4.2.3 on 2023-08-24 15:58

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("main_app", "0003_alter_chant_source_alter_sequence_source"),
]

operations = [
migrations.AlterField(
model_name="chant",
name="source",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="main_app.source"
),
),
migrations.AlterField(
model_name="sequence",
name="source",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="main_app.source"
),
),
]
3 changes: 1 addition & 2 deletions django/cantusdb_project/main_app/models/base_chant.py
Expand Up @@ -44,9 +44,8 @@ class Meta:
col2 = models.CharField(blank=True, null=True, max_length=255)
col3 = models.CharField(blank=True, null=True, max_length=255)
ah_volume = models.CharField(blank=True, null=True, max_length=255)
# Note that some chants do not have a source
source = models.ForeignKey(
"Source", on_delete=models.CASCADE, null=True, blank=True
"Source", on_delete=models.CASCADE
) # PROTECT so that we can't delete a source with chants in it
cantus_id = models.CharField(blank=True, null=True, max_length=255, db_index=True)
image_link = models.URLField(blank=True, null=True)
Expand Down
14 changes: 7 additions & 7 deletions django/cantusdb_project/main_app/templates/chant_create.html
Expand Up @@ -248,14 +248,14 @@ <h5><a id="source" href="{% url 'source-detail' source.id %}">{{ source.title }}
{{ previous_chant.folio }} {{ previous_chant.c_sequence}} <a href="{% url 'chant-detail' previous_chant.id %}" target="_blank">{{ previous_chant.incipit }}</a><br>
Cantus ID: <a href="https://cantusindex.org/id/{{ previous_chant.cantus_id }}" target="_blank">{{ previous_chant.cantus_id }}</a><br>
{% if suggested_chants %}
{% for chant in suggested_chants %}
<input type="button" style="width: 80px" value="{{ chant.cid }}" onclick="autoFill{{ chant.cid }}()"></input>
<strong>{{ chant.genre }}</strong> - {{ chant.fulltext|truncatechars:100 }} (<strong>{{ chant.count }}x</strong>)<br>
{% for cantus_id in suggested_chants %}
<input type="button" style="width: 80px" value="{{ cantus_id.cid }}" onclick="autoFill{{ cantus_id.cid_clean }}()" title="{{ cantus_id.cid }}"></input>
<strong>{{ cantus_id.genre }}</strong> - <span title="{{ cantus_id.fulltext }}">{{ cantus_id.fulltext|truncatechars:100 }}</span> (<strong>{{ cantus_id.count }}x</strong>)<br>
<script>
function autoFill{{ chant.cid }}() {
document.getElementById('id_cantus_id').value = "{{ chant.cid }}";
document.getElementById('id_genre').value = {{ chant.genre_id }};
document.getElementById('id_manuscript_full_text_std_spelling').value = "{{ chant.fulltext }}";
function autoFill{{ cantus_id.cid_clean }}() {
document.getElementById('id_cantus_id').value = "{{ cantus_id.cid }}";
document.getElementById('id_genre').value = {{ cantus_id.genre_id }};
document.getElementById('id_manuscript_full_text_std_spelling').value = "{{ cantus_id.fulltext }}";
}
</script>
{% endfor %}
Expand Down
11 changes: 11 additions & 0 deletions django/cantusdb_project/main_app/templates/chant_detail.html
Expand Up @@ -129,6 +129,17 @@ <h3>{{ chant.incipit }}</h3>
</div>
{% endif %}

{% if chant.differentia_new %}
<div class="col">
<dt>Differentia&nbsp;Database</dt>
<dd>
<a href="https://differentiaedatabase.ca/differentia/{{ chant.differentia_new }}" target="_blank">
{{ chant.differentia_new }}
</a>
</dd>
</div>
{% endif %}

{% if chant.chant_range %}
<div class="col">
<dt>Range</dt>
Expand Down
24 changes: 16 additions & 8 deletions django/cantusdb_project/main_app/templates/chant_edit.html
Expand Up @@ -235,14 +235,22 @@ <h3>Full text &amp; Volpiano edit form</h3>
<dd><small>3) The <b>fulltext</b> and <b>Volpiano</b> fields should appear in this area</small></dd>
<dd><small>4) Edit the fields <b>according to the manuscript, following the fulltext guidelines created by Cantus</b></small></dd>
<dd><small>5) Click <b>"SAVE"</b></small></dd>
</dl>
<a href="{% url "source-create" %}" style="display: inline-block; margin-top:5px;">
<small><b>&plus; Add new source</b></small>
</a>
<br>
<a href="{% url 'source-detail' source.id %}" title="{{ source.title }}" style="display: inline-block; margin-top:5px;">
{{ source.siglum }}
</a>
</dl>
<div style="margin-top:5px;">
<a href="{% url 'source-detail' source.id %}" title="{{ source.title }}">
{{ source.siglum }}
</a>
</div>
<div style="margin-top:5px;">
<a href="{% url "chant-create" source.pk %}">
<small><b>&plus; Add new chant</b></small>
</a>
</div>
<div style="margin-top:5px;">
<a href="{% url "source-create" %}">
<small><b>&plus; Add new source</b></small>
</a>
</div>
{% endif %}
</div>

Expand Down
17 changes: 16 additions & 1 deletion django/cantusdb_project/main_app/templates/chant_proofread.html
Expand Up @@ -243,7 +243,22 @@ <h3>Proofreading tool</h3>
<dd><small>1) Select a <b>folio</b> or a <b>feast</b> (in the right block)</small></dd>
<dd><small>2) Click <b>"EDIT"</b> next to any chant</small></dd>
<dd><small>3) Proofread the chant and click <b>"SAVE"</b></small></dd>
</dl>
</dl>
<div style="margin-top:5px;">
<a href="{% url 'source-detail' source.id %}" title="{{ source.title }}">
{{ source.siglum }}
</a>
</div>
<div style="margin-top:5px;">
<a href="{% url "chant-create" source.pk %}">
<small><b>&plus; Add new chant</b></small>
</a>
</div>
<div style="margin-top:5px;">
<a href="{% url "source-create" %}">
<small><b>&plus; Add new source</b></small>
</a>
</div>
{% endif %}
</div>

Expand Down
10 changes: 6 additions & 4 deletions django/cantusdb_project/main_app/tests/test_views.py
Expand Up @@ -766,7 +766,6 @@ def test_published_vs_unpublished(self):
source.save()
response = self.client.get(reverse("chant-detail", args=[chant.id]))
self.assertEqual(response.status_code, 200)
print(response.context)

source.published = False
source.save()
Expand Down Expand Up @@ -5188,7 +5187,8 @@ def setUp(self):
def test_chant_redirect(self):
# generate dummy object with ID in valid range
example_chant_id = random.randrange(1, 1000000)
Chant.objects.create(id=example_chant_id)
source = make_fake_source()
Chant.objects.create(id=example_chant_id, source=source)

# find dummy object using /node/ path
response_1 = self.client.get(
Expand Down Expand Up @@ -5218,7 +5218,8 @@ def test_source_redirect(self):
def test_sequence_redirect(self):
# generate dummy object with ID in valid range
example_sequence_id = random.randrange(1, 1000000)
Sequence.objects.create(id=example_sequence_id)
source = make_fake_source()
Sequence.objects.create(id=example_sequence_id, source=source)

# find dummy object using /node/ path
response_1 = self.client.get(
Expand Down Expand Up @@ -5274,7 +5275,8 @@ def test_bad_redirect(self):
def test_redirect_above_limit(self):
# generate dummy object with ID outside of valid range
over_limit_node_id = 1000001
Chant.objects.create(id=over_limit_node_id)
source = make_fake_source()
Chant.objects.create(id=over_limit_node_id, source=source)

# ID above limit
response_1 = self.client.get(
Expand Down
5 changes: 5 additions & 0 deletions django/cantusdb_project/main_app/views/chant.py
Expand Up @@ -204,6 +204,11 @@ def make_suggested_chant_dict(
genre_name = cid_dict["genre"]
genre_id = Genre.objects.get(name=genre_name).id
cid_dict["genre_id"] = genre_id
# in the template, we create a js function based on the cantus ID. The function name
# cannot include a "." or a ":", so we have to use a cleaned version
cid_clean = cantus_id.replace(".", "d").replace(":", "c")
# "d"ot "c"olon
cid_dict["cid_clean"] = cid_clean
return cid_dict


Expand Down
2 changes: 0 additions & 2 deletions django/cantusdb_project/main_app/views/views.py
Expand Up @@ -947,8 +947,6 @@ def redirect_documents(request) -> HttpResponse:
try:
new_path = mapping[old_path]
except KeyError:
print("key error!")
print(old_path)
raise Http404
return redirect(new_path)

Expand Down
2 changes: 1 addition & 1 deletion django/cantusdb_project/templates/base.html
Expand Up @@ -184,7 +184,7 @@
Explanation</a>
<a class="dropdown-item" href="/about/acknowledgements/">Acknowledgements</a>
<a class="dropdown-item" href="/about/faq/">FAQ</a>
<a class="dropdown-item" href="https://www.youtube.com/watch?v=iMmGrUxhPj4">Short Video
<a class="dropdown-item" href="https://www.youtube.com/watch?v=iMmGrUxhPj4" target="_blank">Short Video
Introduction (YouTube)</a>
{% if request.user.is_authenticated %}
<a class="dropdown-item" href="{% url 'items-count' %}">Items Count</a>
Expand Down