trace = do_create(params[:file], tags, description, visibility)
if trace.id
- TraceImporterJob.perform_later(trace)
+ trace.schedule_import
render :plain => trace.id.to_s
elsif trace.valid?
head :internal_server_error
if trace.user == current_user
trace.visible = false
trace.save!
- TraceDestroyerJob.perform_later(trace)
+ trace.schedule_destruction
head :ok
else
flash[:notice] = t ".trace_uploaded"
flash[:warning] = t ".traces_waiting", :count => current_user.traces.where(:inserted => false).count if current_user.traces.where(:inserted => false).count > 4
- TraceImporterJob.perform_later(@trace)
+ @trace.schedule_import
redirect_to :action => :index, :display_name => current_user.display_name
else
flash[:error] = t(".upload_failed") if @trace.valid?
trace.visible = false
trace.save
flash[:notice] = t ".scheduled_for_deletion"
- TraceDestroyerJob.perform_later(trace)
+ trace.schedule_destruction
redirect_to :action => :index, :display_name => trace.user.display_name
end
rescue ActiveRecord::RecordNotFound
end
end
+ def schedule_import
+ TraceImporterJob.perform_later(self)
+ end
+
+ def schedule_destruction
+ TraceDestroyerJob.perform_later(self)
+ end
+
private
def content_type(file)