Skip to content
Snippets Groups Projects
Commit 644c10ef authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

Merge branch 'complaints-mailer' into 'master'

Complaints mailer

See merge request portalmec/portalmec!481
parents f235c71f b2fd6b3b
No related branches found
No related tags found
No related merge requests found
......@@ -33,12 +33,13 @@ class V1::ComplaintsController < ApplicationController
# POST v1/complaints
# POST v1/complaints.json
def create
complaint = Complaint.new(complaint_params)
@complaint = Complaint.new(complaint_params)
if complaint.save
render json: complaint, status: :created
if @complaint.save
ComplaintsMailer.new_complaint_received(@complaint, @current_user).deliver_now
render json: @complaint, status: :created
else
render json: complaint.errors, status: :unprocessable_entity
render json: @complaint.errors, status: :unprocessable_entity
end
end
......
# 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 ComplaintsMailer < ApplicationMailer
default to: 'integrada.contato@mec.gov'
default from: Proc.new { @user.email }
def new_complaint_received(complaint, user)
@complaint = complaint
@user = user
mail(subject: "Denuncia de objeto")
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>Nome do usuário: <%= @user.name %></h1>
<h2>Email do usuário: <%= @user.email %></h1>
<h2>Descrição: <%= @complaint.description %></h1>
<h2>Classe denunciada: <%= @complaint.complainable_type %></h1>
<h2>Id: <%= @complaint.complainable_id %></h1>
<h2>Nome: <%= @complaint.complainable.name %></h1>
<h2>Razão: <%= @complaint.complaint_reason.reason %></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