-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Models will soon become the new 'core' rename models to core
- Loading branch information
Showing
29 changed files
with
176 additions
and
78 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,5 +32,4 @@ def value | |
def raw_value | ||
self[:value] | ||
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb')) | ||
|
||
gem 'spree_core', :path => '../core' | ||
gem 'spree_api', :path => '../api' | ||
|
||
gemspec |
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Spree::Core::Engine.config.to_prepare do | ||
if Spree.user_class | ||
Spree.user_class.class_eval do | ||
include Spree::Core::UserBanners | ||
has_and_belongs_to_many :spree_roles, | ||
:join_table => 'spree_roles_users', | ||
:foreign_key => "user_id", | ||
:class_name => "Spree::Role" | ||
|
||
has_many :spree_orders, :foreign_key => "user_id", :class_name => "Spree::Order" | ||
|
||
belongs_to :ship_address, :class_name => 'Spree::Address' | ||
belongs_to :bill_address, :class_name => 'Spree::Address' | ||
|
||
# has_spree_role? simply needs to return true or false whether a user has a role or not. | ||
def has_spree_role?(role_in_question) | ||
spree_roles.where(:name => role_in_question.to_s).any? | ||
end | ||
|
||
def last_incomplete_spree_order | ||
spree_orders.incomplete.order('created_at DESC').last | ||
end | ||
end | ||
end | ||
end |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'money' | ||
|
||
module Spree | ||
class Money | ||
def initialize(amount, options={}) | ||
@money = ::Money.parse([amount, Spree::Config[:currency]].join) | ||
@options = {} | ||
@options[:with_currency] = true if Spree::Config[:display_currency] | ||
@options[:symbol_position] = Spree::Config[:currency_symbol_position].to_sym | ||
@options.merge!(options) | ||
# Must be a symbol because the Money gem doesn't do the conversion | ||
@options[:symbol_position] = @options[:symbol_position].to_sym | ||
end | ||
|
||
def to_s | ||
@money.format(@options) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Spree | ||
module Scopes | ||
# This module is extended by ProductScope | ||
module Dynamic | ||
module_function | ||
|
||
# Sample dynamic scope generating from set of products | ||
# generates 0 or (2..scope_limit) scopes for prices, based | ||
# on number of products (uses Math.log, to guess number of scopes) | ||
def price_scopes_for(products, scope_limit=5) | ||
scopes = [] | ||
|
||
# Price based scopes | ||
all_prices = products.map(&:price).sort | ||
|
||
ranges = [Math.log(products.length).floor, scope_limit].max | ||
|
||
if ranges >= 2 | ||
l = all_prices.length / ranges | ||
scopes << ProductScope.new({:name => "master_price_lte", :arguments => [all_prices[l]] }) | ||
|
||
(ranges - 2).times do |x| | ||
scopes << ProductScope.new({:name => "price_between", | ||
:arguments => [ all_prices[l*(x+1)+1], all_prices[l*(x+2)] ] }) | ||
end | ||
scopes << ProductScope.new({:name => "master_price_gte", :arguments => [all_prices[l*(ranges-1)+1]] }) | ||
end | ||
|
||
scopes | ||
end | ||
end | ||
end | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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