From 371e2bbff3d9d71baeb2a26ab2c1ec9ad3a86a13 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 5 Aug 2022 13:56:28 +0200 Subject: Imports: add post importer actions in order to manage account importer --- ishtar_common/models.py | 11 +++++++++++ ishtar_common/models_imports.py | 1 + ishtar_common/version.py | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 9c139086b..0ee33d5ed 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -74,6 +74,7 @@ from django.template import Context, Template from django.template.defaultfilters import slugify from django.urls import reverse from django.utils.functional import lazy +from ishtar_common.data_importer import post_importer_action from ishtar_common.utils import ( ugettext_lazy as _, ugettext, @@ -3383,6 +3384,16 @@ class IshtarUser(FullSearch): def full_label(self): return self.person.full_label() + @post_importer_action + def import_set_password(self, context, value): + self.user_ptr.set_password(value) + self.user_ptr.save() + + @post_importer_action + def import_create_profile(self, context, value): + UserProfile.objects.get_or_create(person=self.person, profile_type=value, + defaults={"name":value.label}) + post_save.connect(cached_label_changed, sender=IshtarUser) diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 5cf672877..f7a35f849 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -876,6 +876,7 @@ TARGET_MODELS = [ ("ishtar_common.models.SourceType", _("Source type")), ("AuthorType", _("Author type")), ("Format", _("Format")), + ("ProfileType", _("Profile type")), ("ishtar_common.models.Format", _("Format")), ("ishtar_common.models.LicenseType", _("License type")), ("ishtar_common.models.DocumentTag", _("Document tag")), diff --git a/ishtar_common/version.py b/ishtar_common/version.py index 80a1d2738..9425d458a 100644 --- a/ishtar_common/version.py +++ b/ishtar_common/version.py @@ -1,5 +1,5 @@ -# 4.0.12 -VERSION = (4, 0, 12) +# 4.0.13 +VERSION = (4, 0, 13) def get_version(): -- cgit v1.2.3