Save and display creator of Order
This commit is contained in:
parent
69c4fc5817
commit
c17ff281c3
8 changed files with 25 additions and 4 deletions
|
@ -155,4 +155,10 @@ module ApplicationHelper
|
||||||
:target => "_blank"
|
:target => "_blank"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# offers a link for writing message to user
|
||||||
|
# checks for nil (useful for relations)
|
||||||
|
def link_to_user_message_if_valid(user)
|
||||||
|
user.nil? ? '??' : ( link_to user.nick, user_message_path(user), :title => _('Nachricht schreiben') )
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,13 +11,17 @@ class Order < ActiveRecord::Base
|
||||||
has_many :comments, :class_name => "OrderComment", :order => "created_at"
|
has_many :comments, :class_name => "OrderComment", :order => "created_at"
|
||||||
has_many :stock_changes
|
has_many :stock_changes
|
||||||
belongs_to :supplier
|
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
|
# Validations
|
||||||
validates_presence_of :starts
|
validates_presence_of :starts
|
||||||
validate :starts_before_ends, :include_articles
|
validate :starts_before_ends, :include_articles
|
||||||
|
|
||||||
# Callbacks
|
# Callbacks
|
||||||
|
before_create do |order|
|
||||||
|
order.created_by = User.current_user
|
||||||
|
end
|
||||||
after_update :update_price_of_group_orders
|
after_update :update_price_of_group_orders
|
||||||
|
|
||||||
# Finders
|
# Finders
|
||||||
|
|
|
@ -11,6 +11,7 @@ class User < ActiveRecord::Base
|
||||||
has_many :tasks, :through => :assignments
|
has_many :tasks, :through => :assignments
|
||||||
has_many :send_messages, :class_name => "Message", :foreign_key => "sender_id"
|
has_many :send_messages, :class_name => "Message", :foreign_key => "sender_id"
|
||||||
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
|
||||||
|
|
||||||
attr_accessor :password, :setting_attributes
|
attr_accessor :password, :setting_attributes
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
%p
|
%p
|
||||||
%b Lieferantin:
|
%b Lieferantin:
|
||||||
=h @order.name
|
=h @order.name
|
||||||
|
%p
|
||||||
|
%b Erstellt von:
|
||||||
|
=h link_to_user_message_if_valid(@order.created_by)
|
||||||
%p
|
%p
|
||||||
%b Ende:
|
%b Ende:
|
||||||
=h format_time(@order.ends)
|
=h format_time(@order.ends)
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
%p
|
%p
|
||||||
Notiz:
|
Notiz:
|
||||||
=h @order.note
|
=h @order.note
|
||||||
|
%p
|
||||||
|
Erstellt von:
|
||||||
|
=h link_to_user_message_if_valid(@order.created_by)
|
||||||
%p
|
%p
|
||||||
Ende:
|
Ende:
|
||||||
%b=h format_time(@order.ends)
|
%b=h format_time(@order.ends)
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
%p
|
%p
|
||||||
Notiz:
|
Notiz:
|
||||||
=h @order.note
|
=h @order.note
|
||||||
|
%p
|
||||||
|
Erstellt von:
|
||||||
|
=h link_to_user_message_if_valid(@order.created_by)
|
||||||
%p
|
%p
|
||||||
Beginn:
|
Beginn:
|
||||||
%b=h format_time(@order.starts)
|
%b=h format_time(@order.starts)
|
||||||
|
|
|
@ -9,7 +9,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 => 20120622094337) do
|
ActiveRecord::Schema.define(:version => 20121112093327) 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
|
||||||
|
@ -234,6 +234,7 @@ ActiveRecord::Schema.define(:version => 20120622094337) do
|
||||||
t.integer "lock_version", :default => 0, :null => false
|
t.integer "lock_version", :default => 0, :null => false
|
||||||
t.integer "updated_by_user_id"
|
t.integer "updated_by_user_id"
|
||||||
t.decimal "foodcoop_result", :precision => 8, :scale => 2
|
t.decimal "foodcoop_result", :precision => 8, :scale => 2
|
||||||
|
t.integer "created_by_user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "orders", ["state"], :name => "index_orders_on_state"
|
add_index "orders", ["state"], :name => "index_orders_on_state"
|
||||||
|
|
Loading…
Reference in a new issue