

def _domain_alias_operation(self, optype, domain, name, status=200):
    dom = Domain.objects.get(name=domain)
    values = {
        'name': dom.name,
        'quota': dom.quota,
        'enabled': dom.enabled,
        'type': 'domain',
    }
    aliases = [alias.name for alias in dom.domainalias_set.all()]
    if (optype == 'add'):
        aliases.append(name)
    else:
        aliases.remove(name)
    for (cpt, alias) in enumerate(aliases):
        fname = ('aliases' if (not cpt) else ('aliases_%d' % cpt))
        values[fname] = alias
    self.ajax_post(reverse('admin:domain_change', args=[dom.id]), values, status)

dataset/ETHPy150Open tonioo/modoboa/modoboa/limits/tests/test_user_limits.py ResourceTestCase._domain_alias_operation/original