Exemplo n.º 1
0
 def create(self, validated_data):
     """Use backend to serialize data."""
     transport = tr_models.Transport(**validated_data.pop("transport"))
     transport.pattern = validated_data["name"]
     transport.save()
     domain = admin_models.Domain(**validated_data)
     domain.type = "relaydomain"
     domain.transport = transport
     domain.save(creator=self.context["request"].user)
     return domain
Exemplo n.º 2
0
def migrate_domain(old_dom, options):
    print "Migrating domain %s" % old_dom.domain
    newdom = md_models.Domain()
    newdom.name = old_dom.domain
    newdom.enabled = old_dom.active
    newdom.quota = old_dom.maxquota
    newdom.dates = migrate_dates(old_dom)
    newdom.save(using=options.to)
    migrate_mailboxes(newdom, options)
    migrate_mailbox_aliases(newdom, options)
    migrate_domain_aliases(newdom, options)
 def _migrate_domain(self, pf_domain, options, creator):
     """Single domain migration."""
     print "\nMigrating domain %s" % pf_domain.domain
     newdom = admin_models.Domain()
     newdom.name = pf_domain.domain
     newdom.enabled = pf_domain.active
     newdom.quota = pf_domain.maxquota
     self._migrate_dates(newdom, pf_domain)
     newdom.save(creator=creator, using=options["_to"])
     self._migrate_domain_aliases(newdom, options, creator)
     self._migrate_mailboxes(newdom, options, creator)
     self._migrate_mailbox_aliases(newdom, options, creator)
     self._migrate_admins(options, creator, pf_domain, newdom)
Exemplo n.º 4
0
    def from_csv(self, user, row):
        """Import a relay domain from CSV.

        :param user: user importing the relay domain
        :param str row: relay domain definition
        """
        if len(row) != 6:
            raise BadRequest(_("Invalid line"))
        self.domain = admin_models.Domain(
            name=row[1].strip(),
            type="relaydomain",
            enabled=(row[4].strip() in ["True", "1", "yes", "y"]))
        self.domain.save(creator=user)
        self.target_host = row[2].strip()
        self.service, created = Service.objects.get_or_create(
            name=row[3].strip())
        self.verify_recipients = (row[5].strip() in ["True", "1", "yes", "y"])
        self.save(creator=user)
Exemplo n.º 5
0
def import_relaydomain(user, row, formopts):
    """Specific code for relay domains import"""
    if len(row) != 7:
        raise BadRequest(_("Invalid line"))
    domain = admin_models.Domain(name=row[1].strip(),
                                 type="relaydomain",
                                 quota=0,
                                 enabled=(row[5].strip().lower()
                                          in ["true", "1", "yes", "y"]))
    domain.save(creator=user)
    settings = {
        "relay_target_host":
        row[2].strip(),
        "relay_target_port":
        row[3].strip(),
        "relay_verify_recipients": (row[6].strip().lower()
                                    in ["true", "1", "yes", "y"])
    }
    transport = tr_models.Transport(pattern=domain.name,
                                    service="relay",
                                    _settings=settings)
    tr_backends.manager.get_backend("relay").serialize(transport)
    transport.save()