displays voter name if already voted
This commit is contained in:
@@ -11,16 +11,20 @@ class Poll
|
|||||||
end
|
end
|
||||||
|
|
||||||
def has_not_voted
|
def has_not_voted
|
||||||
errors.add(:document_number, :has_voted) if has_voted?
|
errors.add(:document_number, :has_voted, name: name) if has_voted?
|
||||||
end
|
end
|
||||||
|
|
||||||
def census_api_response
|
def census_api_response
|
||||||
CensusApi.new.call(document_type, document_number)
|
@census ||= CensusApi.new.call(document_type, document_number)
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_voted?
|
def has_voted?
|
||||||
poll.voters.where(document_number: document_number, document_type: document_type).present?
|
poll.voters.where(document_number: document_number, document_type: document_type).present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def name
|
||||||
|
@census.name
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -87,7 +87,7 @@ en:
|
|||||||
attributes:
|
attributes:
|
||||||
document_number:
|
document_number:
|
||||||
not_in_census: "Document not in census"
|
not_in_census: "Document not in census"
|
||||||
has_voted: "Has already voted"
|
has_voted: "%{name} has already voted"
|
||||||
proposal:
|
proposal:
|
||||||
attributes:
|
attributes:
|
||||||
tag_list:
|
tag_list:
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ es:
|
|||||||
attributes:
|
attributes:
|
||||||
document_number:
|
document_number:
|
||||||
not_in_census: "Este documento no aparece en el censo"
|
not_in_census: "Este documento no aparece en el censo"
|
||||||
has_voted: "Ya ha votado"
|
has_voted: "%{name} ya ha votado"
|
||||||
proposal:
|
proposal:
|
||||||
attributes:
|
attributes:
|
||||||
tag_list:
|
tag_list:
|
||||||
|
|||||||
@@ -61,6 +61,10 @@ class CensusApi
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def name
|
||||||
|
"#{data[:datos_habitante][:item][:nombre]} #{data[:datos_habitante][:item][:apellido1]}"
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def data
|
def data
|
||||||
@@ -106,7 +110,7 @@ class CensusApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
def stubbed_valid_response
|
def stubbed_valid_response
|
||||||
{get_habita_datos_response: {get_habita_datos_return: {datos_habitante: { item: {fecha_nacimiento_string: "31-12-1980", identificador_documento: "12345678Z", descripcion_sexo: "Varón" }}, datos_vivienda: {item: {codigo_postal: "28013", codigo_distrito: "01"}}}}}
|
{get_habita_datos_response: {get_habita_datos_return: {datos_habitante: { item: {fecha_nacimiento_string: "31-12-1980", identificador_documento: "12345678Z", descripcion_sexo: "Varón", nombre: "José", apellido1: "García" }}, datos_vivienda: {item: {codigo_postal: "28013", codigo_distrito: "01"}}}}}
|
||||||
end
|
end
|
||||||
|
|
||||||
def stubbed_invalid_response
|
def stubbed_invalid_response
|
||||||
|
|||||||
Reference in New Issue
Block a user