forked from joshmcarthur/spree-import-products
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean commit of PR joshmcarthur#17 with 1_1_X
- Loading branch information
Showing
28 changed files
with
827 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,7 @@ | |
tmp | ||
nbproject | ||
*.swp | ||
.rvmrc | ||
Gemfile.lock | ||
.bundle | ||
spec/dummy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
source "http://rubygems.org" | ||
source 'http://rubygems.org' | ||
|
||
group :test do | ||
This comment has been minimized.
Sorry, something went wrong. |
||
gem 'ffaker' | ||
gem 'rspec-rails' | ||
gem 'capybara' | ||
gem 'launchy', '2.0.5' | ||
gem 'factory_girl' | ||
end | ||
|
||
if RUBY_VERSION < "1.9" | ||
gem "ruby-debug" | ||
else | ||
gem "ruby-debug19" | ||
end | ||
|
||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 27 additions & 19 deletions
46
app/controllers/spree/admin/product_imports_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,34 @@ | ||
module Spree | ||
module Admin | ||
class ProductImportsController < BaseController | ||
module Admin | ||
class ProductImportsController < BaseController | ||
|
||
#Sorry for not using resource_controller railsdog - I wanted to, but then... I did it this way. | ||
#Verbosity is nice? | ||
#Feel free to refactor and submit a pull request. | ||
#Sorry for not using resource_controller railsdog - I wanted to, but then... I did it this way. | ||
#Verbosity is nice? | ||
#Feel free to refactor and submit a pull request. | ||
|
||
def index | ||
redirect_to :action => :new | ||
end | ||
def index | ||
@product_import = ProductImport.new | ||
end | ||
|
||
def new | ||
@product_import = ProductImport.new | ||
end | ||
def show | ||
@product_import = ProductImport.find(params[:id]) | ||
@products = @product_import.products | ||
end | ||
|
||
def create | ||
@product_import = ProductImport.create(params[:product_import]) | ||
Delayed::Job.enqueue ImportProducts::ImportJob.new(@product_import, @current_user) | ||
flash[:notice] = t('product_import_processing') | ||
redirect_to admin_product_imports_path | ||
end | ||
|
||
def create | ||
@product_import = ProductImport.create(params[:product_import]) | ||
Delayed::Job.enqueue ImportProducts::ImportJob.new(@product_import, @current_user) | ||
flash[:notice] = t('product_import_processing') | ||
redirect_to admin_product_imports_path | ||
end | ||
end | ||
end | ||
def destroy | ||
@product_import = ProductImport.find(params[:id]) | ||
if @product_import.destroy | ||
flash[:notice] = t('delete_product_import_successful') | ||
end | ||
redirect_to admin_product_imports_path | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# TODO Remove this fix once this pull request is merged and bumped: https://github.com/spree/spree/pull/1308 | ||
Spree::Admin::NavigationHelper.module_eval do | ||
def button(text, icon_name = nil, button_type = 'submit', options={}) | ||
button_tag(content_tag('span', icon(icon_name) + ' ' + text), options.merge(:type => button_type)) | ||
end | ||
|
||
def button_link_to(text, url, html_options = {}) | ||
if (html_options[:method] && | ||
html_options[:method].to_s.downcase != 'get' && | ||
!html_options[:remote]) | ||
form_tag(url, :method => html_options.delete(:method)) do | ||
button(text, html_options.delete(:icon), nil, html_options) | ||
end | ||
else | ||
if html_options['data-update'].nil? && html_options[:remote] | ||
object_name, action = url.split('/')[-2..-1] | ||
html_options['data-update'] = [action, object_name.singularize].join('_') | ||
end | ||
html_options.delete('data-update') unless html_options['data-update'] | ||
link_to(text_for_button_link(text, html_options), url, html_options_for_button_link(html_options)) | ||
end | ||
end | ||
end |
Oops, something went wrong.
Hey @sbounmy,
I'd prefer these gems to be in the gemspec, using
add_development_dependency
- this keeps the Gemfile clean, and makes sure all the gem dependencies are listed in one place.