jp (invitation): added list subcommand
This commit is contained in:
parent
e255b969e0
commit
f07c5991ea
1 changed files with 35 additions and 1 deletions
|
|
@ -21,6 +21,7 @@
|
||||||
import base
|
import base
|
||||||
from sat.core.i18n import _
|
from sat.core.i18n import _
|
||||||
from sat_frontends.jp.constants import Const as C
|
from sat_frontends.jp.constants import Const as C
|
||||||
|
from sat.tools.common.ansi import ANSI as A
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
__commands__ = ["Invitation"]
|
__commands__ = ["Invitation"]
|
||||||
|
|
@ -173,8 +174,41 @@ class Modify(base.CommandBase):
|
||||||
errback=self.invitationModifyEb)
|
errback=self.invitationModifyEb)
|
||||||
|
|
||||||
|
|
||||||
|
class List(base.CommandBase):
|
||||||
|
|
||||||
|
def __init__(self, host):
|
||||||
|
extra_outputs = {'default': self.default_output}
|
||||||
|
base.CommandBase.__init__(self, host, 'list', use_profile=False, use_output=C.OUTPUT_COMPLEX, extra_outputs=extra_outputs, help=_(u'list invitations data'))
|
||||||
|
self.need_loop=True
|
||||||
|
|
||||||
|
def default_output(self, data):
|
||||||
|
for idx, datum in enumerate(data.iteritems()):
|
||||||
|
if idx:
|
||||||
|
self.disp(u"\n")
|
||||||
|
key, invitation_data = datum
|
||||||
|
self.disp(A.color(C.A_HEADER, key))
|
||||||
|
indent = u' '
|
||||||
|
for k, v in invitation_data.iteritems():
|
||||||
|
self.disp(indent + A.color(C.A_SUBHEADER, k + u':') + u' ' + unicode(v))
|
||||||
|
|
||||||
|
def add_parser_options(self):
|
||||||
|
self.parser.add_argument("-p", "--profile", default=C.PROF_KEY_NONE, help=_(u"return only invitations linked to this profile"))
|
||||||
|
|
||||||
|
def invitationListCb(self, data):
|
||||||
|
self.output(data)
|
||||||
|
self.host.quit()
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
self.host.bridge.invitationList(
|
||||||
|
self.args.profile,
|
||||||
|
callback=self.invitationListCb,
|
||||||
|
errback=partial(self.errback,
|
||||||
|
msg=_(u"can't list invitations: {}"),
|
||||||
|
exit_code=C.EXIT_BRIDGE_ERRBACK))
|
||||||
|
|
||||||
|
|
||||||
class Invitation(base.CommandBase):
|
class Invitation(base.CommandBase):
|
||||||
subcommands = (Create, Get, Modify)
|
subcommands = (Create, Get, Modify, List)
|
||||||
|
|
||||||
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