2013-03-26 18:11:38 +02:00
|
|
|
class UsersProjectObserver < BaseObserver
|
2012-09-03 20:48:38 +03:00
|
|
|
def after_commit(users_project)
|
2012-09-07 10:23:45 +03:00
|
|
|
return if users_project.destroyed?
|
2012-08-27 00:32:03 +03:00
|
|
|
end
|
2012-09-09 23:18:28 +03:00
|
|
|
|
2012-09-10 09:19:15 +03:00
|
|
|
def after_create(users_project)
|
2012-09-09 23:18:28 +03:00
|
|
|
Event.create(
|
|
|
|
project_id: users_project.project.id,
|
2013-02-13 15:48:16 +04:00
|
|
|
action: Event::JOINED,
|
2012-09-09 23:18:28 +03:00
|
|
|
author_id: users_project.user.id
|
|
|
|
)
|
2013-03-26 18:11:38 +02:00
|
|
|
|
|
|
|
notification.new_team_member(users_project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def after_update(users_project)
|
|
|
|
notification.update_team_member(users_project)
|
2012-08-27 00:13:03 +03:00
|
|
|
end
|
2012-08-27 00:32:03 +03:00
|
|
|
|
2012-09-10 00:27:47 +03:00
|
|
|
def after_destroy(users_project)
|
|
|
|
Event.create(
|
2012-09-15 01:00:59 +03:00
|
|
|
project_id: users_project.project.id,
|
2013-02-13 15:48:16 +04:00
|
|
|
action: Event::LEFT,
|
2012-09-10 00:27:47 +03:00
|
|
|
author_id: users_project.user.id
|
|
|
|
)
|
|
|
|
end
|
2012-08-27 00:13:03 +03:00
|
|
|
end
|