From 2c3c52a2ecdb4271cea4e8ec31410ef48be3c728 Mon Sep 17 00:00:00 2001 From: Stefan Auditor Date: Wed, 14 Dec 2016 08:16:48 +0100 Subject: [PATCH 1/2] Add method to create a normal user --- admin/manage.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/admin/manage.py b/admin/manage.py index 1b257352..874a1110 100644 --- a/admin/manage.py +++ b/admin/manage.py @@ -34,6 +34,22 @@ def admin(localpart, domain_name, password): db.session.add(user) db.session.commit() +@manager.command +def user(localpart, domain_name, password): + """ Create an user + """ + domain = models.Domain.query.get(domain_name) + if not domain: + domain = models.Domain(name=domain_name) + db.session.add(domain) + user = models.User( + localpart=localpart, + domain=domain, + global_admin=False, + password=hash.sha512_crypt.encrypt(password) + ) + db.session.add(user) + db.session.commit() if __name__ == "__main__": manager.run() From f043e5098336ba420c3e8eca44e98b3d6f77eda6 Mon Sep 17 00:00:00 2001 From: Stefan Auditor Date: Wed, 14 Dec 2016 09:40:49 +0100 Subject: [PATCH 2/2] 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()