2018-11-20 20:47:30 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
module Todos
|
|
|
|
module Destroy
|
|
|
|
class GroupPrivateService < ::Todos::Destroy::BaseService
|
|
|
|
extend ::Gitlab::Utils::Override
|
|
|
|
|
|
|
|
attr_reader :group
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-11-18 11:00:15 +05:30
|
|
|
def initialize(group_id)
|
|
|
|
@group = Group.find_by(id: group_id)
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
override :todos
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-11-18 11:00:15 +05:30
|
|
|
def todos
|
|
|
|
Todo.where(group_id: group.id)
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
override :authorized_users
|
|
|
|
def authorized_users
|
|
|
|
group.direct_and_indirect_users.select(:id)
|
|
|
|
end
|
|
|
|
|
|
|
|
override :todos_to_remove?
|
|
|
|
def todos_to_remove?
|
|
|
|
group&.private?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|