4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/events/cms9_events.rb', line 4
def create_event(event_type, event_id, action, user, del_name)
post_definition_id = nil
post_id = nil
user_info = [ user.id, user.email ? user.email : nil ]
case event_type
when 'post_definition'
post_definition_id = event_id
when 'post'
post_id = event_id
end
@event = Event.new({
'user': user_info,
'action': action,
'post_definition_id': post_definition_id,
'post_id': post_id,
'deleted_field': del_name
})
if @event.save
if del_name != nil
if event_type == 'post_definition'
Event.where(post_definition_id: post_definition_id).update_all(deleted_field: del_name)
elsif event_type == 'post'
Event.where(post_id: post_id).each do |event|
event.update(deleted_field: del_name)
end
end
end
end
end
|