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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6c353c91d9535d57c769d77a22993483c6bf5ff
4
- data.tar.gz: 422375d838e7ae6f300d5c28e01ccc1d3cc90d95
3
+ metadata.gz: 7cbf39151193fd56d6534c18bf0a072120ac1f30
4
+ data.tar.gz: a95c6575885a48531121d4ab1982baa0cccdb298
5
5
  SHA512:
6
- metadata.gz: d1eb050c1dc64d52d09af2be5cac06026bbaf496eea9f0a3402005abc0300e1a469d077f7f19ff8ce25c7d4b55c8f7c401016c332a3f90c68f68456037cfa612
7
- data.tar.gz: 7fcacca4b9419a445695548cce0c65db86f2391e47d4dfd92ce4b97f9b309820d62a66988b249297af5ecf3bdd349f05de5e8965ce8040571da68d2f25ed0214
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: t('tienda.products.create_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, :description, :short_description, :weight, :price, :cost_price, :tax_rate_id, :stock_control, :default_image_file, :data_sheet_file, :active, :featured, :in_the_box, :product_attributes_array => [:key, :value, :searchable, :public])
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')},</div></div>".html_safe
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 a default_image and a data_sheet
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= f.label :default_image_file, t('tienda.products.default_image')
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= f.label :data_sheet_file, t('tienda.products.datasheet')
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.data_sheet
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
@@ -1,29 +1,32 @@
1
1
  namespace :tienda do
2
- desc "Load seed data for the Tienda"
3
- task :seed => :environment do
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 "Create a default admin user"
8
- task :create_default_user => :environment do
9
- Tienda::User.create(:email_address => 'admin@example.com', :password => 'password', :password_confirmation => 'password', :first_name => 'Default', :last_name => 'Admin')
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 " New user has been created successfully."
15
+ puts ' New user has been created successfully.'
12
16
  puts
13
- puts " E-Mail Address..: admin@example.com"
14
- puts " Password........: password"
17
+ puts ' E-Mail Address..: admin@example.com'
18
+ puts ' Password........: password'
15
19
  puts
16
20
  end
17
21
 
18
- desc "Import default set of countries"
19
- task :import_countries => :environment do
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 "Run the key setup tasks for a new application"
24
- task :setup => :environment do
25
- Rake::Task["tienda:import_countries"].invoke if Tienda::Country.all.empty?
26
- Rake::Task["tienda:create_default_user"].invoke if Tienda::User.all.empty?
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 = self.country_ids.map(&:to_i).select { |i| i > 0} if self.country_ids.is_a?(Array) }
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
- self.country_ids.is_a?(Array) && self.country_ids.include?(id.to_i)
10
+ country_ids.is_a?(Array) && country_ids.include?(id.to_i)
12
11
  end
13
12
 
14
13
  def countries
15
- return [] unless self.country_ids.is_a?(Array) && !self.country_ids.empty?
16
- Tienda::Country.where(:id => self.country_ids)
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 = ['Austria', 'Belgium', 'Bulgaria', 'Croatia','Cyprus','Czech Republic','Denmark','Estonia','Finland','France','Germany','Greece','Hungary','Ireland','Italy','Latvia','Lithuania','Luxembourg','Malta','Netherlands','Poland','Portugal','Romania','Slovakia','Slovenia','Spain','Sweden','United Kingdom']
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(:name => name, :code2 => code2, :code3 => code3, :continent => continent, :tld => tld.gsub('.', ''), :currency => currency)
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. Of course,
4
- # modules can make changes to these by removing them or adding their own. This
5
- # file is loaded on application initialization so if you make changes, you'll need
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 :active_record
13
- g.test_framework false
14
- g.stylesheets false
15
- g.javascripts false
16
- g.helper false
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, :currency_unit, :tax_name, :demo_mode]
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["db/migrate"].expanded.each do |expanded_path|
29
- app.config.paths["db/migrate"] << expanded_path
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,6 +1,5 @@
1
1
  module Tienda
2
2
  class Error < StandardError
3
-
4
3
  def initialize(options = {})
5
4
  if options.is_a?(String)
6
5
  @options = {:message => options}
@@ -16,6 +15,5 @@ module Tienda
16
15
  def options
17
16
  @options
18
17
  end
19
-
20
18
  end
21
19
  end
@@ -3,4 +3,4 @@ module Tienda
3
3
  class InappropriateDeliveryService < Error
4
4
  end
5
5
  end
6
- end
6
+ end
@@ -1,7 +1,6 @@
1
1
  module Tienda
2
2
  module Errors
3
3
  class InsufficientStockToFulfil < Error
4
-
5
4
  def order
6
5
  @options[:order]
7
6
  end
@@ -9,7 +8,6 @@ module Tienda
9
8
  def out_of_stock_items
10
9
  @options[:out_of_stock_items]
11
10
  end
12
-
13
11
  end
14
12
  end
15
13
  end
@@ -3,4 +3,4 @@ module Tienda
3
3
  class InvalidConfiguration < Error
4
4
  end
5
5
  end
6
- end
6
+ end
@@ -1,7 +1,6 @@
1
1
  module Tienda
2
2
  module Errors
3
3
  class NotEnoughStock < Error
4
-
5
4
  def available_stock
6
5
  @options[:ordered_item].stock
7
6
  end
@@ -9,7 +8,6 @@ module Tienda
9
8
  def requested_stock
10
9
  @options[:requested_stock]
11
10
  end
12
-
13
11
  end
14
12
  end
15
13
  end
@@ -3,4 +3,4 @@ module Tienda
3
3
  class PaymentDeclined < Tienda::Error
4
4
  end
5
5
  end
6
- end
6
+ end
@@ -3,4 +3,4 @@ module Tienda
3
3
  class RefundFailed < Error
4
4
  end
5
5
  end
6
- end
6
+ end
@@ -3,4 +3,4 @@ module Tienda
3
3
  class UnorderableItem < Error
4
4
  end
5
5
  end
6
- end
6
+ end
@@ -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 << self.new(identifier.to_s)
8
+ managers << new(identifier.to_s)
10
9
  end
11
10
 
12
11
  def self.build(identifier, &block)
13
- manager = self.new(identifier.to_s)
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] if options[:url]
41
- item.link_options = options[:link_options] if options[:link_options]
42
- item.active_if = block if block_given?
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
- @url ||
64
- Tienda::Engine.routes.url_helpers.send("#{identifier}_path")
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
@@ -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("tienda.settings.defaults").keys.include?(key.to_sym)
17
- I18n.translate("tienda.settings.defaults")[key.to_sym]
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
@@ -1,6 +1,5 @@
1
1
  module Tienda
2
2
  class SettingsLoader
3
-
4
3
  def initialize(app)
5
4
  @app = app
6
5
  end
@@ -11,6 +10,5 @@ module Tienda
11
10
  ensure
12
11
  Tienda.reset_settings
13
12
  end
14
-
15
13
  end
16
14
  end
@@ -1,10 +1,8 @@
1
1
  require 'rails/generators'
2
2
  module Tienda
3
3
  class SetupGenerator < Rails::Generators::Base
4
-
5
4
  def create_route
6
5
  route 'mount Tienda::Engine => "/tienda"'
7
6
  end
8
-
9
7
  end
10
8
  end
@@ -1,3 +1,3 @@
1
1
  module Tienda
2
- VERSION = "1.0.0"
2
+ VERSION = '1.1.0'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module Tienda
2
2
  module ViewHelpers
3
-
4
- # Returns currency values with the currency unit as specified by the Tienda settings
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', :default => '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 "coffee-rails"
2
- require "sass-rails"
3
- require "jquery-rails"
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 "tienda/engine"
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.0.0
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-25 00:00:00.000000000 Z
11
+ date: 2015-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails