|
|
|
@ -43,15 +43,19 @@ class OrgManager(models.Manager):
|
|
|
|
|
|
|
|
|
|
def bulk_create(self, objs, batch_size=None, ignore_conflicts=False):
|
|
|
|
|
org = get_current_org()
|
|
|
|
|
org_id = org.id
|
|
|
|
|
for obj in objs:
|
|
|
|
|
obj.org_id = org_id
|
|
|
|
|
if org.is_root():
|
|
|
|
|
if not self.org_id:
|
|
|
|
|
raise ValidationError('Please save in a organization')
|
|
|
|
|
else:
|
|
|
|
|
obj.org_id = org.id
|
|
|
|
|
return super().bulk_create(objs, batch_size, ignore_conflicts)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OrgModelMixin(models.Model):
|
|
|
|
|
org_id = models.CharField(max_length=36, blank=True, default='',
|
|
|
|
|
verbose_name=_("Organization"), db_index=True)
|
|
|
|
|
org_id = models.CharField(
|
|
|
|
|
max_length=36, blank=True, default='', verbose_name=_("Organization"), db_index=True
|
|
|
|
|
)
|
|
|
|
|
objects = OrgManager()
|
|
|
|
|
|
|
|
|
|
sep = '@'
|
|
|
|
|