Skip to content
Snippets Groups Projects
Commit d8de3373 authored by Israel Barreto Sant'Anna's avatar Israel Barreto Sant'Anna
Browse files

Created mailer to notify admins about dspace info

parent 1c66ffd4
No related branches found
No related tags found
No related merge requests found
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class DSpaceMailer < ApplicationMailer
default to: 'portalmec@inf.ufpr.br'
def dspace_info_updated(partner)
@partner = partner
mail(subject: "Dados para OAI harvest atualizados")
end
end
...@@ -88,6 +88,7 @@ class User < ApplicationRecord ...@@ -88,6 +88,7 @@ class User < ApplicationRecord
has_many :applications has_many :applications
after_create :default_role after_create :default_role
after_save :verify_dspace_info
has_attached_file :avatar, styles: { medium: '300x300>', thumb: '60x60>' }, default_url: '' has_attached_file :avatar, styles: { medium: '300x300>', thumb: '60x60>' }, default_url: ''
validates_attachment_content_type :avatar, content_type: ['image/jpg', 'image/jpeg', 'image/png', 'image/gif'] validates_attachment_content_type :avatar, content_type: ['image/jpg', 'image/jpeg', 'image/png', 'image/gif']
...@@ -270,6 +271,12 @@ class User < ApplicationRecord ...@@ -270,6 +271,12 @@ class User < ApplicationRecord
) )
end end
def verify_dspace_info
if roles.include?(Role.find_by_name("partner")) && !(changed & ["dspace_url", "dspace_handle", "dspace_sets"]).empty?
DSpaceMailer.dspace_info_updated(self)
end
end
def activity_owner def activity_owner
self self
end end
...@@ -280,7 +287,7 @@ class User < ApplicationRecord ...@@ -280,7 +287,7 @@ class User < ApplicationRecord
def update_tracked_fields(request) def update_tracked_fields(request)
super super
# Change request.remote_ip to req.env["HTTP_X_REAL_IP"] in production # Change request.remote_ip to request.env["HTTP_X_REAL_IP"] in production
self.current_sign_in_ip = request.remote_ip self.current_sign_in_ip = request.remote_ip
end end
end end
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>/* Email styles need to be inline */</style>
</head>
<body>
<h2>ID do usuário: <%= @partner.id %></h1>
<h2>Nome do usuário: <%= @partner.name %></h1>
<h2>URL do DSpace: <%= @partner.dspace_url %></h1>
<h2>Handle: <%= @partner.dspace_url %></h1>
<h2>Sets: <%= @partner.dspace_sets.join(",") %></h1>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment