Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F904876
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Aug 29, 4:11 PM
Size
4 KB
Mime Type
text/x-diff
Expires
Sun, Aug 31, 4:11 PM (20 h, 14 m)
Engine
blob
Format
Raw Data
Handle
251925
Attached To
rARCHIVING archiving
View Options
diff --git a/app/controllers/admin/hosts_controller.rb b/app/controllers/admin/hosts_controller.rb
index 70f45ff..64bb9bf 100644
--- a/app/controllers/admin/hosts_controller.rb
+++ b/app/controllers/admin/hosts_controller.rb
@@ -1,67 +1,70 @@
class Admin::HostsController < Admin::BaseController
before_action :fetch_host, only: [:verify, :reject, :set_quota]
# GET /admin/hosts/unverified
def unverified
@hosts = Host.unverified
end
# GET /admin/hosts/pending
def pending
@hosts = Host.where(verified: true).not_baculized
end
# GET /admin/hosts/rejected
def rejected
@hosts = RejectedHost.order(created_at: :desc)
end
# POST /admin/hosts/1/verify
def verify
- @host.verify(current_user.id)
+ if @host.verify(current_user.id)
+ UserMailer.notify_admin_for_verification(current_user, @host.fqdn).deliver
+ end
+
redirect_to unverified_admin_hosts_path
end
# POST /admin/hosts/1/reject
def reject
msg = 'You need to provide a reason' if params[:reason].blank?
msg = 'Host is already verified' if @host.verified?
if msg.blank?
if @host.reject(current_user.id, params[:reason])
flash[:success] = 'Client rejected'
else
flash[:error] = 'Something went wrong'
end
else
flash[:error] = msg
end
redirect_to unverified_admin_hosts_path
end
# PUT /admin/hosts/1/set_quota
def set_quota
@host.quota = case params[:unit]
when 'MB'
params[:quota].to_i * ConfigurationSetting::MEGA_BYTES
when 'GB'
params[:quota].to_i * ConfigurationSetting::GIGA_BYTES
when 'TB'
params[:quota].to_i * ConfigurationSetting::TERA_BYTES
end
if @host.save
flash[:success] = 'Changes saved'
else
flash[:error] = 'Changes not saved'
end
redirect_to admin_client_path(@host.client)
end
private
def fetch_host
@host = Host.find(params[:id])
end
end
diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb
index 2d828dc..a67fa27 100644
--- a/app/mailers/user_mailer.rb
+++ b/app/mailers/user_mailer.rb
@@ -1,48 +1,59 @@
class UserMailer < ActionMailer::Base
default from: Archiving.settings[:default_sender]
# Notifies the host's owners that the host has been verified by an admin
# and is now ready to be configured
#
# @param user_emails[Array] the owners' emails
# @param host[String] the host's FQDN
def notify_for_verification(user_emails, host)
@host = host
s = "[Archiving] Host #{host.name} verification"
mail(to: user_emails, subject: s)
end
# Notifies the host's owners that the host has been rejected by an admin
#
# @param user_emails[Array] the ownerss emails
# @param host[String] the host's FQDN
# @param reason[String] the rejection reason
def notify_for_rejection(user_emails, host, reason)
@host = host
@reason = reason
s = "[Archiving] Host #{host.name} rejection"
mail(to: user_emails, subject: s)
end
# Notifies the user that another user has requested that he should be able to
# manage the given client's backups
#
# @param email[String] the user's email
# @param invitation[Invitation] the target host
def notify_for_invitation(email, invitation)
@invitation = invitation
subject = "[Archiving] Invitation to manage #{@invitation.host.name}'s backups"
mail(to: email, subject: subject)
end
# Notifies admins about a new host that needs verification
#
# @param user[User] the user that created the host
# @param host[String] the host's FQDN
def notify_admin(user, host)
admin_emails = User.admin.where(enabled: true).pluck(:email)
@user = user
@host = host
mail(to: admin_emails, subject: 'New host pending verification')
end
+
+ # Notifies admins about a host that was verified
+ #
+ # @param user[User] the admin that verified the host
+ # @param host[String] the host's FQDN
+ def notify_admin_for_verification(user, host)
+ admin_emails = User.admin.where(enabled: true).pluck(:email)
+ @user = user
+ @host = host
+ mail(to: admin_emails, subject: 'New host verification')
+ end
end
diff --git a/app/views/user_mailer/notify_admin_for_verification.text.erb b/app/views/user_mailer/notify_admin_for_verification.text.erb
new file mode 100644
index 0000000..c368ab4
--- /dev/null
+++ b/app/views/user_mailer/notify_admin_for_verification.text.erb
@@ -0,0 +1,7 @@
+New Client was approved by an admin.
+
+admin: <%= @user.username %>
+client: <%= @host %>
+
+---------
+Archiving
Event Timeline
Log In to Comment