Skip to content

Commit

Permalink
287 | Spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
emmabjj committed Dec 31, 2024
1 parent 9ecb074 commit b83f282
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions app/services/evaluator_management_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,53 +48,43 @@ def add_existing_user_as_evaluator(user)
return user_already_added(user) if @phase.evaluators.include?(user)
return invalid_role(user) unless User::VALID_EVALUATOR_ROLES.include?(user.role)

if user.role != 'evaluator'
handle_role_change_needed(user)
else
if user.role == 'evaluator'
handle_evaluator_creation(user)
else
handle_role_change_needed(user)
end
end

def user_already_added(user)
{
success: true,
{ success: true,
message: I18n.t('evaluators.process_evaluator_invitation.already_added',
email: user.email)
}
email: user.email) }
end

def invalid_role(user)
{
success: false,
{ success: false,
message: I18n.t('evaluators.process_evaluator_invitation.invalid_role',
email: user.email)
}
email: user.email) }
end

def handle_role_change_needed(user)
user.update!(status: 'role_change_needed')
create_challenge_phase_evaluator(user)
{
success: true,
{ success: true,
message: I18n.t('evaluators.process_evaluator_invitation.role_change_needed',
email: user.email)
}
email: user.email) }
end

def handle_evaluator_creation(user)
cpe = create_challenge_phase_evaluator(user)
if cpe.persisted?
{
success: true,
{ success: true,
message: I18n.t('evaluators.process_evaluator_invitation.add_success',
email: user.email)
}
email: user.email) }
else
{
success: false,
{ success: false,
message: I18n.t('evaluators.process_evaluator_invitation.add_failure',
email: user.email)
}
email: user.email) }
end
end

Expand Down

0 comments on commit b83f282

Please sign in to comment.