-
-
Save janxious/7576c0851d2c0b30157b to your computer and use it in GitHub Desktop.
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
SuperSecret::Application.routes.draw do | |
# ... | |
resources :magick_file_uploads, only: [:new, :create] do | |
member do | |
get :validate_status | |
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
class MagickFileUploadsController < ApplicationController | |
expose(:magick_files){ current_organization.magick_files } | |
expose(:magick_file) | |
expose(:magick_file_upload) | |
expose(:file_headers) { magick_file.magick_file_upload.file_headers } | |
expose(:file_headers_minus_sku) { magick_mapping.magick_file_upload.file_headers_minus_sku } | |
expose(:validation_data){ | |
data = magick_file_upload.generate_validation_data( | |
validate_status_magick_file_magick_file_upload_url(magick_file, magick_file_upload) | |
) | |
sku_mapping_data = magick_file.generate_validation_mapping_data( | |
validate_mapping_status_magick_file_url(magick_file) | |
) | |
data[:details]["sku"] = sku_mapping_data[:details]["sku"] | |
data | |
} | |
expose(:validation_submit_path) { magick_file_path(magick_file) } | |
expose(:validation_back_path) { magick_files_path } | |
expose(:validation_forward_path) { magick_files_path } | |
before_filter { authorize! :manage, magick_file } | |
skip_filter :require_initial_catalog! | |
def create | |
magick_file_upload = magick_file.magick_file_uploads.new(params[:magick_file_upload]) | |
magick_file_upload.magick_file = magick_file | |
if params[:remote_information] | |
magick_file.build_remote_information(params[:remote_information]).save | |
end | |
if magick_file_upload.save | |
if params[:reminder] | |
params[:reminder][:start_date] = DateTime.now+1.day | |
params[:reminder][:email] = current_admin_user.email | |
magick_file.build_reminder(params[:reminder]).save | |
end | |
redirect_to "/magick_files/#{magick_file.id}/magick_file_uploads/#{magick_file.magick_file_upload.id}/validate" | |
else | |
render :new | |
end | |
end | |
def validate_status | |
render json: magick_file_upload.allow_reupload(validation_data) | |
end | |
end |
Author
janxious
commented
Sep 10, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment