Remove dlist and forward words.

see #783
This commit is contained in:
Antoine Nguyen
2016-08-31 17:57:50 +02:00
parent 576231f876
commit 62a4085473
4 changed files with 8 additions and 55 deletions
+3 -18
View File
@@ -79,24 +79,11 @@ class Alias(AdminObject):
@property
def type(self):
cpt = self.recipients_count
if cpt > 1:
return "dlist"
qset = self.aliasrecipient_set.filter(
r_mailbox__isnull=True, r_alias__isnull=True)
if qset.exists():
return "forward"
return "alias"
@property
def tags(self):
labels = {
"dlist": _("distribution list"),
"forward": _("forward"),
"alias": _("alias")
}
altype = self.type
return [{"name": altype, "label": labels[altype], "type": "idt"}]
return [{"name": "alias", "label": _("alias"), "type": "idt"}]
def get_absolute_url(self):
"""Return detail url for this alias."""
@@ -177,9 +164,7 @@ class Alias(AdminObject):
return self.aliasrecipient_set.count()
def from_csv(self, user, row, expected_elements=5):
"""Create a new alias from a CSV file entry
"""
"""Create a new alias from a CSV file entry."""
if len(row) < expected_elements:
raise BadRequest(_("Invalid line: %s" % row))
address = row[1].strip()
@@ -204,7 +189,7 @@ class Alias(AdminObject):
self.post_create(user)
def to_csv(self, csvwriter):
row = [self.type, self.address.encode("utf-8"), self.enabled]
row = ["alias", self.address.encode("utf-8"), self.enabled]
row += self.recipients
csvwriter.writerow(row)
+2 -16
View File
@@ -37,7 +37,7 @@ class ExportTestCase(ModoTestCase):
def test_export_identities(self):
response = self.__export_identities()
self.assertListEqual(
"account;admin@test.com;{PLAIN}toto;;;True;DomainAdmins;admin@test.com;10;test.com\r\naccount;admin@test2.com;{PLAIN}toto;;;True;DomainAdmins;admin@test2.com;10;test2.com\r\naccount;user@test.com;{PLAIN}toto;;;True;SimpleUsers;user@test.com;10\r\naccount;user@test2.com;{PLAIN}toto;;;True;SimpleUsers;user@test2.com;10\r\nalias;alias@test.com;True;user@test.com\r\nforward;forward@test.com;True;user@external.com\r\ndlist;postmaster@test.com;True;test@truc.fr;toto@titi.com\r\n",
"account;admin@test.com;{PLAIN}toto;;;True;DomainAdmins;admin@test.com;10;test.com\r\naccount;admin@test2.com;{PLAIN}toto;;;True;DomainAdmins;admin@test2.com;10;test2.com\r\naccount;user@test.com;{PLAIN}toto;;;True;SimpleUsers;user@test.com;10\r\naccount;user@test2.com;{PLAIN}toto;;;True;SimpleUsers;user@test2.com;10\r\nalias;alias@test.com;True;user@test.com\r\nalias;forward@test.com;True;user@external.com\r\nalias;postmaster@test.com;True;test@truc.fr;toto@titi.com\r\n",
response.content.strip()
)
@@ -78,19 +78,5 @@ class ExportTestCase(ModoTestCase):
response = self.__export_identities(idtfilter="alias")
self.assertEqual(
response.content.strip(),
"alias;alias@test.com;True;user@test.com"
)
def test_export_forwards(self):
response = self.__export_identities(idtfilter="forward")
self.assertEqual(
response.content.strip(),
"forward;forward@test.com;True;user@external.com"
)
def test_export_dlists(self):
response = self.__export_identities(idtfilter="dlist")
self.assertEqual(
response.content.strip(),
"dlist;postmaster@test.com;True;test@truc.fr;toto@titi.com"
"alias;alias@test.com;True;user@test.com\r\nalias;forward@test.com;True;user@external.com\r\nalias;postmaster@test.com;True;test@truc.fr;toto@titi.com"
)
+2 -18
View File
@@ -80,13 +80,7 @@ def editalias(request, alid, tplname="admin/aliasform.html"):
if not request.user.can_access(alias):
raise PermDeniedException
if request.method == "POST":
altype = alias.type
if altype == "dlist":
successmsg = _("Distribution list modified")
elif altype == "forward":
successmsg = _("Forward modified")
else:
successmsg = _("Alias modified")
successmsg = _("Alias modified")
form = AliasForm(request.user, request.POST, instance=alias)
return _validate_alias(request, form, successmsg)
@@ -109,18 +103,8 @@ def delalias(request):
alias = Alias.objects.get(pk=alid)
if not request.user.can_access(alias):
raise PermDeniedException
if alias.type == 'dlist':
msg = "Distribution list deleted"
msgs = "Distribution lists deleted"
elif alias.type == 'forward':
msg = "Forward deleted"
msgs = "Forwards deleted"
else:
msg = "Alias deleted"
msgs = "Aliases deleted"
alias.delete()
msg = ungettext(msg, msgs, len(selection))
msg = ungettext("Alias deleted", "Aliases deleted", len(selection))
return render_to_json_response(msg)
+1 -3
View File
@@ -120,9 +120,7 @@ def import_identities(request):
helptext = _("""Provide a CSV file where lines respect one of the following formats:
<ul>
<li><em>account; loginname; password; first name; last name; enabled; group; address; quota; [, domain, ...]</em></li>
<li><em>alias; address; enabled; internal recipient</em></li>
<li><em>forward; address; enabled; external recipient</em></li>
<li><em>dlist; address; enabled; recipient; recipient; ...</em></li>
<li><em>alias; address; enabled; recipient; recipient; ...</em></li>
</ul>
<p>The first element of each line is mandatory and must be equal to one of the previous values.</p>