app/controllers/settings_controller.rb
##
# attempt to upgrade `user` to special_user unless they already are one.
attempt to upgrade `user` to special_user unless they already are one.
attempt to upgrade ` user ` to special_user unless they already are one .
def attempt_special_user_upgrade
    if SpecialUsers.is?(@user, @position)
      message = I18n.t(
        'settings.special_users.new.already_is',
        username: @user.username,
        position: @position
      )
      yield json: { message: message }, status: 422
    end
    Setting.set_special_user(@position, @user.username)
    message = I18n.t(
      'settings.special_users.new.elevate_success',
      username: @user.username,
      position: @position
    )
    yield json: { message: message }, status: 200
  end
def attempt_special_user_upgrade if SpecialUsers . is? ( @user , @position ) message = I18n . t ( 'settings.special_users.new.already_is' , username : @user . username , position : @position ) yield json : { message : message } , status : 422 end Setting . set_special_user ( @position , @user . username ) message = I18n . t ( 'settings.special_users.new.elevate_success' , username : @user . username , position : @position ) yield json : { message : message } , status : 200 end
attempt to upgrade `user` to special_user unless they already are one.
attempt to upgrade ` user ` to special_user unless they already are one .
# Check if the user already has the position