2019-05-08 21:28:07 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-23 21:19:08 +08:00
|
|
|
class UserMyModule < ApplicationRecord
|
2018-11-20 21:29:33 +08:00
|
|
|
validates :user, presence: true, uniqueness: { scope: :my_module }
|
|
|
|
validates :my_module, presence: true
|
2016-02-12 23:52:43 +08:00
|
|
|
|
2019-05-08 21:28:07 +08:00
|
|
|
belongs_to :user, inverse_of: :user_my_modules, touch: true
|
|
|
|
belongs_to :assigned_by, foreign_key: 'assigned_by_id', class_name: 'User', optional: true
|
|
|
|
belongs_to :my_module, inverse_of: :user_my_modules, touch: true
|
2022-06-03 16:09:42 +08:00
|
|
|
|
|
|
|
def log_activity(type_of, current_user)
|
|
|
|
Activities::CreateActivityService
|
|
|
|
.call(activity_type: type_of,
|
|
|
|
owner: current_user,
|
|
|
|
team: my_module.experiment.project.team,
|
|
|
|
project: my_module.experiment.project,
|
|
|
|
subject: my_module,
|
|
|
|
message_items: { my_module: my_module.id,
|
|
|
|
user_target: user.id })
|
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|