Skip to content
Snippets Groups Projects
Unverified Commit 5f99756d authored by Giovanni Allegri's avatar Giovanni Allegri Committed by GitHub
Browse files

[Fixes #11617] Introduce icons for thesauri keywords (#11618)

* Introduce icons for thesauri keywords

* fix black
parent 9d6a4ca0
No related branches found
No related tags found
No related merge requests found
# Generated by Django 3.2.22 on 2023-10-18 14:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('base', '0086_linkedresource'),
]
operations = [
migrations.AddField(
model_name='thesauruskeyword',
name='icon',
field=models.CharField(blank=True, max_length=512, null=True, help_text='It can be a fa-class name or a URL to an image'),
),
]
......@@ -545,6 +545,10 @@ class ThesaurusKeyword(models.Model):
thesaurus = models.ForeignKey("Thesaurus", related_name="thesaurus", on_delete=models.CASCADE)
icon = models.CharField(
max_length=512, help_text="It can be a fa-class name or a URL to an image", null=True, blank=True
)
def __str__(self):
return str(self.alt_label)
......
......@@ -79,7 +79,7 @@ class ThesaurusFacetProvider(FacetProvider):
q = (
queryset.filter(**filter)
.values("tkeywords", "tkeywords__alt_label")
.values("tkeywords", "tkeywords__alt_label", "tkeywords__icon")
.annotate(count=Count("tkeywords"))
.annotate(
localized_label=Subquery(
......@@ -102,6 +102,7 @@ class ThesaurusFacetProvider(FacetProvider):
"label": r["localized_label"] or r["tkeywords__alt_label"],
"is_localized": r["localized_label"] is not None,
"count": r["count"],
"icon": r["tkeywords__icon"],
}
for r in q[start:end].all()
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment