spree_delivery_time 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/app/models/order_decorator.rb +21 -0
- data/app/overrides/admin/orders/admin_orders_delivery_time_column.rb +11 -0
- data/app/overrides/admin/orders/admin_orders_delivery_time_filter.rb +5 -0
- data/app/overrides/admin/shared/admin_order_information.rb +5 -0
- data/app/overrides/checkout/delivery_time.rb +5 -0
- data/app/overrides/orders/delivery_time_details.rb +5 -0
- data/app/views/spree/admin/orders/_delivery_time_cell.html.erb +5 -0
- data/app/views/spree/admin/orders/_delivery_time_filter.html.erb +12 -0
- data/app/views/spree/admin/orders/_delivery_time_header.html.erb +1 -0
- data/app/views/spree/admin/shared/_admin_order_information_delivery_time.html.erb +6 -0
- data/app/views/spree/checkout/_delivery_time.html.erb +7 -0
- data/app/views/spree/orders/_order_delivery_time_details.html.erb +8 -0
- data/db/migrate/20130415025010_add_delivery_time_to_orders.rb +11 -0
- data/lib/generators/spree_delivery_time/install/install_generator.rb +29 -0
- data/lib/spree_delivery_time/engine.rb +17 -0
- data/lib/spree_delivery_time/version.rb +3 -0
- data/lib/spree_delivery_time.rb +2 -0
- data/script/rails +7 -0
- data/spree_delivery_date.gemspec +21 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a1908c445dc0c42082dfcd10a1709be58b16cb9a
|
4
|
+
data.tar.gz: d5c328c967880c75b467552a588f8a19984cfd21
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d2411f972721ef86ddf895ce16987d707d63119cb7212f9e65645bf6a3c20732c76cbeaba098d3462d5f7c6bbf3a0ea15fe5cef7f38ebaf27a62e2c721cffdb1
|
7
|
+
data.tar.gz: 3f9b9fc3bc8622c55f5a55684299f511eac7d219bae6ccfcf16131db6015551665af2796574dd9d96cfc89381a8b6b7f8b50be57e28a2aa801e29f2290095270
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Agustin Anfuso
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Spree Delivery Time
|
2
|
+
=================
|
3
|
+
|
4
|
+
Requires user to enter a delivery time during checkout (delivery
|
5
|
+
section)
|
6
|
+
|
7
|
+
* Uses validation to ensure user specifies the start delivery time
|
8
|
+
before the end delivery time.
|
9
|
+
* Shows delivery time during checkout confirmation.
|
10
|
+
* Shows delivery time when viewing or editing order as admin.
|
11
|
+
* Adds delivery date column to orders index page table.
|
12
|
+
|
13
|
+
Installing
|
14
|
+
=======
|
15
|
+
|
16
|
+
Add the gem to your Gemfile
|
17
|
+
|
18
|
+
$ gem 'spree_delivery_date', github: 'aanfuso/spree_delivery_time', branch: '1-3-stable'
|
19
|
+
|
20
|
+
bundle
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
and run
|
25
|
+
|
26
|
+
$ rails g spree_delivery_date:install
|
27
|
+
|
28
|
+
to install and run the migrations. This migration simply
|
29
|
+
adds the start_delivery_time and end_delivery_time columns to Spree::Order.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Spree::Order.class_eval do
|
2
|
+
require 'spree/order/checkout'
|
3
|
+
|
4
|
+
attr_accessible :start_delivery_time, :end_delivery_time
|
5
|
+
|
6
|
+
validate :start_delivery_time, presence: true, allow_nil: false
|
7
|
+
validate :end_delivery_time, presence: true, allow_nil: false
|
8
|
+
validate :delivery_time_specific_validation
|
9
|
+
|
10
|
+
def delivery_time
|
11
|
+
"#{start_delivery_time.strftime("%H:%M")} - #{end_delivery_time.strftime("%H:%M")}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def delivery_time_specific_validation
|
15
|
+
if start_delivery_time && end_delivery_time && ['payment', 'confirm', 'complete'].include?(state)
|
16
|
+
if end_delivery_time <= start_delivery_time
|
17
|
+
self.errors.add(:start_delivery_time, "Tiene que ser anterior a la hora final de entrega.")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Deface::Override.new(virtual_path: "spree/admin/orders/index",
|
2
|
+
name: "add_delivery_time_table_header",
|
3
|
+
insert_top: "[data-hook='admin_orders_index_headers']",
|
4
|
+
partial: "spree/admin/orders/delivery_time_header",
|
5
|
+
disabled: false)
|
6
|
+
|
7
|
+
Deface::Override.new(virtual_path: "spree/admin/orders/index",
|
8
|
+
name: "add_delivery_time_table_row_cell",
|
9
|
+
insert_top: "[data-hook='admin_orders_index_rows']",
|
10
|
+
partial: "spree/admin/orders/delivery_time_cell",
|
11
|
+
disabled: false)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div class="time-range-filter field">
|
2
|
+
<%= label_tag nil, t(:start_delivery_time) %>
|
3
|
+
<div class="time-range-fields">
|
4
|
+
<%= f.text_field :start_delivery_time_gt, class: 'datepicker datepicker-from', value: params[:q][:start_delivery_time_gt], placeholder: t(:start) %>
|
5
|
+
|
6
|
+
<span class="range-divider">
|
7
|
+
<i class="icon-arrow-right"></i>
|
8
|
+
</span>
|
9
|
+
|
10
|
+
<%= f.text_field :start_delivery_time_lt, class: 'datepicker datepicker-to', value: params[:q][:start_delivery_time_lt], placeholder: t(:stop) %>
|
11
|
+
</div>
|
12
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<th><%= sort_link @search, :start_delivery_time, t(:start_delivery_time, scope: 'activerecord.attributes.spree/order') %></th>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class AddDeliveryTimeToOrders < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
add_column :spree_orders, :start_delivery_time, :time
|
4
|
+
add_column :spree_orders, :end_delivery_time, :time
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
remove_column :spree_orders, :start_delivery_time
|
9
|
+
remove_column :spree_orders, :end_delivery_time
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module SpreeDeliveryTime
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
def add_javascripts
|
6
|
+
append_file 'app/assets/javascripts/store/all.js', "//= require store/spree_core\n"
|
7
|
+
append_file 'app/assets/javascripts/admin/all.js', "//= require admin/spree_core\n"
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_stylesheets
|
11
|
+
inject_into_file 'app/assets/stylesheets/store/all.css', " *= require store/spree_core\n", before: /\*\//,verbose: true
|
12
|
+
inject_into_file 'app/assets/stylesheets/admin/all.css', " *= require admin/spree_core\n", before: /\*\//, verbose: true
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_migrations
|
16
|
+
run 'bundle exec rake railties:install:migrations FROM=spree_delivery_time'
|
17
|
+
end
|
18
|
+
|
19
|
+
def run_migrations
|
20
|
+
res = ask 'Would you like to run the migrations now? [Y/n]'
|
21
|
+
if res == '' || res.downcase == 'y'
|
22
|
+
run 'bundle exec rake db:migrate'
|
23
|
+
else
|
24
|
+
puts 'Skipping rake db:migrate, don\'t forget to run it!'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SpreeDeliveryTime
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
require 'spree/core'
|
4
|
+
isolate_namespace Spree
|
5
|
+
engine_name 'spree_delivery_time'
|
6
|
+
|
7
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
8
|
+
|
9
|
+
def self.activate
|
10
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
|
11
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
config.to_prepare &method(:activate).to_proc
|
16
|
+
end
|
17
|
+
end
|
data/script/rails
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
2
|
+
|
3
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
4
|
+
ENGINE_PATH = File.expand_path('../../lib/spree_delivery_time/engine', __FILE__)
|
5
|
+
|
6
|
+
require 'rails/all'
|
7
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'spree_delivery_time/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "spree_delivery_time"
|
7
|
+
spec.version = SpreeDeliveryTime::VERSION
|
8
|
+
spec.authors = ["Agustin Anfuso"]
|
9
|
+
spec.email = ["anfusoagustin89@gmail.com"]
|
10
|
+
spec.summary = %q{Adds a delivery time field in the delivery section of checkout.}
|
11
|
+
spec.description = %q{Adds a delivery time field in the delivery section of the checkout. Allows admin and order owner to view that delivery time in the order details.}
|
12
|
+
spec.homepage = ""
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency 'spree_core', '~> 1.3.2'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_delivery_time
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Agustin Anfuso
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: spree_core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.3.2
|
27
|
+
description: Adds a delivery time field in the delivery section of the checkout. Allows
|
28
|
+
admin and order owner to view that delivery time in the order details.
|
29
|
+
email:
|
30
|
+
- anfusoagustin89@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- .gitignore
|
36
|
+
- CHANGELOG.md
|
37
|
+
- Gemfile
|
38
|
+
- LICENSE
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- app/models/order_decorator.rb
|
42
|
+
- app/overrides/admin/orders/admin_orders_delivery_time_column.rb
|
43
|
+
- app/overrides/admin/orders/admin_orders_delivery_time_filter.rb
|
44
|
+
- app/overrides/admin/shared/admin_order_information.rb
|
45
|
+
- app/overrides/checkout/delivery_time.rb
|
46
|
+
- app/overrides/orders/delivery_time_details.rb
|
47
|
+
- app/views/spree/admin/orders/_delivery_time_cell.html.erb
|
48
|
+
- app/views/spree/admin/orders/_delivery_time_filter.html.erb
|
49
|
+
- app/views/spree/admin/orders/_delivery_time_header.html.erb
|
50
|
+
- app/views/spree/admin/shared/_admin_order_information_delivery_time.html.erb
|
51
|
+
- app/views/spree/checkout/_delivery_time.html.erb
|
52
|
+
- app/views/spree/orders/_order_delivery_time_details.html.erb
|
53
|
+
- db/migrate/20130415025010_add_delivery_time_to_orders.rb
|
54
|
+
- lib/generators/spree_delivery_time/install/install_generator.rb
|
55
|
+
- lib/spree_delivery_time.rb
|
56
|
+
- lib/spree_delivery_time/engine.rb
|
57
|
+
- lib/spree_delivery_time/version.rb
|
58
|
+
- script/rails
|
59
|
+
- spree_delivery_date.gemspec
|
60
|
+
homepage: ''
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.0.14
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Adds a delivery time field in the delivery section of checkout.
|
84
|
+
test_files: []
|