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 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
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_store
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## v0.1.0
2
+
3
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in spree_delivery_time.gemspec
4
+ gemspec
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,5 @@
1
+ Deface::Override.new(virtual_path: "spree/admin/orders/index",
2
+ name: "add_delivery_time_filter_to_orders_index",
3
+ insert_after: ".date-range-filter",
4
+ partial: "spree/admin/orders/delivery_time_filter",
5
+ disabled: false)
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(virtual_path: "spree/admin/shared/_order_tabs",
2
+ name: "add_delivery_time_to_admin_order_information",
3
+ insert_after: "#order_total",
4
+ partial: "spree/admin/shared/admin_order_information_delivery_time",
5
+ disabled: false)
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(virtual_path: "spree/checkout/_delivery",
2
+ name: "add_delivery_time_to_delivery",
3
+ insert_after: "[data-hook='shipping_method_inner']",
4
+ partial: "spree/checkout/delivery_time",
5
+ disabled: false)
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(virtual_path: "spree/shared/_order_details",
2
+ name: "add_delivery_time_details_to_order",
3
+ insert_before: "[data-hook='order_details']",
4
+ partial: "spree/orders/order_delivery_time_details",
5
+ disabled: false)
@@ -0,0 +1,5 @@
1
+ <% if order.start_delivery_time != nil %>
2
+ <td class="align-center"><%= order.delivery_time %></td>
3
+ <% else %>
4
+ <td class="align-center">Unknown</td>
5
+ <% end %>
@@ -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,6 @@
1
+ <dt><%= t(:delivery_time) %>:</dt>
2
+ <% if @order.start_delivery_time != nil %>
3
+ <dd id='delivery_time'><%= @order.delivery_time %></dd>
4
+ <% else %>
5
+ <dd id='delivery_time'>Unknown</dd>
6
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <p id="delivery_time">
2
+ <%= form.label :start_delivery_time, "Start Delivery Time" %><br />
3
+ <%= form.time_select :start_delivery_time %>
4
+ <br/>
5
+ <%= form.label :end_delivery_time, "End Delivery Time" %><br />
6
+ <%= form.time_select :end_delivery_time %>
7
+ </p>
@@ -0,0 +1,8 @@
1
+ <div class="row steps-data">
2
+ <div class="columns sixteen">
3
+ <h6><%= t(:delivery_time) %></h6>
4
+ <div class="delivery-time">
5
+ <%= (order.start_delivery_time != nil) ? order.delivery_time : 'Unknown' %>
6
+ </div>
7
+ </div>
8
+ </div>
@@ -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
@@ -0,0 +1,3 @@
1
+ module SpreeDeliveryTime
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'spree_core'
2
+ require 'spree_delivery_time/engine'
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: []