Merge branch 'master' into allow-no-nickname

Conflicts:
	app/views/home/ordergroup.html.haml
	app/views/login/new_password.html.haml
	app/views/shared/_auto_complete_users.rhtml
	app/views/shared/memberships/_current_members.rhtml
	app/views/shared/memberships/_non_members.rhtml
This commit is contained in:
wvengen 2013-11-18 11:42:49 +01:00
commit 66ac3be81f
63 changed files with 428 additions and 438 deletions

View file

@ -106,7 +106,7 @@ class Article < ActiveRecord::Base
# to get the correspondent shared article
def shared_article
@shared_article ||= self.supplier.shared_supplier.shared_articles.find_by_number(self.order_number)
@shared_article ||= self.supplier.shared_supplier.shared_articles.find_by_number(self.order_number) rescue nil
end
# convert units in foodcoop-size

View file

@ -90,7 +90,8 @@ class OrderArticle < ActiveRecord::Base
end
def ordered_quantities_equal_to_group_orders?
(units_to_order * price.unit_quantity) == group_orders_sum[:quantity]
# the rescue is a workaround for units_to_order not being defined in integration tests
(units_to_order * price.unit_quantity) == group_orders_sum[:quantity] rescue false
end
# Updates order_article and belongings during balancing process

View file

@ -1,56 +0,0 @@
class Page < ActiveRecord::Base
include ActsAsTree
belongs_to :user, :foreign_key => 'updated_by'
acts_as_versioned version_column: :lock_version, limit: 20
self.non_versioned_columns += %w(permalink created_at title)
acts_as_tree :order => "title"
attr_accessor :old_title # Save title to create redirect page when editing title
validates_presence_of :title, :body
validates_uniqueness_of :permalink, :title
before_validation :set_permalink, :on => :create
before_validation :update_permalink, :on => :update
after_update :create_redirect
scope :non_redirected, :conditions => {:redirect => nil}
scope :no_parent, :conditions => {:parent_id => nil}
def self.permalink(title)
title.gsub(/[\/\.,;@\s]/, "_").gsub(/[\"\']/, "")
end
def homepage?
permalink == "Home"
end
def set_permalink
unless title.blank?
self.permalink = Page.count == 0 ? "Home" : Page.permalink(title)
end
end
protected
def update_permalink
if changed.include?("title")
set_permalink
self.old_title = changes["title"].first # Save title for creating redirect
end
end
def create_redirect
unless old_title.blank?
Page.create :redirect => id,
:title => old_title,
:body => I18n.t('model.page.redirect', :title => title),
:permalink => Page.permalink(old_title),
:updated_by => updated_by
end
end
end

View file

@ -17,7 +17,6 @@ class User < ActiveRecord::Base
has_many :assignments, :dependent => :destroy
has_many :tasks, :through => :assignments
has_many :send_messages, :class_name => "Message", :foreign_key => "sender_id"
has_many :pages, :foreign_key => 'updated_by'
has_many :created_orders, :class_name => 'Order', :foreign_key => 'created_by_user_id', :dependent => :nullify
attr_accessor :password, :settings_attributes