diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-10-28 19:21:41 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-10-28 19:21:41 +0200 |
commit | 328de388cf7c8cd213752c01dfadc2a19e8acb6f (patch) | |
tree | bd817bec361eff377bdd7b03b3ac2b37631f8c9d /ishtar_common/models.py | |
parent | 6b2730288641ff0206fca8b2c0cbff1b1e442b1f (diff) | |
download | Ishtar-328de388cf7c8cd213752c01dfadc2a19e8acb6f.tar.bz2 Ishtar-328de388cf7c8cd213752c01dfadc2a19e8acb6f.zip |
Too many lazy evaluations and nobody do the job! Fixed.
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 814387bb4..c0888ec06 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -67,7 +67,6 @@ from ishtar_common.data_importer import Importer, ImportFormater, \ def post_save_user(sender, **kwargs): user = kwargs['instance'] - ishtaruser = None try: q = IshtarUser.objects.filter(username=user.username) if not q.count(): @@ -360,9 +359,9 @@ class GeneralType(Cached, models.Model): :param slug: textual id - :return: the id of the item + :return: id of the item (string) """ - return cls.get_or_create(slug).pk + return unicode(cls.get_or_create(slug).pk) @classmethod def get_or_create_pks(cls, slugs): @@ -377,7 +376,7 @@ class GeneralType(Cached, models.Model): items = [] for slug in slugs: items.append(str(cls.get_or_create(slug).pk)) - return "_".join(items) + return u"_".join(items) @classmethod def get_help(cls, dct={}, exclude=[]): @@ -1580,8 +1579,7 @@ class OrganizationType(GeneralType): post_save.connect(post_save_cache, sender=OrganizationType) post_delete.connect(post_save_cache, sender=OrganizationType) -organization_type_lazy = lazy(OrganizationType.get_or_create, OrganizationType) -organization_type_pk_lazy = lazy(OrganizationType.get_or_create_pk, int) +organization_type_pk_lazy = lazy(OrganizationType.get_or_create_pk, unicode) organization_type_pks_lazy = lazy(OrganizationType.get_or_create_pks, unicode) IMPORTER_CLASSES = {} @@ -2374,8 +2372,7 @@ class PersonType(GeneralType): post_save.connect(post_save_cache, sender=PersonType) post_delete.connect(post_save_cache, sender=PersonType) -person_type_lazy = lazy(PersonType.get_or_create_pk, PersonType) -person_type_pk_lazy = lazy(PersonType.get_or_create_pk, int) +person_type_pk_lazy = lazy(PersonType.get_or_create_pk, unicode) person_type_pks_lazy = lazy(PersonType.get_or_create_pks, unicode) |