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
config/deploy.rb
config/deploy/*
.localeapp

View file

@ -85,6 +85,3 @@ group :test do
gem 'rspec-expectations'
gem 'i18n-spec'
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:
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
remote: git://github.com/technoweenie/acts_as_versioned.git
revision: 63b1fc8529d028fae632fe80ec0cb25df56cd76b
@ -310,7 +303,6 @@ PLATFORMS
ruby
DEPENDENCIES
acts_as_configurable!
acts_as_tree
acts_as_versioned!
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
=========
[![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
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
end

View file

@ -18,7 +18,7 @@ class SuppliersController < ApplicationController
def new
if 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
@supplier = Supplier.new
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
def build_new_article
shared_supplier.supplier.articles.build(
def build_new_article(supplier)
supplier.articles.build(
:name => name,
:unit => unit,
:note => note,

View file

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

View file

@ -66,7 +66,7 @@ class User < ActiveRecord::Base
end
def receive_email?
settings.messages['send_as_email'] == "1" && email.present?
settings.messages['send_as_email'] && email.present?
end
# 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.delivery_days
%td
- if shared_supplier.supplier
- if shared_supplier.suppliers.any?
%i.icon-ok
= associated_supplier_names(shared_supplier)
= link_to t('.subscribe_again'), new_supplier_path(:shared_supplier_id => shared_supplier), class: 'btn'
- else
= link_to t('.subscribe'), new_supplier_path(:shared_supplier_id => shared_supplier), class: 'btn'

View file

@ -1669,6 +1669,7 @@ de:
language:
de: Deutsch
en: English
fr: Französisch
nl: Niederländisch
required:
mark: ! '*'
@ -1772,6 +1773,7 @@ de:
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>
subscribe: abonnieren
subscribe_again: erneut abonnieren
supplier: Lieferantin
title: Externe Listen
show:

View file

@ -236,7 +236,7 @@ en:
option_available: Make articles available
option_delete: Delete article
option_not_available: Make articles unavailable
option_select: Choose special offer ...
option_select: Select action ...
price_netto: Price
unit_quantity_desc: Unit quantity
unit_quantity_short: Quantity
@ -440,7 +440,7 @@ en:
article: Article
category: Category
create_from_blank: Create new article
create_stock_article: Create stock articles
create_stock_article: Create stock article
price: Netprice
quantity: Quantity
title_fill_quantities: 2. Set delivery quantities
@ -1671,6 +1671,7 @@ en:
language:
de: German
en: English
fr: French
nl: Dutch
required:
mark: ! '*'
@ -1774,6 +1775,7 @@ en:
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>
subscribe: Subscribe
subscribe_again: Subscribe again
supplier: Supplier
title: External lists
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:
de: Duits
en: Engels
fr: Frans
nl: Nederlands
required:
mark: ! '*'
@ -1663,6 +1664,7 @@ nl:
shared_suppliers:
body:
subscribe:
subscribe_again:
supplier:
title:
show:

View file

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

View file

@ -1,34 +1,55 @@
class MigrateUserSettings < ActiveRecord::Migration
def up
old_settings = ConfigurableSetting.all
old_settings.each do |old_setting|
# get target (user)
type = old_setting.configurable_type
id = old_setting.configurable_id
user = type.constantize.find(id)
# get the data (settings)
name = old_setting.name
namespace = name.split('.')[0]
key = name.split('.')[1].underscore # Camelcase to underscore
# prepare value
value = YAML.load(old_setting.value)
value = value.nil? ? false : value
# set the settings_attributes (thanks to settings.merge! we can set them one by one)
user.settings_attributes = {
"#{namespace}" => {
"#{key}" => value
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.each do |old_setting|
# get target (user)
type = old_setting.configurable_type
id = old_setting.configurable_id
begin
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)
name = old_setting.name
namespace = name.split('.')[0]
key = name.split('.')[1].underscore # Camelcase to underscore
# prepare value
value = YAML.load(old_setting.value)
value = value.nil? ? false : value
# set the settings_attributes (thanks to settings.merge! we can set them one by one)
user.settings_attributes = {
"#{namespace}" => {
"#{key}" => value
}
}
}
# save the user to apply after_save callback
user.save
# save the user to apply after_save callback
user.save
end
I18n.default_locale = default_locale
end
drop_table :configurable_settings
end
def down
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
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|
t.integer "supplier_id"
t.date "delivered_on"

View file

@ -11,7 +11,7 @@ module FoodsoftFile
def self.parse(file)
articles, outlisted_articles = Array.new, Array.new
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
unless row[2] == "" || row[2].nil?
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
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_to_run = ARGV[1]
task_to_run = ENV['TASK']
FoodsoftConfig.each_coop do |coop|
puts "Run '#{task_to_run}' for #{coop}"
Rake::Task[task_to_run].execute
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_to_run = ARGV[1]
task_to_run = ENV['TASK']
FoodsoftConfig.select_foodcoop ENV['FOODCOOP']
puts "Run '#{task_to_run}' for #{ENV['FOODCOOP']}"
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*sqlite3\\b\)|#\1|" Gemfile.lock
# make sure postgresql db is present, as it is the default heroku db
echo $'\ngem "pg"' >>Gemfile
echo $'\ngem "localeapp"' >>Gemfile
echo "
gem 'pg'" >>Gemfile
# always use unicorn
echo $'\ngem "unicorn"' >>Gemfile
echo "
gem 'unicorn'" >>Gemfile
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
sed -i 's|^\(config/\*.yml\)|#\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']
end
EOF
echo "
gem 'localeapp'" >>Gemfile
# 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
# update Gemfile.lock after Gemfile updates (required by heroku)
bundle install --quiet
# TODO add more extensive database seed
# and push = deploy