Skip to content

Commit

Permalink
Small after review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
luciajanikova committed Sep 27, 2023
1 parent dad5569 commit 4d07e58
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
4 changes: 0 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 3 additions & 5 deletions app/controllers/message_drafts_imports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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
2 changes: 0 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,3 @@

en:
hello: "Hello world"
forbidden:
box_id: 'Forbidden box ID: %{value}'

0 comments on commit 4d07e58

Please sign in to comment.