<commit_before>class ProfileEditorController < MyProfileController

  protect 'edit_profile', :profile, :except => [:destroy_profile]
  protect 'destroy_profile', :profile, :only => [:destroy_profile]

  def index
    @pending_tasks = Task.to(profile).pending.without_spam.select{|i| user.has_permission?(i.permission, profile)}
  end

  helper :profile

  # edits the profile info (posts back)
  def edit
    @profile_data = profile
    @possible_domains = profile.possible_domains
    if request.post?
      params[:profile_data][:fields_privacy] ||= {} if profile.person? && params[:profile_data].is_a?(Hash)
      begin
        Profile.transaction do
        Image.transaction do
          if profile.update_attributes!(params[:profile_data])
            redirect_to :action => 'index', :profile => profile.identifier
          end
        end
        end
      rescue Exception => ex
        if profile.identifier.blank?
          profile.identifier = params[:profile]
        end
        session[:notice] = _('Cannot update profile')
        logger.error ex.to_s
      end
    end
  end

  def enable
    if request.post? && params[:confirmation]
      @to_enable = profile
      unless profile.enable user
        session[:notice] = _('%s was not enabled.') % profile.name
      end
      redirect_to :action => :index
    end
  end

  def disable
    if request.post? && params[:confirmation]
      unless profile.update_attribute :enabled, false
        session[:notice] = _('%s was not disabled.') % profile.name
      end
      redirect_to :action => :index
    end
  end

  def update_categories
    @object = profile
    @categories = @toplevel_categories = environment.top_level_categories
    if params[:category_id]
      @current_category = Category.find(params[:category_id])
      @categories = @current_category.children.alphabetical
    end
    render :partial => 'shared/select_categories', :locals => {:object_name => 'profile_data', :multiple => true}, :layout => false
  end

  def header_footer
    @no_design_blocks = true
    if request.post?<commit_msg>Fix assignment<commit_after>class ProfileEditorController < MyProfileController

  protect 'edit_profile', :profile, :except => [:destroy_profile]
  protect 'destroy_profile', :profile, :only => [:destroy_profile]

  def index
    @pending_tasks = Task.to(profile).pending.without_spam.select{|i| user.has_permission?(i.permission, profile)}
  end

  helper :profile

  # edits the profile info (posts back)
  def edit
    @profile_data = profile
    @possible_domains = profile.possible_domains
    if request.post?
      params[:profile_data][:fields_privacy] ||= {} if profile.person? && params[:profile_data].is_a?(Hash)
      begin
        Profile.transaction do
        Image.transaction do
          if profile.update_attributes!(params[:profile_data])
            redirect_to :action => 'index', :profile => profile.identifier
          end
        end
        end
      rescue Exception => ex
        if profile.identifier.blank?
          profile.identifier = params[:profile]
        end
        session[:notice] = _('Cannot update profile')
        logger.error ex.to_s
      end
    end
  end

  def enable
    @to_enable = profile
    if request.post? && params[:confirmation]
      unless profile.enable user
        session[:notice] = _('%s was not enabled.') % profile.name
      end
      redirect_to :action => :index
    end
  end

  def disable
    if request.post? && params[:confirmation]
      unless profile.update_attribute :enabled, false
        session[:notice] = _('%s was not disabled.') % profile.name
      end
      redirect_to :action => :index
    end
  end

  def update_categories
    @object = profile
    @categories = @toplevel_categories = environment.top_level_categories
    if params[:category_id]
      @current_category = Category.find(params[:category_id])
      @categories = @current_category.children.alphabetical
    end
    render :partial => 'shared/select_categories', :locals => {:object_name => 'profile_data', :multiple => true}, :layout => false
  end

  def header_footer
    @no_design_blocks = true
    if request.post?
{'fraction_non_alphanumeric': 0.10569300984866682, 'fraction_numerical': 0.0, 'mean_word_length': 3.042718446601942, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4149752', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1155, 'n_words': 294}