* New "import data" feature (only supports mailboxes for now)

* Some javascript cleanup into the admin. application

see #191
This commit is contained in:
Antoine Nguyen
2011-12-09 14:38:56 +01:00
parent 767343640a
commit 4fcc5b7911
14 changed files with 226 additions and 86 deletions
+20
View File
@@ -319,6 +319,26 @@ class Mailbox(DatesAware):
self.quota = self.domain.quota
super(Mailbox, self).save()
def create_from_csv(self, line):
"""Create a new mailbox from a CSV file entry
The expected order is the following::
[loginname, password, first name, last name, address]
:param line: a list containing the expected information
"""
if len(line) < 5:
raise AdminError(_("Invalid line"))
mailbox, domname = split_mailbox(line[4])
self.address = mailbox
try:
self.domain = Domain.objects.get(name=domname)
except Domain.DoesNotExist:
raise AdminError(_("Cannot import this mailbox because the associated domain does not exist"))
self.name = "%s %s" % (line[2], line[3])
self.save(password=line[1], enabled=True)
def delete(self, *args, **kwargs):
keepdir = False
if kwargs.has_key("keepdir"):