

def from_csv(self, user, row):
    'Create a domain alias from a CSV row\n\n        Expected format: ["domainalias", domain alias name, targeted domain, enabled]\n\n        :param user: a ``User`` object\n        :param row: a list containing the alias definition\n        '
    if (len(row) < 4):
        raise BadRequest(_('Invalid line'))
    self.name = row[1].strip()
    for model in [DomainAlias, Domain]:
        if model.objects.filter(name=self.name).exists():
            raise Conflict
    domname = row[2].strip()
    try:
        self.target = Domain.objects.get(name=domname)
    except Domain.DoesNotExist:
        raise BadRequest((_('Unknown domain %s') % domname))
    core_signals.can_create_object.send(sender='import', context=self.target, object_type='domain_aliases')
    self.enabled = (row[3].strip() in ['True', '1', 'yes', 'y'])
    self.save(creator=user)

dataset/ETHPy150Open tonioo/modoboa/modoboa/admin/models/domain_alias.py DomainAlias.from_csv/original