def _create_org(self, **kwargs): options = dict(name='default', slug='default') options.update(kwargs) try: org = Organization.objects.get(**options) except Organization.DoesNotExist: org = Organization(**options) org.full_clean() org.save() return org
def _create_organization(self, **kwargs): options = dict(name='org1') options.update(kwargs) options.setdefault('slug', slugify(options['name'])) if not Organization.objects.filter(**kwargs).count(): org = Organization(**options) org.full_clean() org.save() else: org = Organization.objects.get(**kwargs) return org
def _get_or_create_org(self, org_name): try: instance = Organization.objects.get(name=org_name) except ValidationError as e: raise CsvImportException(str(e)) except Organization.DoesNotExist: try: instance = Organization(name=org_name) instance.save() except ValidationError as e: raise CsvImportException(str(e)) return instance
def _create_org(self, **kwargs): options = dict(name='test-organization') options.update(kwargs) org = Organization(**options) org.save() return org