Skip to content

Commit

Permalink
Fix(notification messages): Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisma committed Mar 25, 2019
1 parent 5959030 commit 41a1fbd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/controllers/requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def notify_request_update

if @request.accepted?
([@request.user] + User.admin).uniq.each do |each|
each.notify('Request has been accepted', @request.description_text, @request.description_url(host_url))
each.notify('VM request has been accepted', @request.description_text, @request.description_url(host_url))
end
@request.users.uniq.each do |each|
rights = @request.sudo_users.include?(each) ? 'sudo access' : 'access'
Expand All @@ -155,7 +155,7 @@ def notify_request_update
elsif @request.rejected?
message = @request.description_text
message += @request.rejection_information.empty? ? '' : "\nwith comment: #{@request.rejection_information}"
notify_users('Request has been rejected', message, @request.description_url(host_url))
notify_users('VM request has been rejected', message, @request.description_url(host_url))
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def update_role
@user.update(role: params[:role])
time = Time.zone.now.strftime('%d/%m/%Y')
@user.notify('Changed role',
"Your role has changed from #{former_role} to #{@user.role} on #{time}.",
"Your role has changed from #{former_role} to #{@user.role}.",
url_for(controller: :users, action: 'show', id: @user.id))
redirect_to users_path
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/vms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def request_vm_archivation
return if !@vm || @vm.archived? || @vm.pending_archivation?

@vm.users.each do |each|
each.notify("Your VM #{@vm.name} has been requested to be archived",
"The VM will soon be archived and for that it will then be shut down.\nIf you still need this VM you can stop the archiving of this VM within #{ArchivationRequest.timeout_readable}.",
each.notify("VM #{@vm.name} archiving requested",
"The VM will soon be archived and it will be shut down.\nIf you still need this VM you can stop the archiving of this VM within #{ArchivationRequest.timeout_readable}.",
url_for(controller: :vms, action: 'show', id: @vm.name))
end
@vm.set_pending_archivation
Expand All @@ -84,7 +84,7 @@ def request_vm_revive
return if !@vm || @vm.pending_reviving?

User.admin.each do |each|
each.notify("VM #{@vm.name} has been requested to be revived",
each.notify("VM #{@vm.name} revival requested",
'The VM has to be revived.',
url_for(controller: :vms, action: 'show', id: @vm.name))
end
Expand Down

0 comments on commit 41a1fbd

Please sign in to comment.