changeset 2288:f4d8d83a50e2

jp (event/invitee/invite): command to use new eventInvite backend method
author Goffi <goffi@goffi.org>
date Thu, 29 Jun 2017 20:57:14 +0200
parents ea869f30f204
children f8276bd8baf6
files frontends/src/jp/cmd_event.py
diffstat 1 files changed, 38 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/jp/cmd_event.py	Thu Jun 29 20:57:12 2017 +0200
+++ b/frontends/src/jp/cmd_event.py	Thu Jun 29 20:57:14 2017 +0200
@@ -196,8 +196,45 @@
                             exit_code=C.EXIT_BRIDGE_ERRBACK))
 
 
+class InviteeInvite(base.CommandBase):
+
+    def __init__(self, host):
+        base.CommandBase.__init__(self, host, 'invite', use_pubsub_node_req=True, help=_(u'invite someone to the event through email'))
+        self.need_loop=True
+
+    def add_parser_options(self):
+        self.parser.add_argument("-i", "--item", type=base.unicode_decoder, default=u'', help=_(u"ID of the PubSub Item"))
+        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("-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("-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')
+        self.parser.add_argument("-S", "--subject", type=base.unicode_decoder, default='', help='subject of the invitation email (default: generic subject)')
+        self.parser.add_argument("-b", "--body", type=base.unicode_decoder, default='', help='body of the invitation email (default: generic body)')
+
+    def start(self):
+        common.checkURI(self.args)
+
+        self.host.bridge.eventInvite(
+            self.args.service,
+            self.args.node,
+            self.args.item,
+            self.args.email,
+            self.args.name,
+            self.args.host_name,
+            self.args.lang,
+            self.args.url,
+            self.args.subject,
+            self.args.body,
+            self.args.profile,
+            callback=self.host.quit,
+            errback=partial(self.errback,
+                            msg=_(u"can't create invitation: {}"),
+                            exit_code=C.EXIT_BRIDGE_ERRBACK))
+
+
 class Invitee(base.CommandBase):
-    subcommands = (InviteeGet, InviteeSet)
+    subcommands = (InviteeGet, InviteeSet, InviteeInvite)
 
     def __init__(self, host):
         super(Invitee, self).__init__(host, 'invitee', use_profile=False, help=_(u'manage invities'))