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

feat: add neume exemplars for omr neume search #915

Merged
merged 4 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/public/cantusdata/admin/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ManuscriptAdmin(ModelAdmin): # type: ignore[type-arg]
actions = [reindex_in_solr, "load_chants"]
ordering = ["-public", "name"]
list_per_page = 200
change_form_template = "admin/manuscript_change_form.html"
fieldsets = [
(
"Metadata",
Expand Down
32 changes: 32 additions & 0 deletions app/public/cantusdata/helpers/iiif_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Functions for IIIF API boilerplate.
"""


def construct_image_api_url(image_uri: str, **kwargs: str | int) -> str:
"""
Construct a IIIF image API request URL from an Image URI and
a set of apotion IIIF Image API parameters. Works with the Image
API v2 and v3.
Required parameters:
- image_uri: The URI of the image to request.
Optional parameters (see API docs, eg. https://iiif.io/api/image/2.1/):
- region: The region of the image to request. Region should be a string
that conforms to the IIIF Image API specification (see link above).
- size: The size of the image to request.
- rotation: The rotation of the image to request.
- quality: The quality of the image to request.
- format: The format of the image to request.
Returns:
The constructed IIIF image API request URL.
"""
region = kwargs.get("region", "full") # Default to full image
size = kwargs.get("size", "pct:50") # Default to 50% of the original size
rotation = kwargs.get("rotation", "0") # Default to no rotation
quality = kwargs.get("quality", "default") # Default to default quality
img_format = kwargs.get("format", "jpg") # Default to JPEG format
return f"{image_uri}/{region}/{size}/{rotation}/{quality}.{img_format}"
247 changes: 0 additions & 247 deletions app/public/cantusdata/management/commands/pick_neume_exemplars.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.0.7 on 2024-09-19 18:10

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("cantusdata", "0003_chant_differentiae_database"),
]

operations = [
migrations.AlterModelOptions(
name="neumeexemplar",
options={"ordering": ["order"]},
),
migrations.AddField(
model_name="neumeexemplar",
name="order",
field=models.IntegerField(
default=1,
help_text="A helper field used to order the exemplars.\n See helpers/neume_helpers.py for an explanation of how this is used.",
),
),
]
3 changes: 2 additions & 1 deletion app/public/cantusdata/models/manuscript.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from django.db.models.query import QuerySet
from django.core.management import call_command
from django.utils.text import slugify
import threading
Expand Down Expand Up @@ -82,7 +83,7 @@ def siglum_slug(self):
return slugify(self.siglum)

@property
def neume_exemplars(self):
def neume_exemplars(self) -> QuerySet[NeumeExemplar]:
return NeumeExemplar.objects.filter(folio__manuscript=self)

def create_solr_record(self):
Expand Down
Loading
Loading