diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-02-24 10:08:57 +0100 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-02-25 09:54:49 +0100 |
| commit | 13e838988e0a32e0ef54c15d90c8df2f92dad853 (patch) | |
| tree | 4444b7cfa643af842545c4df67158989941a0eb4 /ishtar_common/models_common.py | |
| parent | d297ccbd9a3da754294cbc174db4242184378aab (diff) | |
| download | Ishtar-13e838988e0a32e0ef54c15d90c8df2f92dad853.tar.bz2 Ishtar-13e838988e0a32e0ef54c15d90c8df2f92dad853.zip | |
✨ imports - key matches: use unicode on keys
Diffstat (limited to 'ishtar_common/models_common.py')
| -rw-r--r-- | ishtar_common/models_common.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 02e47ad56..c90ca7309 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -40,11 +40,11 @@ from django.urls import reverse, NoReverseMatch from django.core.validators import validate_slug from django.db import connection, transaction, OperationalError, IntegrityError from django.db.models import JSONField, Q, Count, Max -from django.db.models.signals import m2m_changed, post_save, post_delete, pre_delete +from django.db.models.signals import m2m_changed, post_save, post_delete from django.template import loader -from django.template.defaultfilters import slugify from django.utils import timezone from django.utils.safestring import SafeText, mark_safe +from django.utils.text import slugify from django.utils.translation import activate, deactivate from ishtar_common.utils import ( BColors, @@ -684,16 +684,18 @@ class GeneralType(Cached, models.Model): if self.pk: old = self.__class__.objects.get(pk=self.pk) content_type = ContentType.objects.get_for_model(self.__class__) - if slugify(self.label) != slugify(old.label): + if slugify(self.label, allow_unicode=True) != slugify(old.label, + allow_unicode=True): ItemKey.objects.filter( - object_id=self.pk, key=slugify(old.label), content_type=content_type + object_id=self.pk, key=slugify(old.label, allow_unicode=True), + content_type=content_type ).delete() if self.txt_idx != old.txt_idx: ItemKey.objects.filter( object_id=self.pk, key=old.txt_idx, content_type=content_type ).delete() - obj = super(GeneralType, self).save(*args, **kwargs) + obj = super().save(*args, **kwargs) self.generate_key(force=True) return obj @@ -725,7 +727,7 @@ class GeneralType(Cached, models.Model): ItemKey.objects.get_or_create(**filtr) def generate_key(self, force=False): - for key in (slugify(self.label), self.txt_idx): + for key in (slugify(self.label, allow_unicode=True), self.txt_idx): self.add_key(key) def get_keys(self, current_import): |
