Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
1.2 KiB

class OrganisationNameChangesController < ApplicationController
before_action :set_organisation, only: %i[create change_name]
before_action :set_previous_name_changes, only: %i[create change_name]
def create
@organisation_name_change = @organisation.organisation_name_changes.new(organisation_name_change_params)
@organisation_name_change.change_type = :user_change
Rails.logger.debug "Params: #{params[:organisation_name_change]}"
if @organisation_name_change.save
notice_message = @organisation_name_change.immediate_change ? "Name change saved successfully." : "Name change scheduled for #{@organisation_name_change.formatted_startdate}."
redirect_to organisation_path(@organisation), notice: notice_message
else
render :new, status: :unprocessable_entity
end
end
def change_name
@organisation_name_change = OrganisationNameChange.new
render :new, layout: "application"
end
private
def set_organisation
@organisation = Organisation.find(params[:id])
end
def set_previous_name_changes
@previous_name_changes = @organisation.name_changes_with_dates
end
def organisation_name_change_params
params.require(:organisation_name_change).permit(:name, :startdate, :immediate_change)
end
end