From e1b19b78dbe84361856d1337a50ad57c4094a568 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Mon, 16 Jan 2017 17:38:33 +0100 Subject: [PATCH] Include target port in import/export. --- .../admin/templates/admin/import_domains_form.html | 2 +- modoboa/relaydomains/models.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modoboa/admin/templates/admin/import_domains_form.html b/modoboa/admin/templates/admin/import_domains_form.html index ef729b4a9..5a8666ef5 100644 --- a/modoboa/admin/templates/admin/import_domains_form.html +++ b/modoboa/admin/templates/admin/import_domains_form.html @@ -8,7 +8,7 @@

The first element of each line is mandatory and must be equal to one of the previous values.

You can use a different character as separator.

diff --git a/modoboa/relaydomains/models.py b/modoboa/relaydomains/models.py index 7b4d20ddb..36f8eee5b 100644 --- a/modoboa/relaydomains/models.py +++ b/modoboa/relaydomains/models.py @@ -106,7 +106,8 @@ class RelayDomain(admin_models.AdminObject): """ csvwriter.writerow( ["relaydomain", self.domain.name, self.target_host, - self.service.name, self.domain.enabled, self.verify_recipients] + self.target_port, self.service.name, self.domain.enabled, + self.verify_recipients] ) for dalias in self.domain.domainalias_set.all(): dalias.to_csv(csvwriter) @@ -117,17 +118,18 @@ class RelayDomain(admin_models.AdminObject): :param user: user importing the relay domain :param str row: relay domain definition """ - if len(row) != 6: + if len(row) != 7: raise BadRequest(_("Invalid line")) self.domain = admin_models.Domain( name=row[1].strip(), type="relaydomain", quota=0, - enabled=(row[4].strip() in ["True", "1", "yes", "y"]) + enabled=(row[5].strip() in ["True", "1", "yes", "y"]) ) self.domain.save(creator=user) self.target_host = row[2].strip() + self.target_port = row[3].strip() self.service, created = Service.objects.get_or_create( - name=row[3].strip()) - self.verify_recipients = (row[5].strip() in ["True", "1", "yes", "y"]) + name=row[4].strip()) + self.verify_recipients = (row[6].strip() in ["True", "1", "yes", "y"]) self.save(creator=user)