From 4d07e585fe6cc6ce0bac716de81dd7c59458586d Mon Sep 17 00:00:00 2001 From: luciajanikova <19lucia99@gmail.com> Date: Wed, 27 Sep 2023 11:38:36 +0200 Subject: [PATCH] Small after review updates --- app/controllers/application_controller.rb | 4 ---- app/controllers/message_drafts_imports_controller.rb | 8 +++----- config/locales/en.yml | 2 -- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5a20db975..2d248cb8f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -17,8 +17,4 @@ def set_menu_context @tags = policy_scope(Tag, policy_scope_class: TagPolicy::Scope).where(visible: true) @menu = SidebarMenu.new(controller_name, action_name, { tags: @tags }) end - - def render_forbidden(key, value: nil) - render status: :forbidden, json: { message: I18n.t("forbidden.#{key}", value: value, locale: :en) } - end end diff --git a/app/controllers/message_drafts_imports_controller.rb b/app/controllers/message_drafts_imports_controller.rb index 5fc4c05df..387654195 100644 --- a/app/controllers/message_drafts_imports_controller.rb +++ b/app/controllers/message_drafts_imports_controller.rb @@ -7,9 +7,8 @@ def create file_storage = FileStorage.new zip_content = params[:content] - import = MessageDraftsImport.create!( - name: "#{Time.now.to_i}_#{zip_content.original_filename}", - box: @box + import = @box.message_drafts_imports.create!( + name: "#{Time.now.to_i}_#{zip_content.original_filename}" ) import_path = file_storage.store("imports", import_path(import), zip_content.read.force_encoding("UTF-8")) @@ -33,7 +32,6 @@ def import_path(import) def load_box return unless params[:box_id].present? - @box = Box.find(params[:box_id].to_i) - render_forbidden(:box_id, value: params[:box_id]) unless @box.tenant == Current.tenant + @box = Current.tenant.boxes.find(params[:box_id]) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 189ea7a2a..cf9b342d0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -31,5 +31,3 @@ en: hello: "Hello world" - forbidden: - box_id: 'Forbidden box ID: %{value}'