Example #1
0
 def __call__(self, name, **data):
     r = Role.create(name, data)
     if not r:
         raise DoesNotExistsException("Cannot create role {0}"
                                      .format(name))
     returner = role_show(cli_mode=self.cli_mode)
     return returner(name)
Example #2
0
 def __call__(self, name):
     r = Role.find(name)
     if not r:
         raise DoesNotExistsException(
             "Role {0} does not exists in database".format(name))
     r.delete()
     if self.cli_mode:
         print("Role {0} deleted".format(name))
Example #3
0
 def __call__(self, **filters):
     if self.cli_mode:
         print(title("Roles:"))
     roles = [r.name for r in Role.filter(**filters)]
     if self.cli_mode:
         for r in roles:
             print(" - {0}".format(r))
     return roles
Example #4
0
 def __call__(self, name):
     r = Role.find(name)
     if not r:
         raise DoesNotExistsException("Role {0} does not exists in database"
                                      .format(name))
     r.delete()
     if self.cli_mode:
         print("Role {0} deleted".format(name))
Example #5
0
 def __call__(self, **filters):
     if self.cli_mode:
         print(title("Roles:"))
     roles = [r.name for r in Role.filter(**filters)]
     if self.cli_mode:
         for r in roles:
             print(" - {0}".format(r))
     return roles
Example #6
0
 def __call__(self, name):
     r = Role.find(name)
     if not r:
         raise DoesNotExistsException(
             "Role {0} does not exists in database".format(name))
     ret = r.as_dict()
     if self.cli_mode:
         print(title(r.name + ':'))
         pretty_print(ret)
     return ret
Example #7
0
 def __call__(self, name):
     r = Role.find(name)
     if not r:
         raise DoesNotExistsException("Role {0} does not exists in database"
                                      .format(name))
     ret = r.as_dict()
     if self.cli_mode:
         print(title(r.name + ':'))
         pretty_print(ret)
     return ret
Example #8
0
 def __call__(self, name, **data):
     r = Role.create(name, data)
     if not r:
         raise DoesNotExistsException("Cannot create role {0}".format(name))
     returner = role_show(cli_mode=self.cli_mode)
     return returner(name)