diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d60b39e14..66cba9691 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -22,12 +22,12 @@ jobs: uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: 3.8 - name: Install and Run Pre-commit - uses: pre-commit/action@v2.0.0 + uses: pre-commit/action@v3.0.1 pytest: runs-on: ubuntu-latest diff --git a/src/rard/research/forms.py b/src/rard/research/forms.py index dee57e8b1..5c0c4b12d 100644 --- a/src/rard/research/forms.py +++ b/src/rard/research/forms.py @@ -900,7 +900,8 @@ class Meta: class TestimoniumForm(HistoricalFormBase): class Meta: model = Testimonium - fields = () + fields = ("tags",) + widgets = {"tags": forms.CheckboxSelectMultiple} class BaseLinkWorkForm(forms.ModelForm): diff --git a/src/rard/research/migrations/0075_add_testimonium_tags.py b/src/rard/research/migrations/0075_add_testimonium_tags.py new file mode 100644 index 000000000..804d4b591 --- /dev/null +++ b/src/rard/research/migrations/0075_add_testimonium_tags.py @@ -0,0 +1,42 @@ +# Generated by Django 3.2 on 2025-04-28 10:45 + +from django.db import migrations, models + + +def create_testimonium_tags(apps, schema_editor): + TestimoniumTag = apps.get_model('research', 'TestimoniumTag') + tags = [ + "Biography: Intellectual (Modus Operandi)", + "Biography: General", + ] + for tag in tags: + TestimoniumTag.objects.create(name=tag) + +class Migration(migrations.Migration): + + dependencies = [ + ('research', '0074_adding_intros_to_citing_authors_works'), + ] + + operations = [ + migrations.CreateModel( + name='TestimoniumTag', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=128, unique=True)), + ], + options={ + 'verbose_name': 'Testimonium Tag', + 'verbose_name_plural': 'Testimonium Tags', + }, + ), + migrations.AddField( + model_name='testimonium', + name='tags', + field=models.ManyToManyField(blank=True, related_name='testimonia', to='research.TestimoniumTag', verbose_name='Tags'), + ), + migrations.RunPython( + create_testimonium_tags, + reverse_code=migrations.RunPython.noop, + ) + ] diff --git a/src/rard/research/models/__init__.py b/src/rard/research/models/__init__.py index 228927b8d..6a0ce7c97 100644 --- a/src/rard/research/models/__init__.py +++ b/src/rard/research/models/__init__.py @@ -10,7 +10,7 @@ from .original_text import Concordance, OriginalText, Translation from .reference import Reference from .symbols import Symbol, SymbolGroup -from .testimonium import Testimonium +from .testimonium import Testimonium, TestimoniumTag from .text_object_field import PublicCommentaryMentions, TextObjectField from .topic import Topic from .work import Book, Work @@ -34,6 +34,7 @@ "Symbol", "SymbolGroup", "Testimonium", + "TestimoniumTag", "TextObjectField", "Topic", "TopicLink", diff --git a/src/rard/research/models/testimonium.py b/src/rard/research/models/testimonium.py index 779d902c1..8bb846196 100644 --- a/src/rard/research/models/testimonium.py +++ b/src/rard/research/models/testimonium.py @@ -1,4 +1,5 @@ from django.contrib.contenttypes.fields import GenericRelation +from django.db import models from django.urls import reverse from simple_history.models import HistoricalRecords @@ -9,6 +10,21 @@ from .base import HistoricalBaseModel, TestimoniumLink +class TestimoniumTag(models.Model): + """ + A tag for a Testimonium. + """ + + class Meta: + verbose_name = "Testimonium Tag" + verbose_name_plural = "Testimonium Tags" + + name = models.CharField(max_length=128, blank=False, unique=True) + + def __str__(self): + return self.name + + class Testimonium(HistoryModelMixin, HistoricalBaseModel): history = HistoricalRecords( excluded_fields=[ @@ -22,6 +38,12 @@ def related_lock_object(self): LINK_TYPE = TestimoniumLink original_texts = GenericRelation("OriginalText", related_query_name="testimonia") + tags = models.ManyToManyField( + TestimoniumTag, + blank=True, + related_name="testimonia", + verbose_name="Tags", + ) def definite_book_links(self): return ( diff --git a/src/rard/static/css/project.css b/src/rard/static/css/project.css index 3ba33d83d..82c911662 100644 --- a/src/rard/static/css/project.css +++ b/src/rard/static/css/project.css @@ -599,3 +599,9 @@ section.footnotes { opacity: 1; visibility: visible; } + +#searchHelpBlock { + a { + font-size: 100% !important; + } +} diff --git a/src/rard/templates/research/partials/testimonium_link_list_item.html b/src/rard/templates/research/partials/testimonium_link_list_item.html index 98cea1364..77ad8d3c8 100644 --- a/src/rard/templates/research/partials/testimonium_link_list_item.html +++ b/src/rard/templates/research/partials/testimonium_link_list_item.html @@ -20,6 +20,9 @@ {{ link_text }} {% endif %} {% endwith %} + {% for tag in link.testimonium.tags.all %} + {{ tag }} + {% endfor %} diff --git a/src/rard/templates/research/search_results.html b/src/rard/templates/research/search_results.html index 89cffb675..ae5f68da2 100644 --- a/src/rard/templates/research/search_results.html +++ b/src/rard/templates/research/search_results.html @@ -69,8 +69,7 @@ match zero or more characters with {{WILDCARD_MANY_CHAR}}, or match proximity with "word1 ~n:m word2" where n and m indicate the upper and lower bounds for the number of intervening words. - Wilcards can be used with proximity searches; e.g. - 'hort?m ~1 biblio*'. + See Search docs for details.