2018-08-11 03:00:39 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-08-02 10:16:58 -04:00
|
|
|
module Todos
|
|
|
|
module Destroy
|
|
|
|
class GroupPrivateService < ::Todos::Destroy::BaseService
|
|
|
|
extend ::Gitlab::Utils::Override
|
|
|
|
|
|
|
|
attr_reader :group
|
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-08-02 10:16:58 -04:00
|
|
|
def initialize(group_id)
|
|
|
|
@group = Group.find_by(id: group_id)
|
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-08-02 10:16:58 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
override :todos
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-08-02 10:16:58 -04:00
|
|
|
def todos
|
|
|
|
Todo.where(group_id: group.id)
|
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-08-02 10:16:58 -04:00
|
|
|
|
|
|
|
override :authorized_users
|
|
|
|
def authorized_users
|
2018-08-06 04:42:51 -04:00
|
|
|
group.direct_and_indirect_users.select(:id)
|
2018-08-02 10:16:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
override :todos_to_remove?
|
|
|
|
def todos_to_remove?
|
|
|
|
group&.private?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|