displays voter name if already voted
This commit is contained in:
@@ -11,16 +11,20 @@ class Poll
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
def census_api_response
|
||||
CensusApi.new.call(document_type, document_number)
|
||||
@census ||= CensusApi.new.call(document_type, document_number)
|
||||
end
|
||||
|
||||
def has_voted?
|
||||
poll.voters.where(document_number: document_number, document_type: document_type).present?
|
||||
end
|
||||
|
||||
def name
|
||||
@census.name
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -87,7 +87,7 @@ en:
|
||||
attributes:
|
||||
document_number:
|
||||
not_in_census: "Document not in census"
|
||||
has_voted: "Has already voted"
|
||||
has_voted: "%{name} has already voted"
|
||||
proposal:
|
||||
attributes:
|
||||
tag_list:
|
||||
|
||||
@@ -87,7 +87,7 @@ es:
|
||||
attributes:
|
||||
document_number:
|
||||
not_in_census: "Este documento no aparece en el censo"
|
||||
has_voted: "Ya ha votado"
|
||||
has_voted: "%{name} ya ha votado"
|
||||
proposal:
|
||||
attributes:
|
||||
tag_list:
|
||||
|
||||
@@ -61,6 +61,10 @@ class CensusApi
|
||||
end
|
||||
end
|
||||
|
||||
def name
|
||||
"#{data[:datos_habitante][:item][:nombre]} #{data[:datos_habitante][:item][:apellido1]}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def data
|
||||
@@ -106,7 +110,7 @@ class CensusApi
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
def stubbed_invalid_response
|
||||
|
||||
Reference in New Issue
Block a user