diff options
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):          """ | 
