Skip to content
Merged
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/rard/research/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,8 @@ class Meta:
class TestimoniumForm(HistoricalFormBase):
class Meta:
model = Testimonium
fields = ()
fields = ("tags",)
widgets = {"tags": forms.CheckboxSelectMultiple}


class BaseLinkWorkForm(forms.ModelForm):
Expand Down
42 changes: 42 additions & 0 deletions src/rard/research/migrations/0075_add_testimonium_tags.py
Original file line number Diff line number Diff line change
@@ -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,
)
]
3 changes: 2 additions & 1 deletion src/rard/research/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,6 +34,7 @@
"Symbol",
"SymbolGroup",
"Testimonium",
"TestimoniumTag",
"TextObjectField",
"Topic",
"TopicLink",
Expand Down
22 changes: 22 additions & 0 deletions src/rard/research/models/testimonium.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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=[
Expand All @@ -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 (
Expand Down
6 changes: 6 additions & 0 deletions src/rard/static/css/project.css
Original file line number Diff line number Diff line change
Expand Up @@ -599,3 +599,9 @@ section.footnotes {
opacity: 1;
visibility: visible;
}

#searchHelpBlock {
a {
font-size: 100% !important;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
{{ link_text }}
{% endif %}
{% endwith %}
{% for tag in link.testimonium.tags.all %}
<span class='badge badge-pill badge-secondary'>{{ tag }}</span>
{% endfor %}

<button class="btn btn-link toggle-element-button" type="button" data-toggles="testimoniumlink_{{ link.pk }}"></button>

Expand Down
3 changes: 1 addition & 2 deletions src/rard/templates/research/search_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 <strong>can</strong> be used with proximity searches; e.g.
'hort?m ~1 biblio*'.
See <a href="https://github.com/UCL/frrant/wiki/Search">Search docs</a> for details.
</small>
</div>
<div class='col-auto'>
Expand Down
21 changes: 11 additions & 10 deletions src/rard/templates/research/testimonium_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@ <h5>{% trans 'Details' %}</h5>
<dt class="col-sm-3">{% trans 'Name' %}</dt>
<dd class="col-sm-9">{{ object.get_display_name }}</dd>

{% if object.topics is not None %}
<dt class="col-sm-3">{% trans 'Topics' %}</dt>
<dd class="col-sm-9">
{% if object.topics.count == 0%}-{% endif %}
{% for topic in object.topics.all %}{% if forloop.counter0 > 0 %}, {% endif %}
{% if perms.research.view_topic %}
<a href='{% url "topic:detail" topic.slug %}'>{{ topic.name }}</a>
{% else %}
{{ topic.name }}
{% endif %}
{% if object.tags is not None %}
<dt class="col-sm-3">{% trans 'Tags' %}</dt>
<dd class="col-sm-7">
{% if object.tags.count == 0%}-{% endif %}
{% for tag in object.tags.all %}
{{ tag.name }}{% if not forloop.last %}, {% endif %}
{% endfor %}
</dd>
<dd class='col-sm-2 actions'>
{% if perms.research.change_testimonium and has_object_lock %}
<a style='float:right;' href='{% url "testimonium:update" object.pk %}'>{% trans 'Edit' %}</a>
{% endif %}
</dd>
{% endif %}

<dt class="col-sm-3">{% trans 'Original Texts' %}</dt>
Expand Down
Loading