|
|
|
@ -1,5 +1,8 @@ |
|
|
|
class LettingsLogsController < LogsController |
|
|
|
class LettingsLogsController < LogsController |
|
|
|
before_action :find_resource, except: %i[create index edit delete_confirmation] |
|
|
|
rescue_from ActiveRecord::RecordNotFound, with: :render_not_found |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before_action :find_resource, only: %i[update show] |
|
|
|
|
|
|
|
|
|
|
|
before_action :session_filters, if: :current_user, only: %i[index email_csv download_csv] |
|
|
|
before_action :session_filters, if: :current_user, only: %i[index email_csv download_csv] |
|
|
|
before_action :set_session_filters, if: :current_user, only: %i[index email_csv download_csv] |
|
|
|
before_action :set_session_filters, if: :current_user, only: %i[index email_csv download_csv] |
|
|
|
before_action :authenticate_scope!, only: %i[download_csv email_csv] |
|
|
|
before_action :authenticate_scope!, only: %i[download_csv email_csv] |
|
|
|
@ -55,22 +58,19 @@ class LettingsLogsController < LogsController |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def edit |
|
|
|
def edit |
|
|
|
@log = current_user.lettings_logs.find_by(id: params[:id]) |
|
|
|
@log = current_user.lettings_logs.find(params[:id]) |
|
|
|
if @log |
|
|
|
|
|
|
|
if @log.unresolved |
|
|
|
if @log.unresolved |
|
|
|
redirect_to(send(@log.form.unresolved_log_path, @log)) |
|
|
|
redirect_to(send(@log.form.unresolved_log_path, @log)) |
|
|
|
else |
|
|
|
else |
|
|
|
render("logs/edit", locals: { current_user: }) |
|
|
|
render("logs/edit", locals: { current_user: }) |
|
|
|
end |
|
|
|
end |
|
|
|
else |
|
|
|
|
|
|
|
render_not_found |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def destroy |
|
|
|
def destroy |
|
|
|
render_not_found and return unless @log |
|
|
|
@log = LettingsLog.visible.find(params[:id]) |
|
|
|
|
|
|
|
|
|
|
|
authorize @log, policy_class: LogPolicy |
|
|
|
authorize @log |
|
|
|
|
|
|
|
|
|
|
|
@log.discard! |
|
|
|
@log.discard! |
|
|
|
|
|
|
|
|
|
|
|
@ -78,11 +78,9 @@ class LettingsLogsController < LogsController |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def delete_confirmation |
|
|
|
def delete_confirmation |
|
|
|
@log = LettingsLog.visible.find_by(id: params[:lettings_log_id]) |
|
|
|
@log = LettingsLog.visible.find(params[:lettings_log_id]) |
|
|
|
|
|
|
|
|
|
|
|
render_not_found and return unless @log |
|
|
|
authorize @log, :destroy? |
|
|
|
|
|
|
|
|
|
|
|
authorize @log, :destroy?, policy_class: LogPolicy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render "logs/delete_confirmation" |
|
|
|
render "logs/delete_confirmation" |
|
|
|
end |
|
|
|
end |
|
|
|
@ -113,14 +111,14 @@ class LettingsLogsController < LogsController |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
def org_params |
|
|
|
def org_params |
|
|
|
super.merge( |
|
|
|
super.merge( |
|
|
|
{ "managing_organisation_id" => current_user.organisation.id }, |
|
|
|
{ "managing_organisation_id" => current_user.organisation.id }, |
|
|
|
) |
|
|
|
) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def authenticate_scope! |
|
|
|
def authenticate_scope! |
|
|
|
head :unauthorized and return if codes_only_export? && !current_user.support? |
|
|
|
head :unauthorized and return if codes_only_export? && !current_user.support? |
|
|
|
end |
|
|
|
end |
|
|
|
|