예제 #1
0
 def run(self):
     role_name = prompt('Role name')
     role = Role.objects(name=role_name).first()
     if not role:
         role = Role(name=role_name)
         role.save()
         return
예제 #2
0
 def run(self):
     deployments = Deployment.objects
     option = prompt_choices('Deployment', [
         (str(i), v) for i, v in enumerate(deployments, 1)])
     deployment = deployments[int(option) - 1]
     email = prompt('Email')
     user = users.first(email=email, deployment=deployment)
     role_name = prompt('Role')
     role = Role.objects(name=role_name).first()
     if not user:
         print 'Invalid user'
         return
     if not role:
         print 'Invalid role'
         return
     user.update(add_to_set__roles=role)
     print 'Role added to User successfully'