1 class Log < ArvadosModel
4 include CommonApiTemplate
5 serialize :properties, Hash
6 before_validation :set_default_event_at
7 attr_accessor :object, :object_kind
9 api_accessible :user, extend: :common do |t|
11 t.add :object, :if => :object
20 if k = ArvadosModel::resource_class_for_uuid(object_uuid)
25 def fill_object(thing)
26 self.object_uuid ||= thing.uuid
27 self.summary ||= "#{self.event_type} of #{thing.uuid}"
31 def fill_properties(age, etag_prop, attrs_prop)
32 self.properties.merge!({"#{age}_etag" => etag_prop,
33 "#{age}_attributes" => attrs_prop})
37 fill_properties('new', thing.andand.etag, thing.andand.logged_attributes)
40 self.event_at = thing.created_at
42 self.event_at = thing.modified_at
44 self.event_at = Time.now
51 def permission_to_create
55 def permission_to_update
56 current_user.andand.is_admin
59 alias_method :permission_to_delete, :permission_to_update
61 def set_default_event_at
62 self.event_at ||= Time.now
65 def log_change(event_type)
66 # Don't log changes to logs.
69 def ensure_valid_uuids
70 # logs can have references to deleted objects