diff frontends/src/jp/cmd_invitation.py @ 2291:c05000d00dbb

plugin events, invitations + jp (event/create, invitation/invitee/invite): several emails addresses can now be specified for a single invitation: if several addresses are specified, the same invitation (same ID and data) is sent to all the addresses
author Goffi <goffi@goffi.org>
date Fri, 30 Jun 2017 00:04:47 +0200
parents 688ff67d6ae9
children 8b37a62336c3
line wrap: on
line diff
--- a/frontends/src/jp/cmd_invitation.py	Fri Jun 30 00:02:16 2017 +0200
+++ b/frontends/src/jp/cmd_invitation.py	Fri Jun 30 00:04:47 2017 +0200
@@ -22,6 +22,7 @@
 from sat.core.i18n import _
 from sat_frontends.jp.constants import Const as C
 from sat.tools.common.ansi import ANSI as A
+from sat.tools.common import data_format
 from functools import partial
 
 __commands__ = ["Invitation"]
@@ -38,7 +39,7 @@
         self.parser.add_argument("-P", "--password", type=base.unicode_decoder, default='', help='password of the invitee profile/XMPP account (default: generate one)')
         self.parser.add_argument("-n", "--name", type=base.unicode_decoder, default='', help='name of the invitee')
         self.parser.add_argument("-N", "--host-name", type=base.unicode_decoder, default='', help='name of the host')
-        self.parser.add_argument("-e", "--email", type=base.unicode_decoder, default='', help='email to send the invitation to (if --no-email is set, email will just be saved)')
+        self.parser.add_argument("-e", "--email", action="append", type=base.unicode_decoder, default=[], help='email(s) to send the invitation to (if --no-email is set, email will just be saved)')
         self.parser.add_argument("--no-email", action="store_true", help='do NOT send invitation email')
         self.parser.add_argument("-l", "--lang", type=base.unicode_decoder, default='', help='main language spoken by the invitee')
         self.parser.add_argument("-u", "--url", type=base.unicode_decoder, default='', help='template to construct the URL')
@@ -58,20 +59,23 @@
 
     def start(self):
         extra = dict(self.args.extra)
-        email = self.args.email
+        email = self.args.email[0] if self.args.email else None
+        emails_extra = self.args.email[1:]
         if self.args.no_email:
             if email:
                 extra['email'] = email
+                data_format.iter2dict(u'emails_extra', emails_extra)
         else:
             if not email:
                 self.parser.error(_(u'you need to specify an email address to send email invitation'))
 
         self.host.bridge.invitationCreate(
+            email,
+            emails_extra,
             self.args.jid,
             self.args.password,
             self.args.name,
             self.args.host_name,
-            email,
             self.args.lang,
             self.args.url,
             self.args.subject,