예제 #1
0
 def __call__(self, args):
     super(WelcomeMessagesListCommand, self).__call__(args)
     endpoint = self.ls.welcome_messages
     tbu = TableBuilder(self.ls, endpoint, self.IDENTIFIER)
     tbu.load_args(args)
     tbu.add_custom_cell("welcomeMessagesEntries", WelcomeEntriesCell)
     tbu.add_custom_cell("myDomain",
                         ComplexCellBuilder('{label} <{identifier}>'))
     tbu.add_filters(PartialOr(self.IDENTIFIER, args.identifiers, True), )
     json_obj = []
     if args.detail:
         keys = []
         keys.append(self.IDENTIFIER)
         keys.append(self.RESOURCE_IDENTIFIER)
         keys += endpoint.languages()
         tbu.columns = keys
         tbu.vertical = True
         filteror = PartialOr(self.IDENTIFIER, args.identifiers, True)
         for json_row in endpoint.list(args.current_domain):
             if filteror(json_row):
                 data = json_row.get('welcomeMessagesEntries')
                 data[self.IDENTIFIER] = json_row.get(self.IDENTIFIER)
                 data[self.RESOURCE_IDENTIFIER] = json_row.get(
                     self.RESOURCE_IDENTIFIER)
                 json_obj.append(data)
         # json_obj = sorted(json_obj, reverse=args.reverse, key=lambda x: x.get(table.sortby))
     else:
         json_obj = endpoint.list(args.current_domain)
     table = tbu.build()
     return table.load_v2(json_obj).render()
예제 #2
0
 def __call__(self, args):
     super(WgNodeContentDisplayCommand, self).__call__(args)
     endpoint = self.ls.workgroup_nodes
     tbu = TableBuilder(self.ls, endpoint, self.IDENTIFIER)
     tbu.vertical = True
     tbu.load_args(args)
     tbu.add_custom_cell("lastAuthor",
                         ComplexCellBuilder('{name} <{mail}>'))
     tbu.add_custom_cell("treePath", TreeCell)
     tbu.columns = endpoint.get_rbu().get_keys(args.extended)
     tbu.columns.append('treePath')
     json_obj = []
     for node_uuid in args.nodes:
         node_uuid = get_uuid_from(node_uuid)
         node = endpoint.get(args.wg_uuid, node_uuid, tree=True)
         # self.pretty_json(node)
         json_obj.append(node)
     return tbu.build().load_v2(json_obj).render()