Пример #1
0
 def do_strip(self, username):
     """
     Strip a user of all permissions
     Usage: strip <handle>
     """
     user = User.by_handle(username)
     if user is None:
         print (WARN + "'%s' user not found in database." % username)
     else:
         username = user.handle
         permissions = Permission.by_user_id(user.id)
         if len(permissions) == 0:
             print (WARN + "%s has no permissions." % user.handle)
         else:
             for perm in permissions:
                 print (INFO + "Removing permission: " + perm.permission_name)
                 dbsession.delete(perm)
         dbsession.flush()
         print (INFO + "Successfully removed %s's permissions." % user.handle)
Пример #2
0
 def do_delete(self, username):
     """
     Delete a user from the database
     Usage: delete <handle>
     """
     user = User.by_handle(username)
     if user is None:
         print (WARN + "'%s' user not found in database." % username)
     else:
         username = user.handle
         print (WARN + str("Are you sure you want to delete %s?" % username))
         if raw_input(PROMPT + "Delete [y/n]: ").lower() == "y":
             permissions = Permission.by_user_id(user.id)
             for perm in permissions:
                 print (INFO + "Removing permission: " + perm.permission_name)
                 dbsession.delete(perm)
             dbsession.flush()
             dbsession.delete(user)
             dbsession.flush()
             print (INFO + "Successfully deleted %s from database." % username)
Пример #3
0
 def do_strip(self, username):
     '''
     Strip a user of all permissions
     Usage: strip <handle>
     '''
     user = User.by_handle(username)
     if user is None:
         print(WARN + str("%s user not found in database." % username))
     else:
         username = user.handle
         permissions = Permission.by_user_id(user.id)
         if len(permissions) == 0:
             print(WARN + str("%s has no permissions." % user.handle))
         else:
             for perm in permissions:
                 print(INFO + "Removing permission: " +
                       perm.permission_name)
                 dbsession.delete(perm)
         dbsession.flush()
         print(INFO +
               "Successfully removed %s's permissions." % user.handle)
 def do_strip(self, username):
     '''
     Strip a user of all permissions
     Usage: strip <user name>
     '''
     user = User.by_user_name(username)
     if user == None:
         print(WARN + str("%s user not found in database." % username))
     else:
         username = user.user_name
         permissions = Permission.by_user_id(user.id)
         if len(permissions) == 0:
             print(WARN + str("%s has no permissions." % user.user_name))
         else:
             for perm in permissions:
                 print(
                     INFO + "Removing permission: " + perm.permission_name)
                 dbsession.delete(perm)
         dbsession.flush()
         print(INFO +
               "Successfully removed %s's permissions." % user.user_name)
Пример #5
0
 def do_delete(self, username):
     '''
     Delete a user from the database
     Usage: delete <handle>
     '''
     user = User.by_handle(username)
     if user is None:
         print(WARN + str("%s user not found in database." % username))
     else:
         username = user.handle
         print(WARN + str("Are you sure you want to delete %s?" % username))
         if raw_input(PROMPT + "Delete [y/n]: ").lower() == 'y':
             permissions = Permission.by_user_id(user.id)
             for perm in permissions:
                 print(INFO + "Removing permission: " +
                       perm.permission_name)
                 dbsession.delete(perm)
             dbsession.flush()
             dbsession.delete(user)
             dbsession.flush()
             print(INFO +
                   str("Successfully deleted %s from database." % username))