allow upload of giftcards
This commit is contained in:
parent
de8324e87d
commit
a2fd9cb87a
|
|
@ -28,7 +28,7 @@ ActiveAdmin.register_page "Giftcarduploads" do
|
|||
end
|
||||
|
||||
content do
|
||||
semantic_form_for GiftCard.new, :url => admin_giftcarduploads_upload_giftcards_path, :builder => ActiveAdmin::FormBuilder do |f|
|
||||
active_admin_form_for GiftCard.new, :url => admin_giftcarduploads_upload_giftcards_path, :builder => ActiveAdmin::FormBuilder do |f|
|
||||
f.inputs "Upload Gift Cards" do
|
||||
f.input :csv, as: :file, required: true, :label => "A single column CSV that contains ONE type of gift card (5 JamTrack, 10 JamTrack, etc)"
|
||||
f.input :card_type, required:true, as: :select, :collection => JamRuby::GiftCard::CARD_TYPES
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
ActiveAdmin.register_page "POSA Card Uploads" do
|
||||
|
||||
menu :label => 'Posa Cards Upload', :parent => 'JamClass'
|
||||
|
||||
page_action :upload_posacards, :method => :post do
|
||||
PosaCard.transaction do
|
||||
|
||||
puts params
|
||||
|
||||
file = params[:jam_ruby_posa_card][:csv]
|
||||
array_of_arrays = CSV.read(file.tempfile.path)
|
||||
array_of_arrays.each do |row|
|
||||
if row.length != 1
|
||||
raise "UKNONWN CSV FORMAT! Must be 1 column"
|
||||
end
|
||||
|
||||
code = row[0]
|
||||
|
||||
posa_card = PosaCard.new
|
||||
posa_card.code = code
|
||||
posa_card.card_type = params[:jam_ruby_posa_card][:card_type]
|
||||
posa_card.origin = file .original_filename
|
||||
posa_card.save!
|
||||
end
|
||||
|
||||
redirect_to admin_posa_card_uploads_path, :notice => "Created #{array_of_arrays.length} POSA cards!"
|
||||
end
|
||||
end
|
||||
|
||||
=begin
|
||||
form :html => {:multipart => true} do |f|
|
||||
f.inputs "Details" do
|
||||
f.input :version, :hint => "Should match Jenkins build number of artifact"
|
||||
f.input :environment, :hint => "Typically just 'public'"
|
||||
f.input :product, :as => :select, :collection => JamRuby::ArtifactUpdate::PRODUCTS
|
||||
end
|
||||
f.inputs "Artifact Upload" do
|
||||
f.input :uri, :as => :file, :hint => "Upload the artifact from Jenkins"
|
||||
end
|
||||
|
||||
f.actions
|
||||
|
||||
end
|
||||
=end
|
||||
|
||||
content do
|
||||
active_admin_form_for PosaCard.new, :url => admin_posa_card_uploads_upload_posacards_path, :builder => ActiveAdmin::FormBuilder do |f|
|
||||
f.inputs "Upload POSA Cards" do
|
||||
f.input :csv, as: :file, required: true, :label => "A single column CSV that contains ONE type of gift card (5 JamTrack, 10 JamTrack, 4 JamClass etc)"
|
||||
f.input :card_type, required:true, as: :select, :collection => JamRuby::PosaCard::CARD_TYPES
|
||||
|
||||
end
|
||||
f.actions
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue