Merge branch 'master' into master-to-rails3

Conflicts:
	Gemfile
	README_DEVEL
	app/controllers/articles_controller.rb
	app/controllers/orders_controller.rb
	app/controllers/tasks_controller.rb
	app/models/task.rb
	app/views/articles/_import_search_results.haml
	app/views/articles/index.haml
	app/views/messages/new.haml
	app/views/ordering/_order_head.haml
	app/views/ordering/my_order_result.haml
	app/views/orders/show.haml
	app/views/stockit/new.html.haml
	db/schema.rb
This commit is contained in:
benni 2012-12-14 18:10:46 +01:00
commit 0edd29dfd4
15 changed files with 44 additions and 22 deletions

View file

@ -12,13 +12,17 @@ class Order < ActiveRecord::Base
has_many :comments, :class_name => "OrderComment", :order => "created_at"
has_many :stock_changes
belongs_to :supplier
belongs_to :updated_by, :class_name => "User", :foreign_key => "updated_by_user_id"
belongs_to :updated_by, :class_name => 'User', :foreign_key => 'updated_by_user_id'
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by_user_id'
# Validations
validates_presence_of :starts
validate :starts_before_ends, :include_articles
# Callbacks
before_create do |order|
order.created_by = User.current_user
end
after_update :update_price_of_group_orders
after_save :save_order_articles

View file

@ -8,8 +8,5 @@ class SharedSupplier < ActiveRecord::Base
has_one :supplier
has_many :shared_articles, :foreign_key => :supplier_id
# save the lists as an array
serialize :lists
end

View file

@ -59,9 +59,10 @@ class Task < ActiveRecord::Base
# Get users from comma seperated ids
# and makes the users responsible for the task
# TODO: check for maximal number of users
def user_list=(ids)
list = ids.split(",")
new_users = list - users.collect(&:id)
new_users = (list - users.collect(&:id)).uniq
old_users = users.reject { |user| list.include?(user.id) }
logger.debug "[debug] New users: #{new_users}"

View file

@ -17,6 +17,7 @@ class User < ActiveRecord::Base
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, :setting_attributes
@ -79,10 +80,6 @@ class User < ActiveRecord::Base
def receive_email?
settings['messages.sendAsEmail'] == "1" && email.present?
end
def ordergroup_name
ordergroup.name if ordergroup
end
# Sets the user's password. It will be stored encrypted along with a random salt.
def set_password