From a87736452d908fffd41d1bdee64a0a996fcae3ad Mon Sep 17 00:00:00 2001 From: tcouch Date: Mon, 28 Apr 2025 11:07:48 +0100 Subject: [PATCH 1/7] Include link to search docs in search form help text --- src/rard/static/css/project.css | 6 ++++++ src/rard/templates/research/search_results.html | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rard/static/css/project.css b/src/rard/static/css/project.css index 3ba33d83..82c91166 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/search_results.html b/src/rard/templates/research/search_results.html index 89cffb67..ae5f68da 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.
From 50a816364209aa6d97ec2dd4912e8b8603dbd446 Mon Sep 17 00:00:00 2001 From: tcouch Date: Mon, 28 Apr 2025 11:57:11 +0100 Subject: [PATCH 2/7] Create testimonium tags model, link to testimonium and add migration with initial tags --- .../migrations/0075_add_testimonium_tags.py | 43 +++++++++++++++++++ src/rard/research/models/testimonium.py | 22 ++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/rard/research/migrations/0075_add_testimonium_tags.py 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 00000000..f82f2b8d --- /dev/null +++ b/src/rard/research/migrations/0075_add_testimonium_tags.py @@ -0,0 +1,43 @@ +# 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 = [ + "Modus Operandi", + "Biography: Family", + "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/testimonium.py b/src/rard/research/models/testimonium.py index 779d902c..8bb84619 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 ( From 179ec44c518856747b7f7c4215519deaa99d8e02 Mon Sep 17 00:00:00 2001 From: tcouch Date: Mon, 28 Apr 2025 13:00:55 +0100 Subject: [PATCH 3/7] update initial tags --- src/rard/research/migrations/0075_add_testimonium_tags.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rard/research/migrations/0075_add_testimonium_tags.py b/src/rard/research/migrations/0075_add_testimonium_tags.py index f82f2b8d..804d4b59 100644 --- a/src/rard/research/migrations/0075_add_testimonium_tags.py +++ b/src/rard/research/migrations/0075_add_testimonium_tags.py @@ -6,8 +6,7 @@ def create_testimonium_tags(apps, schema_editor): TestimoniumTag = apps.get_model('research', 'TestimoniumTag') tags = [ - "Modus Operandi", - "Biography: Family", + "Biography: Intellectual (Modus Operandi)", "Biography: General", ] for tag in tags: From 2c3da4170222ba485f4fae0cad8cc4b09706b1ad Mon Sep 17 00:00:00 2001 From: tcouch Date: Mon, 28 Apr 2025 13:01:28 +0100 Subject: [PATCH 4/7] Include tags in testimonium form and show on detail page --- src/rard/research/forms.py | 3 ++- .../research/testimonium_detail.html | 21 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/rard/research/forms.py b/src/rard/research/forms.py index dee57e8b..5c0c4b12 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/templates/research/testimonium_detail.html b/src/rard/templates/research/testimonium_detail.html index 217894be..57420c57 100644 --- a/src/rard/templates/research/testimonium_detail.html +++ b/src/rard/templates/research/testimonium_detail.html @@ -33,18 +33,19 @@
{% trans 'Details' %}
{% trans 'Name' %}
{{ object.get_display_name }}
- {% if object.topics is not None %} -
{% trans 'Topics' %}
-
- {% if object.topics.count == 0%}-{% endif %} - {% for topic in object.topics.all %}{% if forloop.counter0 > 0 %}, {% endif %} - {% if perms.research.view_topic %} - {{ topic.name }} - {% else %} - {{ topic.name }} - {% endif %} + {% if object.tags is not None %} +
{% trans 'Tags' %}
+
+ {% if object.tags.count == 0%}-{% endif %} + {% for tag in object.tags.all %} + {{ tag.name }}{% if not forloop.last %}, {% endif %} {% endfor %}
+
+ {% if perms.research.change_testimonium and has_object_lock %} + {% trans 'Edit' %} + {% endif %} +
{% endif %}
{% trans 'Original Texts' %}
From 4fd8751bee2fc9b1f5d531255fceb2bccd3b3094 Mon Sep 17 00:00:00 2001 From: tcouch Date: Mon, 28 Apr 2025 13:50:37 +0100 Subject: [PATCH 5/7] Show tags as badges in link list --- .../research/partials/testimonium_link_list_item.html | 3 +++ 1 file changed, 3 insertions(+) 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 98cea136..77ad8d3c 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 %} From 8d8be1fe0c5acb8dec31274b43aea173e390e0d3 Mon Sep 17 00:00:00 2001 From: tcouch Date: Mon, 28 Apr 2025 13:51:00 +0100 Subject: [PATCH 6/7] Add TestimoniumTag in models.__init__.py --- src/rard/research/models/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rard/research/models/__init__.py b/src/rard/research/models/__init__.py index 228927b8..6a0ce7c9 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", From bb6656907ee817bdc1d5a9a6c31b3a268c26adf6 Mon Sep 17 00:00:00 2001 From: tcouch Date: Mon, 28 Apr 2025 13:59:13 +0100 Subject: [PATCH 7/7] update gh workflow --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d60b39e1..66cba969 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