1 class Log < ArvadosModel
4 include CommonApiTemplate
5 serialize :properties, Hash
6 before_validation :set_default_event_at
7 before_save { self.owner_uuid = self.system_user_uuid }
10 api_accessible :user, extend: :common do |t|
13 t.add :object, :if => :object
20 def self.start_from(thing, event_type)
22 log.event_type = event_type
25 'old_attributes' => nil,
27 log.seed_basics_from thing
32 self.seed_basics_from thing
33 self.properties["new_etag"] = thing.andand.etag
34 self.properties["new_attributes"] = thing.andand.attributes
37 self.event_at = thing.created_at
39 self.event_at = thing.modified_at
41 self.event_at = Time.now
45 def seed_basics_from(thing)
47 self.object_kind ||= thing.kind
48 self.object_uuid ||= thing.uuid
49 self.summary ||= "#{self.event_type} of #{thing.uuid}"
55 def permission_to_create
59 def permission_to_update
60 current_user.andand.is_admin
63 alias_method :permission_to_delete, :permission_to_update
65 def set_default_event_at
66 self.event_at ||= Time.now