Merge branch 'master' into tests-rspec

Conflicts:
	Gemfile
This commit is contained in:
wvengen 2013-09-07 01:11:24 +02:00
commit 7de57715f2
21 changed files with 2010 additions and 72 deletions

1
.gitignore vendored
View file

@ -16,3 +16,4 @@ doc/app/
Capfile Capfile
config/deploy.rb config/deploy.rb
config/deploy/* config/deploy/*
.localeapp

View file

@ -85,6 +85,3 @@ group :test do
gem 'rspec-expectations' gem 'rspec-expectations'
gem 'i18n-spec' gem 'i18n-spec'
end end
# Gems left for backwards compatibility
gem 'acts_as_configurable', git: 'git://github.com/bwalding/acts_as_configurable.git' # user settings migration needs it

View file

@ -4,13 +4,6 @@ GIT
specs: specs:
localize_input (0.1.0) localize_input (0.1.0)
GIT
remote: git://github.com/bwalding/acts_as_configurable.git
revision: cdf6f6f979019275b523d10684b748f08e2dd8e8
specs:
acts_as_configurable (0.0.1)
rake
GIT GIT
remote: git://github.com/technoweenie/acts_as_versioned.git remote: git://github.com/technoweenie/acts_as_versioned.git
revision: 63b1fc8529d028fae632fe80ec0cb25df56cd76b revision: 63b1fc8529d028fae632fe80ec0cb25df56cd76b
@ -310,7 +303,6 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
acts_as_configurable!
acts_as_tree acts_as_tree
acts_as_versioned! acts_as_versioned!
better_errors better_errors

View file

@ -1,8 +1,3 @@
Important
--------
We changed the branch structure. The rails3 branch is now master. But you can safely send pull requests to rails3. It'll remain there for a couple of weeks.
FoodSoft FoodSoft
========= =========
[![Build Status](https://travis-ci.org/foodcoops/foodsoft.png?branch=tests-rspec)](https://travis-ci.org/foodcoops/foodsoft) [![Build Status](https://travis-ci.org/foodcoops/foodsoft.png?branch=tests-rspec)](https://travis-ci.org/foodcoops/foodsoft)

View file

@ -209,7 +209,7 @@ class ArticlesController < ApplicationController
# fills a form whith values of the selected shared_article # fills a form whith values of the selected shared_article
def import def import
@article = SharedArticle.find(params[:shared_article_id]).build_new_article @article = SharedArticle.find(params[:shared_article_id]).build_new_article(@supplier)
render :action => 'new', :layout => false render :action => 'new', :layout => false
end end

View file

@ -18,7 +18,7 @@ class SuppliersController < ApplicationController
def new def new
if params[:shared_supplier_id] if params[:shared_supplier_id]
shared_supplier = SharedSupplier.find(params[:shared_supplier_id]) shared_supplier = SharedSupplier.find(params[:shared_supplier_id])
@supplier = shared_supplier.build_supplier(shared_supplier.autofill_attributes) @supplier = shared_supplier.suppliers.new(shared_supplier.autofill_attributes)
else else
@supplier = Supplier.new @supplier = Supplier.new
end end

View file

@ -0,0 +1,6 @@
module SuppliersHelper
def associated_supplier_names(shared_supplier)
"(#{shared_supplier.suppliers.map(&:name).join(', ')})"
end
end

View file

@ -7,8 +7,8 @@ class SharedArticle < ActiveRecord::Base
belongs_to :shared_supplier, :foreign_key => :supplier_id belongs_to :shared_supplier, :foreign_key => :supplier_id
def build_new_article def build_new_article(supplier)
shared_supplier.supplier.articles.build( supplier.articles.build(
:name => name, :name => name,
:unit => unit, :unit => unit,
:note => note, :note => note,

View file

@ -5,7 +5,7 @@ class SharedSupplier < ActiveRecord::Base
# set correct table_name in external DB # set correct table_name in external DB
self.table_name = 'suppliers' self.table_name = 'suppliers'
has_one :supplier has_many :suppliers
has_many :shared_articles, :foreign_key => :supplier_id has_many :shared_articles, :foreign_key => :supplier_id
# These set of attributes are used to autofill attributes of new supplier, # These set of attributes are used to autofill attributes of new supplier,

View file

@ -66,7 +66,7 @@ class User < ActiveRecord::Base
end end
def receive_email? def receive_email?
settings.messages['send_as_email'] == "1" && email.present? settings.messages['send_as_email'] && email.present?
end end
# Sets the user's password. It will be stored encrypted along with a random salt. # Sets the user's password. It will be stored encrypted along with a random salt.

View file

@ -17,7 +17,9 @@
%td= shared_supplier.note %td= shared_supplier.note
%td= shared_supplier.delivery_days %td= shared_supplier.delivery_days
%td %td
- if shared_supplier.supplier - if shared_supplier.suppliers.any?
%i.icon-ok %i.icon-ok
= associated_supplier_names(shared_supplier)
= link_to t('.subscribe_again'), new_supplier_path(:shared_supplier_id => shared_supplier), class: 'btn'
- else - else
= link_to t('.subscribe'), new_supplier_path(:shared_supplier_id => shared_supplier), class: 'btn' = link_to t('.subscribe'), new_supplier_path(:shared_supplier_id => shared_supplier), class: 'btn'

View file

@ -1669,6 +1669,7 @@ de:
language: language:
de: Deutsch de: Deutsch
en: English en: English
fr: Französisch
nl: Niederländisch nl: Niederländisch
required: required:
mark: ! '*' mark: ! '*'
@ -1772,6 +1773,7 @@ de:
shared_suppliers: shared_suppliers:
body: <p>Hier werden die Lieferantinnen der externen Datenbank angezeigt.</p> <p>Ihr könnt externe Lieferantinnen importieren, indem ihr sie einfach abonniert. (siehe unten)</p> <p>Damit wird eine neue Lieferantin angelegt und mit der externen Datenbank verknüpft.</p> body: <p>Hier werden die Lieferantinnen der externen Datenbank angezeigt.</p> <p>Ihr könnt externe Lieferantinnen importieren, indem ihr sie einfach abonniert. (siehe unten)</p> <p>Damit wird eine neue Lieferantin angelegt und mit der externen Datenbank verknüpft.</p>
subscribe: abonnieren subscribe: abonnieren
subscribe_again: erneut abonnieren
supplier: Lieferantin supplier: Lieferantin
title: Externe Listen title: Externe Listen
show: show:

View file

@ -236,7 +236,7 @@ en:
option_available: Make articles available option_available: Make articles available
option_delete: Delete article option_delete: Delete article
option_not_available: Make articles unavailable option_not_available: Make articles unavailable
option_select: Choose special offer ... option_select: Select action ...
price_netto: Price price_netto: Price
unit_quantity_desc: Unit quantity unit_quantity_desc: Unit quantity
unit_quantity_short: Quantity unit_quantity_short: Quantity
@ -440,7 +440,7 @@ en:
article: Article article: Article
category: Category category: Category
create_from_blank: Create new article create_from_blank: Create new article
create_stock_article: Create stock articles create_stock_article: Create stock article
price: Netprice price: Netprice
quantity: Quantity quantity: Quantity
title_fill_quantities: 2. Set delivery quantities title_fill_quantities: 2. Set delivery quantities
@ -1671,6 +1671,7 @@ en:
language: language:
de: German de: German
en: English en: English
fr: French
nl: Dutch nl: Dutch
required: required:
mark: ! '*' mark: ! '*'
@ -1774,6 +1775,7 @@ en:
shared_suppliers: shared_suppliers:
body: <p>Suppliers of the external database are displayed here.</p> <p>You can import external suppliers by subscribing (see below).</p> <p>A new supplier will be created and connected to the external database.</p> body: <p>Suppliers of the external database are displayed here.</p> <p>You can import external suppliers by subscribing (see below).</p> <p>A new supplier will be created and connected to the external database.</p>
subscribe: Subscribe subscribe: Subscribe
subscribe_again: Subscribe again
supplier: Supplier supplier: Supplier
title: External lists title: External lists
show: show:

1916
config/locales/fr.yml Normal file

File diff suppressed because it is too large Load diff

View file

@ -1560,6 +1560,7 @@ nl:
language: language:
de: Duits de: Duits
en: Engels en: Engels
fr: Frans
nl: Nederlands nl: Nederlands
required: required:
mark: ! '*' mark: ! '*'
@ -1663,6 +1664,7 @@ nl:
shared_suppliers: shared_suppliers:
body: body:
subscribe: subscribe:
subscribe_again:
supplier: supplier:
title: title:
show: show:

View file

@ -35,6 +35,8 @@ class MoveWeeklyTasks < ActiveRecord::Migration
private private
def weekly_task?(workgroup, task) def weekly_task?(workgroup, task)
return false if task.due_date.nil?
group_task = { group_task = {
weekday: workgroup.weekday, weekday: workgroup.weekday,
name: workgroup.task_name, name: workgroup.task_name,

View file

@ -1,12 +1,25 @@
class MigrateUserSettings < ActiveRecord::Migration class MigrateUserSettings < ActiveRecord::Migration
def up def up
say_with_time 'Save old user settings in new RailsSettings module' do
# Allow setting default locale via env parameter
# This is used, when setting users language settings
default_locale = I18n.default_locale
tmp_locale = ENV['DEFAULT_LOCALE'].present? ? ENV['DEFAULT_LOCALE'].to_sym : default_locale
I18n.default_locale = tmp_locale
old_settings = ConfigurableSetting.all old_settings = ConfigurableSetting.all
old_settings.each do |old_setting| old_settings.each do |old_setting|
# get target (user) # get target (user)
type = old_setting.configurable_type type = old_setting.configurable_type
id = old_setting.configurable_id id = old_setting.configurable_id
begin
user = type.constantize.find(id) user = type.constantize.find(id)
rescue ActiveRecord::RecordNotFound
Rails.logger.debug "Can't find configurable object with type: #{type.inspect}, id: #{id.inspect}"
next
end
# get the data (settings) # get the data (settings)
name = old_setting.name name = old_setting.name
@ -27,8 +40,16 @@ class MigrateUserSettings < ActiveRecord::Migration
# save the user to apply after_save callback # save the user to apply after_save callback
user.save user.save
end end
I18n.default_locale = default_locale
end
drop_table :configurable_settings
end end
def down def down
end end
end end
# this is the base class of all configurable settings
class ConfigurableSetting < ActiveRecord::Base; end

View file

@ -66,18 +66,6 @@ ActiveRecord::Schema.define(:version => 20130718183101) do
add_index "assignments", ["user_id", "task_id"], :name => "index_assignments_on_user_id_and_task_id", :unique => true add_index "assignments", ["user_id", "task_id"], :name => "index_assignments_on_user_id_and_task_id", :unique => true
create_table "configurable_settings", :force => true do |t|
t.integer "configurable_id"
t.string "configurable_type"
t.integer "targetable_id"
t.string "targetable_type"
t.string "name", :default => "", :null => false
t.string "value_type"
t.text "value"
end
add_index "configurable_settings", ["name"], :name => "index_configurable_settings_on_name"
create_table "deliveries", :force => true do |t| create_table "deliveries", :force => true do |t|
t.integer "supplier_id" t.integer "supplier_id"
t.date "delivered_on" t.date "delivered_on"

View file

@ -11,7 +11,7 @@ module FoodsoftFile
def self.parse(file) def self.parse(file)
articles, outlisted_articles = Array.new, Array.new articles, outlisted_articles = Array.new, Array.new
row_index = 2 row_index = 2
::CSV.parse(file.read, {:col_sep => ";", :headers => true}) do |row| ::CSV.parse(file.read.force_encoding('utf-8'), {:col_sep => ";", :headers => true}) do |row|
# check if the line is empty # check if the line is empty
unless row[2] == "" || row[2].nil? unless row[2] == "" || row[2].nil?
article = {:number => row[1], article = {:number => row[1],

View file

@ -1,17 +1,21 @@
# This namespace is used for a collection of tasks to maintain a hosting environment with multiple foodcoops
# This tasks are a kind of wrapper for other tasks. The wrapper makes sure, that the appropriate database and config
# for each foodcoop is used.
namespace :multicoops do namespace :multicoops do
desc 'Runs a specific rake task for each registered foodcoop, use rake multicoops:run db:migrate' desc 'Runs a specific rake task for each registered foodcoop, use rake multicoops:run TASK=db:migrate'
task :run => :environment do task :run => :environment do
task_to_run = ARGV[1] task_to_run = ENV['TASK']
FoodsoftConfig.each_coop do |coop| FoodsoftConfig.each_coop do |coop|
puts "Run '#{task_to_run}' for #{coop}" puts "Run '#{task_to_run}' for #{coop}"
Rake::Task[task_to_run].execute Rake::Task[task_to_run].execute
end end
end end
desc 'Runs a specific rake task for a single coop, use rake mutlicoops:run_single db:migrate FOODCOOP=demo' desc 'Runs a specific rake task for a single coop, use rake mutlicoops:run_single TASK=db:migrate FOODCOOP=demo'
task :run_single => :environment do task :run_single => :environment do
task_to_run = ARGV[1] task_to_run = ENV['TASK']
FoodsoftConfig.select_foodcoop ENV['FOODCOOP'] FoodsoftConfig.select_foodcoop ENV['FOODCOOP']
puts "Run '#{task_to_run}' for #{ENV['FOODCOOP']}" puts "Run '#{task_to_run}' for #{ENV['FOODCOOP']}"
Rake::Task[task_to_run].execute Rake::Task[task_to_run].execute

View file

@ -55,12 +55,16 @@ fi
sed -i "s|^\\(\\s*gem\\s\\+'sqlite3'\\)|#\1|" Gemfile sed -i "s|^\\(\\s*gem\\s\\+'sqlite3'\\)|#\1|" Gemfile
sed -i "s|^\\(\\s*sqlite3\\b\)|#\1|" Gemfile.lock sed -i "s|^\\(\\s*sqlite3\\b\)|#\1|" Gemfile.lock
# make sure postgresql db is present, as it is the default heroku db # make sure postgresql db is present, as it is the default heroku db
echo $'\ngem "pg"' >>Gemfile echo "
echo $'\ngem "localeapp"' >>Gemfile gem 'pg'" >>Gemfile
# always use unicorn # always use unicorn
echo $'\ngem "unicorn"' >>Gemfile echo "
gem 'unicorn'" >>Gemfile
echo 'web: bundle exec unicorn -p $PORT -E $RACK_ENV' >Procfile echo 'web: bundle exec unicorn -p $PORT -E $RACK_ENV' >Procfile
bundle install --quiet # to update Gemfile.lock # don't complain when mail cannot be sent,
# XXX when you're hosting a production instance, use a real smtp server instead
sed -i 's|\(#\s*\)\?\(config\.action_mailer\.raise_delivery_errors\)\s*=.*|\2 = false|' config/environments/${RAILS_ENV}.rb
sed -i 's|\(#\s*\)\?\(config\.action_mailer\.delivery_method\)\s*=.*|\2 = :smtp|' config/environments/${RAILS_ENV}.rb
# do not ignore deployment files # do not ignore deployment files
sed -i 's|^\(config/\*.yml\)|#\1|' .gitignore sed -i 's|^\(config/\*.yml\)|#\1|' .gitignore
sed -i 's|^\(config/initializers/secret_token.rb\)|#\1|' .gitignore sed -i 's|^\(config/initializers/secret_token.rb\)|#\1|' .gitignore
@ -92,9 +96,13 @@ Localeapp.configure do |config|
config.polling_environments = ['$RAILS_ENV'] config.polling_environments = ['$RAILS_ENV']
end end
EOF EOF
echo "
gem 'localeapp'" >>Gemfile
# also do not cache so we get locale updates # also do not cache so we get locale updates
sed -i 's|config\.cache_classes\s*=.*|config.cache_classes = false|' config/environments/${RAILS_ENV}.rb sed -i 's|\(#\s*\)\?\(config\.cache_classes\)\s*=.*|\2 = false|' config/environments/${RAILS_ENV}.rb
fi fi
# update Gemfile.lock after Gemfile updates (required by heroku)
bundle install --quiet
# TODO add more extensive database seed # TODO add more extensive database seed
# and push = deploy # and push = deploy