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

[Fixes #11622] Rename icon filed to image field for thesaurus keywords (#11623)

* Rename icon filed to image field for thesaurus keywords

* add migration

* fix formatting
parent 90dc8ef5
Branches
No related tags found
No related merge requests found
# Generated by Django 3.2.22 on 2023-10-19 12:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('base', '0087_thesauruskeyword_icon'),
]
operations = [
migrations.RemoveField(
model_name='thesauruskeyword',
name='icon',
),
migrations.AddField(
model_name='thesauruskeyword',
name='image',
field=models.CharField(blank=True, help_text='A URL to an image', max_length=512, null=True),
),
]
......@@ -545,9 +545,7 @@ 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
)
image = models.CharField(max_length=512, help_text="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", "tkeywords__icon")
.values("tkeywords", "tkeywords__alt_label", "tkeywords__image")
.annotate(count=Count("tkeywords"))
.annotate(
localized_label=Subquery(
......@@ -102,7 +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"],
"image": r["tkeywords__image"],
}
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