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|
12 t.add :object_owner_uuid
21 if k = ArvadosModel::resource_class_for_uuid(object_uuid)
26 def fill_object(thing)
27 self.object_uuid ||= thing.uuid
28 if respond_to? :object_owner_uuid=
29 # Skip this if the object_owner_uuid migration hasn't happened
30 # yet, i.e., we're in the process of migrating an old database.
31 self.object_owner_uuid = thing.owner_uuid
33 self.summary ||= "#{self.event_type} of #{thing.uuid}"
37 def fill_properties(age, etag_prop, attrs_prop)
38 self.properties.merge!({"#{age}_etag" => etag_prop,
39 "#{age}_attributes" => attrs_prop})
43 fill_properties('new', thing.andand.etag, thing.andand.logged_attributes)
46 self.event_at = thing.created_at
48 self.event_at = thing.modified_at
50 self.event_at = Time.now
57 def permission_to_create
61 def permission_to_update
62 current_user.andand.is_admin
65 alias_method :permission_to_delete, :permission_to_update
67 def set_default_event_at
68 self.event_at ||= Time.now
72 # don't log start state on logs
75 def log_change(event_type)
76 # Don't log changes to logs.
79 def ensure_valid_uuids
80 # logs can have references to deleted objects