diff --git a/app/models/decidim/stratified_sortitions/stratified_sortition.rb b/app/models/decidim/stratified_sortitions/stratified_sortition.rb
index 7885792..bbc0e26 100644
--- a/app/models/decidim/stratified_sortitions/stratified_sortition.rb
+++ b/app/models/decidim/stratified_sortitions/stratified_sortition.rb
@@ -51,6 +51,10 @@ def strata_and_substrata_configured?
def can_execute?
strata_and_substrata_configured? && !sample_participants.empty?
end
+
+ def executed?
+ status == "executed"
+ end
end
end
end
diff --git a/app/packs/stylesheets/decidim/stratified_sortitions/admin/stratified_sortitions.scss b/app/packs/stylesheets/decidim/stratified_sortitions/admin/stratified_sortitions.scss
index dc88511..4d406eb 100644
--- a/app/packs/stylesheets/decidim/stratified_sortitions/admin/stratified_sortitions.scss
+++ b/app/packs/stylesheets/decidim/stratified_sortitions/admin/stratified_sortitions.scss
@@ -191,4 +191,16 @@ input[readonly] {
.upload-census-btn {
margin: 0 !important;
+}
+
+.upload-disabled-wrapper {
+ cursor: not-allowed;
+ width: auto;
+
+ .upload-census-btn {
+ pointer-events: none;
+ border: 1px solid #3e4c5c;
+ background-color: #efefef;
+ color: #3e4c5c;
+ }
}
\ No newline at end of file
diff --git a/app/services/decidim/stratified_sortitions/sortition_results_exporter.rb b/app/services/decidim/stratified_sortitions/sortition_results_exporter.rb
index 9e857d2..f44c181 100644
--- a/app/services/decidim/stratified_sortitions/sortition_results_exporter.rb
+++ b/app/services/decidim/stratified_sortitions/sortition_results_exporter.rb
@@ -84,12 +84,21 @@ def export_json
private
+ def i18n_scope
+ "decidim.stratified_sortitions.admin.stratified_sortitions.execute"
+ end
+
def metadata_headers
- @metadata_headers ||= %w(
- algorithm total_participants generated_at generation_time
- num_panels selected_at verification_seed random_value_used
- selected_panel_probability
- )
+ @metadata_headers ||= [
+ I18n.t("algorithm", scope: i18n_scope),
+ I18n.t("total_participants", scope: i18n_scope),
+ I18n.t("generated_at", scope: i18n_scope),
+ I18n.t("generation_time", scope: i18n_scope),
+ I18n.t("num_panels", scope: i18n_scope),
+ I18n.t("selected_at", scope: i18n_scope),
+ I18n.t("random_value_used", scope: i18n_scope),
+ I18n.t("selected_panel_probability", scope: i18n_scope),
+ ]
end
def metadata_values
@@ -100,7 +109,6 @@ def metadata_values
@portfolio.generation_time_seconds,
@portfolio.num_panels,
@portfolio.selected_at,
- @portfolio.verification_seed || "-",
@portfolio.random_value_used,
format_percentage(@portfolio.selected_panel_probability),
]
@@ -108,10 +116,16 @@ def metadata_values
def participant_headers
@participant_headers ||= begin
- headers = %w(personal_data_1 personal_data_2 personal_data_3 personal_data_4)
+ template_scope = "decidim.stratified_sortitions.admin.samples.template"
+ headers = [
+ I18n.t("personal_data_1", scope: template_scope),
+ I18n.t("personal_data_2", scope: template_scope),
+ I18n.t("personal_data_3", scope: template_scope),
+ I18n.t("personal_data_4", scope: template_scope),
+ ]
@strata.each do |stratum|
stratum_name = stratum.name.values.compact.first || stratum.id.to_s
- headers << "stratum_#{stratum_name}"
+ headers << stratum_name
end
headers
end
diff --git a/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_form.html.erb b/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_form.html.erb
index edd761e..3abf7fa 100644
--- a/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_form.html.erb
+++ b/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_form.html.erb
@@ -13,7 +13,7 @@
<%= form.translated :text_field, :title, autofocus: true, aria: { label: :title } %>
-
+
<%= form.number_field :num_candidates %>
diff --git a/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/execute.html.erb b/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/execute.html.erb
index 7e07565..e1b9e28 100644
--- a/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/execute.html.erb
+++ b/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/execute.html.erb
@@ -57,7 +57,6 @@
<%= t(".generation_time") %> |
<%= t(".num_panels") %> |
<%= t(".selected_at") %> |
-
<%= t(".verification_seed") %> |
<%= t(".random_value_used") %> |
<%= t(".selected_panel_probability") %> |
@@ -71,9 +70,8 @@
<%= number_with_precision(@portfolio.generation_time_seconds, precision: 2) %>s |
<%= @portfolio.num_panels %> |
<%= l @portfolio.selected_at, format: :decidim_short %> |
-
<%= @portfolio.verification_seed || "-" %> |
<%= @portfolio.random_value_used %> |
-
<%= number_to_percentage(@portfolio.selected_panel_probability.to_f * 100, precision: 4) %> |
+
<%= number_to_percentage(@portfolio.selected_panel_probability.to_f * 100, precision: 2) %> |
diff --git a/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/upload_sample.html.erb b/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/upload_sample.html.erb
index 6ada393..0fc3af5 100644
--- a/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/upload_sample.html.erb
+++ b/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/upload_sample.html.erb
@@ -6,6 +6,13 @@
<%= render 'navigation_menu' %>
+
<%= t(".description") %>
@@ -15,7 +22,7 @@
<%= link_to t('.download_template'), download_template_samples_path(id: @stratified_sortition.id), class: 'button button__sm button__secondary' %>
-
+
<%= decidim_form_for(@form, url: samples_path(id: @stratified_sortition.id), method: :post, html: { id: "sample-upload-form", class: "form", multipart: true }) do |form| %>
<%= form.upload :file,
label: false,
diff --git a/config/locales/ca.yml b/config/locales/ca.yml
index 4db0ed9..745d0d4 100644
--- a/config/locales/ca.yml
+++ b/config/locales/ca.yml
@@ -6,7 +6,7 @@ ca:
created_at: Data de creació
title: Títol
description: Descripció
- num_candidates: Nombre de candidats
+ num_candidates: Nombre de persones candidates a seleccionar
selection_criteria: Criteris de selecció
selected_profiles_description: Descripció dels perfils seleccionats
errors:
@@ -42,14 +42,14 @@ ca:
execute: Executar sorteig
new_stratified_sortition: "Nou sorteig estratificat"
title: "Accions"
- census_management: Gestió cens
+ census_management: Gestionar mostra
models:
stratified_sortition:
fields:
created_at: Data de creació
title: Títol
description: Descripció
- num_candidates: Nombre de candidats
+ num_candidates: Nombre de candidates a seleccionar
selection_criteria: Criteris de selecció
selected_profiles_description: Descripció dels perfils seleccionats
stratified_sortitions:
@@ -100,7 +100,7 @@ ca:
one: "1 participant seleccionat"
other: "%{count} participants seleccionats"
participant_id: ID
- personal_data_1: Dada personal 1
+ personal_data_1: "Dada personal 1 (identificador únic)"
personal_data_2: Dada personal 2
personal_data_3: Dada personal 3
personal_data_4: Dada personal 4
@@ -182,7 +182,8 @@ ca:
remove_uploaded_samples: Eliminar tots els registres
confirm_remove_uploaded_samples: Estàs segur que vols eliminar totes les registres?
target: Objectiu
- title: Importar nova mostra
+ title: Gestionar mostra
+ upload_census: Pujar una nova mostra
upload_file: Afegir arxiu
uploaded_file: Dades de la mostra carregada
uploaded_files: "S'han agregat els següents fitxers:"
@@ -252,7 +253,7 @@ ca:
one: S'ha seleccionat 1 participant
other: "S'han seleccionat %{count} participants"
sortition_details: Detalls del sorteig
- num_candidates: Nombre de candidats
+ num_candidates: Nombre de candidates a seleccionar
status: Estat
strata_count: Nombre d'estrats
algorithm: Algorisme
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 9bf46fe..c2dc973 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -6,7 +6,7 @@ en:
created_at: Created At
title: Title
description: Description
- num_candidates: Number of Candidates
+ num_candidates: Number of candidates to select
selection_criteria: Selection Criteria
selected_profiles_description: Selected Profiles Description
errors:
@@ -42,14 +42,14 @@ en:
execute: Execute sortition
new_stratified_sortition: "New Stratified Sortition"
title: "Actions"
- census_management: Census management
+ census_management: Manage sample
models:
stratified_sortition:
fields:
created_at: Created At
title: Title
description: Description
- num_candidates: Number of Candidates
+ num_candidates: Number of candidates to select
selection_criteria: Selection Criteria
selected_profiles_description: Selected Profiles Description
stratified_sortitions:
@@ -182,7 +182,8 @@ en:
confirm_remove_uploaded_samples: Are you sure you want to remove all uploaded samples?
strata_not_configured: You must configure strata and substrata first
target: Target
- title: Import new sample
+ title: Manage sample
+ upload_census: Upload new sample
upload_file: Upload file
uploaded_file: Uploaded sample data
uploaded_files: "The following files have been added:"
@@ -252,7 +253,7 @@ en:
one: 1 participant has been selected
other: "%{count} participants have been selected"
sortition_details: Sortition details
- num_candidates: Number of candidates
+ num_candidates: Number of candidates to select
status: Status
strata_count: Number of strata
algorithm: Algorithm
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 7346130..b5d2681 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -6,7 +6,7 @@ es:
created_at: Fecha de creación
title: Título
description: Descripción
- num_candidates: Número de candidatos
+ num_candidates: Número de personas candidatas a seleccionar
selection_criteria: Criterios de selección
selected_profiles_description: Descripción de los perfiles seleccionados
errors:
@@ -42,14 +42,14 @@ es:
execute: Ejecutar sorteo
new_stratified_sortition: "Nuevo sorteo estratificado"
title: "Acciones"
- census_management: Gestión censo
+ census_management: Gestionar muestra
models:
stratified_sortition:
fields:
created_at: Fecha de creación
title: Título
description: Descripción
- num_candidates: Número de candidatos
+ num_candidates: Número de candidatas a seleccionar
selection_criteria: Criterios de selección
selected_profiles_description: Descripción de los perfiles seleccionados
stratified_sortitions:
@@ -182,7 +182,8 @@ es:
confirm_remove_uploaded_samples: ¿Estás seguro de que quieres eliminar todas las muestras cargadas?
strata_not_configured: Primero debes configurar los estratos y subestratos
target: Objetivo
- title: Importar nueva muestra
+ title: Gestionar muestra
+ upload_census: Subir una nueva muestra
upload_file: Subir archivo
uploaded_file: Datos de la muestra cargada
uploaded_files: "Se han agregado los siguientes archivos:"
@@ -252,7 +253,7 @@ es:
one: Se ha seleccionado 1 participante
other: "Se han seleccionado %{count} participantes"
sortition_details: Detalles del sorteo
- num_candidates: Número de candidatos
+ num_candidates: Número de candidatas a seleccionar
status: Estado
strata_count: Número de estratos
algorithm: Algoritmo
diff --git a/spec/services/decidim/stratified_sortitions/sortition_results_exporter_spec.rb b/spec/services/decidim/stratified_sortitions/sortition_results_exporter_spec.rb
index 661deb3..57d5a36 100644
--- a/spec/services/decidim/stratified_sortitions/sortition_results_exporter_spec.rb
+++ b/spec/services/decidim/stratified_sortitions/sortition_results_exporter_spec.rb
@@ -78,9 +78,8 @@ module StratifiedSortitions
let(:rows) { CSV.parse(result.read, col_sep: Decidim.default_csv_col_sep) }
it "has metadata headers in the first row" do
- expect(rows[0]).to include("algorithm")
- expect(rows[0]).to include("total_participants")
- expect(rows[0]).to include("verification_seed")
+ expect(rows[0]).to include("Algorithm")
+ expect(rows[0]).to include("Total participants")
end
it "has metadata values in the second row" do
@@ -93,12 +92,12 @@ module StratifiedSortitions
end
it "has participant headers in the fourth row" do
- expect(rows[3]).to include("personal_data_1")
- expect(rows[3]).to include("personal_data_2")
+ expect(rows[3]).to include("Personal data 1 (unique identifier)")
+ expect(rows[3]).to include("Personal data 2")
end
it "has a stratum column header derived from stratum name" do
- expect(rows[3]).to include("stratum_Gender")
+ expect(rows[3]).to include("Gender")
end
it "has participant data starting at the fifth row" do
@@ -108,7 +107,7 @@ module StratifiedSortitions
end
it "includes substratum names in the stratum column" do
- stratum_col_idx = rows[3].index("stratum_Gender")
+ stratum_col_idx = rows[3].index("Gender")
substratum_values = rows[4..].map { |row| row[stratum_col_idx] }
expect(substratum_values).to include("Woman")
expect(substratum_values).to include("Man")
@@ -170,7 +169,7 @@ module StratifiedSortitions
end
it "has algorithm in metadata" do
- expect(parsed["metadata"]["algorithm"]).to match(/LEXIMIN/)
+ expect(parsed["metadata"]["Algorithm"]).to match(/LEXIMIN/)
end
it "includes all selected participants" do
@@ -178,12 +177,12 @@ module StratifiedSortitions
end
it "includes personal_data_1 for each participant" do
- ids = parsed["participants"].map { |p| p["personal_data_1"] }
+ ids = parsed["participants"].map { |p| p["Personal data 1 (unique identifier)"] }
expect(ids).to include("ID001", "ID002")
end
it "includes stratum substratum values for each participant" do
- genders = parsed["participants"].map { |p| p["stratum_Gender"] }
+ genders = parsed["participants"].map { |p| p["Gender"] }
expect(genders).to include("Woman", "Man")
end
end