def set_private_viewability_of_exploration(committer_id, exploration_id, viewable_if_private):
 if (not Actor(committer_id).can_change_private_viewability(feconf.ACTIVITY_TYPE_EXPLORATION, exploration_id)):
  logging.error(('User %s tried to change private viewability of exploration %s but was refused permission.' % (committer_id, exploration_id)))
  raise Exception('The viewability status of this exploration cannot be changed.')
 exploration_rights = get_exploration_rights(exploration_id)
 old_viewable_if_private = exploration_rights.viewable_if_private
 if (old_viewable_if_private == viewable_if_private):
  raise Exception(('Trying to change viewability status of this exploration to %s, but that is already the current value.' % viewable_if_private))
 exploration_rights.viewable_if_private = viewable_if_private
 commit_cmds = [{'cmd': CMD_CHANGE_PRIVATE_VIEWABILITY, 'old_viewable_if_private': old_viewable_if_private, 'new_viewable_if_private': viewable_if_private}]
 commit_message = ('Made exploration viewable to anyone with the link.' if viewable_if_private else 'Made exploration viewable only to invited playtesters.')
 _save_activity_rights(committer_id, exploration_rights, feconf.ACTIVITY_TYPE_EXPLORATION, commit_message, commit_cmds)
 _update_exploration_summary(exploration_rights)

def set_private_viewability_of_exploration ( committer_id , exploration_id , viewable_if_private ) : if ( not Actor ( committer_id ) . can_change_private_viewability ( feconf . ACTIVITY_TYPE_EXPLORATION , exploration_id ) ) : logging . error ( ( 'User %s tried to change private viewability of exploration %s but was refused permission.' % ( committer_id , exploration_id ) ) ) raise Exception ( 'The viewability status of this exploration cannot be changed.' ) exploration_rights = get_exploration_rights ( exploration_id ) old_viewable_if_private = exploration_rights . viewable_if_private if ( old_viewable_if_private == viewable_if_private ) : raise Exception ( ( 'Trying to change viewability status of this exploration to %s, but that is already the current value.' % viewable_if_private ) ) exploration_rights . viewable_if_private = viewable_if_private commit_cmds = [ { 'cmd' : CMD_CHANGE_PRIVATE_VIEWABILITY , 'old_viewable_if_private' : old_viewable_if_private , 'new_viewable_if_private' : viewable_if_private } ] commit_message = ( 'Made exploration viewable to anyone with the link.' if viewable_if_private else 'Made exploration viewable only to invited playtesters.' ) _save_activity_rights ( committer_id , exploration_rights , feconf . ACTIVITY_TYPE_EXPLORATION , commit_message , commit_cmds ) _update_exploration_summary ( exploration_rights )
sets the viewable_if_private attribute for an explorations rights object .