Commit 9f0feb9c authored by Fabrício Ceschin's avatar Fabrício Ceschin
Browse files

issue#2830: Translate service places

parent 8262d972
......@@ -131,16 +131,16 @@
# Chave primária.
# @return [Integer]
#
class LocalAtendimento < ActiveRecord::Base
class ServicePlace < ActiveRecord::Base
##############################
# Associações #
##############################
has_and_belongs_to_many :cidadaos, :join_table => "cidadaos_locais_atendimento"
has_and_belongs_to_many :tipo_atendimentos, :join_table => "locais_atendimento_tipo_atendimentos"
belongs_to :municipio, :foreign_key => "municipio_id"
belongs_to :prefeitura, :foreign_key => "prefeitura_id"
has_many :escalas
has_many :agendamentos
has_and_belongs_to_many :citizens, :join_table => "citizeens_service_places"
has_and_belongs_to_many :service_types, :join_table => "service_places_service_types"
belongs_to :city, :foreign_key => "city_id"
belongs_to :city_hall, :foreign_key => "city_hall_id"
has_many :shifts
has_many :schedules
##############################
# Atributos #
......@@ -154,15 +154,16 @@ class LocalAtendimento < ActiveRecord::Base
##############################
# Validações #
##############################
validates_presence_of :nome, :bairro, :numero_endereco, :logradouro, :municipio_id, :prefeitura_id
validates_presence_of :name, :neighborhood, :addres_number, :addres_street,
:city_id, :city_hall_id
validates_inclusion_of :ativo, :in => [true, false]
validates_inclusion_of :active, :in => [true, false]
validates_with EmailValidator
validates_with CepValidator
validates_with PhonesValidator, fields: [:telefone1, :telefone2]
validates_length_of :bairro, :complemento_endereco, :email,
:endereco, :nome, :url, maximum: 255
validates_length_of :numero_endereco, :within => 0..10, :allow_blank => true
validates_with PhonesValidator, fields: [:phone1, :phone2]
validates_length_of :neighborhood, :addres_complement, :email,
:addres_street, :name, :url, maximum: 255
validates_length_of :addres_number, :within => 0..10, :allow_blank => true
##############################
# Scopes #
......
<div id="texto-maior">
<h2>Alterar <%=t('orgao')%>: <%= @orgao.nome %></h2>
<%= render 'form' %>
<br />
<%= link_to 'Mostrar', @orgao, :class => 'bt' %>
<%= link_to 'Voltar', orgaos_path, :class => 'back-bt' %>
</div>
<div class="form">
<%= form_for(@orgao) do |f| %>
<% if @orgao.errors.any? %>
<%= form_for(@service_place) do |f| %>
<% if @service_place.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@orgao.errors.count, "erro") %>, <%=t('orgao')%> não pode ser salvo:</h2>
<h2><%= pluralize(@service_place.errors.count, "erro") %>, <%=t('orgao')%> não pode ser salvo:</h2>
<ul>
<% @orgao.errors.full_messages.each do |msg| %>
<% @service_place.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
......@@ -15,17 +15,17 @@
<%= hidden_field_tag :app_root_url, root_url %>
<div class="field-required">
<%= f.label :ativo, "Situação*:" %><br />
<% if @orgao.new_record? %>
<%= f.text_field :ativo, :value => "Ativo", :disabled => true %>
<%= f.label :active, "Situação*:" %><br />
<% if @service_place.new_record? %>
<%= f.text_field :active, :value => "Ativo", :disabled => true %>
<% else %>
<%= f.select :ativo, [["Ativo",true],["Inativo",false]] %>
<%= f.select :active, [["Ativo",true],["Inativo",false]] %>
<% end %>
</div>
<div class="field-required">
<%= f.label :nome, "Nome do " + t('orgao')+ "*: " %><br />
<%= f.text_field :nome %>
<%= f.label :name, "Nome do " + t('orgao')+ "*: " %><br />
<%= f.text_field :name %>
</div>
<div class="field-required">
......@@ -36,7 +36,7 @@
<div class="field-required">
<%= f.label :tufibge_id, "Estado*: " %><br />
<%= collection_select(:orgao, :tufibge_id,
<%= collection_select(:service_place, :tufibge_id,
Tufibge.all, :id, :nome_uf, { :selected => @estado.first.id }, { :disabled => "disabled" }) %>
</div>
......@@ -44,54 +44,54 @@ Tufibge.all, :id, :nome_uf, { :selected => @estado.first.id }, { :disabled => "d
<%= hidden_field_tag :lista_municipios, root_url %>
<%= f.label :tmibge_id, "Município*: " %><br />
<p id="orgao_tmibge_id_loading" style="display: none;"><i>Carregando lista de municípios...</i></p>
<%= collection_select(:orgao, :tmibge_id,
Tmibge.where("tufibge_id = ?", @prefeitura.tufibge.id), :id,
:nome_municipio, { :selected => @cidade.first.id }, { :disabled => "disabled" }) %>
<%= collection_select(:service_place, :tmibge_id,
Tmibge.where("tufibge_id = ?", @city_hall.tufibge.id), :id,
:nome_municipio, { :selected => @city.first.id }, { :disabled => "disabled" }) %>
</div>
<div class="field-required">
<%= f.label :bairro, "Bairro*: " %><br />
<%= f.text_field :bairro, { :disabled => "disabled" } %>
<%= f.label :neighborhood, "Bairro*: " %><br />
<%= f.text_field :neighborhood, { :disabled => "disabled" } %>
</div>
<div class="field-required">
<%= f.label :endereco, "Endereço*: " %><br />
<%= f.text_field :endereco, { :disabled => "disabled" }%>
<%= f.label :addres_street, "Endereço*: " %><br />
<%= f.text_field :addres_street, { :disabled => "disabled" }%>
</div>
<div class="field">
<%= f.label :numero_endereco, "Número: " %><br />
<%= f.text_field :numero_endereco %>
<%= f.label :addres_number, "Número: " %><br />
<%= f.text_field :addres_number %>
</div>
<div class="field">
<%= f.label :complemento_endereco, "Complemento: " %><br />
<%= f.text_field :complemento_endereco %>
<%= f.label :addres_complement, "Complemento: " %><br />
<%= f.text_field :addres_complement %>
</div>
<div class="field-required">
<%= f.label :prefeitura, "Prefeitura*:" %><br />
<%= f.text_field :prefeitura, :value => Prefeitura.first.nome, :disabled => true %>
<%= f.label :city_hall, "Prefeitura*:" %><br />
<%= f.text_field :city_hall, :value => CityHall.first.nome, :disabled => true %>
</div>
<div class="field">
<label> Tipos de Atendimento: </label><br />
<% for tta in TipoAtendimento.where("ativo = ?",true) %>
<%= check_box_tag "orgao[tipo_atendimento_ids][]", tta.id, @orgao.tipo_atendimentos.include?(tta) %>
<%= tta.descricao %><br />
<% for tta in ServiceType.where("active = ?",true) %>
<%= check_box_tag "service_place[service_type_ids][]", tta.id, @service_place.service_types.include?(tta) %>
<%= tta.description %><br />
<% end %>
</div>
<div class="field">
<%= f.label :telefone1, "Telefone 1: " %><br />
<%= f.text_field :telefone1, :class => "phone", :type => "tel" %>
<%= f.label :phone1, "Telefone 1: " %><br />
<%= f.text_field :phone1, :class => "phone", :type => "tel" %>
</div>
<div class="field">
<%= f.label :telefone2, "Telefone 2: "%><br />
<%= f.text_field :telefone2, :class => "phone", :type => "tel" %>
<%= f.label :phone2, "Telefone 2: "%><br />
<%= f.text_field :phone2, :class => "phone", :type => "tel" %>
</div>
<div class="field">
......
<%= page_entries_info @orgaos %>
<% if !@orgaos.empty? %>
<%= page_entries_info @service_places %>
<% if !@service_places.empty? %>
<div class="table-border">
<table class="tabela">
<thead>
<tr>
<th><%= sort_link(@search, :nome, "Nome") %></th>
<th><%= sort_link(@search, :name, "Nome") %></th>
<th><%= sort_link(@search, :cep, "CEP") %></th>
<th><%= sort_link(@search, :bairro, "Bairro") %></th>
<th><%= sort_link(@search, :neighborhood, "Bairro") %></th>
<th><%= sort_link(@search, :tufibge_nome_uf, "Estado") %></th>
<th><%= sort_link(@search, :tmibge_nome_municipio, "Município") %></th>
<th>Telefone</th>
<th>Email</th>
<th>Site</th>
<th><%= sort_link(@search, :ativo, "Situação") %></th>
<th><%= sort_link(@search, :active, "Situação") %></th>
<th class="edit"></th>
</tr>
</thead>
<tbody>
<% cache ['orgaos', Orgao.latest] do %>
<% @orgaos.each do |orgao| %>
<% cache ['orgao', orgao] do %>
<% cache ['service_places', ServicePlace.latest] do %>
<% @service_places.each do |service_place| %>
<% cache ['service_place', service_place] do %>
<tr>
<td><%= link_to orgao.nome, orgao %></td>
<td><%= orgao.cep %></td>
<td><%= orgao.bairro %></td>
<td><%= estado(orgao) %></td>
<td><%= municipio(orgao) %></td>
<td><%= orgao.telefone1 %></td>
<td><%= orgao.email %></td>
<td><%= link_to orgao.url, orgao.url, :target => "_blank" %></td>
<td><%= situacao(orgao) %></td>
<td><%= link_to service_place.nome, service_place %></td>
<td><%= service_place.cep %></td>
<td><%= service_place.neighborhood %></td>
<td><%= estado(service_place) %></td>
<td><%= municipio(service_place) %></td>
<td><%= service_place.phone1 %></td>
<td><%= service_place.email %></td>
<td><%= link_to service_place.url, service_place.url, :target => "_blank" %></td>
<td><%= situacao(service_place) %></td>
<td class="edit">
<a href="<%= edit_orgao_path(orgao) %>">
<a href="<%= edit_service_place_path(service_place) %>">
<%= image_tag("edit.png",:alt => "Editar", :title => "Editar",:hidden => @contraste.present?, :class => "img-padrao") %>
<%= image_tag("edit_white.png",:alt => "Editar", :title => "Editar", :hidden => @contraste.nil?, :class => "img-alto-contraste") %>
</a>
......@@ -45,4 +45,4 @@
</table>
</div>
<% end %>
<%= will_paginate_remote @orgaos %>
<%= will_paginate_remote @service_places %>
<div id="texto-maior">
<h2>Alterar <%=t('service_place')%>: <%= @service_place.nome %></h2>
<%= render 'form' %>
<br />
<%= link_to 'Mostrar', @service_place, :class => 'bt' %>
<%= link_to 'Voltar', service_places_path, :class => 'back-bt' %>
</div>
<div id="texto-maior">
<h2><%=t('orgaos')%></h2>
<h2><%=t('service_places')%></h2>
<div id="search-form">
<h4>Buscar <%=t('orgaos')%>:</h4>
<h4>Buscar <%=t('service_places')%>:</h4>
<%= search_form_for(@search) do |f| %>
<div class="field">
<%= f.label :nome, "Nome: " %><br />
<%= f.text_field :nome_cont, :class => "search-field"%>
<%= f.label :name, "Nome: " %><br />
<%= f.text_field :name_cont, :class => "search-field"%>
</div>
<div class="field">
......@@ -15,8 +15,8 @@
</div>
<div class="field">
<%= f.label :bairro, "Bairro: " %><br />
<%= f.text_field :bairro_cont, :class => "search-field" %>
<%= f.label :neighborhood, "Bairro: " %><br />
<%= f.text_field :neighborhood_cont, :class => "search-field" %>
</div>
<br />
<div class="field">
......@@ -30,8 +30,8 @@
</div>
<br />
<div class="field">
<%= f.label :ativo, "Situação: " %><br />
<%= f.select :ativo_eq,
<%= f.label :active, "Situação: " %><br />
<%= f.select :active_eq,
options_for_select([["Ativo",true],["Inativo",false]], @search.ativo_eq),
{:include_blank => "Todos"}, {:class => "search-field"} %>
</div>
......@@ -44,12 +44,12 @@
<hr>
</div>
<div id="tabela_orgaos">
<%= render "tabela_orgaos" %>
<div id="tabela_service_places">
<%= render "tabela_service_places" %>
</div>
<br />
<%= link_to 'Novo '+t('orgao'), new_orgao_path , :class => 'bt'%>
<%= link_to 'Novo '+t('service_place'), new_service_place_path , :class => 'bt'%>
</div>
<div id="texto-maior">
<h2>Cadastrar <%=t('orgao')%>:</h2>
<h2>Cadastrar <%=t('service_place')%>:</h2>
<%= render 'form' %>
<br />
<%= link_to 'Voltar', orgaos_path , :class => 'back-bt' %>
<%= link_to 'Voltar', service_places_path , :class => 'back-bt' %>
</div>
<div id="texto-maior">
<h2>Informações <%=t('orgao')%>:</h2>
<h2>Informações <%=t('service_place')%>:</h2>
<h4><%= @orgao.nome %></h4>
<h4><%= @service_place.name %></h4>
<p>
<b>Situação:</b>
<%= situacao(@orgao) %>
<%= situacao(@service_place) %>
</p>
<p>
<b>Nome:</b>
<%= @orgao.nome %>
<%= @service_place.name %>
</p>
<p>
<b>Prefeitura:</b>
<% if @orgao.prefeitura.nil? %>
<% if @service_place.city_hall.nil? %>
ERRO: não possui prefeitura, por favor atualize!
<% else %>
<%= link_to @orgao.prefeitura.nome, @orgao.prefeitura %>
<%= link_to @service_place.city_hall.name, @service_place.city_hall %>
<% end %>
</p>
<p>
<b>CEP:</b>
<%= @orgao.cep %>
<%= @service_place.cep %>
</p>
<p>
<b>Bairro:</b>
<%= @orgao.bairro %>
<%= @service_place.neighborhood %>
</p>
<p>
<b>Endereço:</b>
<%= @orgao.endereco %>
<%= @service_place.addres_street %>
</p>
<p>
<b>Número:</b>
<%= @orgao.numero_endereco %>
<%= @service_place.addres_number %>
</p>
<p>
<b>Complemento:</b>
<%= @orgao.complemento_endereco %>
<%= @service_place.addres_complement %>
</p>
<p>
<b>Telefone 1:</b>
<%= @orgao.telefone1 %>
<%= @service_place.phone1 %>
</p>
<p>
<b>Telefone 2:</b>
<%= @orgao.telefone2 %>
<%= @service_place.phone2 %>
</p>
<p>
<b>E-mail:</b>
<%= @orgao.email %>
<%= @service_place.email %>
</p>
<p>
<b>Site:</b>
<%= link_to @orgao.url, @orgao.url %>
<%= link_to @service_place.url, @service_place.url %>
</p>
<p>
<b>Estado:</b>
<%= estado(@orgao) %>
<%= estado(@service_place) %>
</p>
<p>
<b>Município:</b>
<%= municipio(@orgao) %>
<%= municipio(@service_place) %>
</p>
<p>
<b>Serviços: </b>
<ul>
<% @orgao.tipo_atendimentos.each do |tta| %>
<li><%= link_to "#{tta.descricao} (#{situacao(tta)})", tta %></li>
<% @service_place.service_types.each do |tta| %>
<li><%= link_to "#{tta.description} (#{situacao(tta)})", tta %></li>
<% end %>
</ul>
</p>
......@@ -89,8 +89,8 @@
<p>
<b>Profissionais: </b>
<ul>
<% @orgao.profissionais.each do |pro| %>
<li><%= link_to "#{pro.nome} (#{pro.role}, #{situacao(pro)})", pro
<% @service_place.professionals.each do |pro| %>
<li><%= link_to "#{pro.name} (#{pro.role}, #{situacao(pro)})", pro
%></li>
<% end %>
</ul>
......@@ -98,16 +98,16 @@
<p>
<b>Atualizado em:</b>
<%= @orgao.updated_at.strftime("%m/%d/%Y, %H:%M") %>
<%= @service_place.updated_at.strftime("%m/%d/%Y, %H:%M") %>
</p>
<p>
<b>Criado em:</b>
<%= @orgao.created_at.strftime("%m/%d/%Y, %H:%M") %>
<%= @service_place.created_at.strftime("%m/%d/%Y, %H:%M") %>
</p>
<%= link_to 'Alterar', edit_orgao_path(@orgao) , :class => 'bt'%>
<%= link_to 'Voltar', orgaos_path , :class => 'back-bt' %>
<%= link_to 'Alterar', edit_service_place_path(@service_place) , :class => 'bt'%>
<%= link_to 'Voltar', service_places_path , :class => 'back-bt' %>
</div>
class CreateLocaisAtendimento < ActiveRecord::Migration
def change
create_table :locais_atendimento do |t|
t.string :nome, :null => false
t.string :cep, :limit => 10
t.string :bairro, :null => false
t.string :logradouro, :null => false
t.string :numero_endereco, :null => false, :limit => 10
t.string :complemento_endereco
t.string :telefone1, :limit => 13
t.string :telefone2, :limit => 13
t.string :email
t.string :url
t.boolean :ativo, :null => false, :default => true
t.references :municipio, :null => false
t.references :prefeitura, :null => false
t.timestamps
end
add_index :locais_atendimento, :municipio_id
add_index :locais_atendimento, :prefeitura_id
end
end
class CreateServicePlaces < ActiveRecord::Migration
def change
create_table :service_places do |t|
t.string :name, :null => false
t.string :cep, :limit => 10
t.string :neighborhood, :null => false
t.string :addres_street, :null => false
t.string :addres_number, :null => false, :limit => 10
t.string :addres_complement
t.string :phone1, :limit => 13
t.string :phone2, :limit => 13
t.string :email
t.string :url
t.boolean :active, :null => false, :default => true
t.references :city, :null => false
t.references :city_hall, :null => false
t.timestamps
end
add_index :service_places, :city_id
add_index :service_places, :city_hall_id
end
end
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
service_places_Unidade_Saude_Cajuru:
name: Unidade de Saúde - Cajuru
cep: 88321-760
neighborhood: Cajuru
addres_street: R. Pedro Bochino
addres_number: 750
addres_complement:
phone1: (41)3361-2343
phone2: (99)9999-9999
email: usc@org.br
url: www.usc.org.br
tufibge_id: tufibge_PR
tmibge_id: tmibge_Curitiba
city_hall: prefeituras_Curitiba
active: true
service_places_Administracao_Sistema:
name: Administração do Sistema
cep:
neighborhood: Prado Velho
addres_street: R. Manoel Martins de Abreu
addres_number: 25
addres_complement:
phone1: (41)3218-2400
phone2:
email:
url:
tufibge_id: tufibge_PR
tmibge_id: tmibge_Curitiba
city_hall: prefeituras_Curitiba
active: true
service_places_Unidade_Saude_Oswaldo_Cruz:
name: Unidade de Saúde - Oswaldo Cruz
cep:
neighborhood: Cidade Industrial
addres_street: R. Pedro Gusso
addres_number: 3749
addres_complement:
phone1: (41)3212-1418
phone2:
email:
url:
tufibge_id: tufibge_PR
tmibge_id: tmibge_Curitiba
city_hall: prefeituras_Curitiba
active: false
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment