diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-06-16 13:45:35 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-06-16 13:45:35 +0200 |
commit | 35bad41efd18022a89f53c4cddc1f1e97a516f96 (patch) | |
tree | b087ea7e13a0ea35b3408c862f57b8b1768c54db /ishtar_common/models.py | |
parent | fc8f8313dff6511f1ee588ff413027f1145aa1d9 (diff) | |
download | Ishtar-35bad41efd18022a89f53c4cddc1f1e97a516f96.tar.bz2 Ishtar-35bad41efd18022a89f53c4cddc1f1e97a516f96.zip |
Import: specialize targetkey (refs #2533)
Model: a targetkey connection can now be applied to on particular import
(associated_import), one particular user (associated_user) or to all imports
(associated_import and associated_user are empty).
To be done: change import and forms to fully use this mechanism.
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 2729aeeef..55b28d4f7 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1206,15 +1206,21 @@ class TargetKey(models.Model): """ User's link between import source and ishtar database. Also temporary used for GeneralType to point missing link before adding - them in ItemKey table + them in ItemKey table. + A targetkey connection can be create to be applied to on particular + import (associated_import), one particular user (associated_user) or to all + imports (associated_import and associated_user are empty). """ target = models.ForeignKey(ImportTarget, related_name='keys') key = models.TextField(_(u"Key")) value = models.TextField(_(u"Value"), blank=True, null=True) is_set = models.BooleanField(_(u"Is set"), default=False) + associated_import = models.ForeignKey('Import', blank=True, null=True) + associated_user = models.ForeignKey('IshtarUser', blank=True, null=True) class Meta: - unique_together = ('target', 'key') + unique_together = ('target', 'key', 'associated_user', + 'associated_import') verbose_name = _(u"Importer - Target key") verbose_name_plural = _(u"Importer - Targets keys") @@ -1376,8 +1382,8 @@ class Import(models.Model): unicode(self.user)) def need_matching(self): - return bool(ImporterType.objects.filter(pk=self.importer_type.pk, - columns__targets__keys__is_set=False).count()) + return bool(TargetKey.objects.filter(associated_import=self, + is_set=False).count()) def get_actions(self): """ |