Upgrade the extension to work with Spree 1.2
* Now that we need to pass the shipment.. * We need to copy the shipped_email text..
This commit is contained in:
parent
f56d05b8f5
commit
833e597cda
|
@ -0,0 +1 @@
|
|||
//= require admin/spree_core
|
|
@ -0,0 +1 @@
|
|||
//= require store/spree_core
|
|
@ -0,0 +1,3 @@
|
|||
/*
|
||||
*= require admin/spree_core
|
||||
*/
|
|
@ -0,0 +1,3 @@
|
|||
/*
|
||||
*= require store/spree_core
|
||||
*/
|
|
@ -1,3 +0,0 @@
|
|||
class Admin::DhlsController < Admin::BaseController
|
||||
respond_to :html
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class Spree::Admin::DhlsController < Spree::Admin::BaseController
|
||||
respond_to :html
|
||||
end
|
||||
|
||||
puts("LOADED\n");
|
|
@ -1,7 +1,6 @@
|
|||
Admin::ShipmentsController.class_eval do
|
||||
Spree::Admin::ShipmentsController.class_eval do
|
||||
def dhllabel
|
||||
load_shipment
|
||||
name = '%s_dhllabel.csv' % [@order.number]
|
||||
name = '%s_dhllabel.csv' % [order.number]
|
||||
headers["Content-type"] = "text/plain; charset=iso-8859-15"
|
||||
headers["Cache-Control"] = "no-cache, max-age=0, must-revalidate"
|
||||
headers["Pragma"] = "no-cache"
|
||||
|
@ -9,8 +8,8 @@ Admin::ShipmentsController.class_eval do
|
|||
headers["Content-Disposition"] = "attachment; filename=\"%s\"" % name
|
||||
|
||||
# Try hard to render it as latin1
|
||||
res = render
|
||||
res = render :locals => { :shipment => shipment }
|
||||
response.charset = 'iso-8859-15'
|
||||
response.body = Iconv.conv('iso-8859-15', 'utf-8', res)
|
||||
response.body = Iconv.conv('iso-8859-15', 'utf-8', res[0])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
Spree::ShippingMethod.class_eval do
|
||||
attr_accessible :method_details
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
Deface::Override.new(:virtual_path => "spree/layouts/admin",
|
||||
:name => "dhl_admin_tabs",
|
||||
:insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]",
|
||||
:text => "<%= tab(:dhls, :url => spree.admin_dhls_path) %>",
|
||||
:disabled => false,
|
||||
:original => 'b06db401e133fa2491f542e73196e0bb79a4ca05')
|
||||
|
||||
Deface::Override.new(:virtual_path => "spree/admin/shipments/edit",
|
||||
:name => "dhl_label",
|
||||
:insert_bottom => "[data-hook='admin_shipment_edit_buttons']",
|
||||
:partial => 'spree/admin/dhls/address_label',
|
||||
:original => 'e5254ea08fdafd6dfaf37a2631fdc384f0a4a3ae')
|
||||
|
||||
Deface::Override.new(:virtual_path => "spree/admin/shipping_methods/_form",
|
||||
:name => 'dhl_shipment_method',
|
||||
:insert_bottom => "[data-hook='admin_shipping_method_form_fields']",
|
||||
:partial => 'spree/admin/dhls/method_details_form')
|
||||
|
||||
|
||||
# This doesn't work with the shipment mailer..
|
|
@ -0,0 +1,18 @@
|
|||
<%= t('shipment_mailer.shipped_email.dear_customer') %>
|
||||
|
||||
<%= t('shipment_mailer.shipped_email.instructions') %>
|
||||
|
||||
============================================================
|
||||
<%= t('shipment_mailer.shipped_email.shipment_summary') %>
|
||||
============================================================
|
||||
<% @shipment.manifest.each do |item| %>
|
||||
<%= item.variant.sku %> <%= item.variant.product.name %> <%= item.variant.options_text %>
|
||||
<% end %>
|
||||
============================================================
|
||||
|
||||
<%= t('shipment_mailer.shipped_email.track_information', :tracking => @shipment.tracking) if @shipment.tracking %>
|
||||
|
||||
<%= render :partial => 'spree/shipment_mailer/dhls/tracking_description' %>
|
||||
|
||||
<%= t('shipment_mailer.shipped_email.thanks') %>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
Rails.application.routes.draw do
|
||||
Spree::Core::Engine.routes.draw do
|
||||
# Add your extension routes here
|
||||
namespace :admin do
|
||||
resources :dhls do
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
module SysmocomDhl
|
||||
module Generators
|
||||
class InstallGenerator < Rails::Generators::Base
|
||||
|
||||
def add_javascripts
|
||||
append_file 'app/assets/javascripts/store/all.js', "//= require store/sysmocom_dhl\n"
|
||||
append_file 'app/assets/javascripts/admin/all.js', "//= require admin/sysmocom_dhl\n"
|
||||
end
|
||||
|
||||
def add_stylesheets
|
||||
inject_into_file 'app/assets/stylesheets/store/all.css', " *= require store/sysmocom_dhl\n", :before => /\*\//, :verbose => true
|
||||
inject_into_file 'app/assets/stylesheets/admin/all.css', " *= require admin/sysmocom_dhl\n", :before => /\*\//, :verbose => true
|
||||
end
|
||||
|
||||
def add_migrations
|
||||
run 'bundle exec rake railties:install:migrations FROM=sysmocom_dhl'
|
||||
end
|
||||
|
||||
def run_migrations
|
||||
res = ask 'Would you like to run the migrations now? [Y/n]'
|
||||
if res == '' || res.downcase == 'y'
|
||||
run 'bundle exec rake db:migrate'
|
||||
else
|
||||
puts 'Skipping rake db:migrate, don\'t forget to run it!'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,17 +1,3 @@
|
|||
require 'spree_core'
|
||||
require 'sysmocom_dhl_hooks'
|
||||
|
||||
module SysmocomDhl
|
||||
class Engine < Rails::Engine
|
||||
|
||||
config.autoload_paths += %W(#{config.root}/lib)
|
||||
|
||||
def self.activate
|
||||
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
|
||||
Rails.env.production? ? require(c) : load(c)
|
||||
end
|
||||
end
|
||||
|
||||
config.to_prepare &method(:activate).to_proc
|
||||
end
|
||||
end
|
||||
require 'sysmocom_dhl/engine'
|
||||
require 'iconv'
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
module SpreeTest
|
||||
class Engine < Rails::Engine
|
||||
require 'spree/core'
|
||||
isolate_namespace Spree
|
||||
engine_name 'sysmocom_dhl'
|
||||
|
||||
config.autoload_paths += %W(#{config.root}/lib)
|
||||
|
||||
# use rspec for tests
|
||||
config.generators do |g|
|
||||
g.test_framework :rspec
|
||||
end
|
||||
|
||||
def self.activate
|
||||
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
|
||||
Rails.configuration.cache_classes ? require(c) : load(c)
|
||||
end
|
||||
end
|
||||
|
||||
config.to_prepare &method(:activate).to_proc
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
class SysmocomDhlHooks < Spree::ThemeSupport::HookListener
|
||||
# custom hooks go here
|
||||
insert_after :admin_tabs do
|
||||
"<%= tab(:dhls) %>"
|
||||
end
|
||||
|
||||
# Add the DHL label download
|
||||
insert_after :admin_shipment_edit_buttons, 'admin/dhls/address_label'
|
||||
|
||||
# Add shipment identification..
|
||||
insert_after :shipment_mailer_shipped_email_tracking, 'shipment_mailer/dhls/tracking_description'
|
||||
insert_after :admin_shipping_method_form_fields, 'admin/dhls/method_details_form'
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
namespace :sysmocom_dhl do
|
||||
desc "Copies all migrations and assets (NOTE: This will be obsolete with Rails 3.1)"
|
||||
task :install do
|
||||
Rake::Task['sysmocom_dhl:install:migrations'].invoke
|
||||
Rake::Task['sysmocom_dhl:install:assets'].invoke
|
||||
end
|
||||
|
||||
namespace :install do
|
||||
desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
|
||||
task :migrations do
|
||||
source = File.join(File.dirname(__FILE__), '..', '..', 'db')
|
||||
destination = File.join(Rails.root, 'db')
|
||||
Spree::FileUtilz.mirror_files(source, destination)
|
||||
end
|
||||
|
||||
desc "Copies all assets (NOTE: This will be obsolete with Rails 3.1)"
|
||||
task :assets do
|
||||
source = File.join(File.dirname(__FILE__), '..', '..', 'public')
|
||||
destination = File.join(Rails.root, 'public')
|
||||
puts "INFO: Mirroring assets from #{source} to #{destination}"
|
||||
Spree::FileUtilz.mirror_files(source, destination)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1 +0,0 @@
|
|||
# add custom rake tasks here
|
|
@ -1,10 +1,10 @@
|
|||
Gem::Specification.new do |s|
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.name = 'sysmocom_dhl'
|
||||
s.version = '0.60.1'
|
||||
s.version = '1.2.0'
|
||||
s.summary = 'sysmocom_dhl shipping helper'
|
||||
s.description = 'Deal with shipping cost, zones, insurance'
|
||||
s.required_ruby_version = '>= 1.8.7'
|
||||
s.required_ruby_version = '>= 1.9.1'
|
||||
|
||||
# s.author = 'David Heinemeier Hansson'
|
||||
# s.email = 'david@loudthinking.com'
|
||||
|
@ -16,5 +16,5 @@ Gem::Specification.new do |s|
|
|||
s.require_path = 'lib'
|
||||
s.requirements << 'none'
|
||||
|
||||
s.add_dependency('spree_core', '>= 0.60.1')
|
||||
s.add_dependency('spree_core', '>= 1.2.0')
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue