From f043e5098336ba420c3e8eca44e98b3d6f77eda6 Mon Sep 17 00:00:00 2001 From: Stefan Auditor Date: Wed, 14 Dec 2016 09:40:49 +0100 Subject: [PATCH] Add method to create an alias --- admin/manage.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/admin/manage.py b/admin/manage.py index 874a1110..9563f66b 100644 --- a/admin/manage.py +++ b/admin/manage.py @@ -51,5 +51,22 @@ def user(localpart, domain_name, password): db.session.add(user) db.session.commit() +@manager.command +def alias(localpart, domain_name, destination): + """ Create an alias + """ + domain = models.Domain.query.get(domain_name) + if not domain: + domain = models.Domain(name=domain_name) + db.session.add(domain) + alias = models.Alias( + localpart=localpart, + domain=domain, + destination=destination.split(','), + email="%s@%s" % (localpart, domain_name) + ) + db.session.add(alias) + db.session.commit() + if __name__ == "__main__": manager.run()