Commit 6cc4a32c authored by Sarah Yasonik's avatar Sarah Yasonik Committed by Alex Pooley

Swap OncallRotations::BaseService to use ::BaseProjectService

Per developer style guides, we prefer to use a BaseContainerService
class as the base class for any services.
parent fc53b78d
......@@ -2,9 +2,9 @@
module IncidentManagement
module OncallRotations
class BaseService
class BaseService < ::BaseProjectService
def allowed?
user&.can?(:admin_incident_management_oncall_schedule, project)
current_user&.can?(:admin_incident_management_oncall_schedule, project)
end
def available?
......
......@@ -8,22 +8,22 @@ module IncidentManagement
# @param schedule [IncidentManagement::OncallSchedule]
# @param project [Project]
# @param user [User]
# @param params [Hash<Symbol,Any>]
# @param params - name [String] The name of the on-call rotation.
# @param params - length [Integer] The length of the rotation.
# @param params - length_unit [String] The unit of the rotation length. (One of 'hours', days', 'weeks')
# @param params - starts_at [DateTime] The datetime the rotation starts on.
# @param params - ends_at [DateTime] The datetime the rotation ends on.
# @param params - active_period_start [String] The time the on-call shifts should start, for example: "08:00"
# @param params - active_period_end [String] The time the on-call shifts should end, for example: "17:00"
# @param params - participants [Array<hash>] An array of hashes defining participants of the on-call rotations.
# @param create_params [Hash<Symbol,Any>]
# @param create_params - name [String] The name of the on-call rotation.
# @param create_params - length [Integer] The length of the rotation.
# @param create_params - length_unit [String] The unit of the rotation length. (One of 'hours', days', 'weeks')
# @param create_params - starts_at [DateTime] The datetime the rotation starts on.
# @param create_params - ends_at [DateTime] The datetime the rotation ends on.
# @param create_params - active_period_start [String] The time the on-call shifts should start, for example: "08:00"
# @param create_params - active_period_end [String] The time the on-call shifts should end, for example: "17:00"
# @param create_params - participants [Array<hash>] An array of hashes defining participants of the on-call rotations.
# @option opts - participant [User] The user who is part of the rotation
# @option opts - color_palette [String] The color palette to assign to the on-call user, for example: "blue".
# @option opts - color_weight [String] The color weight to assign to for the on-call user, for example "500". Max 4 chars.
def initialize(schedule, project, user, params)
def initialize(schedule, project, user, create_params)
super(project: project, current_user: user, params: create_params)
@schedule = schedule
@project = project
@user = user
@rotation_params = params.except(:participants)
@participants_params = Array(params[:participants])
end
......@@ -50,7 +50,7 @@ module IncidentManagement
private
attr_reader :schedule, :project, :user, :rotation_params, :participants_params, :oncall_rotation
attr_reader :schedule, :rotation_params, :participants_params, :oncall_rotation
def error_no_permissions
error('You have insufficient permissions to create an on-call rotation for this project')
......
......@@ -6,9 +6,9 @@ module IncidentManagement
# @param oncall_schedule [IncidentManagement::OncallRotation]
# @param user [User]
def initialize(oncall_rotation, user)
super(project: oncall_rotation.project, current_user: user)
@oncall_rotation = oncall_rotation
@user = user
@project = oncall_rotation.project
end
def execute
......@@ -24,7 +24,7 @@ module IncidentManagement
private
attr_reader :oncall_rotation, :user, :project
attr_reader :oncall_rotation
def error_no_permissions
error(_('You have insufficient permissions to remove an on-call rotation from this project'))
......
......@@ -6,21 +6,20 @@ module IncidentManagement
include IncidentManagement::OncallRotations::SharedRotationLogic
# @param rotation [IncidentManagement::OncallRotation]
# @param user [User]
# @param params [Hash<Symbol,Any>]
# @param params - name [String] The name of the on-call rotation.
# @param params - length [Integer] The length of the rotation.
# @param params - length_unit [String] The unit of the rotation length. (One of 'hours', days', 'weeks')
# @param params - starts_at [DateTime] The datetime the rotation starts on.
# @param params - ends_at [DateTime] The datetime the rotation ends on.
# @param params - participants [Array<hash>] An array of hashes defining participants of the on-call rotations.
# @param edit_params [Hash<Symbol,Any>]
# @param edit_params - name [String] The name of the on-call rotation.
# @param edit_params - length [Integer] The length of the rotation.
# @param edit_params - length_unit [String] The unit of the rotation length. (One of 'hours', days', 'weeks')
# @param edit_params - starts_at [DateTime] The datetime the rotation starts on.
# @param edit_params - ends_at [DateTime] The datetime the rotation ends on.
# @param edit_params - participants [Array<hash>] An array of hashes defining participants of the on-call rotations.
# @option opts - user [User] The user who is part of the rotation
# @option opts - color_palette [String] The color palette to assign to the on-call user, for example: "blue".
# @option opts - color_weight [String] The color weight to assign to for the on-call user, for example "500". Max 4 chars.
def initialize(oncall_rotation, user, params)
def initialize(oncall_rotation, user, edit_params)
super(project: oncall_rotation.project, current_user: user, params: edit_params)
@oncall_rotation = oncall_rotation
@user = user
@project = oncall_rotation.project
@params = params
@participants_params = params.delete(:participants)
end
......@@ -51,7 +50,7 @@ module IncidentManagement
private
attr_reader :oncall_rotation, :user, :project, :params, :participants_params
attr_reader :oncall_rotation, :participants_params
def save_participants!
return if participants_params.nil?
......
......@@ -8,6 +8,8 @@ module IncidentManagement
# @param user_to_remove [User]
# @param async_email [Boolean]
def initialize(oncall_rotation, user_to_remove, async_email = true)
super(project: oncall_rotation.project)
@oncall_rotation = oncall_rotation
@user_to_remove = user_to_remove
@async_email = async_email
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment