tienda 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/tienda/products_controller.rb +7 -2
- data/app/helpers/tienda/application_helper.rb +1 -1
- data/app/models/tienda/product.rb +12 -1
- data/app/views/tienda/products/_form.html.haml +32 -4
- data/lib/tasks/tienda.rake +18 -15
- data/lib/tienda/associated_countries.rb +4 -6
- data/lib/tienda/country_importer.rb +8 -3
- data/lib/tienda/default_navigation.rb +4 -4
- data/lib/tienda/engine.rb +10 -9
- data/lib/tienda/error.rb +0 -2
- data/lib/tienda/errors/inappropriate_delivery_service.rb +1 -1
- data/lib/tienda/errors/insufficient_stock_to_fulfil.rb +0 -2
- data/lib/tienda/errors/invalid_configuration.rb +1 -1
- data/lib/tienda/errors/not_enough_stock.rb +0 -2
- data/lib/tienda/errors/payment_declined.rb +1 -1
- data/lib/tienda/errors/refund_failed.rb +1 -1
- data/lib/tienda/errors/unorderable_item.rb +1 -1
- data/lib/tienda/navigation_manager.rb +8 -10
- data/lib/tienda/orderable_item.rb +0 -2
- data/lib/tienda/settings.rb +2 -4
- data/lib/tienda/settings_loader.rb +0 -2
- data/lib/tienda/setup_generator.rb +0 -2
- data/lib/tienda/version.rb +1 -1
- data/lib/tienda/view_helpers.rb +3 -4
- data/lib/tienda.rb +4 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cbf39151193fd56d6534c18bf0a072120ac1f30
|
4
|
+
data.tar.gz: a95c6575885a48531121d4ab1982baa0cccdb298
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e7ccf7113bcf2b07f1fef6b177e7edbf277775acc0f9111638ad038918b8e0f9944cd024ae459b47469cc0d8797c60fb842288f9f6703b84871e4170890048f
|
7
|
+
data.tar.gz: cfef63a6fc1c72b4134b901bd4240b2225ca25333d1669319b86b75c78cc3c05152a5f05ebb8543a2ab2252d89e5cad643f9e9cbb4799d444e585a1ecb62ba4f
|
@@ -15,7 +15,7 @@ module Tienda
|
|
15
15
|
def create
|
16
16
|
@product = Tienda::Product.new(safe_params)
|
17
17
|
if @product.save
|
18
|
-
redirect_to :products, flash: { notice:
|
18
|
+
redirect_to :products, flash: { notice: t('tienda.products.create_notice') }
|
19
19
|
else
|
20
20
|
render action: "new"
|
21
21
|
end
|
@@ -51,7 +51,12 @@ module Tienda
|
|
51
51
|
private
|
52
52
|
|
53
53
|
def safe_params
|
54
|
-
params[:product].permit(:product_category_id, :name, :sku, :permalink,
|
54
|
+
params[:product].permit(:product_category_id, :name, :sku, :permalink,
|
55
|
+
:description, :short_description, :weight, :price, :cost_price,
|
56
|
+
:tax_rate_id, :stock_control, :default_image_file, :second_image_file,
|
57
|
+
:third_image_file, :fourth_image_file, :fifth_image_file,
|
58
|
+
:data_sheet_file, :active, :featured, :in_the_box,
|
59
|
+
:product_attributes_array => [:key, :value, :searchable, :public])
|
55
60
|
end
|
56
61
|
|
57
62
|
end
|
@@ -28,7 +28,7 @@ module Tienda
|
|
28
28
|
s << "</div>"
|
29
29
|
end.html_safe
|
30
30
|
elsif !options[:hide_if_blank]
|
31
|
-
"<div class='attachmentPreview'><div class='imgContainer'><div class='img none'></div></div><div class='desc none'>#{t('helpers.attachment_preview.no_attachment')}
|
31
|
+
"<div class='attachmentPreview'><div class='imgContainer'><div class='img none'></div></div><div class='desc none'>#{t('helpers.attachment_preview.no_attachment')}</div></div>".html_safe
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -9,8 +9,12 @@ module Tienda
|
|
9
9
|
require_dependency 'tienda/product/product_attributes'
|
10
10
|
require_dependency 'tienda/product/variants'
|
11
11
|
|
12
|
-
# Products have
|
12
|
+
# Products have 5 images and a data_sheet
|
13
13
|
attachment :default_image
|
14
|
+
attachment :second_image
|
15
|
+
attachment :third_image
|
16
|
+
attachment :fourth_image
|
17
|
+
attachment :fifth_image
|
14
18
|
attachment :data_sheet
|
15
19
|
|
16
20
|
# The product's category
|
@@ -94,6 +98,13 @@ module Tienda
|
|
94
98
|
self.stock_level_adjustments.sum(:adjustment)
|
95
99
|
end
|
96
100
|
|
101
|
+
# Return all product images
|
102
|
+
#
|
103
|
+
# @return [Array]
|
104
|
+
def images
|
105
|
+
nifty_attachments.select { |attachment| attachment.role != "data_sheet" }
|
106
|
+
end
|
107
|
+
|
97
108
|
# Search for products which include the given attributes and return an active record
|
98
109
|
# scope of these products. Chainable with other scopes and with_attributes methods.
|
99
110
|
# For example:
|
@@ -57,15 +57,43 @@
|
|
57
57
|
= field_set_tag t('tienda.products.attachments') do
|
58
58
|
.splitContainer
|
59
59
|
%dl.half
|
60
|
-
%dt
|
60
|
+
%dt
|
61
|
+
= f.label :default_image_file, t('tienda.products.default_image')
|
62
|
+
%p= f.file_field :default_image_file
|
61
63
|
%dd
|
62
64
|
= attachment_preview @product.default_image
|
63
|
-
%p= f.file_field :default_image_file
|
64
65
|
%dl.half
|
65
|
-
%dt
|
66
|
+
%dt
|
67
|
+
= f.label :second_image_file, t('tienda.products.second_image')
|
68
|
+
%p= f.file_field :second_image_file
|
66
69
|
%dd
|
67
|
-
= attachment_preview @product.
|
70
|
+
= attachment_preview @product.second_image
|
71
|
+
.splitContainer
|
72
|
+
%dl.half
|
73
|
+
%dt
|
74
|
+
= f.label :third_image_file, t('tienda.products.third_image')
|
75
|
+
%p= f.file_field :third_image_file
|
76
|
+
%dd
|
77
|
+
= attachment_preview @product.third_image
|
78
|
+
%dl.half
|
79
|
+
%dt
|
80
|
+
= f.label :fourth_image_file, t('tienda.products.fourth_image')
|
81
|
+
%p= f.file_field :fourth_image_file
|
82
|
+
%dd
|
83
|
+
= attachment_preview @product.fourth_image
|
84
|
+
.splitContainer
|
85
|
+
%dl.half
|
86
|
+
%dt
|
87
|
+
= f.label :fifth_image_file, t('tienda.products.fifth_image')
|
88
|
+
%p= f.file_field :fifth_image_file
|
89
|
+
%dd
|
90
|
+
= attachment_preview @product.fifth_image
|
91
|
+
%dl.half
|
92
|
+
%dt
|
93
|
+
= f.label :data_sheet_file, t('tienda.products.datasheet')
|
68
94
|
%p= f.file_field :data_sheet_file
|
95
|
+
%dd
|
96
|
+
= attachment_preview @product.data_sheet
|
69
97
|
|
70
98
|
- unless @product.has_variants?
|
71
99
|
= field_set_tag t('tienda.products.pricing') do
|
data/lib/tasks/tienda.rake
CHANGED
@@ -1,29 +1,32 @@
|
|
1
1
|
namespace :tienda do
|
2
|
-
desc
|
3
|
-
task :
|
2
|
+
desc 'Load seed data for the Tienda'
|
3
|
+
task seed: :environment do
|
4
4
|
require File.join(Tienda.root, 'db', 'seeds')
|
5
5
|
end
|
6
6
|
|
7
|
-
desc
|
8
|
-
task :
|
9
|
-
Tienda::User.create(
|
7
|
+
desc 'Create a default admin user'
|
8
|
+
task create_default_user: :environment do
|
9
|
+
Tienda::User.create(
|
10
|
+
email_address: 'admin@example.com',
|
11
|
+
password: 'password', password_confirmation: 'password',
|
12
|
+
first_name: 'Default', last_name: 'Admin'
|
13
|
+
)
|
10
14
|
puts
|
11
|
-
puts
|
15
|
+
puts ' New user has been created successfully.'
|
12
16
|
puts
|
13
|
-
puts
|
14
|
-
puts
|
17
|
+
puts ' E-Mail Address..: admin@example.com'
|
18
|
+
puts ' Password........: password'
|
15
19
|
puts
|
16
20
|
end
|
17
21
|
|
18
|
-
desc
|
19
|
-
task :
|
22
|
+
desc 'Import default set of countries'
|
23
|
+
task import_countries: :environment do
|
20
24
|
Tienda::CountryImporter.import
|
21
25
|
end
|
22
26
|
|
23
|
-
desc
|
24
|
-
task :
|
25
|
-
Rake::Task[
|
26
|
-
Rake::Task[
|
27
|
+
desc 'Run the key setup tasks for a new application'
|
28
|
+
task setup: :environment do
|
29
|
+
Rake::Task['tienda:import_countries'].invoke if Tienda::Country.all.empty?
|
30
|
+
Rake::Task['tienda:create_default_user'].invoke if Tienda::User.all.empty?
|
27
31
|
end
|
28
|
-
|
29
32
|
end
|
@@ -1,20 +1,18 @@
|
|
1
1
|
module Tienda
|
2
2
|
module AssociatedCountries
|
3
|
-
|
4
3
|
def self.included(base)
|
5
4
|
base.serialize :country_ids, Array
|
6
|
-
base.before_validation { self.country_ids =
|
5
|
+
base.before_validation { self.country_ids = country_ids.map(&:to_i).select { |i| i > 0 } if country_ids.is_a?(Array) }
|
7
6
|
end
|
8
7
|
|
9
8
|
def country?(id)
|
10
9
|
id = id.id if id.is_a?(Tienda::Country)
|
11
|
-
|
10
|
+
country_ids.is_a?(Array) && country_ids.include?(id.to_i)
|
12
11
|
end
|
13
12
|
|
14
13
|
def countries
|
15
|
-
return [] unless
|
16
|
-
Tienda::Country.where(:
|
14
|
+
return [] unless country_ids.is_a?(Array) && !country_ids.empty?
|
15
|
+
Tienda::Country.where(id: country_ids)
|
17
16
|
end
|
18
|
-
|
19
17
|
end
|
20
18
|
end
|
@@ -1,14 +1,19 @@
|
|
1
1
|
module Tienda
|
2
2
|
module CountryImporter
|
3
3
|
def self.import
|
4
|
-
eu_members = [
|
4
|
+
eu_members = [
|
5
|
+
'Austria', 'Belgium', 'Bulgaria', 'Croatia', 'Cyprus', 'Czech Republic',
|
6
|
+
'Denmark', 'Estonia', 'Finland', 'France', 'Germany', 'Greece',
|
7
|
+
'Hungary', 'Ireland', 'Italy', 'Latvia', 'Lithuania', 'Luxembourg',
|
8
|
+
'Malta', 'Netherlands', 'Poland', 'Portugal', 'Romania', 'Slovakia',
|
9
|
+
'Slovenia', 'Spain', 'Sweden', 'United Kingdom'
|
10
|
+
]
|
5
11
|
countries = File.read(File.join(Tienda.root, 'db', 'countries.txt')).gsub(/\r/, "\n").split("\n").map { |c| c.split(/\t/) }
|
6
12
|
countries.each do |code2, code3, name, continent, tld, currency|
|
7
|
-
country = Country.new(:
|
13
|
+
country = Country.new(name: name, code2: code2, code3: code3, continent: continent, tld: tld.gsub('.', ''), currency: currency)
|
8
14
|
country.eu_member = true if eu_members.map(&:upcase).include?(name.upcase)
|
9
15
|
country.save
|
10
16
|
end
|
11
|
-
|
12
17
|
end
|
13
18
|
end
|
14
19
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'tienda/navigation_manager'
|
2
2
|
|
3
|
-
# This file defines all the default navigation managers used in Tienda.
|
4
|
-
# modules can make changes to these by removing them or adding their
|
5
|
-
# file is loaded on application initialization so if you make changes,
|
6
|
-
# to restart the webserver.
|
3
|
+
# This file defines all the default navigation managers used in Tienda.
|
4
|
+
# Of course, modules can make changes to these by removing them or adding their
|
5
|
+
# own. This file is loaded on application initialization so if you make changes,
|
6
|
+
# you'll need to restart the webserver.
|
7
7
|
|
8
8
|
#
|
9
9
|
# This is the default navigation manager for the admin interface.
|
data/lib/tienda/engine.rb
CHANGED
@@ -9,24 +9,26 @@ module Tienda
|
|
9
9
|
|
10
10
|
# We don't want any automatic generators in the engine.
|
11
11
|
config.generators do |g|
|
12
|
-
g.orm
|
13
|
-
g.test_framework
|
14
|
-
g.stylesheets
|
15
|
-
g.javascripts
|
16
|
-
g.helper
|
12
|
+
g.orm :active_record
|
13
|
+
g.test_framework false
|
14
|
+
g.stylesheets false
|
15
|
+
g.javascripts false
|
16
|
+
g.helper false
|
17
17
|
end
|
18
18
|
|
19
19
|
initializer 'tienda.initialize' do |app|
|
20
20
|
# Add the default settings
|
21
|
-
Tienda.add_settings_group :system_settings, [:store_name, :email_address,
|
21
|
+
Tienda.add_settings_group :system_settings, [:store_name, :email_address,
|
22
|
+
:currency_unit, :tax_name,
|
23
|
+
:demo_mode]
|
22
24
|
|
23
25
|
# Add middleware
|
24
26
|
app.config.middleware.use Tienda::SettingsLoader
|
25
27
|
|
26
28
|
# Load our migrations into the application's db/migrate path
|
27
29
|
unless app.root.to_s.match root.to_s
|
28
|
-
config.paths[
|
29
|
-
app.config.paths[
|
30
|
+
config.paths['db/migrate'].expanded.each do |expanded_path|
|
31
|
+
app.config.paths['db/migrate'] << expanded_path
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -43,6 +45,5 @@ module Tienda
|
|
43
45
|
generators do
|
44
46
|
require 'tienda/setup_generator'
|
45
47
|
end
|
46
|
-
|
47
48
|
end
|
48
49
|
end
|
data/lib/tienda/error.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
module Tienda
|
2
2
|
class NavigationManager
|
3
|
-
|
4
3
|
def self.managers
|
5
4
|
@managers ||= []
|
6
5
|
end
|
7
6
|
|
8
7
|
def self.create(identifier)
|
9
|
-
managers <<
|
8
|
+
managers << new(identifier.to_s)
|
10
9
|
end
|
11
10
|
|
12
11
|
def self.build(identifier, &block)
|
13
|
-
manager =
|
12
|
+
manager = new(identifier.to_s)
|
14
13
|
manager.instance_eval(&block) if block_given?
|
15
14
|
managers << manager
|
16
15
|
end
|
@@ -37,9 +36,9 @@ module Tienda
|
|
37
36
|
item = NavigationItem.new
|
38
37
|
item.manager = self
|
39
38
|
item.identifier = identifier.to_s
|
40
|
-
item.url = options[:url]
|
41
|
-
item.link_options = options[:link_options]
|
42
|
-
item.active_if = block
|
39
|
+
item.url = options[:url] if options[:url]
|
40
|
+
item.link_options = options[:link_options] if options[:link_options]
|
41
|
+
item.active_if = block if block_given?
|
43
42
|
items << item
|
44
43
|
end
|
45
44
|
|
@@ -59,9 +58,9 @@ module Tienda
|
|
59
58
|
end
|
60
59
|
|
61
60
|
def url(request = nil)
|
62
|
-
(@url.is_a?(Proc) && request && request.instance_eval(&@url)
|
63
|
-
|
64
|
-
|
61
|
+
(@url.is_a?(Proc) && request && request.instance_eval(&@url)) ||
|
62
|
+
@url ||
|
63
|
+
Tienda::Engine.routes.url_helpers.send("#{identifier}_path")
|
65
64
|
end
|
66
65
|
|
67
66
|
def active?(request)
|
@@ -76,6 +75,5 @@ module Tienda
|
|
76
75
|
@link_options ||= {}
|
77
76
|
end
|
78
77
|
end
|
79
|
-
|
80
78
|
end
|
81
79
|
end
|
@@ -2,7 +2,6 @@ module Tienda
|
|
2
2
|
# All items which can be ordered should include this module and ensure that all methods
|
3
3
|
# have been overridden. It's a lazy-mans protocol.
|
4
4
|
module OrderableItem
|
5
|
-
|
6
5
|
# stock_level_adjustments must be an association
|
7
6
|
|
8
7
|
def full_name
|
@@ -34,6 +33,5 @@ module Tienda
|
|
34
33
|
|
35
34
|
def weight
|
36
35
|
end
|
37
|
-
|
38
36
|
end
|
39
37
|
end
|
data/lib/tienda/settings.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Tienda
|
2
2
|
class Settings
|
3
|
-
|
4
3
|
def initialize(hash)
|
5
4
|
@hash = hash
|
6
5
|
end
|
@@ -13,14 +12,13 @@ module Tienda
|
|
13
12
|
key = key.to_s.gsub(/\?\z/, '')
|
14
13
|
if value = @hash[key.to_s]
|
15
14
|
value
|
16
|
-
elsif I18n.translate(
|
17
|
-
I18n.translate(
|
15
|
+
elsif I18n.translate('tienda.settings.defaults').keys.include?(key.to_sym)
|
16
|
+
I18n.translate('tienda.settings.defaults')[key.to_sym]
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
20
|
def [](value)
|
22
21
|
@hash[value]
|
23
22
|
end
|
24
|
-
|
25
23
|
end
|
26
24
|
end
|
data/lib/tienda/version.rb
CHANGED
data/lib/tienda/view_helpers.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Tienda
|
2
2
|
module ViewHelpers
|
3
|
-
|
4
|
-
#
|
3
|
+
# Returns currency values with the currency unit as specified by
|
4
|
+
# the Tienda settings
|
5
5
|
def number_to_currency(number, options = {})
|
6
6
|
options[:unit] ||= Tienda.settings.currency_unit
|
7
7
|
super
|
@@ -9,8 +9,7 @@ module Tienda
|
|
9
9
|
|
10
10
|
# Returns a number of kilograms with the appropriate suffix
|
11
11
|
def number_to_weight(kg)
|
12
|
-
"#{kg}#{t('tienda.helpers.number_to_weight.kg', :
|
12
|
+
"#{kg}#{t('tienda.helpers.number_to_weight.kg', default: 'kg')}"
|
13
13
|
end
|
14
|
-
|
15
14
|
end
|
16
15
|
end
|
data/lib/tienda.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'coffee-rails'
|
2
|
+
require 'sass-rails'
|
3
|
+
require 'jquery-rails'
|
4
4
|
require 'haml'
|
5
5
|
require 'bcrypt'
|
6
6
|
require 'dynamic_form'
|
@@ -50,10 +50,8 @@ module Tienda
|
|
50
50
|
def settings_groups
|
51
51
|
@settings_groups ||= {}
|
52
52
|
end
|
53
|
-
|
54
53
|
end
|
55
|
-
|
56
54
|
end
|
57
55
|
|
58
56
|
# Start your engines.
|
59
|
-
require
|
57
|
+
require 'tienda/engine'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tienda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gonzalo Robaina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01
|
11
|
+
date: 2015-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|