venue_management/app/controllers/admin/venue_management_contracts_...

63 lines
1.8 KiB
Ruby

# frozen_string_literal: true
class Admin::VenueManagementContractsController < Admin::VenueAdminController
include Admin::VenueManagementsHelper
before_action ->(module_app = @app_title) { set_variables module_app }
before_action :set_venue_management_contract, only: [:edit, :update, :destroy]
def initialize
super
@app_title = 'venue_management'
end
def index
@table_fields = [
'venue_management.title',
'vm_contract.case_no',
'vm_contract.vendor',
'vm_contract.start_end',
'vm_contract.renewal_permission',
'vm_contract.note',
]
@contracts = VenueManagementContract.order(updated_at: :desc).page(params[:page]).per(10)
end
def new
@venue_management = VenueManagementMain.find(params[:id])
@venue_management_contract = @venue_management.venue_management_contracts.build
end
def create
@venue_management_contract = VenueManagementContract.new(venue_management_contract_params)
@venue_management_contract.save
redirect_to params['referer_url']
end
def edit
@venue_management = VenueManagementMain.find(@venue_management_contract.venue_management_main_id)
end
def update
@venue_management_contract.update_attributes!(venue_management_contract_params)
redirect_to venue_management_contracts_admin_venue_management_path(@venue_management_contract.venue_management_main_id)
end
def destroy
@venue_management_main_id = @venue_management_contract.venue_management_main_id
@venue_management_contract.destroy
redirect_to venue_management_contracts_admin_venue_management_path(@venue_management_main_id)
end
private
def set_venue_management_contract
@venue_management_contract = VenueManagementContract.find(params[:id])
end
def venue_management_contract_params
params.require(:venue_management_contract).permit!
end
end