jp (invitation): added modify command
This commit is contained in:
parent
feac2da87d
commit
fcbeec5fa5
1 changed files with 44 additions and 1 deletions
|
|
@ -130,8 +130,51 @@ class Get(base.CommandBase):
|
||||||
exit_code=C.EXIT_BRIDGE_ERRBACK))
|
exit_code=C.EXIT_BRIDGE_ERRBACK))
|
||||||
|
|
||||||
|
|
||||||
|
class Modify(base.CommandBase):
|
||||||
|
|
||||||
|
def __init__(self, host):
|
||||||
|
base.CommandBase.__init__(self, host, 'modify', use_profile=False, help=_(u'modify existing invitation'))
|
||||||
|
self.need_loop=True
|
||||||
|
|
||||||
|
def add_parser_options(self):
|
||||||
|
self.parser.add_argument("--replace", action='store_true', help='replace the whole data')
|
||||||
|
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("-l", "--lang", type=base.unicode_decoder, default='', help='main language spoken by the invitee')
|
||||||
|
self.parser.add_argument("-x", "--extra", metavar=('KEY', 'VALUE'), type=base.unicode_decoder, action='append', nargs=2, default=[], help='extra data to associate with invitation/invitee')
|
||||||
|
self.parser.add_argument("-p", "--profile", type=base.unicode_decoder, default='', help="profile doing the invitation (default: don't associate profile")
|
||||||
|
self.parser.add_argument("id", type=base.unicode_decoder,
|
||||||
|
help=_(u"invitation UUID"))
|
||||||
|
|
||||||
|
def invitationModifyCb(self):
|
||||||
|
self.disp(_(u'invitations have been modified correctly'))
|
||||||
|
self.host.quit(C.EXIT_OK)
|
||||||
|
|
||||||
|
def invitationModifyEb(self, failure_):
|
||||||
|
self.disp(u"can't create invitation: {reason}".format(
|
||||||
|
reason=failure_), error=True)
|
||||||
|
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
extra = dict(self.args.extra)
|
||||||
|
for arg_name in ('name', 'host_name', 'email', 'lang', 'profile'):
|
||||||
|
value = getattr(self.args, arg_name)
|
||||||
|
if not value:
|
||||||
|
continue
|
||||||
|
if arg_name in extra:
|
||||||
|
self.parser.error(_(u"you can't set {arg_name} in both optional argument and extra").format(arg_name=arg_name))
|
||||||
|
extra[arg_name] = value
|
||||||
|
self.host.bridge.invitationModify(
|
||||||
|
self.args.id,
|
||||||
|
extra,
|
||||||
|
self.args.replace,
|
||||||
|
callback=self.invitationModifyCb,
|
||||||
|
errback=self.invitationModifyEb)
|
||||||
|
|
||||||
|
|
||||||
class Invitation(base.CommandBase):
|
class Invitation(base.CommandBase):
|
||||||
subcommands = (Create, Get)
|
subcommands = (Create, Get, Modify)
|
||||||
|
|
||||||
def __init__(self, host):
|
def __init__(self, host):
|
||||||
super(Invitation, self).__init__(host, 'invitation', use_profile=False, help=_(u'invitation of user(s) without XMPP account'))
|
super(Invitation, self).__init__(host, 'invitation', use_profile=False, help=_(u'invitation of user(s) without XMPP account'))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue