comparison 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
comparison
equal deleted inserted replaced
2290:d5c75be1c8c0 2291:c05000d00dbb
20 20
21 import base 21 import base
22 from sat.core.i18n import _ 22 from sat.core.i18n import _
23 from sat_frontends.jp.constants import Const as C 23 from sat_frontends.jp.constants import Const as C
24 from sat.tools.common.ansi import ANSI as A 24 from sat.tools.common.ansi import ANSI as A
25 from sat.tools.common import data_format
25 from functools import partial 26 from functools import partial
26 27
27 __commands__ = ["Invitation"] 28 __commands__ = ["Invitation"]
28 29
29 30
36 def add_parser_options(self): 37 def add_parser_options(self):
37 self.parser.add_argument("-j", "--jid", type=base.unicode_decoder, default='', help='jid of the invitee (default: generate one)') 38 self.parser.add_argument("-j", "--jid", type=base.unicode_decoder, default='', help='jid of the invitee (default: generate one)')
38 self.parser.add_argument("-P", "--password", type=base.unicode_decoder, default='', help='password of the invitee profile/XMPP account (default: generate one)') 39 self.parser.add_argument("-P", "--password", type=base.unicode_decoder, default='', help='password of the invitee profile/XMPP account (default: generate one)')
39 self.parser.add_argument("-n", "--name", type=base.unicode_decoder, default='', help='name of the invitee') 40 self.parser.add_argument("-n", "--name", type=base.unicode_decoder, default='', help='name of the invitee')
40 self.parser.add_argument("-N", "--host-name", type=base.unicode_decoder, default='', help='name of the host') 41 self.parser.add_argument("-N", "--host-name", type=base.unicode_decoder, default='', help='name of the host')
41 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)') 42 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)')
42 self.parser.add_argument("--no-email", action="store_true", help='do NOT send invitation email') 43 self.parser.add_argument("--no-email", action="store_true", help='do NOT send invitation email')
43 self.parser.add_argument("-l", "--lang", type=base.unicode_decoder, default='', help='main language spoken by the invitee') 44 self.parser.add_argument("-l", "--lang", type=base.unicode_decoder, default='', help='main language spoken by the invitee')
44 self.parser.add_argument("-u", "--url", type=base.unicode_decoder, default='', help='template to construct the URL') 45 self.parser.add_argument("-u", "--url", type=base.unicode_decoder, default='', help='template to construct the URL')
45 self.parser.add_argument("-s", "--subject", type=base.unicode_decoder, default='', help='subject of the invitation email (default: generic subject)') 46 self.parser.add_argument("-s", "--subject", type=base.unicode_decoder, default='', help='subject of the invitation email (default: generic subject)')
46 self.parser.add_argument("-b", "--body", type=base.unicode_decoder, default='', help='body of the invitation email (default: generic body)') 47 self.parser.add_argument("-b", "--body", type=base.unicode_decoder, default='', help='body of the invitation email (default: generic body)')
56 reason=failure_), error=True) 57 reason=failure_), error=True)
57 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 58 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
58 59
59 def start(self): 60 def start(self):
60 extra = dict(self.args.extra) 61 extra = dict(self.args.extra)
61 email = self.args.email 62 email = self.args.email[0] if self.args.email else None
63 emails_extra = self.args.email[1:]
62 if self.args.no_email: 64 if self.args.no_email:
63 if email: 65 if email:
64 extra['email'] = email 66 extra['email'] = email
67 data_format.iter2dict(u'emails_extra', emails_extra)
65 else: 68 else:
66 if not email: 69 if not email:
67 self.parser.error(_(u'you need to specify an email address to send email invitation')) 70 self.parser.error(_(u'you need to specify an email address to send email invitation'))
68 71
69 self.host.bridge.invitationCreate( 72 self.host.bridge.invitationCreate(
73 email,
74 emails_extra,
70 self.args.jid, 75 self.args.jid,
71 self.args.password, 76 self.args.password,
72 self.args.name, 77 self.args.name,
73 self.args.host_name, 78 self.args.host_name,
74 email,
75 self.args.lang, 79 self.args.lang,
76 self.args.url, 80 self.args.url,
77 self.args.subject, 81 self.args.subject,
78 self.args.body, 82 self.args.body,
79 extra, 83 extra,