Fixed multi coop routing and changed config accessors.
This commit is contained in:
parent
2860a3ca44
commit
ec2e761e7f
28 changed files with 124 additions and 88 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,7 +5,6 @@ db/*.sqlite3
|
||||||
nbproject/
|
nbproject/
|
||||||
config/environments/development.rb
|
config/environments/development.rb
|
||||||
capfile
|
capfile
|
||||||
config/environments/fcschinke09.rb
|
|
||||||
*.swp
|
*.swp
|
||||||
public/**/*_cached.*
|
public/**/*_cached.*
|
||||||
.idea
|
.idea
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
TODO..
|
MULTI_COOP_INSTALL
|
||||||
|
------------------
|
||||||
|
|
||||||
|
TODO ...
|
|
@ -5,8 +5,6 @@ class ApplicationController < ActionController::Base
|
||||||
before_filter :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
|
||||||
|
|
||||||
helper_method :current_user
|
|
||||||
|
|
||||||
# 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]
|
||||||
|
@ -18,10 +16,11 @@ class ApplicationController < ActionController::Base
|
||||||
# check if there is a valid session and return the logged-in user (its object)
|
# check if there is a valid session and return the logged-in user (its object)
|
||||||
if session[:user_id] and params[:foodcoop]
|
if session[:user_id] and params[:foodcoop]
|
||||||
# for shared-host installations. check if the cookie-subdomain fits to request.
|
# for shared-host installations. check if the cookie-subdomain fits to request.
|
||||||
@current_user ||= User.find_by_id(session[:user_id]) if params[:foodcoop] == Foodsoft.env
|
@current_user ||= User.find_by_id(session[:user_id]) if session[:scope] == FoodsoftConfig.scope
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
helper_method :current_user
|
||||||
|
|
||||||
def deny_access
|
def deny_access
|
||||||
self.return_to = request.request_uri
|
self.return_to = request.request_uri
|
||||||
redirect_to login_url, :alert => 'Access denied!'
|
redirect_to login_url, :alert => 'Access denied!'
|
||||||
|
@ -104,28 +103,22 @@ class ApplicationController < ActionController::Base
|
||||||
# It uses the subdomain to select the appropriate section in the config files
|
# It uses the subdomain to select the appropriate section in the config files
|
||||||
# Use this method as a before filter (first filter!) in ApplicationController
|
# Use this method as a before filter (first filter!) in ApplicationController
|
||||||
def select_foodcoop
|
def select_foodcoop
|
||||||
if Foodsoft.config[:multi_coop_install]
|
if FoodsoftConfig[:multi_coop_install]
|
||||||
if !params[:foodcoop].blank?
|
if params[:foodcoop].present?
|
||||||
begin
|
begin
|
||||||
# Set Config
|
# Set Config and database connection
|
||||||
Foodsoft.env = params[:foodcoop]
|
FoodsoftConfig.select_foodcoop params[:foodcoop]
|
||||||
# Set database-connection
|
|
||||||
ActiveRecord::Base.establish_connection(Foodsoft.database)
|
|
||||||
rescue => error
|
rescue => error
|
||||||
flash[:error] = error.to_s
|
redirect_to root_url, alert: error.message
|
||||||
redirect_to root_path
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
redirect_to root_path
|
redirect_to root_url
|
||||||
end
|
end
|
||||||
else
|
|
||||||
# Deactivate routing filter
|
|
||||||
RoutingFilter::Foodcoop.active = false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def items_per_page
|
def items_per_page
|
||||||
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)
|
if params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100
|
||||||
@per_page = params[:per_page].to_i
|
@per_page = params[:per_page].to_i
|
||||||
else
|
else
|
||||||
@per_page = 20
|
@per_page = 20
|
||||||
|
@ -143,4 +136,9 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
default
|
default
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Always stay in foodcoop url scope
|
||||||
|
def default_url_options(options = {})
|
||||||
|
{foodcoop: FoodsoftConfig.scope}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -127,13 +127,13 @@ class OrdersController < ApplicationController
|
||||||
def text_fax_template
|
def text_fax_template
|
||||||
order = Order.find(params[:id])
|
order = Order.find(params[:id])
|
||||||
supplier = order.supplier
|
supplier = order.supplier
|
||||||
contact = Foodsoft.config[:contact].symbolize_keys
|
contact = FoodsoftConfig[:contact].symbolize_keys
|
||||||
text = "Bestellung für" + " #{Foodsoft.config[:name]}"
|
text = "Bestellung für" + " #{FoodsoftConfig[:name]}"
|
||||||
text += "\n" + "Kundennummer" + ": #{supplier.customer_number}" unless supplier.customer_number.blank?
|
text += "\n" + "Kundennummer" + ": #{supplier.customer_number}" unless supplier.customer_number.blank?
|
||||||
text += "\n" + "Liefertag" + ": "
|
text += "\n" + "Liefertag" + ": "
|
||||||
text += "\n\n#{supplier.name}\n#{supplier.address}\nFAX: #{supplier.fax}\n\n"
|
text += "\n\n#{supplier.name}\n#{supplier.address}\nFAX: #{supplier.fax}\n\n"
|
||||||
text += "****** " + "Versandadresse" + "\n\n"
|
text += "****** " + "Versandadresse" + "\n\n"
|
||||||
text += "#{Foodsoft.config[:name]}\n#{contact[:street]}\n#{contact[:zip_code]} #{contact[:city]}\n\n"
|
text += "#{FoodsoftConfig[:name]}\n#{contact[:street]}\n#{contact[:zip_code]} #{contact[:city]}\n\n"
|
||||||
text += "****** " + "Artikel" + "\n\n"
|
text += "****** " + "Artikel" + "\n\n"
|
||||||
text += "Nummer" + " " + "Menge" + " " + "Name" + "\n"
|
text += "Nummer" + " " + "Menge" + " " + "Name" + "\n"
|
||||||
# now display all ordered articles
|
# now display all ordered articles
|
||||||
|
|
|
@ -10,6 +10,7 @@ class SessionsController < ApplicationController
|
||||||
user = User.authenticate(params[:nick], params[:password])
|
user = User.authenticate(params[:nick], params[:password])
|
||||||
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
|
||||||
redirect_to session['return_to'] || root_url, :notice => "Logged in!"
|
redirect_to session['return_to'] || root_url, :notice => "Logged in!"
|
||||||
else
|
else
|
||||||
flash.now.alert = "Invalid email or password"
|
flash.now.alert = "Invalid email or password"
|
||||||
|
|
|
@ -4,15 +4,15 @@ class Mailer < ActionMailer::Base
|
||||||
|
|
||||||
layout 'email' # Use views/layouts/email.txt.erb
|
layout 'email' # Use views/layouts/email.txt.erb
|
||||||
|
|
||||||
default from: "FoodSoft <#{Foodsoft.config[:email_sender]}>",
|
default from: "FoodSoft <#{FoodsoftConfig[:email_sender]}>",
|
||||||
sender: Foodsoft.config[:email_sender],
|
sender: FoodsoftConfig[:email_sender],
|
||||||
errors_to: Foodsoft.config[:email_sender]
|
errors_to: FoodsoftConfig[:email_sender]
|
||||||
|
|
||||||
# Sends an email copy of the given internal foodsoft message.
|
# Sends an email copy of the given internal foodsoft message.
|
||||||
def foodsoft_message(message, recipient)
|
def foodsoft_message(message, recipient)
|
||||||
@message = message
|
@message = message
|
||||||
|
|
||||||
mail subject: "[#{Foodsoft.config[:name]}] " + message.subject,
|
mail subject: "[#{FoodsoftConfig[:name]}] " + message.subject,
|
||||||
to: recipient.email,
|
to: recipient.email,
|
||||||
from: "#{message.sender.nick} <#{message.sender.email}>"
|
from: "#{message.sender.nick} <#{message.sender.email}>"
|
||||||
end
|
end
|
||||||
|
@ -24,7 +24,7 @@ class Mailer < ActionMailer::Base
|
||||||
@link = url_for(:controller => "login", :action => "password", :id => user.id, :token => user.reset_password_token)
|
@link = url_for(:controller => "login", :action => "password", :id => user.id, :token => user.reset_password_token)
|
||||||
|
|
||||||
mail :to => user.email,
|
mail :to => user.email,
|
||||||
:subject => "[#{Foodsoft.config[:name]}] Neues Passwort für/ New password for #{user.nick}"
|
:subject => "[#{FoodsoftConfig[:name]}] Neues Passwort für/ New password for #{user.nick}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sends an invite email.
|
# Sends an invite email.
|
||||||
|
@ -33,7 +33,7 @@ class Mailer < ActionMailer::Base
|
||||||
@link = url_for(:controller => "login", :action => "invite", :id => invite.token)
|
@link = url_for(:controller => "login", :action => "invite", :id => invite.token)
|
||||||
|
|
||||||
mail :to => invite.email,
|
mail :to => invite.email,
|
||||||
:subject => "Einladung in die Foodcoop #{Foodsoft.config[:name]} - Invitation to the Foodcoop"
|
:subject => "Einladung in die Foodcoop #{FoodsoftConfig[:name]} - Invitation to the Foodcoop"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Notify user of upcoming task.
|
# Notify user of upcoming task.
|
||||||
|
@ -42,7 +42,7 @@ class Mailer < ActionMailer::Base
|
||||||
@task = task
|
@task = task
|
||||||
|
|
||||||
mail :to => user.email,
|
mail :to => user.email,
|
||||||
:subject => "[#{Foodsoft.config[:name]}] Aufgaben werden fällig!"
|
:subject => "[#{FoodsoftConfig[:name]}] Aufgaben werden fällig!"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sends order result for specific Ordergroup
|
# Sends order result for specific Ordergroup
|
||||||
|
@ -51,7 +51,7 @@ class Mailer < ActionMailer::Base
|
||||||
@group_order = group_order
|
@group_order = group_order
|
||||||
|
|
||||||
mail :to => user.email,
|
mail :to => user.email,
|
||||||
:subject => "[#{Foodsoft.config[:name]}] Bestellung beendet: #{group_order.order.name}"
|
:subject => "[#{FoodsoftConfig[:name]}] Bestellung beendet: #{group_order.order.name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Notify user if account balance is less than zero
|
# Notify user if account balance is less than zero
|
||||||
|
@ -60,17 +60,17 @@ class Mailer < ActionMailer::Base
|
||||||
@transaction = transaction
|
@transaction = transaction
|
||||||
|
|
||||||
mail :to => user.email,
|
mail :to => user.email,
|
||||||
:subject => "[#{Foodsoft.config[:name]}] Gruppenkonto im Minus"
|
:subject => "[#{FoodsoftConfig[:name]}] Gruppenkonto im Minus"
|
||||||
end
|
end
|
||||||
|
|
||||||
def feedback(user, feedback)
|
def feedback(user, feedback)
|
||||||
@user = user
|
@user = user
|
||||||
@feedback = feedback
|
@feedback = feedback
|
||||||
|
|
||||||
mail :to => Foodsoft.config[:notification]["error_recipients"],
|
mail :to => FoodsoftConfig[:notification]["error_recipients"],
|
||||||
:from => "#{user.nick} <#{user.email}>",
|
:from => "#{user.nick} <#{user.email}>",
|
||||||
:sender => Foodsoft.config[:notification]["sender_address"],
|
:sender => FoodsoftConfig[:notification]["sender_address"],
|
||||||
:errors_to => Foodsoft.config[:notification]["sender_address"],
|
:errors_to => FoodsoftConfig[:notification]["sender_address"],
|
||||||
:subject => "[Foodsoft] Feeback von #{user.email}"
|
:subject => "[Foodsoft] Feeback von #{user.email}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ class Mailer < ActionMailer::Base
|
||||||
@user = user
|
@user = user
|
||||||
|
|
||||||
mail :to => user.email,
|
mail :to => user.email,
|
||||||
:subject => "[#{Foodsoft.config[:name]}] \"#{task.name}\" braucht noch Leute!"
|
:subject => "[#{FoodsoftConfig[:name]}] \"#{task.name}\" braucht noch Leute!"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Article < ActiveRecord::Base
|
||||||
|
|
||||||
# The price for the foodcoop-member.
|
# The price for the foodcoop-member.
|
||||||
def fc_price
|
def fc_price
|
||||||
(gross_price * (Foodsoft.config[:price_markup] / 100 + 1)).round(2)
|
(gross_price * (FoodsoftConfig[:price_markup] / 100 + 1)).round(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if article has been updated at least 2 days ago
|
# Returns true if article has been updated at least 2 days ago
|
||||||
|
@ -120,8 +120,8 @@ class Article < ActiveRecord::Base
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
else # get factors for fc and supplier
|
else # get factors for fc and supplier
|
||||||
fc_unit_factor = Foodsoft.config[:units][self.unit]
|
fc_unit_factor = FoodsoftConfig[:units][self.unit]
|
||||||
supplier_unit_factor = Foodsoft.config[:units][self.shared_article.unit]
|
supplier_unit_factor = FoodsoftConfig[:units][self.shared_article.unit]
|
||||||
if fc_unit_factor and supplier_unit_factor
|
if fc_unit_factor and supplier_unit_factor
|
||||||
convertion_factor = fc_unit_factor / supplier_unit_factor
|
convertion_factor = fc_unit_factor / supplier_unit_factor
|
||||||
new_price = BigDecimal((convertion_factor * shared_article.price).to_s).round(2)
|
new_price = BigDecimal((convertion_factor * shared_article.price).to_s).round(2)
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ArticlePrice < ActiveRecord::Base
|
||||||
|
|
||||||
# The price for the foodcoop-member.
|
# The price for the foodcoop-member.
|
||||||
def fc_price
|
def fc_price
|
||||||
(gross_price * (Foodsoft.config[:price_markup] / 100 + 1)).round(2)
|
(gross_price * (FoodsoftConfig[:price_markup] / 100 + 1)).round(2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ class GroupOrderArticle < ActiveRecord::Base
|
||||||
# will be the value depending of the article results.
|
# will be the value depending of the article results.
|
||||||
def total_price
|
def total_price
|
||||||
unless order_article.order.finished?
|
unless order_article.order.finished?
|
||||||
if Foodsoft.config[:tolerance_is_costly]
|
if FoodsoftConfig[:tolerance_is_costly]
|
||||||
order_article.article.fc_price * (quantity + tolerance)
|
order_article.article.fc_price * (quantity + tolerance)
|
||||||
else
|
else
|
||||||
order_article.article.fc_price * quantity
|
order_article.article.fc_price * quantity
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class SharedArticle < ActiveRecord::Base
|
class SharedArticle < ActiveRecord::Base
|
||||||
|
|
||||||
# connect to database from sharedLists-Application
|
# connect to database from sharedLists-Application
|
||||||
SharedArticle.establish_connection(Foodsoft.config[:shared_lists])
|
SharedArticle.establish_connection(FoodsoftConfig[:shared_lists])
|
||||||
# set correct table_name in external DB
|
# set correct table_name in external DB
|
||||||
set_table_name :articles
|
set_table_name :articles
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class SharedSupplier < ActiveRecord::Base
|
class SharedSupplier < ActiveRecord::Base
|
||||||
|
|
||||||
# connect to database from sharedLists-Application
|
# connect to database from sharedLists-Application
|
||||||
SharedSupplier.establish_connection(Foodsoft.config[:shared_lists])
|
SharedSupplier.establish_connection(FoodsoftConfig[:shared_lists])
|
||||||
# set correct table_name in external DB
|
# set correct table_name in external DB
|
||||||
set_table_name :suppliers
|
set_table_name :suppliers
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#{data_to_js(@ordering_data)}
|
#{data_to_js(@ordering_data)}
|
||||||
setGroupBalance(#{@ordering_data[:available_funds]});
|
setGroupBalance(#{@ordering_data[:available_funds]});
|
||||||
setDecimalSeparator(",");
|
setDecimalSeparator(",");
|
||||||
setToleranceBehaviour(#{Foodsoft.config[:tolerance_is_costly]});
|
setToleranceBehaviour(#{FoodsoftConfig[:tolerance_is_costly]});
|
||||||
setStockit(#{@order.stockit?});
|
setStockit(#{@order.stockit?});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
%b= h category
|
%b= h category
|
||||||
%td{:colspan => "9"}
|
%td{:colspan => "9"}
|
||||||
- order_articles.each do |order_article|
|
- order_articles.each do |order_article|
|
||||||
- if Foodsoft.config[:tolerance_is_costly]
|
- if FoodsoftConfig[:tolerance_is_costly]
|
||||||
- article_total = @price[i] * (@tolerance[i] + @quantity[i])
|
- article_total = @price[i] * (@tolerance[i] + @quantity[i])
|
||||||
- else
|
- else
|
||||||
- article_total = @price[i] * @quantity[i]
|
- article_total = @price[i] * @quantity[i]
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#logo
|
#logo
|
||||||
= link_to root_path do
|
= link_to root_path do
|
||||||
<span>food</span>soft
|
<span>food</span>soft
|
||||||
%span{:style => "color:white; font-size:45%; letter-spacing: -1px;"}= Foodsoft.config[:name]
|
%span{:style => "color:white; font-size:45%; letter-spacing: -1px;"}= FoodsoftConfig[:name]
|
||||||
#nav= render :partial => 'layouts/main_tabnav'
|
#nav= render :partial => 'layouts/main_tabnav'
|
||||||
|
|
||||||
#main
|
#main
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
--
|
--
|
||||||
FoodSoft: <%= root_url %>
|
FoodSoft: <%= root_url %>
|
||||||
Foodcoop-Homepage: <%= Foodsoft.config[:homepage] %>
|
Foodcoop-Homepage: <%= FoodsoftConfig[:homepage] %>
|
||||||
Hilfe/Help: <%= Foodsoft.config[:help_url] %>
|
Hilfe/Help: <%= FoodsoftConfig[:help_url] %>
|
||||||
|
|
|
@ -15,4 +15,4 @@
|
||||||
= yield
|
= yield
|
||||||
#meta
|
#meta
|
||||||
Foodcoop
|
Foodcoop
|
||||||
= link_to_if Foodsoft.config[:homepage], Foodsoft.config[:name], Foodsoft.config[:homepage]
|
= link_to_if FoodsoftConfig[:homepage], FoodsoftConfig[:name], FoodsoftConfig[:homepage]
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
- title "Einladung in die #{Foodsoft.config[:name]}"
|
- title "Einladung in die #{FoodsoftConfig[:name]}"
|
||||||
%p
|
%p
|
||||||
Du bist eingeladen worden als Mitglied der Gruppe
|
Du bist eingeladen worden als Mitglied der Gruppe
|
||||||
%b= @invite.group.name
|
%b= @invite.group.name
|
||||||
in der Foodcoop
|
in der Foodcoop
|
||||||
= Foodsoft.config[:name]
|
= FoodsoftConfig[:name]
|
||||||
mitzumachen.
|
mitzumachen.
|
||||||
%p
|
%p
|
||||||
Wenn Du mitmachen möchtest, dann fülle bitte dieses Formular aus.
|
Wenn Du mitmachen möchtest, dann fülle bitte dieses Formular aus.
|
||||||
|
|
|
@ -6,4 +6,4 @@ Es wurden <%= @transaction.amount %> für "<%= @transaction.note %>" abgebucht,
|
||||||
|
|
||||||
Bitte zahlt so bald wie möglich wieder Geld ein, um das Gruppenkonto auszugleichen.
|
Bitte zahlt so bald wie möglich wieder Geld ein, um das Gruppenkonto auszugleichen.
|
||||||
|
|
||||||
Viele Grüße von <%= Foodsoft.config[:name] %>
|
Viele Grüße von <%= FoodsoftConfig[:name] %>
|
|
@ -11,4 +11,4 @@ Gesamtpreis: <%= @group_order.price %>
|
||||||
|
|
||||||
Bestellung online einsehen: <%= group_order_url(@group_order) %>
|
Bestellung online einsehen: <%= group_order_url(@group_order) %>
|
||||||
|
|
||||||
Viele Grüße von <%= Foodsoft.config[:name] %>
|
Viele Grüße von <%= FoodsoftConfig[:name] %>
|
|
@ -12,4 +12,4 @@ Aufgaben für die nächste Woche:
|
||||||
|
|
||||||
Meine Aufgaben: <%= user_tasks_url %>
|
Meine Aufgaben: <%= user_tasks_url %>
|
||||||
|
|
||||||
Viele Grüße von <%= Foodsoft.config[:name] %>
|
Viele Grüße von <%= FoodsoftConfig[:name] %>
|
|
@ -21,18 +21,18 @@
|
||||||
- title "Neue Nachricht"
|
- title "Neue Nachricht"
|
||||||
|
|
||||||
= simple_form_for @message do |f|
|
= simple_form_for @message do |f|
|
||||||
- if Foodsoft.config[:mailing_list].blank?
|
- if FoodsoftConfig[:mailing_list].blank?
|
||||||
= f.input :sent_to_all, :as => :boolean
|
= f.input :sent_to_all, :as => :boolean
|
||||||
- else
|
- else
|
||||||
%b Nachrichten an alle
|
%b Nachrichten an alle
|
||||||
verschickst Du bitte über den Verteiler:
|
verschickst Du bitte über den Verteiler:
|
||||||
= mail_to Foodsoft.config[:mailing_list]
|
= mail_to FoodsoftConfig[:mailing_list]
|
||||||
%br/
|
%br/
|
||||||
%small{:style => "color:grey"}
|
%small{:style => "color:grey"}
|
||||||
Eventuell musst Du Dich dem Verteiler erst bekannt machen.
|
Eventuell musst Du Dich dem Verteiler erst bekannt machen.
|
||||||
%br/
|
%br/
|
||||||
z.b. mit einer Mail an
|
z.b. mit einer Mail an
|
||||||
= mail_to Foodsoft.config[:mailing_list_subscribe]
|
= mail_to FoodsoftConfig[:mailing_list_subscribe]
|
||||||
|
|
||||||
#recipients
|
#recipients
|
||||||
= f.input :recipient_tokens, :input_html => { 'data-pre' => User.find_all_by_id(@message.recipients_ids).map { |u| u.token_attributes }.to_json }
|
= f.input :recipient_tokens, :input_html => { 'data-pre' => User.find_all_by_id(@message.recipients_ids).map { |u| u.token_attributes }.to_json }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Get ActiveRecord objects
|
# Get ActiveRecord objects
|
||||||
contact = Foodsoft.config[:contact].symbolize_keys
|
contact = FoodsoftConfig[:contact].symbolize_keys
|
||||||
|
|
||||||
# Define header and footer
|
# Define header and footer
|
||||||
#pdf.header [pdf.margin_box.left,pdf.margin_box.top+30] do
|
#pdf.header [pdf.margin_box.left,pdf.margin_box.top+30] do
|
||||||
|
@ -12,7 +12,7 @@ end
|
||||||
|
|
||||||
# From paragraph
|
# From paragraph
|
||||||
pdf.bounding_box [pdf.margin_box.right-200,pdf.margin_box.top], :width => 200 do
|
pdf.bounding_box [pdf.margin_box.right-200,pdf.margin_box.top], :width => 200 do
|
||||||
pdf.text Foodsoft.config[:name], :align => :right
|
pdf.text FoodsoftConfig[:name], :align => :right
|
||||||
pdf.move_down 5
|
pdf.move_down 5
|
||||||
pdf.text contact[:street], :align => :right
|
pdf.text contact[:street], :align => :right
|
||||||
pdf.move_down 5
|
pdf.move_down 5
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
%li
|
%li
|
||||||
= image_tag 'b_user.png' , :size => '7x10', :border => 0, :alt => "Profil"
|
= image_tag 'b_user.png' , :size => '7x10', :border => 0, :alt => "Profil"
|
||||||
= link_to h(@current_user.nick), my_profile_path, { :title => "Profil bearbeiten" }
|
= link_to h(@current_user.nick), my_profile_path, { :title => "Profil bearbeiten" }
|
||||||
- if Foodsoft.config[:homepage]
|
- if FoodsoftConfig[:homepage]
|
||||||
%li= link_to Foodsoft.config[:name], Foodsoft.config[:homepage], { :title => "Go to your FoodCoop-Hompage" }
|
%li= link_to FoodsoftConfig[:name], FoodsoftConfig[:homepage], { :title => "Go to your FoodCoop-Hompage" }
|
||||||
%li= link_to "Hilfe", 'http://dev.foodcoops.net/wiki/FoodsoftDoku'
|
%li= link_to "Hilfe", 'http://dev.foodcoops.net/wiki/FoodsoftDoku'
|
||||||
%li= link_to "Feedback", new_feedback_path, :title => "Fehler gefunden? Vorschlag? Idee? Kritik?"
|
%li= link_to "Feedback", new_feedback_path, :title => "Fehler gefunden? Vorschlag? Idee? Kritik?"
|
||||||
%li= link_to "Abmelden", logout_path
|
%li= link_to "Abmelden", logout_path
|
|
@ -1,10 +1,13 @@
|
||||||
# Foodsoft configuration
|
# Foodsoft configuration
|
||||||
|
|
||||||
development: &defaults
|
default: &defaults
|
||||||
# If you wanna serve more than one foodcoop with one installation
|
# If you wanna serve more than one foodcoop with one installation
|
||||||
# Don't forget to setup databases for each foodcoop. See also MULTI_COOP_INSTALL
|
# Don't forget to setup databases for each foodcoop. See also MULTI_COOP_INSTALL
|
||||||
multi_coop_install: false
|
multi_coop_install: false
|
||||||
|
|
||||||
|
# If multi_coop_install you have to use a coop name, which you you wanna be selected by default
|
||||||
|
default_scope: 'f'
|
||||||
|
|
||||||
# http config for this host
|
# http config for this host
|
||||||
# Required for action mailer
|
# Required for action mailer
|
||||||
protocol: http
|
protocol: http
|
||||||
|
@ -75,6 +78,9 @@ development: &defaults
|
||||||
100g: 0.1
|
100g: 0.1
|
||||||
50g: 0.05
|
50g: 0.05
|
||||||
|
|
||||||
|
development:
|
||||||
|
<<: *defaults
|
||||||
|
|
||||||
test:
|
test:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,15 @@
|
||||||
# Loads and returns config and databases for selected foodcoop.
|
|
||||||
# TODO: When to use class or module. It seems this could also be a Foodsoft-class?
|
|
||||||
module Foodsoft
|
|
||||||
mattr_accessor :env, :config, :database
|
|
||||||
CONFIGS = YAML.load(File.read(File.join(Rails.root, "/config/app_config.yml")))
|
|
||||||
DATABASES = YAML.load(File.read(File.join(Rails.root, "/config/database.yml")))
|
|
||||||
|
|
||||||
class << self
|
|
||||||
def env=(env)
|
|
||||||
raise "No config or database for this environment (#{env}) available!" if CONFIGS[env].nil? or DATABASES[env].nil?
|
|
||||||
@@config = CONFIGS[env].symbolize_keys
|
|
||||||
@@database = DATABASES[env].symbolize_keys
|
|
||||||
@@env = env
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
# Initial load the default config and database from rails environment
|
# Initial load the default config and database from rails environment
|
||||||
Foodsoft.env = Rails.env
|
# See config/app_config.yml for further details
|
||||||
|
# Load Config, start by selecting defaults via current environment
|
||||||
|
require 'foodsoft_config'
|
||||||
|
FoodsoftConfig.init
|
||||||
|
|
||||||
# Set action mailer default host for url generating
|
# Set action mailer default host for url generating
|
||||||
url_options = {
|
url_options = {
|
||||||
:host => Foodsoft.config[:host],
|
:host => FoodsoftConfig[:host],
|
||||||
:protocol => Foodsoft.config[:protocol]
|
:protocol => FoodsoftConfig[:protocol]
|
||||||
}
|
}
|
||||||
url_options.merge!({:port => Foodsoft.config[:port]}) if Foodsoft.config[:port]
|
url_options.merge!({:port => FoodsoftConfig[:port]}) if FoodsoftConfig[:port]
|
||||||
|
|
||||||
Foodsoft::Application.configure do
|
Foodsoft::Application.configure do
|
||||||
config.action_mailer.default_url_options = url_options
|
config.action_mailer.default_url_options = url_options
|
||||||
|
@ -31,9 +18,9 @@ Foodsoft::Application.configure do
|
||||||
# Configuration of the exception_notification plugin
|
# Configuration of the exception_notification plugin
|
||||||
# Mailadresses are set in config/app_config.yml
|
# Mailadresses are set in config/app_config.yml
|
||||||
config.middleware.use ExceptionNotifier,
|
config.middleware.use ExceptionNotifier,
|
||||||
:email_prefix => Foodsoft.config[:notification]['email_prefix'],
|
:email_prefix => FoodsoftConfig[:notification]['email_prefix'],
|
||||||
:sender_address => Foodsoft.config[:notification]['sender_address'],
|
:sender_address => FoodsoftConfig[:notification]['sender_address'],
|
||||||
:exception_recipients => Foodsoft.config[:notification]['error_recipients']
|
:exception_recipients => FoodsoftConfig[:notification]['error_recipients']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ Foodsoft::Application.routes.draw do
|
||||||
|
|
||||||
get "sessions/new"
|
get "sessions/new"
|
||||||
|
|
||||||
root :to => redirect("/#{Foodsoft.env}")
|
root :to => redirect("/#{FoodsoftConfig.scope}")
|
||||||
|
|
||||||
scope '/:foodcoop', :defaults => { :foodcoop => Foodsoft.env } do
|
scope '/:foodcoop' do
|
||||||
|
|
||||||
# Root path
|
# Root path
|
||||||
root :to => 'home#index'
|
root :to => 'home#index'
|
||||||
|
|
42
lib/foodsoft_config.rb
Normal file
42
lib/foodsoft_config.rb
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
class FoodsoftConfig
|
||||||
|
mattr_accessor :scope, :config
|
||||||
|
APP_CONFIG = YAML.load(File.read(File.join(Rails.root, "/config/app_config.yml")))
|
||||||
|
|
||||||
|
class << self
|
||||||
|
|
||||||
|
def init
|
||||||
|
# Load initial config from development or production
|
||||||
|
set_config Rails.env
|
||||||
|
# Overwrite scope to have a better namescope than 'production'
|
||||||
|
self.scope = config[:default_scope] or raise "No default_scope is set"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Set config and database connection for specific foodcoop
|
||||||
|
# Only needed in multi coop mode
|
||||||
|
def select_foodcoop(foodcoop)
|
||||||
|
set_config foodcoop
|
||||||
|
setup_database
|
||||||
|
end
|
||||||
|
|
||||||
|
# Provides a nice accessor for config values
|
||||||
|
# FoodsoftConfig[:name] # => 'FC Test'
|
||||||
|
def [](key)
|
||||||
|
config[key]
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_config(foodcoop)
|
||||||
|
raise "No config for this environment (#{foodcoop}) available!" if APP_CONFIG[foodcoop].nil?
|
||||||
|
self.config = APP_CONFIG[foodcoop].symbolize_keys
|
||||||
|
self.scope = foodcoop
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup_database
|
||||||
|
database_config = ActiveRecord::Base.configurations[Rails.env]
|
||||||
|
database_config.merge!(config[:database]) if config[:database].present?
|
||||||
|
ActiveRecord::Base.establish_connection(database_config)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,8 +3,8 @@ class Wikilink < WikiCloth::WikiLinkHandler
|
||||||
|
|
||||||
def link_attributes_for(page)
|
def link_attributes_for(page)
|
||||||
permalink = Page.permalink(page)
|
permalink = Page.permalink(page)
|
||||||
url_options = {:host => Foodsoft.config[:host], :protocol => Foodsoft.config[:protocol]}
|
url_options = {:host => FoodsoftConfig[:host], :protocol => FoodsoftConfig[:protocol]}
|
||||||
url_options.merge!({:port => Foodsoft.config[:port]}) if Foodsoft.config[:port]
|
url_options.merge!({:port => FoodsoftConfig[:port]}) if FoodsoftConfig[:port]
|
||||||
|
|
||||||
if Page.exists?(:permalink => permalink)
|
if Page.exists?(:permalink => permalink)
|
||||||
{ :href => url_for(url_options.merge({:controller => "pages", :action => "show",
|
{ :href => url_for(url_options.merge({:controller => "pages", :action => "show",
|
||||||
|
|
Loading…
Reference in a new issue