Removed gettext and simplified_localization-plugin. L18n is now the appropriate module.

Upgraded to rails 2.2.2 and replaced complex foodsoft.rb-loader with simple
initializers/load_app_config.rb. Multiple foodcoops option is temporarly deactivated.
This commit is contained in:
Benjamin Meichsner 2009-01-06 15:45:19 +01:00
parent 5b9a7e05df
commit 9f8d0d28ac
121 changed files with 1197 additions and 15237 deletions

View file

@ -31,22 +31,22 @@ class Article < ActiveRecord::Base
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def net_price=(net_price)
self[:net_price] = FoodSoft::delocalizeDecimalString(net_price)
self[:net_price] = String.delocalized_decimal(net_price)
end
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def tax=(tax)
self[:tax] = FoodSoft::delocalizeDecimalString(tax)
self[:tax] = String.delocalized_decimal(tax)
end
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def deposit=(deposit)
self[:deposit] = FoodSoft::delocalizeDecimalString(deposit)
self[:deposit] = String.delocalized_decimal(deposit)
end
# calculate the fc price and sets the attribute
def calc_gross_price
self.gross_price = ((net_price + deposit) * (tax / 100 + 1)) * (FoodSoft::getPriceMarkup / 100 + 1)
self.gross_price = ((net_price + deposit) * (tax / 100 + 1)) * (APP_CONFIG[:price_markup] / 100 + 1)
end
# Returns true if article has been updated at least 2 days ago
@ -150,7 +150,7 @@ class Article < ActiveRecord::Base
end
# convert units in foodcoop-size
# uses FoodSoft.get_units_factors to calc the price/unit_quantity
# uses unit factors in app_config.yml to calc the price/unit_quantity
# returns new price and unit_quantity in array, when calc is possible => [price, unit_quanity]
# returns false if units aren't foodsoft-compatible
# returns nil if units are eqal
@ -166,7 +166,8 @@ class Article < ActiveRecord::Base
false
end
else # get factors for fc and supplier
fc_unit_factor, supplier_unit_factor = FoodSoft.get_units_factors[self.unit], FoodSoft.get_units_factors[self.shared_article.unit]
fc_unit_factor = APP_CONFIG[:units][self.unit]
supplier_unit_factor = APP_CONFIG[:units][self.shared_article.unit]
if fc_unit_factor and supplier_unit_factor
convertion_factor = fc_unit_factor / supplier_unit_factor
new_price = BigDecimal((convertion_factor * shared_article.price).to_s).round(2)

View file

@ -1,6 +1,4 @@
class Assignment < ActiveRecord::Base
# gettext-option
untranslate_all
belongs_to :user
belongs_to :task

View file

@ -15,7 +15,7 @@ class FinancialTransaction < ActiveRecord::Base
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def amount=(amount)
self[:amount] = FoodSoft::delocalizeDecimalString(amount)
self[:amount] = String.delocalized_decimal(amount)
end
end

View file

@ -10,8 +10,6 @@
# * updated_by (User): the user who last updated this order
#
class GroupOrder < ActiveRecord::Base
# gettext-option
untranslate_all
belongs_to :order
belongs_to :order_group

View file

@ -9,8 +9,6 @@
# * updated_on (timestamp): updated automatically by ActiveRecord
#
class GroupOrderArticle < ActiveRecord::Base
# gettext-option
untranslate_all
belongs_to :group_order
belongs_to :order_article

View file

@ -8,8 +8,6 @@
# * created_on (timestamp)
class GroupOrderArticleQuantity < ActiveRecord::Base
# gettext-option
untranslate_all
belongs_to :group_order_article

View file

@ -21,7 +21,7 @@ class GroupOrderArticleResult < ActiveRecord::Base
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def quantity=(quantity)
self[:quantity] = FoodSoft::delocalizeDecimalString(quantity)
self[:quantity] = String.delocalized_decimal(quantity)
end
end

View file

@ -6,8 +6,6 @@
# * group_order_article_results: collection of associated GroupOrderArticleResults
#
class GroupOrderResult < ActiveRecord::Base
# gettext-option
untranslate_all
belongs_to :order
has_many :group_order_article_results, :dependent => :destroy

View file

@ -5,37 +5,37 @@ class Mailer < ActionMailer::Base
# Assumes user.setResetPasswordToken has been successfully called already.
def password(user)
request = ApplicationController.current.request
subject "[#{FoodSoft::getFoodcoopName}] Neues Passwort für/ New password for " + user.nick
subject "[#{APP_CONFIG[:name]}] Neues Passwort für/ New password for " + user.nick
recipients user.email
from "FoodSoft <#{FoodSoft::getEmailSender}>"
from "FoodSoft <#{APP_CONFIG[:email_sender]}>"
body :user => user,
:link => url_for(:host => FoodSoft::getHost || request.host, :controller => "login", :action => "password", :id => user.id, :token => user.reset_password_token),
:foodsoftUrl => url_for(:host => FoodSoft::getHost || request.host, :controller => "index")
:link => url_for(:host => request.host, :controller => "login", :action => "password", :id => user.id, :token => user.reset_password_token),
:foodsoftUrl => url_for(:host => request.host, :controller => "index")
end
# Sends an email copy of the given internal foodsoft message.
def message(message)
request = ApplicationController.current.request
subject "[#{FoodSoft::getFoodcoopName}] " + message.subject
subject "[#{APP_CONFIG[:name]}] " + message.subject
recipients message.recipient.email
from (message.system_message? ? "FoodSoft <#{FoodSoft::getEmailSender}>" : "#{message.sender.nick} <#{message.sender.email}>")
from (message.system_message? ? "FoodSoft <#{APP_CONFIG[:email_sender]}>" : "#{message.sender.nick} <#{message.sender.email}>")
body :body => message.body, :sender => (message.system_message? ? 'Foodsoft' : message.sender.nick),
:recipients => message.recipients,
:reply => url_for(:host => FoodSoft::getHost || request.host, :controller => "messages", :action => "reply", :id => message),
:profile => url_for(:host => FoodSoft::getHost || request.host, :controller => "index", :action => "myProfile", :id => message.recipient),
:link => url_for(:host => FoodSoft::getHost || request.host, :controller => "messages", :action => "show", :id => message),
:foodsoftUrl => url_for(:host => FoodSoft::getHost || request.host, :controller => "index")
:reply => url_for(:host => request.host, :controller => "messages", :action => "reply", :id => message),
:profile => url_for(:host => request.host, :controller => "index", :action => "myProfile", :id => message.recipient),
:link => url_for(:host => request.host, :controller => "messages", :action => "show", :id => message),
:foodsoftUrl => url_for(:host => request.host, :controller => "index")
end
# Sends an invite email.
def invite(invite)
request = ApplicationController.current.request
subject "Einladung in die Foodcoop #{FoodSoft::getFoodcoopName} - Invitation to the Foodcoop"
subject "Einladung in die Foodcoop #{APP_CONFIG[:name]} - Invitation to the Foodcoop"
recipients invite.email
from "FoodSoft <#{FoodSoft::getEmailSender}>"
from "FoodSoft <#{APP_CONFIG[:email_sender]}>"
body :invite => invite,
:link => url_for(:host => FoodSoft::getHost || request.host, :controller => "login", :action => "invite", :id => invite.token),
:foodsoftUrl => url_for(:host => FoodSoft::getHost || request.host, :controller => "index")
:link => url_for(:host => request.host, :controller => "login", :action => "invite", :id => invite.token),
:foodsoftUrl => url_for(:host => request.host, :controller => "index")
end
end

View file

@ -1,8 +1,5 @@
class Membership < ActiveRecord::Base
# gettext-option
untranslate_all
belongs_to :user
belongs_to :group

View file

@ -14,8 +14,6 @@ class Message < ActiveRecord::Base
attr_accessible :recipient_id, :recipient, :subject, :body, :recipients
# needed for method 'from_template'
include GetText::Rails
# Values for the email_state attribute: :none, :pending, :sent, :failed
EMAIL_STATE = {

View file

@ -26,17 +26,17 @@ class Order < ActiveRecord::Base
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def invoice_amount=(amount)
self[:invoice_amount] = FoodSoft::delocalizeDecimalString(amount)
self[:invoice_amount] = String.delocalized_decimal(amount)
end
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def deposit=(deposit)
self[:deposit] = FoodSoft::delocalizeDecimalString(deposit)
self[:deposit] = String.delocalized_decimal(deposit)
end
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def deposit_credit=(deposit)
self[:deposit_credit] = FoodSoft::delocalizeDecimalString(deposit)
self[:deposit_credit] = String.delocalized_decimal(deposit)
end
# Create or destroy OrderArticle associations on create/update
@ -169,7 +169,7 @@ class Order < ActiveRecord::Base
:gross_price => oa.article.gross_price,
:tax => oa.article.tax,
:deposit => oa.article.deposit,
:fc_markup => FoodSoft::getPriceMarkup,
:fc_markup => APP_CONFIG[:price_markup],
:order_number => oa.article.order_number,
:unit_quantity => oa.article.unit_quantity,
:units_to_order => oa.units_to_order)

View file

@ -8,10 +8,7 @@
# * units_to_order (int): number of packaging units to be ordered according to the order quantity/tolerance
#
class OrderArticle < ActiveRecord::Base
# gettext-option
untranslate_all
belongs_to :order
belongs_to :article
has_many :group_order_articles, :dependent => :destroy

View file

@ -28,22 +28,22 @@ class OrderArticleResult < ActiveRecord::Base
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def net_price=(net_price)
self[:net_price] = FoodSoft::delocalizeDecimalString(net_price)
self[:net_price] = String.delocalized_decimal(net_price)
end
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def tax=(tax)
self[:tax] = FoodSoft::delocalizeDecimalString(tax)
self[:tax] = String.delocalized_decimal(tax)
end
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def deposit=(deposit)
self[:deposit] = FoodSoft::delocalizeDecimalString(deposit)
self[:deposit] = String.delocalized_decimal(deposit)
end
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def units_to_order=(units_to_order)
self[:units_to_order] = FoodSoft::delocalizeDecimalString(units_to_order)
self[:units_to_order] = String.delocalized_decimal(units_to_order)
end
# counts from every GroupOrderArticleResult for this ArticleResult

View file

@ -1,10 +1,7 @@
class SharedArticle < ActiveRecord::Base
# gettext-option
untranslate_all
# connect to database from sharedLists-Application
SharedArticle.establish_connection(FoodSoft::get_shared_lists_config)
SharedArticle.establish_connection(APP_CONFIG[:shared_lists])
# set correct table_name in external DB
set_table_name :articles

View file

@ -1,9 +1,7 @@
class SharedSupplier < ActiveRecord::Base
# used for gettext
untranslate_all
# connect to database from sharedLists-Application
SharedSupplier.establish_connection(FoodSoft::get_shared_lists_config)
SharedSupplier.establish_connection(APP_CONFIG[:shared_lists])
# set correct table_name in external DB
set_table_name :suppliers

View file

@ -12,6 +12,7 @@ require 'digest/sha1'
class User < ActiveRecord::Base
has_many :memberships, :dependent => :destroy
has_many :groups, :through => :memberships
has_many :order_groups, :through => :memberships, :source => :group
has_many :assignments, :dependent => :destroy
has_many :tasks, :through => :assignments
@ -119,8 +120,9 @@ class User < ActiveRecord::Base
end
# Returns the user's OrderGroup or nil if none found.
def find_ordergroup
groups.find(:first, :conditions => "type = 'OrderGroup'")
def find_ordergroup
order_groups.first
#groups.find(:first, :conditions => "type = 'OrderGroup'")
end
# Find all tasks, for which the current user should be responsible