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_owner_uuid
20 if k = ArvadosModel::resource_class_for_uuid(object_uuid)
25 def fill_object(thing)
26 self.object_uuid ||= thing.uuid
27 if respond_to? :object_owner_uuid=
28 # Skip this if the object_owner_uuid migration hasn't happened
29 # yet, i.e., we're in the process of migrating an old database.
30 self.object_owner_uuid = thing.owner_uuid
32 self.summary ||= "#{self.event_type} of #{thing.uuid}"
36 def fill_properties(age, etag_prop, attrs_prop)
37 self.properties.merge!({"#{age}_etag" => etag_prop,
38 "#{age}_attributes" => attrs_prop})
42 fill_properties('new', thing.andand.etag, thing.andand.logged_attributes)
45 self.event_at = thing.created_at
47 self.event_at = thing.modified_at
49 self.event_at = Time.now
56 def permission_to_create
60 def permission_to_update
61 current_user.andand.is_admin
64 alias_method :permission_to_delete, :permission_to_update
66 def set_default_event_at
67 self.event_at ||= Time.now
71 # don't log start state on logs
74 def log_change(event_type)
75 # Don't log changes to logs.
78 def ensure_valid_uuids
79 # logs can have references to deleted objects