Merge branch 'master' into updated-gems
Conflicts: Gemfile.lock
This commit is contained in:
commit
b9599ce455
22 changed files with 342 additions and 117 deletions
7
Gemfile
7
Gemfile
|
@ -36,7 +36,7 @@ gem 'simple-navigation-bootstrap'
|
||||||
gem 'meta_search'
|
gem 'meta_search'
|
||||||
gem 'acts_as_versioned', git: 'git://github.com/technoweenie/acts_as_versioned.git' # Use this instead of rubygem
|
gem 'acts_as_versioned', git: 'git://github.com/technoweenie/acts_as_versioned.git' # Use this instead of rubygem
|
||||||
gem 'acts_as_tree'
|
gem 'acts_as_tree'
|
||||||
gem 'acts_as_configurable', git: 'git://github.com/bwalding/acts_as_configurable.git'
|
gem "rails-settings-cached", "0.2.4"
|
||||||
gem 'resque'
|
gem 'resque'
|
||||||
gem 'whenever', require: false # For defining cronjobs, see config/schedule.rb
|
gem 'whenever', require: false # For defining cronjobs, see config/schedule.rb
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ group :development do
|
||||||
# Better error output
|
# Better error output
|
||||||
gem 'better_errors'
|
gem 'better_errors'
|
||||||
gem 'binding_of_caller'
|
gem 'binding_of_caller'
|
||||||
|
# gem "rails-i18n-debug"
|
||||||
|
|
||||||
# Re-enable rails benchmarker/profiler
|
# Re-enable rails benchmarker/profiler
|
||||||
gem 'ruby-prof'
|
gem 'ruby-prof'
|
||||||
|
@ -69,3 +70,7 @@ group :development do
|
||||||
# Avoid having content-length warnings
|
# Avoid having content-length warnings
|
||||||
gem 'thin'
|
gem 'thin'
|
||||||
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
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,8 @@ GEM
|
||||||
activesupport (= 3.2.13)
|
activesupport (= 3.2.13)
|
||||||
bundler (~> 1.0)
|
bundler (~> 1.0)
|
||||||
railties (= 3.2.13)
|
railties (= 3.2.13)
|
||||||
|
rails-settings-cached (0.2.4)
|
||||||
|
rails (>= 3.0.0)
|
||||||
railties (3.2.13)
|
railties (3.2.13)
|
||||||
actionpack (= 3.2.13)
|
actionpack (= 3.2.13)
|
||||||
activesupport (= 3.2.13)
|
activesupport (= 3.2.13)
|
||||||
|
@ -299,6 +301,7 @@ DEPENDENCIES
|
||||||
prawn
|
prawn
|
||||||
quiet_assets
|
quiet_assets
|
||||||
rails (~> 3.2.9)
|
rails (~> 3.2.9)
|
||||||
|
rails-settings-cached (= 0.2.4)
|
||||||
resque
|
resque
|
||||||
ruby-prof
|
ruby-prof
|
||||||
sass-rails (~> 3.2.3)
|
sass-rails (~> 3.2.3)
|
||||||
|
|
|
@ -219,3 +219,21 @@ tr.unavailable {
|
||||||
dt { width: 160px; }
|
dt { width: 160px; }
|
||||||
dd { margin-left: 170px; }
|
dd { margin-left: 170px; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.settings {
|
||||||
|
.settings-group {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
.control-label {
|
||||||
|
margin: 5px 0 0 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.control-group {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
.control-group.h_wrapper {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
.control-group.select {
|
||||||
|
margin-bottom: 15px
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
|
include Foodsoft::ControllerExtensions::Locale
|
||||||
|
helper_method :available_locales
|
||||||
|
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
before_filter :select_language, :select_foodcoop, :authenticate, :store_controller, :items_per_page, :set_redirect_to
|
before_filter :select_foodcoop, :authenticate, :store_controller, :items_per_page, :set_redirect_to
|
||||||
after_filter :remove_controller
|
after_filter :remove_controller
|
||||||
|
|
||||||
|
|
||||||
# Returns the controller handling the current request.
|
# Returns the controller handling the current request.
|
||||||
def self.current
|
def self.current
|
||||||
Thread.current[:application_controller]
|
Thread.current[:application_controller]
|
||||||
|
@ -142,8 +145,4 @@ class ApplicationController < ActionController::Base
|
||||||
{foodcoop: FoodsoftConfig.scope}
|
{foodcoop: FoodsoftConfig.scope}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Used to prevent accidently switching to :en in production mode.
|
|
||||||
def select_language
|
|
||||||
I18n.locale = :de
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,6 +16,7 @@ class HomeController < ApplicationController
|
||||||
|
|
||||||
def update_profile
|
def update_profile
|
||||||
if @current_user.update_attributes(params[:user])
|
if @current_user.update_attributes(params[:user])
|
||||||
|
session[:locale] = @current_user.locale
|
||||||
redirect_to my_profile_url, notice: I18n.t('home.changes_saved')
|
redirect_to my_profile_url, notice: I18n.t('home.changes_saved')
|
||||||
else
|
else
|
||||||
render :profile
|
render :profile
|
||||||
|
|
|
@ -58,6 +58,7 @@ class LoginController < ApplicationController
|
||||||
if @user.save
|
if @user.save
|
||||||
Membership.new(:user => @user, :group => @invite.group).save!
|
Membership.new(:user => @user, :group => @invite.group).save!
|
||||||
@invite.destroy
|
@invite.destroy
|
||||||
|
session[:locale] = @user.locale
|
||||||
redirect_to login_url, notice: I18n.t('login.controller.accept_invitation.notice')
|
redirect_to login_url, notice: I18n.t('login.controller.accept_invitation.notice')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,6 +11,8 @@ class SessionsController < ApplicationController
|
||||||
if user
|
if user
|
||||||
session[:user_id] = user.id
|
session[:user_id] = user.id
|
||||||
session[:scope] = FoodsoftConfig.scope # Save scope in session to not allow switching between foodcoops with one account
|
session[:scope] = FoodsoftConfig.scope # Save scope in session to not allow switching between foodcoops with one account
|
||||||
|
session[:locale] = user.locale
|
||||||
|
|
||||||
if session[:return_to].present?
|
if session[:return_to].present?
|
||||||
redirect_to_url = session[:return_to]
|
redirect_to_url = session[:return_to]
|
||||||
session[:return_to] = nil
|
session[:return_to] = nil
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
require 'digest/sha1'
|
require 'digest/sha1'
|
||||||
# specific user rights through memberships (see Group)
|
# specific user rights through memberships (see Group)
|
||||||
class User < ActiveRecord::Base
|
class User < ActiveRecord::Base
|
||||||
|
include RailsSettings::Extend
|
||||||
#TODO: acts_as_paraniod ??
|
#TODO: acts_as_paraniod ??
|
||||||
|
|
||||||
has_many :memberships, :dependent => :destroy
|
has_many :memberships, :dependent => :destroy
|
||||||
|
@ -19,7 +20,10 @@ class User < ActiveRecord::Base
|
||||||
has_many :pages, :foreign_key => 'updated_by'
|
has_many :pages, :foreign_key => 'updated_by'
|
||||||
has_many :created_orders, :class_name => 'Order', :foreign_key => 'created_by_user_id', :dependent => :nullify
|
has_many :created_orders, :class_name => 'Order', :foreign_key => 'created_by_user_id', :dependent => :nullify
|
||||||
|
|
||||||
attr_accessor :password, :setting_attributes
|
attr_accessor :password, :settings_attributes
|
||||||
|
|
||||||
|
# makes the current_user (logged-in-user) available in models
|
||||||
|
cattr_accessor :current_user
|
||||||
|
|
||||||
validates_presence_of :nick, :email
|
validates_presence_of :nick, :email
|
||||||
validates_presence_of :password, :on => :create
|
validates_presence_of :password, :on => :create
|
||||||
|
@ -32,53 +36,37 @@ class User < ActiveRecord::Base
|
||||||
validates_length_of :password, :in => 5..25, :allow_blank => true
|
validates_length_of :password, :in => 5..25, :allow_blank => true
|
||||||
|
|
||||||
before_validation :set_password
|
before_validation :set_password
|
||||||
after_save :update_settings
|
after_initialize do
|
||||||
|
settings.defaults['profile'] = { 'language' => I18n.default_locale } unless settings.profile
|
||||||
# Adds support for configuration settings (through "settings" attribute).
|
settings.defaults['messages'] = { 'send_as_email' => true } unless settings.messages
|
||||||
acts_as_configurable
|
settings.defaults['notify'] = { 'upcoming_tasks' => true } unless settings.notify
|
||||||
|
|
||||||
# makes the current_user (logged-in-user) available in models
|
|
||||||
cattr_accessor :current_user
|
|
||||||
|
|
||||||
# User settings keys
|
|
||||||
# returns the User-settings and the translated description
|
|
||||||
def self.setting_keys
|
|
||||||
{
|
|
||||||
"notify.orderFinished" => I18n.t('model.user.notify.order_finished'),
|
|
||||||
"notify.negativeBalance" => I18n.t('model.user.notify.negative_balance'),
|
|
||||||
"notify.upcoming_tasks" => I18n.t('model.user.notify.upcoming_tasks'),
|
|
||||||
"messages.sendAsEmail" => I18n.t('model.user.notify.send_as_email'),
|
|
||||||
"profile.phoneIsPublic" => I18n.t('model.user.notify.phone_is_public'),
|
|
||||||
"profile.emailIsPublic" => I18n.t('model.user.notify.email_is_public'),
|
|
||||||
"profile.nameIsPublic" => I18n.t('model.user.notify.name_is_public')
|
|
||||||
}
|
|
||||||
end
|
|
||||||
# retuns the default setting for a NEW user
|
|
||||||
# for old records nil will returned
|
|
||||||
# TODO: integrate default behaviour in acts_as_configurable plugin
|
|
||||||
def settings_default(setting)
|
|
||||||
# define a default for the settings
|
|
||||||
defaults = {
|
|
||||||
"messages.sendAsEmail" => true,
|
|
||||||
"notify.upcoming_tasks" => true
|
|
||||||
}
|
|
||||||
return true if self.new_record? && defaults[setting]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_settings
|
after_save do
|
||||||
unless setting_attributes.nil?
|
return if settings_attributes.nil?
|
||||||
for setting in User::setting_keys.keys
|
settings_attributes.each do |key, value|
|
||||||
self.settings[setting] = setting_attributes[setting] && setting_attributes[setting] == '1' ? '1' : nil
|
value.each do |k, v|
|
||||||
|
case v
|
||||||
|
when '1'
|
||||||
|
value[k] = true
|
||||||
|
when '0'
|
||||||
|
value[k] = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
self.settings.merge!(key, value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def locale
|
||||||
|
settings.profile['language']
|
||||||
|
end
|
||||||
|
|
||||||
def name
|
def name
|
||||||
[first_name, last_name].join(" ")
|
[first_name, last_name].join(" ")
|
||||||
end
|
end
|
||||||
|
|
||||||
def receive_email?
|
def receive_email?
|
||||||
settings['messages.sendAsEmail'] == "1" && email.present?
|
settings.messages['send_as_email'] == "1" && 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.
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
.well
|
.well
|
||||||
%h4= t '.preference'
|
%h4= t '.preference'
|
||||||
%table.table
|
%table.table
|
||||||
- for setting in User::setting_keys.keys
|
- @user.settings.profile.each do |key, setting|
|
||||||
%tr
|
%tr
|
||||||
%td= User::setting_keys[setting]
|
%td= t("simple_form.labels.settings.profile.#{key}")
|
||||||
%td= @user.settings[setting] == '1' ? t('simple_form.yes') : t('simple_form.no')
|
%td= (setting != true and setting != false) ? setting : (setting === true ? t('simple_form.yes') : t('simple_form.no'))
|
||||||
.span3
|
.span3
|
||||||
.well
|
.well
|
||||||
%h4= t '.groupabos'
|
%h4= t '.groupabos'
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
- for user in @users
|
- for user in @users
|
||||||
%tr
|
%tr
|
||||||
%td= user.nick
|
%td= user.nick
|
||||||
%td= user.name if @current_user.role_admin? || user.settings["profile.nameIsPublic"] == '1'
|
%td= user.name if @current_user.role_admin? || user.settings.profile["name_is_public"]
|
||||||
%td= user.email if @current_user.role_admin? || user.settings["profile.emailIsPublic"] == '1'
|
%td= user.email if @current_user.role_admin? || user.settings.profile["email_is_public"]
|
||||||
%td= user.phone if @current_user.role_admin? || user.settings["profile.phoneIsPublic"] == '1'
|
%td= user.phone if @current_user.role_admin? || user.settings.profile["phone_is_public"]
|
||||||
%td= user.ordergroup_name
|
%td= user.ordergroup_name
|
||||||
%td= user.workgroups.collect(&:name).join(', ')
|
%td= user.workgroups.collect(&:name).join(', ')
|
||||||
%td= link_to_new_message(message_params: {mail_to: user.id})
|
%td= link_to_new_message(message_params: {mail_to: user.id})
|
||||||
|
|
|
@ -5,11 +5,31 @@
|
||||||
= f.input :phone
|
= f.input :phone
|
||||||
= f.input :password, :required => f.object.new_record?
|
= f.input :password, :required => f.object.new_record?
|
||||||
= f.input :password_confirmation
|
= f.input :password_confirmation
|
||||||
.control-group
|
|
||||||
.controls
|
= f.simple_fields_for :settings_attributes do |s|
|
||||||
- for setting in User::setting_keys.keys
|
= s.simple_fields_for :profile, defaults: { inline_label: true } do |profile|
|
||||||
%label.checkbox{:for => "user[setting_attributes][#{setting}]"}
|
= profile.input 'language', as: :select, collection: available_locales, required: false, selected: f.object.settings.profile['language']
|
||||||
= hidden_field_tag "user[setting_attributes][#{setting}]", '0'
|
|
||||||
= check_box_tag "user[setting_attributes][#{setting}]", '1',
|
.settings
|
||||||
f.object.settings[setting] == '1' || f.object.settings_default(setting)
|
.settings-group
|
||||||
= User::setting_keys[setting]
|
= s.simple_fields_for :profile, defaults: { inline_label: true } do |profile|
|
||||||
|
|
||||||
|
%div{class: 'control-group h_wrapper'}
|
||||||
|
%h5{class: 'controls'}
|
||||||
|
= t 'simple_form.labels.settings.settings_group.privacy'
|
||||||
|
= profile.input 'phone_is_public', as: :boolean, label: false, input_html: { checked: f.object.settings.profile['phone_is_public'] }
|
||||||
|
= profile.input 'email_is_public', as: :boolean, label: false, input_html: { checked: f.object.settings.profile['email_is_public'] }
|
||||||
|
= profile.input 'name_is_public', as: :boolean, label: false, input_html: { checked: f.object.settings.profile['name_is_public'] }
|
||||||
|
|
||||||
|
.settings-group
|
||||||
|
%div{class: 'control-group'}
|
||||||
|
%h5{class: 'controls'}
|
||||||
|
= t 'simple_form.labels.settings.settings_group.messages'
|
||||||
|
|
||||||
|
= s.simple_fields_for :messages, defaults: { inline_label: true, label: false } do |messages|
|
||||||
|
= messages.input 'send_as_email', as: :boolean, input_html: { checked: f.object.settings.messages['send_as_email'] }
|
||||||
|
= s.simple_fields_for :notify, defaults: { inline_label: true, label: false } do |notify|
|
||||||
|
= notify.input 'order_finished', as: :boolean, input_html: { checked: f.object.settings.notify['order_finished'] }
|
||||||
|
= notify.input 'negative_balance', as: :boolean, input_html: { checked: f.object.settings.notify['negative_balance'] }
|
||||||
|
= notify.input 'upcoming_tasks', as: :boolean, input_html: { checked: f.object.settings.notify['upcoming_tasks'] }
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ class UserNotifier
|
||||||
Order.find(order_id).group_orders.each do |group_order|
|
Order.find(order_id).group_orders.each do |group_order|
|
||||||
group_order.ordergroup.users.each do |user|
|
group_order.ordergroup.users.each do |user|
|
||||||
begin
|
begin
|
||||||
Mailer.order_result(user, group_order).deliver if user.settings["notify.orderFinished"] == '1'
|
Mailer.order_result(user, group_order).deliver if user.settings.notify["order_finished"]
|
||||||
rescue
|
rescue
|
||||||
Rails.logger.warn "Can't deliver mail to #{user.email}"
|
Rails.logger.warn "Can't deliver mail to #{user.email}"
|
||||||
end
|
end
|
||||||
|
@ -34,7 +34,7 @@ class UserNotifier
|
||||||
|
|
||||||
Ordergroup.find(ordergroup_id).users.each do |user|
|
Ordergroup.find(ordergroup_id).users.each do |user|
|
||||||
begin
|
begin
|
||||||
Mailer.negative_balance(user, transaction).deliver if user.settings["notify.negativeBalance"] == '1'
|
Mailer.negative_balance(user, transaction).deliver if user.settings.notify["negative_balance"]
|
||||||
rescue
|
rescue
|
||||||
Rails.logger.warn "Can't deliver mail to #{user.email}"
|
Rails.logger.warn "Can't deliver mail to #{user.email}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,7 @@ module Foodsoft
|
||||||
|
|
||||||
# Internationalization.
|
# Internationalization.
|
||||||
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
|
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
|
||||||
config.i18n.default_locale = :de
|
config.i18n.default_locale = :en
|
||||||
|
|
||||||
# Configure the default encoding used in templates for Ruby 1.9.
|
# Configure the default encoding used in templates for Ruby 1.9.
|
||||||
config.encoding = "utf-8"
|
config.encoding = "utf-8"
|
||||||
|
|
|
@ -465,11 +465,11 @@ de:
|
||||||
title_articles: Artikel
|
title_articles: Artikel
|
||||||
unit: Einheit
|
unit: Einheit
|
||||||
stock_article_for_adding:
|
stock_article_for_adding:
|
||||||
action_add_to_delivery: 'Liefern'
|
action_add_to_delivery: Liefern
|
||||||
action_edit: 'Bearbeiten'
|
action_edit: Bearbeiten
|
||||||
action_other_price: 'Kopieren'
|
action_other_price: Kopieren
|
||||||
stock_article_form:
|
stock_article_form:
|
||||||
copy_stock_article: 'Lagerartikel kopieren'
|
copy_stock_article: Lagerartikel kopieren
|
||||||
stock_change_fields:
|
stock_change_fields:
|
||||||
remove_article: Artikel aus Lieferung entfernen
|
remove_article: Artikel aus Lieferung entfernen
|
||||||
suppliers_overview: Lieferantenübersicht
|
suppliers_overview: Lieferantenübersicht
|
||||||
|
@ -1179,14 +1179,6 @@ de:
|
||||||
redirect: Weiterleiting auf [[%{title}]]...
|
redirect: Weiterleiting auf [[%{title}]]...
|
||||||
user:
|
user:
|
||||||
no_ordergroup: keine Bestellgruppe
|
no_ordergroup: keine Bestellgruppe
|
||||||
notify:
|
|
||||||
email_is_public: E-Mail ist für Mitglieder sichtbar
|
|
||||||
name_is_public: Name ist für Mitglieder sichtbar
|
|
||||||
negative_balance: Informiere mich, falls meine Bestellgruppe ins Minus rutscht.
|
|
||||||
order_finished: Informier mich über meine Bestellergebnisse (nach Ende der Bestellung).
|
|
||||||
phone_is_public: Telefon ist für Mitglieder sichtbar
|
|
||||||
send_as_email: Bekomme Nachrichten als Emails.
|
|
||||||
upcoming_tasks: Erinnere mich an anstehende Aufgaben.
|
|
||||||
navigation:
|
navigation:
|
||||||
admin:
|
admin:
|
||||||
home: Übersicht
|
home: Übersicht
|
||||||
|
@ -1534,11 +1526,11 @@ de:
|
||||||
units_to_order: Anzahl gelieferter Gebinde
|
units_to_order: Anzahl gelieferter Gebinde
|
||||||
update_current_price: Ändert auch den Preis für aktuelle Bestellungen
|
update_current_price: Ändert auch den Preis für aktuelle Bestellungen
|
||||||
stock_article:
|
stock_article:
|
||||||
supplier:
|
|
||||||
copy_stock_article:
|
copy_stock_article:
|
||||||
name: Bitte ändern
|
name: Bitte ändern
|
||||||
edit_stock_article:
|
edit_stock_article:
|
||||||
price: ! '<ul><li>Preisänderung gesperrt.</li><li>Bei Bedarf %{stock_article_copy_link}.</li></ul>'
|
price: <ul><li>Preisänderung gesperrt.</li><li>Bei Bedarf %{stock_article_copy_link}.</li></ul>
|
||||||
|
supplier:
|
||||||
supplier:
|
supplier:
|
||||||
min_order_quantity: Die Mindestbestellmenge wird während der Bestellung angezeigt und soll motivieren
|
min_order_quantity: Die Mindestbestellmenge wird während der Bestellung angezeigt und soll motivieren
|
||||||
task:
|
task:
|
||||||
|
@ -1613,6 +1605,21 @@ de:
|
||||||
page:
|
page:
|
||||||
body: Inhalt
|
body: Inhalt
|
||||||
parent_id: Oberseite
|
parent_id: Oberseite
|
||||||
|
settings:
|
||||||
|
messages:
|
||||||
|
send_as_email: Bekomme Nachrichten als Emails.
|
||||||
|
notify:
|
||||||
|
negative_balance: Informiere mich, falls meine Bestellgruppe ins Minus rutscht.
|
||||||
|
order_finished: Informier mich über meine Bestellergebnisse (nach Ende der Bestellung).
|
||||||
|
upcoming_tasks: Erinnere mich an anstehende Aufgaben.
|
||||||
|
profile:
|
||||||
|
email_is_public: E-Mail ist für Mitglieder sichtbar.
|
||||||
|
language: Sprache
|
||||||
|
name_is_public: Name ist für Mitglieder sichtbar.
|
||||||
|
phone_is_public: Telefon ist für Mitglieder sichtbar.
|
||||||
|
settings_group:
|
||||||
|
messages: Nachrichten
|
||||||
|
privacy: Privatsphäre
|
||||||
stock_article:
|
stock_article:
|
||||||
supplier: Lieferant
|
supplier: Lieferant
|
||||||
supplier:
|
supplier:
|
||||||
|
@ -1656,6 +1663,13 @@ de:
|
||||||
role_orders: Bestellverwaltung
|
role_orders: Bestellverwaltung
|
||||||
role_suppliers: Lieferanten
|
role_suppliers: Lieferanten
|
||||||
'no': Nein
|
'no': Nein
|
||||||
|
options:
|
||||||
|
settings:
|
||||||
|
profile:
|
||||||
|
language:
|
||||||
|
de: Deutsch
|
||||||
|
en: English
|
||||||
|
nl: Niederländisch
|
||||||
required:
|
required:
|
||||||
mark: ! '*'
|
mark: ! '*'
|
||||||
text: benötigt
|
text: benötigt
|
||||||
|
@ -1858,7 +1872,7 @@ de:
|
||||||
history: Verlauf anzeigen
|
history: Verlauf anzeigen
|
||||||
marks:
|
marks:
|
||||||
close: ! '×'
|
close: ! '×'
|
||||||
success: ! '<i class="icon icon-ok"></i>'
|
success: <i class="icon icon-ok"></i>
|
||||||
or_cancel: oder abbrechen
|
or_cancel: oder abbrechen
|
||||||
please_wait: Bitte warten...
|
please_wait: Bitte warten...
|
||||||
save: Speichern
|
save: Speichern
|
||||||
|
|
|
@ -426,7 +426,7 @@ en:
|
||||||
year: years
|
year: years
|
||||||
deliveries:
|
deliveries:
|
||||||
add_stock_change:
|
add_stock_change:
|
||||||
how_many_units: 'How many units (%{unit}) to deliver? Stock article name: %{name}.'
|
how_many_units: ! 'How many units (%{unit}) to deliver? Stock article name: %{name}.'
|
||||||
create:
|
create:
|
||||||
notice: Delivery was created. Please don’t forget to create invoice!
|
notice: Delivery was created. Please don’t forget to create invoice!
|
||||||
create_stock_article:
|
create_stock_article:
|
||||||
|
@ -439,8 +439,8 @@ en:
|
||||||
actions: Tasks
|
actions: Tasks
|
||||||
article: Article
|
article: Article
|
||||||
category: Category
|
category: Category
|
||||||
copy_order_article: Copy order article
|
create_from_blank: Create new article
|
||||||
new_stock_article: Create new stock article
|
create_stock_article: Create stock articles
|
||||||
price: Netprice
|
price: Netprice
|
||||||
quantity: Quantity
|
quantity: Quantity
|
||||||
title_fill_quantities: 2. Set delivery quantities
|
title_fill_quantities: 2. Set delivery quantities
|
||||||
|
@ -467,11 +467,11 @@ en:
|
||||||
title_articles: Article
|
title_articles: Article
|
||||||
unit: Unit
|
unit: Unit
|
||||||
stock_article_for_adding:
|
stock_article_for_adding:
|
||||||
action_add_to_delivery: 'Add to delivery'
|
action_add_to_delivery: Add to delivery
|
||||||
action_edit: 'Edit'
|
action_edit: Edit
|
||||||
action_other_price: 'Copy'
|
action_other_price: Copy
|
||||||
stock_article_form:
|
stock_article_form:
|
||||||
copy_stock_article: 'Lagerartikel kopieren'
|
copy_stock_article: Copy stock article
|
||||||
stock_change_fields:
|
stock_change_fields:
|
||||||
remove_article: Remove article from delivery
|
remove_article: Remove article from delivery
|
||||||
suppliers_overview: Supplier overview
|
suppliers_overview: Supplier overview
|
||||||
|
@ -1181,14 +1181,6 @@ en:
|
||||||
redirect: Redirect to [[%{title}]]...
|
redirect: Redirect to [[%{title}]]...
|
||||||
user:
|
user:
|
||||||
no_ordergroup: no order group
|
no_ordergroup: no order group
|
||||||
notify:
|
|
||||||
email_is_public: Email is visible for other members.
|
|
||||||
name_is_public: Name is visible for other members.
|
|
||||||
negative_balance: inform me when by order group has a negative balance.
|
|
||||||
order_finished: Inform me about my order result (when the order is closed).
|
|
||||||
phone_is_public: Phone number is visible for other members.
|
|
||||||
send_as_email: Receive messages as emails.
|
|
||||||
upcoming_tasks: Remind me of upcoming tasks.
|
|
||||||
navigation:
|
navigation:
|
||||||
admin:
|
admin:
|
||||||
home: Overview
|
home: Overview
|
||||||
|
@ -1536,11 +1528,11 @@ en:
|
||||||
units_to_order: Amount of delivered units
|
units_to_order: Amount of delivered units
|
||||||
update_current_price: Also update the price of the current order
|
update_current_price: Also update the price of the current order
|
||||||
stock_article:
|
stock_article:
|
||||||
supplier:
|
|
||||||
copy_stock_article:
|
copy_stock_article:
|
||||||
name: Please modify
|
name: Please modify
|
||||||
edit_stock_article:
|
edit_stock_article:
|
||||||
price: ! '<ul><li>Price changes are forbidden.</li><li>If necessary, %{stock_article_copy_link}.</li></ul>'
|
price: <ul><li>Price changes are forbidden.</li><li>If necessary, %{stock_article_copy_link}.</li></ul>
|
||||||
|
supplier:
|
||||||
supplier:
|
supplier:
|
||||||
min_order_quantity: The minimum amount which has to be orderd will be shown during the order process and should motivate ordering
|
min_order_quantity: The minimum amount which has to be orderd will be shown during the order process and should motivate ordering
|
||||||
task:
|
task:
|
||||||
|
@ -1615,6 +1607,21 @@ en:
|
||||||
page:
|
page:
|
||||||
body: Body
|
body: Body
|
||||||
parent_id: Parent page
|
parent_id: Parent page
|
||||||
|
settings:
|
||||||
|
messages:
|
||||||
|
send_as_email: Receive messages as emails.
|
||||||
|
notify:
|
||||||
|
negative_balance: Inform me when my order group has a negative balance.
|
||||||
|
order_finished: Inform me about my order result (when the order is closed).
|
||||||
|
upcoming_tasks: Remind me of upcoming tasks.
|
||||||
|
profile:
|
||||||
|
email_is_public: Email is visible for other members.
|
||||||
|
language: Language
|
||||||
|
name_is_public: Name is visible for other members.
|
||||||
|
phone_is_public: Phone number is visible for other members.
|
||||||
|
settings_group:
|
||||||
|
messages: Messages
|
||||||
|
privacy: Privacy
|
||||||
stock_article:
|
stock_article:
|
||||||
supplier: Supplier
|
supplier: Supplier
|
||||||
supplier:
|
supplier:
|
||||||
|
@ -1658,6 +1665,13 @@ en:
|
||||||
role_orders: Order management
|
role_orders: Order management
|
||||||
role_suppliers: Suppliers
|
role_suppliers: Suppliers
|
||||||
'no': 'No'
|
'no': 'No'
|
||||||
|
options:
|
||||||
|
settings:
|
||||||
|
profile:
|
||||||
|
language:
|
||||||
|
de: German
|
||||||
|
en: English
|
||||||
|
nl: Dutch
|
||||||
required:
|
required:
|
||||||
mark: ! '*'
|
mark: ! '*'
|
||||||
text: required
|
text: required
|
||||||
|
@ -1860,7 +1874,9 @@ en:
|
||||||
history: Show history
|
history: Show history
|
||||||
marks:
|
marks:
|
||||||
close: ! '×'
|
close: ! '×'
|
||||||
|
success: <i class="icon icon-ok"></i>
|
||||||
or_cancel: or cancel
|
or_cancel: or cancel
|
||||||
|
please_wait: Please wait...
|
||||||
save: Save
|
save: Save
|
||||||
show: Show
|
show: Show
|
||||||
views:
|
views:
|
||||||
|
|
|
@ -39,6 +39,8 @@ nl:
|
||||||
article_category: categorie
|
article_category: categorie
|
||||||
availability: Artikel leverbaar?
|
availability: Artikel leverbaar?
|
||||||
deposit: statiegeld
|
deposit: statiegeld
|
||||||
|
fc_price:
|
||||||
|
fc_share:
|
||||||
gross_price: bruto prijs
|
gross_price: bruto prijs
|
||||||
price: netto prijs
|
price: netto prijs
|
||||||
tax: BTW
|
tax: BTW
|
||||||
|
@ -421,20 +423,28 @@ nl:
|
||||||
second: seconden
|
second: seconden
|
||||||
year: jaren
|
year: jaren
|
||||||
deliveries:
|
deliveries:
|
||||||
|
add_stock_change:
|
||||||
|
how_many_units:
|
||||||
create:
|
create:
|
||||||
notice:
|
notice:
|
||||||
|
create_stock_article:
|
||||||
|
notice:
|
||||||
destroy:
|
destroy:
|
||||||
notice:
|
notice:
|
||||||
edit:
|
edit:
|
||||||
title:
|
title:
|
||||||
form:
|
form:
|
||||||
add_article:
|
actions:
|
||||||
new_article:
|
article:
|
||||||
search:
|
category:
|
||||||
title:
|
create_from_blank:
|
||||||
note_new_article:
|
create_stock_article:
|
||||||
note_new_article_link:
|
price:
|
||||||
remove_article:
|
quantity:
|
||||||
|
title_fill_quantities:
|
||||||
|
title_finish_delivery:
|
||||||
|
title_select_stock_articles:
|
||||||
|
unit:
|
||||||
index:
|
index:
|
||||||
confirm_delete:
|
confirm_delete:
|
||||||
new_delivery:
|
new_delivery:
|
||||||
|
@ -454,11 +464,19 @@ nl:
|
||||||
title:
|
title:
|
||||||
title_articles:
|
title_articles:
|
||||||
unit:
|
unit:
|
||||||
stock_change:
|
stock_article_for_adding:
|
||||||
|
action_add_to_delivery:
|
||||||
|
action_edit:
|
||||||
|
action_other_price:
|
||||||
|
stock_article_form:
|
||||||
|
copy_stock_article:
|
||||||
|
stock_change_fields:
|
||||||
remove_article:
|
remove_article:
|
||||||
suppliers_overview:
|
suppliers_overview:
|
||||||
update:
|
update:
|
||||||
notice:
|
notice:
|
||||||
|
update_stock_article:
|
||||||
|
notice:
|
||||||
documents:
|
documents:
|
||||||
order_by_articles:
|
order_by_articles:
|
||||||
filename:
|
filename:
|
||||||
|
@ -1044,6 +1062,8 @@ nl:
|
||||||
subject:
|
subject:
|
||||||
title:
|
title:
|
||||||
model:
|
model:
|
||||||
|
delivery:
|
||||||
|
each_stock_article_must_be_unique:
|
||||||
membership:
|
membership:
|
||||||
no_admin_delete:
|
no_admin_delete:
|
||||||
order_article:
|
order_article:
|
||||||
|
@ -1052,14 +1072,6 @@ nl:
|
||||||
redirect:
|
redirect:
|
||||||
user:
|
user:
|
||||||
no_ordergroup:
|
no_ordergroup:
|
||||||
notify:
|
|
||||||
email_is_public:
|
|
||||||
name_is_public:
|
|
||||||
negative_balance:
|
|
||||||
order_finished: Informeer me over mijn bestelresultaat (wanneer de bestelling gesloten wordt).
|
|
||||||
phone_is_public:
|
|
||||||
send_as_email:
|
|
||||||
upcoming_tasks:
|
|
||||||
navigation:
|
navigation:
|
||||||
admin:
|
admin:
|
||||||
home: Overzicht
|
home: Overzicht
|
||||||
|
@ -1405,6 +1417,10 @@ nl:
|
||||||
units_to_order:
|
units_to_order:
|
||||||
update_current_price:
|
update_current_price:
|
||||||
stock_article:
|
stock_article:
|
||||||
|
copy_stock_article:
|
||||||
|
name:
|
||||||
|
edit_stock_article:
|
||||||
|
price:
|
||||||
supplier:
|
supplier:
|
||||||
supplier:
|
supplier:
|
||||||
min_order_quantity:
|
min_order_quantity:
|
||||||
|
@ -1480,6 +1496,21 @@ nl:
|
||||||
page:
|
page:
|
||||||
body:
|
body:
|
||||||
parent_id:
|
parent_id:
|
||||||
|
settings:
|
||||||
|
messages:
|
||||||
|
send_as_email: Berichten als emails ontvangen.
|
||||||
|
notify:
|
||||||
|
negative_balance: Informeer me wanneer mijn huishouden een negatief saldo krijgt.
|
||||||
|
order_finished: Informeer me over mijn bestelresultaat (wanneer de bestelling gesloten wordt).
|
||||||
|
upcoming_tasks: Herinner me aan aankomende taken.
|
||||||
|
profile:
|
||||||
|
email_is_public: E-mail is zichtbaar voor andere leden.
|
||||||
|
language: Taal
|
||||||
|
name_is_public: Naam is zichtbaar voor andere leden.
|
||||||
|
phone_is_public: Telefoonnummer is zichtbaar voor andere leden.
|
||||||
|
settings_group:
|
||||||
|
messages: Berichten
|
||||||
|
privacy: Privacy
|
||||||
stock_article:
|
stock_article:
|
||||||
supplier:
|
supplier:
|
||||||
supplier:
|
supplier:
|
||||||
|
@ -1523,6 +1554,13 @@ nl:
|
||||||
role_orders:
|
role_orders:
|
||||||
role_suppliers: Leveranciers
|
role_suppliers: Leveranciers
|
||||||
'no': Nee
|
'no': Nee
|
||||||
|
options:
|
||||||
|
settings:
|
||||||
|
profile:
|
||||||
|
language:
|
||||||
|
de: Duits
|
||||||
|
en: Engels
|
||||||
|
nl: Nederlands
|
||||||
required:
|
required:
|
||||||
mark: ! '*'
|
mark: ! '*'
|
||||||
text: verplicht
|
text: verplicht
|
||||||
|
@ -1725,7 +1763,9 @@ nl:
|
||||||
history:
|
history:
|
||||||
marks:
|
marks:
|
||||||
close: ! '×'
|
close: ! '×'
|
||||||
|
success:
|
||||||
or_cancel: of annuleren
|
or_cancel: of annuleren
|
||||||
|
please_wait:
|
||||||
save: Opslaan
|
save: Opslaan
|
||||||
show: Tonen
|
show: Tonen
|
||||||
views:
|
views:
|
||||||
|
|
|
@ -8,6 +8,7 @@ Foodsoft::Application.routes.draw do
|
||||||
|
|
||||||
root :to => redirect("/#{FoodsoftConfig.scope}")
|
root :to => redirect("/#{FoodsoftConfig.scope}")
|
||||||
|
|
||||||
|
|
||||||
scope '/:foodcoop' do
|
scope '/:foodcoop' do
|
||||||
|
|
||||||
# Root path
|
# Root path
|
||||||
|
|
17
db/migrate/20130718183100_create_settings.rb
Normal file
17
db/migrate/20130718183100_create_settings.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
class CreateSettings < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
create_table :settings do |t|
|
||||||
|
t.string :var, null: false
|
||||||
|
t.text :value, null: true
|
||||||
|
t.integer :thing_id, null: true
|
||||||
|
t.string :thing_type, limit: 30, null: true
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :settings, [ :thing_type, :thing_id, :var ], unique: true
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
drop_table :settings
|
||||||
|
end
|
||||||
|
end
|
34
db/migrate/20130718183101_migrate_user_settings.rb
Normal file
34
db/migrate/20130718183101_migrate_user_settings.rb
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# save the user to apply after_save callback
|
||||||
|
user.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
13
db/schema.rb
13
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20130624085246) do
|
ActiveRecord::Schema.define(:version => 20130718183101) do
|
||||||
|
|
||||||
create_table "article_categories", :force => true do |t|
|
create_table "article_categories", :force => true do |t|
|
||||||
t.string "name", :default => "", :null => false
|
t.string "name", :default => "", :null => false
|
||||||
|
@ -268,6 +268,17 @@ ActiveRecord::Schema.define(:version => 20130624085246) do
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "settings", :force => true do |t|
|
||||||
|
t.string "var", :null => false
|
||||||
|
t.text "value"
|
||||||
|
t.integer "thing_id"
|
||||||
|
t.string "thing_type", :limit => 30
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "settings", ["thing_type", "thing_id", "var"], :name => "index_settings_on_thing_type_and_thing_id_and_var", :unique => true
|
||||||
|
|
||||||
create_table "stock_changes", :force => true do |t|
|
create_table "stock_changes", :force => true do |t|
|
||||||
t.integer "delivery_id"
|
t.integer "delivery_id"
|
||||||
t.integer "order_id"
|
t.integer "order_id"
|
||||||
|
|
55
lib/foodsoft/controller_extensions.rb
Normal file
55
lib/foodsoft/controller_extensions.rb
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
module Foodsoft
|
||||||
|
module ControllerExtensions
|
||||||
|
module Locale
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
before_filter :set_locale
|
||||||
|
end
|
||||||
|
|
||||||
|
def explicitly_requested_language
|
||||||
|
params[:locale]
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_settings_language
|
||||||
|
current_user.locale if current_user
|
||||||
|
end
|
||||||
|
|
||||||
|
def session_language
|
||||||
|
session[:locale]
|
||||||
|
end
|
||||||
|
|
||||||
|
def browser_language
|
||||||
|
request.env['HTTP_ACCEPT_LANGUAGE'] ? request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first : nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def default_language
|
||||||
|
::I18n.default_locale
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def select_language_according_to_priority
|
||||||
|
language = explicitly_requested_language || session_language || user_settings_language || browser_language
|
||||||
|
language.to_sym unless language.blank?
|
||||||
|
end
|
||||||
|
|
||||||
|
def available_locales
|
||||||
|
::I18n.available_locales
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_locale
|
||||||
|
if available_locales.include?(select_language_according_to_priority)
|
||||||
|
::I18n.locale = select_language_according_to_priority
|
||||||
|
else
|
||||||
|
::I18n.locale = default_language
|
||||||
|
end
|
||||||
|
|
||||||
|
locale = session[:locale] = ::I18n.locale
|
||||||
|
logger.info("Set locale to #{locale}")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -8,7 +8,7 @@ namespace :foodsoft do
|
||||||
puts "Send notifications for #{task.name} to .."
|
puts "Send notifications for #{task.name} to .."
|
||||||
for user in task.users
|
for user in task.users
|
||||||
begin
|
begin
|
||||||
Mailer.upcoming_tasks(user, task).deliver if user.settings['notify.upcoming_tasks'] == 1
|
Mailer.upcoming_tasks(user, task).deliver if user.settings.notify['upcoming_tasks'] == 1
|
||||||
rescue
|
rescue
|
||||||
puts "deliver aborted for #{user.email}.."
|
puts "deliver aborted for #{user.email}.."
|
||||||
end
|
end
|
||||||
|
@ -23,7 +23,7 @@ namespace :foodsoft do
|
||||||
unless task.enough_users_assigned?
|
unless task.enough_users_assigned?
|
||||||
puts "Notify workgroup: #{workgroup.name} for task #{task.name}"
|
puts "Notify workgroup: #{workgroup.name} for task #{task.name}"
|
||||||
for user in workgroup.users
|
for user in workgroup.users
|
||||||
if user.settings['messages.sendAsEmail'] == "1" && !user.email.blank?
|
if user.settings.messages['send_as_email'] == "1" && !user.email.blank?
|
||||||
begin
|
begin
|
||||||
Mailer.not_enough_users_assigned(task, user).deliver
|
Mailer.not_enough_users_assigned(task, user).deliver
|
||||||
rescue
|
rescue
|
||||||
|
|
Loading…
Reference in a new issue