def do_deactivate_realm(realm):
 if realm.deactivated:
  return
 realm.deactivated = True
 realm.save(update_fields=['deactivated'])
 for user in active_humans_in_realm(realm):
  delete_user_sessions(user)

def do_deactivate_realm ( realm ) : if realm . deactivated : return realm . deactivated = True realm . save ( update_fields = [ 'deactivated' ] ) for user in active_humans_in_realm ( realm ) : delete_user_sessions ( user )
deactivate this realm .