Save and display creator of Order
This commit is contained in:
parent
69c4fc5817
commit
c17ff281c3
8 changed files with 25 additions and 4 deletions
|
@ -172,4 +172,4 @@ class OrdersController < ApplicationController
|
|||
end
|
||||
redirect_to order
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -154,5 +154,11 @@ module ApplicationHelper
|
|||
link_to h(address), "http://maps.google.de/?q=#{h(address)}", :title => "Show it on google maps",
|
||||
:target => "_blank"
|
||||
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
|
||||
|
|
|
@ -11,13 +11,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
|
||||
|
||||
# Finders
|
||||
|
|
|
@ -11,6 +11,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
|
||||
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
%p
|
||||
%b Lieferantin:
|
||||
=h @order.name
|
||||
%p
|
||||
%b Erstellt von:
|
||||
=h link_to_user_message_if_valid(@order.created_by)
|
||||
%p
|
||||
%b Ende:
|
||||
=h format_time(@order.ends)
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
%p
|
||||
Notiz:
|
||||
=h @order.note
|
||||
%p
|
||||
Erstellt von:
|
||||
=h link_to_user_message_if_valid(@order.created_by)
|
||||
%p
|
||||
Ende:
|
||||
%b=h format_time(@order.ends)
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
%p
|
||||
Notiz:
|
||||
=h @order.note
|
||||
%p
|
||||
Erstellt von:
|
||||
=h link_to_user_message_if_valid(@order.created_by)
|
||||
%p
|
||||
Beginn:
|
||||
%b=h format_time(@order.starts)
|
||||
|
@ -90,4 +93,4 @@
|
|||
%br/
|
||||
= submit_tag "Kommentar hinzufügen"
|
||||
|
||||
= link_to_top
|
||||
= link_to_top
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#
|
||||
# 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|
|
||||
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 "updated_by_user_id"
|
||||
t.decimal "foodcoop_result", :precision => 8, :scale => 2
|
||||
t.integer "created_by_user_id"
|
||||
end
|
||||
|
||||
add_index "orders", ["state"], :name => "index_orders_on_state"
|
||||
|
|
Loading…
Reference in a new issue