From 0758329c62e8b37eec9bd6d417c5083ac5cddff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Sat, 7 Oct 2023 12:45:39 +0200 Subject: [PATCH 01/19] add is number validation to vote app --- .../parliament_vote_app/application_form.rb | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/models/apps/parliament_vote_app/application_form.rb b/app/models/apps/parliament_vote_app/application_form.rb index 0dcc9b65..4045fb5e 100644 --- a/app/models/apps/parliament_vote_app/application_form.rb +++ b/app/models/apps/parliament_vote_app/application_form.rb @@ -40,6 +40,7 @@ class ApplicationForm on: [:identity, :world_sk_permanent_resident, :world_abroad_permanent_resident, :authorized_person] validates_presence_of :pin, message: 'Rodné číslo je povinná položka', on: [:identity, :world_sk_permanent_resident, :world_abroad_permanent_resident, :authorized_person] + validate :pin_is_ok, on: [:identity, :world_sk_permanent_resident, :world_abroad_permanent_resident, :authorized_person] validates_presence_of :street, message: 'Zadajte ulicu alebo názov obce ak obec nemá ulice', on: [:identity, :world_sk_permanent_resident, :authorized_person] validates_presence_of :pobox, message: 'Zadajte poštové smerové čislo', @@ -155,6 +156,26 @@ def world_sk_resident_email_body ) end + private def pin_is_ok + return errors.add(:pin, 'Rodné číslo je pocinná položka') if pin.blank? + + pin = self.pin.gsub(%r{/}, '') + return errors.add(:pin, 'Rodné číslo nie je deliteľné číslom 11') if pin.length == 10 and pin % 11 != 0 + return errors.add(:pin, 'Rodné číslo má nesprávnu dĺžku') if pin.length != 10 and pin.length != 9 + + case pin[2..3].to_i + when 0, 13..50, 63..99 + return errors.add(:pin, 'Rodné číslo obsahuje neplatný mesiac') + + month = pin[2..3].to_i % 50 + year = pin[0..1].to_i + (pin[2..3].to_i > 12 ? 1900 : 2000) + begin + Date.new(year, month, pin[4..5].to_i) + rescue ArgumentError + errors.add(:pin, 'Rodné číslo obsahuje neplatný dátum') + end + end + def run(listener) case step when 'start' From 514c26655181b3e8eeb940d9c43b36b3f90b3d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Sat, 7 Oct 2023 13:54:04 +0200 Subject: [PATCH 02/19] fix syntax --- .../apps/parliament_vote_app/application_form.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/models/apps/parliament_vote_app/application_form.rb b/app/models/apps/parliament_vote_app/application_form.rb index 4045fb5e..228d3cc2 100644 --- a/app/models/apps/parliament_vote_app/application_form.rb +++ b/app/models/apps/parliament_vote_app/application_form.rb @@ -159,13 +159,20 @@ def world_sk_resident_email_body private def pin_is_ok return errors.add(:pin, 'Rodné číslo je pocinná položka') if pin.blank? + begin + pin.to_i + rescue ArgumentError + return errors.add(:pin, 'Rodné číslo obsahuje neplatné znaky') + end + pin = self.pin.gsub(%r{/}, '') - return errors.add(:pin, 'Rodné číslo nie je deliteľné číslom 11') if pin.length == 10 and pin % 11 != 0 + return errors.add(:pin, 'Rodné číslo nie je deliteľné číslom 11') if pin.length == 10 and pin.to_i % 11 != 0 return errors.add(:pin, 'Rodné číslo má nesprávnu dĺžku') if pin.length != 10 and pin.length != 9 case pin[2..3].to_i - when 0, 13..50, 63..99 - return errors.add(:pin, 'Rodné číslo obsahuje neplatný mesiac') + when 0, 13..50, 63..99 + return errors.add(:pin, 'Rodné číslo obsahuje neplatný mesiac') + end month = pin[2..3].to_i % 50 year = pin[0..1].to_i + (pin[2..3].to_i > 12 ? 1900 : 2000) From c5e4e66e4ae371c92404ca2f8084d75b476ec9f0 Mon Sep 17 00:00:00 2001 From: zuzana Date: Wed, 11 Oct 2023 13:28:58 +0200 Subject: [PATCH 03/19] fix: go back button (#622) * added Go Back button to pages where missing * fix: test in spec/features/apps/parliament_vote_app_spec.rb --- .../apps/parliament_vote_app/application_form.rb | 15 ++++++++++++--- .../application_forms/delivery.html.erb | 1 + .../application_forms/permanent_resident.erb | 1 + .../application_forms/sk_citizen.html.erb | 1 + db/seeds.rb | 1 - spec/features/apps/parliament_vote_app_spec.rb | 4 ++-- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/models/apps/parliament_vote_app/application_form.rb b/app/models/apps/parliament_vote_app/application_form.rb index 228d3cc2..0f52e4ef 100644 --- a/app/models/apps/parliament_vote_app/application_form.rb +++ b/app/models/apps/parliament_vote_app/application_form.rb @@ -220,7 +220,10 @@ def run(listener) end private def sk_citizen_step(listener) - if valid?(:sk_citizen) + if go_back? + self.step = 'start' + listener.render :start + elsif valid?(:sk_citizen) case sk_citizen when 'yes' self.step = 'permanent_resident' @@ -234,7 +237,10 @@ def run(listener) end private def permanent_resident_step(listener) - if valid?(:permanent_resident) + if go_back? + self.step = 'sk_citizen' + listener.render :sk_citizen + elsif valid?(:permanent_resident) case permanent_resident when 'yes' self.step = 'place' @@ -269,7 +275,10 @@ def run(listener) # Home flow private def delivery_step(listener) - if valid?(:delivery) + if go_back? + self.step = 'place' + listener.render :place + elsif valid?(:delivery) case delivery when 'post' self.step = 'identity' diff --git a/app/views/apps/parliament_vote_app/application_forms/delivery.html.erb b/app/views/apps/parliament_vote_app/application_forms/delivery.html.erb index e5dba084..c12958e2 100644 --- a/app/views/apps/parliament_vote_app/application_forms/delivery.html.erb +++ b/app/views/apps/parliament_vote_app/application_forms/delivery.html.erb @@ -10,6 +10,7 @@ <%= render 'apps/parliament_vote_app/application_forms/subscribe' %> <% else %> <%= form_for @application_form, :builder => AppFormBuilder, url: request.original_url do |f| %> + <%= render 'apps/parliament_vote_app/application_forms/back', form: f %> <%= render 'components/error_summary', form: @application_form %> <%= f.hidden_field :step %> <%= f.hidden_field :sk_citizen %> diff --git a/app/views/apps/parliament_vote_app/application_forms/permanent_resident.erb b/app/views/apps/parliament_vote_app/application_forms/permanent_resident.erb index 05269977..f2ebf44d 100644 --- a/app/views/apps/parliament_vote_app/application_forms/permanent_resident.erb +++ b/app/views/apps/parliament_vote_app/application_forms/permanent_resident.erb @@ -4,6 +4,7 @@
<%= form_for @application_form, :builder => AppFormBuilder, url: request.original_url do |f| %> + <%= render 'apps/parliament_vote_app/application_forms/back', form: f %> <%= render 'components/error_summary', form: @application_form %> <%= f.hidden_field :step %> <%= f.radios :permanent_resident, 'Máte trvalý pobyt na Slovensku?' do %> diff --git a/app/views/apps/parliament_vote_app/application_forms/sk_citizen.html.erb b/app/views/apps/parliament_vote_app/application_forms/sk_citizen.html.erb index 37355fa2..e00a87aa 100644 --- a/app/views/apps/parliament_vote_app/application_forms/sk_citizen.html.erb +++ b/app/views/apps/parliament_vote_app/application_forms/sk_citizen.html.erb @@ -4,6 +4,7 @@
<%= form_for @application_form, :builder => AppFormBuilder, url: request.original_url do |f| %> + <%= render 'apps/parliament_vote_app/application_forms/back', form: f %> <%= render 'components/error_summary', form: @application_form %> <%= f.hidden_field :step %> <%= f.radios :sk_citizen, 'Ste občan Slovenskej republiky?', inline: true do %> diff --git a/db/seeds.rb b/db/seeds.rb index 52ae2d71..7ba0fd5e 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -23,7 +23,6 @@ position: 1, title: "Založenie živnosti", slug: "zalozenie-zivnosti", - short_description: "empty", description: "

Založenie živnosti: krok po kroku

Zistite, čo treba vybaviť na založenie živnosti.

Založenie živnosti zvyčajne trvá 5 až 10 pracovných dní.

", diff --git a/spec/features/apps/parliament_vote_app_spec.rb b/spec/features/apps/parliament_vote_app_spec.rb index f1f335ea..a178efb0 100644 --- a/spec/features/apps/parliament_vote_app_spec.rb +++ b/spec/features/apps/parliament_vote_app_spec.rb @@ -135,7 +135,7 @@ def start click_button 'Pokračovať' fill_in 'Meno, priezvisko, titul', with: 'Ferko Mrkva', class: 'person' - fill_in 'Rodné číslo', with: '123', class: 'person' + fill_in 'Rodné číslo', with: '600101/1973', class: 'person' fill_in 'Ulica', with: 'Pupavova 31' fill_in 'PSČ', with: '456' fill_in 'Obec', with: 'Bratislava - Karlova ves' @@ -144,7 +144,7 @@ def start click_button 'Pokračovať' expect(page).to have_content('Meno: Ferko Mrkva') - expect(page).to have_content('Rodné číslo: 123') + expect(page).to have_content('Rodné číslo: 600101/1973') expect(page).to have_content('Trvalý pobyt: Pupavova 31, 456 Bratislava - Karlova ves') expect(page).to have_content("Preukaz vyzdvihne splnomocnená osoba:\r \r Meno: Jarko Mrkva\r Číslo občianskeho preukazu: 567") From 945da0c3e385af61d6f690bfb16f7bea608c5632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Wed, 17 Jan 2024 15:56:32 +0100 Subject: [PATCH 04/19] add ux tweaks and rewords based on ux recommendations --- Gemfile | 2 ++ Gemfile.lock | 7 ++++ app/assets/stylesheets/application.css | 13 ++++++++ .../_municipality_email_warning.html.erb | 2 +- .../application_forms/send.html.erb | 33 ++++++++++++++----- 5 files changed, 47 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 661419ff..04ad906b 100644 --- a/Gemfile +++ b/Gemfile @@ -94,6 +94,8 @@ group :development do gem 'spring-watcher-listen' gem 'letter_opener_web' gem 'wdm', '~> 0.1.0', platforms: [:mingw, :mswin, :x64_mingw] + gem 'ruby-debug-ide' + gem 'debase' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index b98bce40..6483518d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -129,6 +129,9 @@ GEM css_parser (1.14.0) addressable date (3.3.3) + debase (0.2.5.beta2) + debase-ruby_core_source (>= 0.10.12) + debase-ruby_core_source (3.2.2) diff-lcs (1.5.0) docile (1.4.0) domain_name (0.5.20190701) @@ -366,6 +369,8 @@ GEM rspec-support (3.12.0) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) + ruby-debug-ide (0.7.3) + rake (>= 0.8.1) ruby2_keywords (0.0.5) rubyzip (2.3.2) sass-rails (6.0.0) @@ -467,6 +472,7 @@ DEPENDENCIES byebug capybara (~> 3.39.2) clockwork + debase dotenv-rails exception_handler factory_bot_rails @@ -500,6 +506,7 @@ DEPENDENCIES rollbar rspec-rails (= 4.0.2) rspec_junit_formatter + ruby-debug-ide sass-rails selenium-webdriver (~> 4.9.0) show_me_the_cookies diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index fba004e1..357fd11d 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -125,6 +125,19 @@ margin-bottom: 0; } +.light-button { + border: 2px solid #3a67e8; + color: #3a67e8; + background-color: inherit; + border-radius: 3px; + margin-bottom: 0; +} + +.light-button:hover { + background-color: #3a67e8; + color: white; +} + .active-topic { background-color: #F3F2F1; padding: 20px 0; diff --git a/app/views/apps/parliament_vote_app/application_forms/_municipality_email_warning.html.erb b/app/views/apps/parliament_vote_app/application_forms/_municipality_email_warning.html.erb index 7d19577d..a22e3761 100644 --- a/app/views/apps/parliament_vote_app/application_forms/_municipality_email_warning.html.erb +++ b/app/views/apps/parliament_vote_app/application_forms/_municipality_email_warning.html.erb @@ -2,6 +2,6 @@ Upozornenie - <% unless @application_form.municipality_email_verified? %>Emailové adresy obcí je veľmi problematické získať a adresa tejto obce nebola ešte overená. <% end %>Uistite sa, či dostanete potvrdenie o prijatí žiadosti. Ak potvrdenie nedostanete, kontaktujte obec telefonicky alebo osobne. + Uistite sa, či dostanete potvrdenie o prijatí žiadosti. Ak potvrdenie nedostanete, kontaktujte obec telefonicky alebo osobne.
diff --git a/app/views/apps/parliament_vote_app/application_forms/send.html.erb b/app/views/apps/parliament_vote_app/application_forms/send.html.erb index 0d0b0d6e..f559353e 100644 --- a/app/views/apps/parliament_vote_app/application_forms/send.html.erb +++ b/app/views/apps/parliament_vote_app/application_forms/send.html.erb @@ -3,28 +3,43 @@
-

Pošlite žiadosť na úrad

+

Pošlite email so žiadosťou na úrad

<% if @application_form.municipality_email.present? %> -

Otvorte - <%= mail_to @application_form.municipality_email, 'pripravenú žiadosť v emailovom klientovi'.html_safe, +

Vygenorovanú žiadosť potrebujete poslať z Vašej emailovej adresy na príslušnú adresu obce: + <%= mail_to @application_form.municipality_email, @application_form.municipality_email, target: '_blank', body: @application_form.from_slovakia_email_body, subject: 'Žiadosť o hlasovací preukaz do parlamentných volieb.' %> - alebo ju manuálne skopírujte a odošlite na emailovú adresu obce: - <%= mail_to @application_form.municipality_email, @application_form.municipality_email %>

<% else %> -

Skopírujte text žiadosti a pošlite ho na emailovú adresu obce.

+

Vygenorovanú žiadosť potrebujete poslať z Vašej emailovej adresy na príslušnú emailovú adresu obce + <%= @application_form.municipality %>

+

Emailovú adresu je možné nájsť na webovej stránke obce.

<% end %>
+ + <%= render 'municipality_email_warning' %> +
- +
+ - <%= render 'municipality_email_warning' %> +
+ <% if @application_form.municipality_email.present? %> + <%= button_tag 'Skopírovať text', class: 'govuk-button light-button', onclick: 'myFunction("emailContent")' %> + <% end %> +
@@ -32,7 +47,7 @@
<%= form_with url: end_apps_parliament_vote_app_application_forms_url, method: :get, local: true do |form| %> - <%= form.submit 'Pokračovať', id: 'nextButton', class: 'govuk-button govuk-!-margin-top-5', disabled: true %> + <%= form.submit 'Dokončiť návod', id: 'nextButton', class: 'govuk-button govuk-!-margin-top-5', disabled: true %> <% end %>
From 2e5fde08cd83f1cabafc72eacd33781efb1b2d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Mon, 22 Jan 2024 08:59:42 +0100 Subject: [PATCH 05/19] add president_vote_app --- .env.sample | 4 + .../application_forms_controller.rb | 64 ++++ app/helpers/format_days_helper.rb | 14 +- .../president_vote_app/application_form.rb | 346 ++++++++++++++++++ .../application_forms/_back.html.erb | 9 + ...akia_authorized_person_email_body.text.erb | 19 + .../_from_slovakia_email_body.text.erb | 21 ++ .../_municipality_ui.html.erb | 236 ++++++++++++ .../_next_vote_notifications.html.erb | 7 + .../application_forms/_subscribe.html.erb | 3 + .../authorized_person.html.erb | 36 ++ .../authorized_person_send.html.erb | 67 ++++ .../application_forms/delivery.html.erb | 58 +++ .../delivery_address.html.erb | 41 +++ .../application_forms/end.html.erb | 20 + .../application_forms/home.html.erb | 16 + .../application_forms/identity.html.erb | 31 ++ .../application_forms/inactive.html.erb | 8 + .../non_sk_nationality.html.erb | 18 + .../application_forms/permanent_resident.erb | 22 ++ .../application_forms/person.html.erb | 10 + .../application_forms/place.html.erb | 30 ++ .../application_forms/send.html.erb | 62 ++++ .../application_forms/sk_citizen.html.erb | 18 + .../application_forms/start.html.erb | 17 + .../application_forms/world.html.erb | 17 + config/routes.rb | 14 + 27 files changed, 1206 insertions(+), 2 deletions(-) create mode 100644 app/controllers/apps/president_vote_app/application_forms_controller.rb create mode 100644 app/models/apps/president_vote_app/application_form.rb create mode 100644 app/views/apps/president_vote_app/application_forms/_back.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/_from_slovakia_authorized_person_email_body.text.erb create mode 100644 app/views/apps/president_vote_app/application_forms/_from_slovakia_email_body.text.erb create mode 100644 app/views/apps/president_vote_app/application_forms/_municipality_ui.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/_next_vote_notifications.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/_subscribe.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/authorized_person.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/authorized_person_send.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/delivery.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/delivery_address.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/end.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/home.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/identity.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/inactive.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/non_sk_nationality.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/permanent_resident.erb create mode 100644 app/views/apps/president_vote_app/application_forms/person.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/place.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/send.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/sk_citizen.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/start.html.erb create mode 100644 app/views/apps/president_vote_app/application_forms/world.html.erb diff --git a/.env.sample b/.env.sample index 85e7c2c9..aa727517 100644 --- a/.env.sample +++ b/.env.sample @@ -15,6 +15,10 @@ APP_PARLIAMENT_PICKUP_DEADLINE_DATE= APP_PARLIAMENT_VOTE_BY_POST_DEADLINE_DATE= APP_PARLIAMENT_REQUEST_SENDING_DEADLINE_DATE= +APP_PRESIDENT_VOTE_DATE= +APP_PRESIDENT_PICKUP_DEADLINE_DATE= +APP_PRESIDENT_REQUEST_SENDING_DEADLINE_DATE= + DEFAULT_EMAIL_FROM=navody@digital AUTOFORM_URL= diff --git a/app/controllers/apps/president_vote_app/application_forms_controller.rb b/app/controllers/apps/president_vote_app/application_forms_controller.rb new file mode 100644 index 00000000..956108a5 --- /dev/null +++ b/app/controllers/apps/president_vote_app/application_forms_controller.rb @@ -0,0 +1,64 @@ +class Apps::PresidentVoteApp::ApplicationFormsController < ApplicationController + helper FormatDaysHelper + before_action :set_metadata, :check_inactive_president_application + before_action :disable_feedback, only: [:show, :delivery, :create] + + def show + render_step('start') + end + + def delivery + return render_self if request.post? + render_step('delivery') + end + + def permanent_resident + return render_self if request.post? + render_step('permanent_resident') + end + + def create + render_self + end + + private def render_self + @application_form = Apps::PresidentVoteApp::ApplicationForm.new(form_params) + @application_form.run(self) + end + + private def render_step(step) + @application_form = Apps::PresidentVoteApp::ApplicationForm.new(step: step) + render step + end + + private def form_params + params.require(:apps_president_vote_app_application_form).permit( + :step, + :place_first_round, + :place_second_round, + :sk_citizen, + :delivery, + :full_name, :pin, :nationality, :maiden_name, + :authorized_person_full_name, :authorized_person_pin, + :street, :pobox, :municipality, + :same_delivery_address, + :delivery_street, :delivery_pobox, :delivery_municipality, :delivery_country, + :municipality_email, + :municipality_email_verified, + :permanent_resident, + :back + ) + end + + private def set_metadata + @metadata.og.title = 'Žiadosť o hlasovací preukaz' + @metadata.og.image = 'facebook_share_2020.png' + @metadata.og.description = 'Aj keď budete počas volieb mimo trvalého pobytu, voliť sa dá. Stačí požiadať.' + end + + private def check_inactive_president_application + return if Apps::PresidentVoteApp::ApplicationForm.active? + return redirect_to apps_president_vote_app_application_forms_path if action_name != "show" + render 'inactive' + end +end diff --git a/app/helpers/format_days_helper.rb b/app/helpers/format_days_helper.rb index 61a76c47..3381de29 100644 --- a/app/helpers/format_days_helper.rb +++ b/app/helpers/format_days_helper.rb @@ -11,6 +11,16 @@ def format_remaining_days(remaining_days) "Dnes je posledný možný termín." end end -end - + def format_remaining_days_count(remaining_days) + if remaining_days > 4 + "#{remaining_days} dní" + elsif remaining_days > 1 + "#{remaining_days} dni" + elsif remaining_days == 1 + "1 deň" + elsif remaining_days == 0 + "posledný deň" + end + end +end diff --git a/app/models/apps/president_vote_app/application_form.rb b/app/models/apps/president_vote_app/application_form.rb new file mode 100644 index 00000000..3f9c1f78 --- /dev/null +++ b/app/models/apps/president_vote_app/application_form.rb @@ -0,0 +1,346 @@ +module Apps + module PresidentVoteApp + class ApplicationForm + VOTE_DATE = Date.parse(ENV.fetch('APP_PRESIDENT_VOTE_DATE', '2023-09-30')) + PICKUP_DEADLINE_DATE = Date.parse(ENV.fetch('APP_PRESIDENT_PICKUP_DEADLINE_DATE', '2023-09-29')) + REQUEST_SENDING_DEADLINE_DATE = Date.parse(ENV.fetch('APP_PRESIDENT_REQUEST_SENDING_DEADLINE_DATE', '2023-09-08')) + + include ActiveModel::Model + + attr_accessor :step + attr_accessor :place_first_round + attr_accessor :place_second_round + attr_accessor :place + attr_accessor :sk_citizen + attr_accessor :permanent_resident + attr_accessor :delivery + attr_accessor :full_name, :pin + attr_accessor :authorized_person_full_name, :authorized_person_pin + attr_accessor :street, :pobox, :municipality + attr_accessor :same_delivery_address + attr_accessor :delivery_street, :delivery_pobox, :delivery_municipality, :delivery_country + attr_accessor :municipality_email + attr_accessor :municipality_email_verified + attr_accessor :back + + validates_presence_of :place_first_round, message: 'Vyberte si jednu z možností v prvom kole', + on: [:place, :identity, :delivery_address, :authorized_person] + validates_presence_of :place_second_round, message: 'Vyberte si jednu z možností v druhom kole', + on: [:place, :identity, :delivery_address, :authorized_person] + + validates_presence_of :sk_citizen, message: 'Vyberte áno pokiaľ ste občan Slovenskej republiky', on: :sk_citizen + validates_presence_of :permanent_resident, message: 'Vyberte áno pokiaľ máte trvalý pobyt na Slovensku', on: :permanent_resident + + validates_presence_of :delivery, message: 'Vyberte si spôsob prevzatia hlasovacieho preukazu', on: :delivery + validates_exclusion_of :delivery, in: %w(post authorized_person), + if: -> { request_sending_expired? }, + message: 'Lehota na zaslanie žiadosti o hlasovací preukaz uplynula 10.2.2020.', on: :delivery + validates_exclusion_of :delivery, in: %w(person), + if: -> { pickup_expired? }, + message: 'Termín na vybavenie hlasovacieho preukazu uplynul 28.2.2020.', on: :delivery + + validates_presence_of :full_name, message: 'Meno je povinná položka', + on: [:identity, :world_abroad_permanent_resident, :authorized_person] + validates_presence_of :pin, message: 'Rodné číslo je povinná položka', + on: [:identity, :world_abroad_permanent_resident, :authorized_person] + validate :pin_is_ok, on: [:identity, :world_abroad_permanent_resident, :authorized_person] + validates_presence_of :street, message: 'Zadajte ulicu alebo názov obce ak obec nemá ulice', + on: [:identity, :authorized_person] + validates_presence_of :pobox, message: 'Zadajte poštové smerové čislo', + on: [:identity, :authorized_person] + validates_presence_of :municipality, message: 'Vyberte obec', + on: [:identity, :authorized_person] + + validates_presence_of :authorized_person_full_name, message: 'Meno splnomocnenej osoby je povinná položka', + on: [:authorized_person] + validates_presence_of :authorized_person_pin, message: 'Číslo občianskeho preukazu splnomocnenej osoby je povinná položka', + on: [:authorized_person] + + validates_presence_of :same_delivery_address, message: 'Zadajte kam chcete zaslať hlasovací preukaz', + on: :delivery_address + validates_presence_of :delivery_street, message: 'Zadajte ulicu alebo názov obce ak obec nemá ulice', + on: [:delivery_address, :world_abroad_permanent_resident], + if: -> (f) { f.custom_delivery_address? } + validates_presence_of :delivery_pobox, message: 'Zadajte poštové smerové čislo', + on: [:delivery_address, :world_abroad_permanent_resident], + if: -> (f) { f.custom_delivery_address? } + validates_presence_of :delivery_municipality, message: 'Zadajte obec', + on: [:delivery_address, :world_abroad_permanent_resident], + if: -> (f) { f.custom_delivery_address? } + validates_presence_of :delivery_country, message: 'Zadajte štát', + on: [:delivery_address, :world_abroad_permanent_resident], + if: -> (f) { f.custom_delivery_address? } + + def self.active? + VOTE_DATE >= Date.current + end + + def minv_email + "volby@minv.sk" + end + + def year + VOTE_DATE.year + end + + def custom_delivery_address? + same_delivery_address == '0' || step == 'world_abroad_permanent_resident' + end + + def municipality_email_verified? + municipality_email_verified == "OK" + end + + def full_address + "#{street}, #{pobox} #{municipality}" + end + + def go_back? + back == "true" + end + + def place_choice + if place_first_round == 'sk' + if place_second_round == 'sk' + 'obe kolá' + else + 'prvé kolo' + end + else + 'druhé kolo' + end + end + + def pickup_remaining_days + (PICKUP_DEADLINE_DATE - Date.current).to_i + end + + def request_sending_remaining_days + (REQUEST_SENDING_DEADLINE_DATE - Date.current).to_i + end + + def pickup_expired? + Date.current > PICKUP_DEADLINE_DATE + end + + def request_sending_first_round_expired? + false + end + + def request_sending_expired? + Date.current > REQUEST_SENDING_DEADLINE_DATE + end + + def from_slovakia_email_body + ActionController::Base.new.render_to_string( + partial: "apps/president_vote_app/application_forms/from_slovakia_email_body", + locals: { model: self }, + ).gsub(/\n/, "\r\n") + end + + def from_slovakia_authorized_person_email_body + ActionController::Base.new.render_to_string( + partial: "apps/president_vote_app/application_forms/from_slovakia_authorized_person_email_body", + locals: { model: self }, + ).gsub(/\n/, "\r\n") + end + + private def pin_is_ok + return errors.add(:pin, 'Rodné číslo je pocinná položka') if pin.blank? + + begin + pin.to_i + rescue ArgumentError + return errors.add(:pin, 'Rodné číslo obsahuje neplatné znaky') + end + + pin = self.pin.gsub(%r{/}, '') + return errors.add(:pin, 'Rodné číslo nie je deliteľné číslom 11') if pin.length == 10 and pin.to_i % 11 != 0 + return errors.add(:pin, 'Rodné číslo má nesprávnu dĺžku') if pin.length != 10 and pin.length != 9 + + case pin[2..3].to_i + when 0, 13..50, 63..99 + return errors.add(:pin, 'Rodné číslo obsahuje neplatný mesiac') + end + + month = pin[2..3].to_i % 50 + year = pin[0..1].to_i + (pin[2..3].to_i > 12 ? 1900 : 2000) + begin + Date.new(year, month, pin[4..5].to_i) + rescue ArgumentError + errors.add(:pin, 'Rodné číslo obsahuje neplatný dátum') + end + end + + def run(listener) + case step + when 'start' + start_step(listener) + when 'place' + place_step(listener) + when 'sk_citizen' + sk_citizen_step(listener) + when 'permanent_resident' + permanent_resident_step(listener) + when 'delivery' + delivery_step(listener) + when 'identity' + identity_step(listener) + when 'authorized_person' + authorized_person_step(listener) + when 'address' + address_step(listener) + when 'delivery_address' + delivery_address_step(listener) + when 'world_abroad_permanent_resident' + world_abroad_permanent_resident_step(listener) + when 'non_sk_nationality' + non_sk_nationality(listener) + when 'home' + home(listener) + end + end + + private def start_step(listener) + self.step = 'sk_citizen' + listener.render :sk_citizen + end + + private def sk_citizen_step(listener) + if go_back? + self.step = 'start' + listener.render :start + elsif valid?(:sk_citizen) + case sk_citizen + when 'yes' + self.step = 'permanent_resident' + listener.render :permanent_resident + when 'no' + listener.redirect_to action: :non_sk_nationality + end + else + listener.render :sk_citizen + end + end + + private def permanent_resident_step(listener) + if go_back? + self.step = 'sk_citizen' + listener.render :sk_citizen + elsif valid?(:permanent_resident) + case permanent_resident + when 'yes' + self.step = 'place' + listener.render :place + when 'no' + listener.redirect_to action: :world + end + else + listener.render :permanent_resident + end + end + + private def place_step(listener) + if go_back? + self.step = 'permanent_resident' + listener.render :permanent_resident + elsif valid?(:place) + if place_first_round == 'sk' || place_second_round == 'sk' + self.place_first_round = place_first_round + self.place_second_round = place_second_round + self.step = 'delivery' + listener.render :delivery + else + listener.redirect_to action: :home + end + else + listener.render :place + end + end + + private def delivery_step(listener) + if go_back? + self.step = 'place' + listener.render :place + elsif valid?(:delivery) + case delivery + when 'post' + self.step = 'identity' + listener.render :identity + when 'authorized_person' + self.step = 'authorized_person' + listener.render :authorized_person + when 'person' + listener.redirect_to action: :person + end + else + listener.render :delivery + end + end + + private def identity_step(listener) + if go_back? + self.step = 'delivery' + listener.render :delivery + elsif valid?(:identity) + self.step = 'delivery_address' + listener.render :delivery_address + else + listener.render :identity + end + end + + private def delivery_address_step(listener) + if go_back? + self.step = 'identity' + listener.render :identity + elsif valid?(:delivery_address) + self.step = 'send' + listener.render :send + else + listener.render :delivery_address + end + end + + private def authorized_person_step(listener) + if go_back? + self.step = 'delivery' + listener.render :delivery + elsif valid?(:authorized_person) + self.step = 'authorized_person_send' + listener.render :authorized_person_send + else + self.step = 'authorized_person' + listener.render :authorized_person + end + end + + private def world_abroad_permanent_resident_step(listener) + if go_back? + self.step = 'permanent_resident' + listener.render :permanent_resident + else + listener.render :world_abroad_permanent_resident + end + end + + private def non_sk_nationality(listener) + if go_back? + self.step = 'sk_citizen' + listener.render :sk_citizen + else + listener.render :non_sk_nationality + end + end + + private def home(listener) + if go_back? + self.step = 'place' + listener.render :place + else + listener.render :home + end + end + end + end +end diff --git a/app/views/apps/president_vote_app/application_forms/_back.html.erb b/app/views/apps/president_vote_app/application_forms/_back.html.erb new file mode 100644 index 00000000..c63978c5 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/_back.html.erb @@ -0,0 +1,9 @@ + +<%= form.hidden_field :back, value: false %> + diff --git a/app/views/apps/president_vote_app/application_forms/_from_slovakia_authorized_person_email_body.text.erb b/app/views/apps/president_vote_app/application_forms/_from_slovakia_authorized_person_email_body.text.erb new file mode 100644 index 00000000..0ac047dc --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/_from_slovakia_authorized_person_email_body.text.erb @@ -0,0 +1,19 @@ +Dobrý deň, + +týmto žiadam o vydanie hlasovacieho preukazu pre voľby prezidenta Slovenskej republiky. Žiadam o vydanie preukazu pre <%= model.place_choice %> volieb. + +Moje identifikačné údaje sú: + +Meno: <%= model.full_name %> +Rodné číslo: <%= model.pin %> +Trvalý pobyt: <%= model.street %>, <%= model.pobox%> <%= model.municipality %> +Štátna príslušnosť: slovenská + +Preukaz vyzdvihne splnomocnená osoba: + +Meno: <%= model.authorized_person_full_name %> +Číslo občianskeho preukazu: <%= model.authorized_person_pin %> + +Zároveň žiadam o zaslanie potvrdenia, že ste túto žiadosť prijali. + +Ďakujem. diff --git a/app/views/apps/president_vote_app/application_forms/_from_slovakia_email_body.text.erb b/app/views/apps/president_vote_app/application_forms/_from_slovakia_email_body.text.erb new file mode 100644 index 00000000..ddad751b --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/_from_slovakia_email_body.text.erb @@ -0,0 +1,21 @@ +Dobrý deň, + +týmto žiadam o vydanie hlasovacieho preukazu pre voľby prezidenta Slovenskej republiky. Žiadam o vydanie preukazu pre <%= model.place_choice %> volieb. + +Moje identifikačné údaje sú: + +Meno: <%= model.full_name %> +Rodné číslo: <%= model.pin %> +Trvalý pobyt: <%= model.street %>, <%= model.pobox%> <%= model.municipality %> +Štátna príslušnosť: slovenská + +<% unless model.custom_delivery_address? %> +Preukaz prosím zaslať na adresu trvalého pobytu. +<% else %> +Preukaz prosím zaslať na korešpondenčnú adresu: +<%= model.delivery_street %>, <%= model.delivery_pobox %> <%= model.delivery_municipality %>, <%= model.delivery_country %> +<% end %> + +Zároveň žiadam o zaslanie potvrdenia, že ste túto žiadosť prijali. + +Ďakujem. diff --git a/app/views/apps/president_vote_app/application_forms/_municipality_ui.html.erb b/app/views/apps/president_vote_app/application_forms/_municipality_ui.html.erb new file mode 100644 index 00000000..7603e662 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/_municipality_ui.html.erb @@ -0,0 +1,236 @@ + + +<%= stylesheet_link_tag 'accessible-autocomplete', media: 'all', 'data-turbolinks-track': 'reload' %> +<%= javascript_include_tag 'apps/ep_vote_app/libs.js', 'data-turbolinks-track': 'reload' %> + diff --git a/app/views/apps/president_vote_app/application_forms/_next_vote_notifications.html.erb b/app/views/apps/president_vote_app/application_forms/_next_vote_notifications.html.erb new file mode 100644 index 00000000..78c36270 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/_next_vote_notifications.html.erb @@ -0,0 +1,7 @@ +<%= render_notification_subscription_component ['NextVoteSubscription', 'NewsletterSubscription'] do %> +

Aktivujte si notifikácie na email, aby Vám už žiaden dôležitý termín neunikol.

+<% end %> +

Čo ďalej?

+

Ak sa vám táto aplikácia páčila, môžete sa zapojiť a pomôcť nám s vývojom či obsahom, alebo nás <%= link_to 'podporte finančne', 'https://slovensko.digital/podpora' %>.

+

Na portáli Návody.Digital nájdete <%= link_to 'množstvo ďalších návodov', root_path %> ako vyriešiť aj iné životné situácie, ktoré si vyžadujú kontakt so štátnou byrokraciou.

+ diff --git a/app/views/apps/president_vote_app/application_forms/_subscribe.html.erb b/app/views/apps/president_vote_app/application_forms/_subscribe.html.erb new file mode 100644 index 00000000..68e21097 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/_subscribe.html.erb @@ -0,0 +1,3 @@ +<%= render_notification_subscription_component ['VoteSubscription', 'NewsletterSubscription'] do %> +

Aktivujte si aj upozornenia na email, aby ste na nič nezabudli.

+<% end %> diff --git a/app/views/apps/president_vote_app/application_forms/authorized_person.html.erb b/app/views/apps/president_vote_app/application_forms/authorized_person.html.erb new file mode 100644 index 00000000..ea1e40c3 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/authorized_person.html.erb @@ -0,0 +1,36 @@ +<%= content_for :title, build_page_title('Osobné prevzatie hlasovacieho preukazu', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+ <%= form_for @application_form, :builder => AppFormBuilder, url: request.original_url do |f| %> + <%= render 'apps/president_vote_app/application_forms/back', form: f %> + <%= render 'components/error_summary', form: @application_form %> +

Prevzatie hlasovacieho preukazu splnomocnenou osobou

+

Vaše osobné údaje

+ <%= f.hidden_field :step %> + <%= f.hidden_field :municipality_email %> + <%= f.hidden_field :municipality_email_verified %> + <%= f.hidden_field :place_first_round %> + <%= f.hidden_field :place_second_round %> + + <%= f.text_field :full_name, class: 'govuk-input--width-20 person', label: 'Meno, priezvisko, titul', hint: 'Ako na občianskom preukaze. Napríklad: JUDr. Ján Mrkvička', autocomplete: 'name' %> + <%= f.text_field :pin, class: 'govuk-input--width-10 person', label: 'Rodné číslo', hint: 'Napríklad: 123456/1234' %> + +
+

Adresa trvalého pobytu

+ <%= f.text_field :street, label: 'Ulica a číslo', hint: 'Napríklad: Kaštieľska 2', class: 'govuk-input--width-20', 'autocomplete': 'address-line1' %> + <%= f.text_field :pobox, label: 'PSČ', hint: 'Napríklad: 841 01', class: 'govuk-input--width-5', 'autocomplete': 'postal-code' %> + <%= f.text_field :municipality, label: 'Obec', class: 'govuk-input--width-20 input-to-replace' %> + +
+

Splnomocnená osoba

+ <%= f.text_field :authorized_person_full_name, class: 'govuk-input--width-20 authorized-person', label: 'Meno, priezvisko, titul', hint: 'Ako na občianskom preukaze. Napríklad: JUDr. Ján Mrkvička', autocomplete: 'name' %> + <%= f.text_field :authorized_person_pin, class: 'govuk-input--width-10 authorized-person', label: 'Číslo občianskeho preukazu', hint: 'Napríklad: EP123456' %> + + <%= f.submit 'Pokračovať'%> + <% end %> +
+
+ +<%= render "apps/president_vote_app/application_forms/municipality_ui" %> diff --git a/app/views/apps/president_vote_app/application_forms/authorized_person_send.html.erb b/app/views/apps/president_vote_app/application_forms/authorized_person_send.html.erb new file mode 100644 index 00000000..bad40a0b --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/authorized_person_send.html.erb @@ -0,0 +1,67 @@ +<%= content_for :title, build_page_title('Zaslanie žiadosti', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+ <%= form_for @application_form, :builder => AppFormBuilder, url: request.original_url do |f| %> + <%= render 'apps/president_vote_app/application_forms/back', form: f %> + <%= f.hidden_field :step %> + <% end %> + +

Pošlite email so žiadosťou na úrad

+ +
+ <% if @application_form.municipality_email.present? %> +

Vygenorovanú žiadosť potrebujete poslať z Vašej emailovej adresy na príslušnú adresu obce: + <%= mail_to @application_form.municipality_email, @application_form.municipality_email, + target: '_blank', + body: @application_form.from_slovakia_authorized_person_email_body, + subject: 'Žiadosť o hlasovací preukaz do prezidentských volieb.' + %> +

+ <% else %> +

Vygenorovanú žiadosť potrebujete poslať z Vašej emailovej adresy na príslušnú emailovú adresu obce + <%= @application_form.municipality %>

+

Emailovú adresu je možné nájsť na webovej stránke obce.

+ <% end %> +
+ +
+ +
+ + +
+ <%= button_tag 'Skopírovať text', class: 'govuk-button light-button', onclick: 'copyToClipboard("emailContent")' %> + <%= mail_to @application_form.municipality_email, "Poslať emailovým klientom", + target: '_blank', + body: @application_form.from_slovakia_authorized_person_email_body, + subject: 'Žiadosť o hlasovací preukaz do prezidentských volieb.' + %> +
+ +
+ + + Upozornenie + Na odoslanie zostáva ešte <%= format_remaining_days_count(@application_form.request_sending_remaining_days) %>. + +
+ +
+ + +
+ + <%= form_with url: end_apps_president_vote_app_application_forms_url, method: :get, local: true do |form| %> + <%= form.submit 'Dokončiť návod', id: 'nextButton', class: 'govuk-button govuk-!-margin-top-5', disabled: true %> + <% end %> +
+
diff --git a/app/views/apps/president_vote_app/application_forms/delivery.html.erb b/app/views/apps/president_vote_app/application_forms/delivery.html.erb new file mode 100644 index 00000000..fdf9af29 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/delivery.html.erb @@ -0,0 +1,58 @@ +<%= content_for :title, build_page_title('Hlasovací preukaz', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+

+ Potrebujete požiadať o hlasovací preukaz pre <%= @application_form.place_choice %> volieb +

+

Aby ste mohli v deň volieb voliť mimo vášho trvalého bydliska, musíte požiadať vašu obec o vydanie hlasovacieho preukazu – osobne alebo elektronicky. Hlasovací preukaz vás oprávňuje voliť z ktoréhokoľvek volebného okrsku v SR.

+ <% if false %> +

Obce potrebné informácie k žiadostiam v súčastnosti ešte len zverejňujú, ak nám však necháte email, dáme Vám vedieť, keď už bude možné o hlasovací preukaz požiadať. Posledný termín na zaslanie žiadosti je 8. septembra.

+ <%= render 'apps/president_vote_app/application_forms/subscribe' %> + <% else %> + <%= form_for @application_form, :builder => AppFormBuilder, url: request.original_url do |f| %> + <%= render 'apps/president_vote_app/application_forms/back', form: f %> + <%= render 'components/error_summary', form: @application_form %> + <%= f.hidden_field :step %> + <%= f.hidden_field :sk_citizen %> + <%= f.hidden_field :place_first_round %> + <%= f.hidden_field :place_second_round %> +
+

+ Ako prevezmete hlasovací preukaz? +

+ <%= f.error_message :delivery %> + +
+ <%= f.radio_button :delivery, 'post', + label: "Nechám si ho poslať poštou", + disabled: @application_form.request_sending_expired?, + hint: @application_form.request_sending_expired? ? + "Termín na zaslanie žiadosti o hlasovací preukaz uplynul 8.3.2024." : + "O hlasovací preukaz môžete požiadať elektronicky (emailom) a bude vám doručený na adresu uvedenú v žiadosti. #{format_remaining_days(@application_form.request_sending_remaining_days)}", + strong_label: true + %> + <%= f.radio_button :delivery, 'authorized_person', + label: "Vyzdvihne ho za mňa iná osoba", + disabled: @application_form.request_sending_expired?, + hint: @application_form.request_sending_expired? ? + "Termín na zaslanie žiadosti o hlasovací preukaz uplynul 22.3.2024." : + "Hlasovací preukaz za vás môže vyzdvihnúť aj iná osoba, ktorú uvediete v žiadosti. #{format_remaining_days(@application_form.request_sending_remaining_days)}", + strong_label: true + %> + <%= f.radio_button :delivery, 'person', + label: "Vyzdvihnem ho osobne na úrade", + disabled: @application_form.pickup_expired?, + hint: @application_form.pickup_expired? ? + "Termín na vyzdvihnutie hlasovacieho preukazu už uplynul." : + "O hlasovací preukaz môžete požiadať osobne najneskôr posledný pracovný deň pred konaním volieb v úradných hodinách obce. Hlasovací preukaz vám vystavia na počkanie. #{format_remaining_days(@application_form.pickup_remaining_days)}", + strong_label: true + %> +
+
+ <%= submit_tag 'Pokračovať', class: 'govuk-button' %> + <% end %> + <% end %> +
+
diff --git a/app/views/apps/president_vote_app/application_forms/delivery_address.html.erb b/app/views/apps/president_vote_app/application_forms/delivery_address.html.erb new file mode 100644 index 00000000..0a8aea8c --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/delivery_address.html.erb @@ -0,0 +1,41 @@ +<%= content_for :title, build_page_title('Spôsob prevzatia hlasovacieho preukazu', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+ <%= form_for @application_form, :builder => AppFormBuilder, url: request.original_url do |f| %> + <%= render 'apps/president_vote_app/application_forms/back', form: f %> + <%= render 'components/error_summary', form: @application_form %> + <%= f.hidden_field :step %> + <%= f.hidden_field :full_name %> + <%= f.hidden_field :pin %> + <%= f.hidden_field :street %> + <%= f.hidden_field :pobox %> + <%= f.hidden_field :municipality %> + <%= f.hidden_field :municipality_email %> + <%= f.hidden_field :municipality_email_verified %> + <%= f.hidden_field :place_first_round %> + <%= f.hidden_field :place_second_round %> + +

Kam chcete zaslať hlasovací preukaz?

+ +
+ <%= f.error_message :same_delivery_address %> + +
+ <%= f.radio_button :same_delivery_address, '1', label: "Na adresu trvalého bydliska", hint: @application_form.full_address%> + <%= f.radio_button :same_delivery_address, '0', label: "Na inú adresu", data: {'aria-controls' => 'conditional-delivery-address'}%> + +
+ <%= f.text_field :delivery_street, label: 'Ulica a číslo', hint: 'Napríklad: Kaštieľska 2', class: 'govuk-input--width-20', 'autocomplete': 'address-line1' %> + <%= f.text_field :delivery_pobox, label: 'PSČ', hint: 'Napríklad: 841 01', class: 'govuk-input--width-5', 'autocomplete': 'postal-code' %> + <%= f.text_field :delivery_municipality, label: 'Obec', class: 'govuk-input--width-10', 'autocomplete': 'address-level2' %> + <%= f.text_field :delivery_country, label: 'Štát', class: 'govuk-input--width-10', 'autocomplete': 'country-name' %> +
+
+
+ + <%= f.submit 'Pokračovať' %> + <% end %> +
+
diff --git a/app/views/apps/president_vote_app/application_forms/end.html.erb b/app/views/apps/president_vote_app/application_forms/end.html.erb new file mode 100644 index 00000000..31a2cba0 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/end.html.erb @@ -0,0 +1,20 @@ +<%= content_for :title, build_page_title('Notifikácie', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+

Počkajte na hlasovací preukaz

+

Nezabudnite voliť a voľte zodpovedne.

+ +
+ + + Upozornenie + Ak vám do 3 dní nepríde potvrdenie o prijatí žiadosti, kontaktujte obec telefonicky alebo osobne. + +
+ + + <%= render 'apps/president_vote_app/application_forms/subscribe' %> +
+
diff --git a/app/views/apps/president_vote_app/application_forms/home.html.erb b/app/views/apps/president_vote_app/application_forms/home.html.erb new file mode 100644 index 00000000..f4b21dc0 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/home.html.erb @@ -0,0 +1,16 @@ +<%= content_for :title, build_page_title('Hlasovanie v mieste trvalého bydliska', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+ <%= form_for 'apps_president_vote_app_application_form', :builder => AppFormBuilder, url: apps_president_vote_app_application_forms_path do |f| %> + <%= render 'apps/president_vote_app/application_forms/back', form: f %> + <%= f.hidden_field :step, :value => 'home' %> + <% end %> + +

Nepotrebujete nič vybavovať

+

V čase volieb volíte vo volebnom okrsku, v ktorom ste zapísaný podľa miesta vášho trvalého bydliska.

+

O volebnom okrsku informuje obec v oznámení o čase a miesta konania volieb. V deň konania volieb si nezabudnite do volebnej miestnosti priniesť občiansky preukaz.

+ <%= render 'apps/president_vote_app/application_forms/subscribe' %> +
+
diff --git a/app/views/apps/president_vote_app/application_forms/identity.html.erb b/app/views/apps/president_vote_app/application_forms/identity.html.erb new file mode 100644 index 00000000..dd4c107e --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/identity.html.erb @@ -0,0 +1,31 @@ +<%= content_for :title, build_page_title('Osobné údaje', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+ <%= form_for @application_form, :builder => AppFormBuilder, url: request.original_url do |f| %> + <%= render 'apps/president_vote_app/application_forms/back', form: f %> + <%= render 'components/error_summary', form: @application_form %> + +

Vaše osobné údaje

+ <%= f.hidden_field :step %> + <%= f.hidden_field :municipality_email %> + <%= f.hidden_field :municipality_email_verified %> + <%= f.hidden_field :place_first_round %> + <%= f.hidden_field :place_second_round %> + + <%= f.text_field :full_name, class: 'govuk-input--width-20', label: 'Meno, priezvisko, titul', hint: 'Ako na občianskom preukaze. Napríklad: JUDr. Ján Mrvička', autocomplete: 'name' %> + <%= f.text_field :pin, class: 'govuk-input--width-10', label: 'Rodné číslo', hint: 'Napríklad: 123456/1234' %> + +
+

Adresa trvalého pobytu

+ <%= f.text_field :street, label: 'Ulica a číslo', hint: 'Napríklad: Kaštieľska 2', class: 'govuk-input--width-20', 'autocomplete': 'address-line1' %> + <%= f.text_field :pobox, label: 'PSČ', hint: 'Napríklad: 841 01', class: 'govuk-input--width-5', 'autocomplete': 'postal-code' %> + <%= f.text_field :municipality, label: 'Obec', class: 'govuk-input--width-20 input-to-replace' %> + + <%= f.submit 'Pokračovať'%> + <% end %> +
+
+ +<%= render "apps/president_vote_app/application_forms/municipality_ui" %> diff --git a/app/views/apps/president_vote_app/application_forms/inactive.html.erb b/app/views/apps/president_vote_app/application_forms/inactive.html.erb new file mode 100644 index 00000000..914a5514 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/inactive.html.erb @@ -0,0 +1,8 @@ +<%= content_for :title, build_page_title('Prezidentské voľby') %> + +
+
+

Prezidentské voľby sa už konali

+ <%= render 'apps/president_vote_app/application_forms/subscribe' %> +
+
diff --git a/app/views/apps/president_vote_app/application_forms/non_sk_nationality.html.erb b/app/views/apps/president_vote_app/application_forms/non_sk_nationality.html.erb new file mode 100644 index 00000000..36409645 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/non_sk_nationality.html.erb @@ -0,0 +1,18 @@ +<%= content_for :title, build_page_title('V prezidentských voľbách nemôžete voliť', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+ <%= form_for 'apps_president_vote_app_application_form', :builder => AppFormBuilder, url: apps_president_vote_app_application_forms_path do |f| %> + <%= render 'apps/president_vote_app/application_forms/back', form: f %> + <%= f.hidden_field :step, :value => "non_sk_nationality" %> + <% end %> + +

V prezidentských voľbách nemôžete voliť

+

+ Vo voľbách prezidenta Slovenskej republiky (prezidentské voľby) môžu voliť len občania Slovenskej republiky. +

+ + <%= render 'apps/president_vote_app/application_forms/subscribe' %> +
+
diff --git a/app/views/apps/president_vote_app/application_forms/permanent_resident.erb b/app/views/apps/president_vote_app/application_forms/permanent_resident.erb new file mode 100644 index 00000000..9f7d0115 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/permanent_resident.erb @@ -0,0 +1,22 @@ +<%= content_for :title, build_page_title('Miesto voľby', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+ <%= form_for @application_form, :builder => AppFormBuilder, url: request.original_url do |f| %> + <%= render 'apps/president_vote_app/application_forms/back', form: f %> + <%= render 'components/error_summary', form: @application_form %> + <%= f.hidden_field :step %> + <%= f.radios :permanent_resident, 'Máte trvalý pobyt na Slovensku?' do %> +

Na to aby ste nemali trvalý pobyt na Slovensku, museli ste si ho odhlásiť.

+ <%= f.radio_button :permanent_resident, 'yes', label: "Áno" %> + <%= f.radio_button :permanent_resident, 'no', + label: "Nie, mám odhlásený trvalý pobyt zo Slovenska", + hint: "Pri odhlasovaní trvalého pobytu sa odovzdáva občiansky preukaz. Ak ste ho odovzdali, zvoľte túto možnosť." + %> + <% end %> + + <%= f.submit 'Pokračovať' %> + <% end %> +
+
diff --git a/app/views/apps/president_vote_app/application_forms/person.html.erb b/app/views/apps/president_vote_app/application_forms/person.html.erb new file mode 100644 index 00000000..d49f9402 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/person.html.erb @@ -0,0 +1,10 @@ +<%= content_for :title, build_page_title('Osobné prevzatie hlasovacieho preukazu', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+

Prevzatie hlasovacieho preukazu osobne

+

Hlasovací preukaz vám vystavia na počkanie na obecnom úrade v mieste trvalého bydliska. Osobne si preukaz vybavíte najneskôr v posledný pracovný deň pred voľbami, počas pracovných hodín úradu.

+ <%= render 'apps/president_vote_app/application_forms/subscribe' %> +
+
diff --git a/app/views/apps/president_vote_app/application_forms/place.html.erb b/app/views/apps/president_vote_app/application_forms/place.html.erb new file mode 100644 index 00000000..dede9223 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/place.html.erb @@ -0,0 +1,30 @@ +<%= content_for :title, build_page_title('Miesto voľby', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+ <%= form_for @application_form, :builder => AppFormBuilder do |f| %> + <%= render 'apps/president_vote_app/application_forms/back', form: f %> + <%= render 'components/error_summary', form: @application_form %> + <%= f.hidden_field :step %> + <% hint = 'Prezidentské voľby sa na Slovensku konajú v sobotu 23. marca 2024 (prvé kolo) a 6. apríla 2024 (druhé kolo), od 7:00 do 22:00. Hlasovať je možné jedine osobne na území Slovenska.' %> + <%= f.radios :place, 'Kde plánujete ísť voliť?', hint: hint do %> +

1. kolo

+ <% if @application_form.request_sending_first_round_expired? %> + <%= f.hidden_field :place_first_round, :value => 'home' %> +

+ Prvé kolo sa už konalo +

+ <% else %> + <%= f.radio_button :place_first_round, 'sk', label: "Mimo trvalého bydliska", hint: "Ak ešte neviete, či budete počas volieb v mieste trvalého bydliska, zvoľte si túto možnosť. Budete tak môcť hlasovať kdekoľvek na Slovensku - aj v mieste trvalého bydliska." %> + <%= f.radio_button :place_first_round, 'home', label: "V mieste trvalého bydliska" %> + <% end %> +

2. kolo

+ <%= f.radio_button :place_second_round, 'sk', label: "Mimo trvalého bydliska", hint: "Ak ešte neviete, či budete počas volieb v mieste trvalého bydliska, zvoľte si túto možnosť. Budete tak môcť hlasovať kdekoľvek na Slovensku - aj v mieste trvalého bydliska." %> + <%= f.radio_button :place_second_round, 'home', label: "V mieste trvalého bydliska" %> + <%= f.radio_button :place_second_round, 'none', label: "Ešte neviem a nechcem teraz riešiť druhé kolo" %> + <% end %> + <%= f.submit 'Pokračovať' %> + <% end %> +
+
diff --git a/app/views/apps/president_vote_app/application_forms/send.html.erb b/app/views/apps/president_vote_app/application_forms/send.html.erb new file mode 100644 index 00000000..0570f56b --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/send.html.erb @@ -0,0 +1,62 @@ +<%= content_for :title, build_page_title('Zaslanie žiadosti', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+

Pošlite email so žiadosťou na úrad

+ +
+ <% if @application_form.municipality_email.present? %> +

Vygenorovanú žiadosť potrebujete poslať z Vašej emailovej adresy na príslušnú adresu obce: + <%= mail_to @application_form.municipality_email, @application_form.municipality_email, + target: '_blank', + body: @application_form.from_slovakia_email_body, + subject: 'Žiadosť o hlasovací preukaz do prezidentských volieb.' + %> +

+ <% else %> +

Vygenorovanú žiadosť potrebujete poslať z Vašej emailovej adresy na príslušnú emailovú adresu obce + <%= @application_form.municipality %>

+

Emailovú adresu je možné nájsť na webovej stránke obce.

+ <% end %> +
+ +
+ +
+ + +
+ <%= button_tag 'Skopírovať text', class: 'govuk-button light-button', onclick: 'copyToClipboard("emailContent")' %> + <%= mail_to @application_form.municipality_email, "Poslať emailovým klientom", + target: '_blank', + body: @application_form.from_slovakia_email_body, + subject: 'Žiadosť o hlasovací preukaz do prezidentských volieb.' + %> +
+ +
+ + + Upozornenie + Na odoslanie zostáva ešte <%= format_remaining_days_count(@application_form.request_sending_remaining_days) %>. + +
+ +
+ + +
+ + <%= form_with url: end_apps_president_vote_app_application_forms_url, method: :get, local: true do |form| %> + <%= form.submit 'Dokončiť návod', id: 'nextButton', class: 'govuk-button govuk-!-margin-top-5', disabled: true %> + <% end %> +
+
diff --git a/app/views/apps/president_vote_app/application_forms/sk_citizen.html.erb b/app/views/apps/president_vote_app/application_forms/sk_citizen.html.erb new file mode 100644 index 00000000..385f2b5f --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/sk_citizen.html.erb @@ -0,0 +1,18 @@ +<%= content_for :title, build_page_title('Ste občan SR?', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+ <%= form_for @application_form, :builder => AppFormBuilder, url: request.original_url do |f| %> + <%= render 'apps/president_vote_app/application_forms/back', form: f %> + <%= render 'components/error_summary', form: @application_form %> + <%= f.hidden_field :step %> + <%= f.radios :sk_citizen, 'Ste občan Slovenskej republiky?', inline: true do %> + <%= f.radio_button :sk_citizen, 'yes', label: "Áno" %> + <%= f.radio_button :sk_citizen, 'no', label: "Nie" %> + <% end %> + + <%= f.submit 'Pokračovať' %> + <% end %> +
+
diff --git a/app/views/apps/president_vote_app/application_forms/start.html.erb b/app/views/apps/president_vote_app/application_forms/start.html.erb new file mode 100644 index 00000000..a59a6842 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/start.html.erb @@ -0,0 +1,17 @@ +<%= content_for :title, build_page_title('Prezidentské voľby') %> + +
+
+

Prezidentské voľby

+

Prezidentské voľby na Slovensku budú 23. marca a 6. apríla 2024.

+

Ak budete počas volieb mimo trvalého bydliska, táto služba vám pomôže vytvoriť žiadosť o hlasovací preukaz tak, aby ste na nič dôležité nezabudli.

+

Je to veľmi jednoduché a trvá to len pár minút.

+

Používaním tejto služby súhlasíte so spracovaním osobných údajov v rozsahu nevyhnutnom pre určenie spôsobu voľby a vytvorenie žiadosti o hlasovací preukaz. Následne sú všetky údaje nenávratne zmazané.

+ <%= form_for @application_form do |f| %> +
+ <%= f.hidden_field :step %> +
+ <%= submit_tag 'Súhlasím a chcem začať', class: 'govuk-button govuk-button--large' %> + <% end %> +
+
diff --git a/app/views/apps/president_vote_app/application_forms/world.html.erb b/app/views/apps/president_vote_app/application_forms/world.html.erb new file mode 100644 index 00000000..d41636f0 --- /dev/null +++ b/app/views/apps/president_vote_app/application_forms/world.html.erb @@ -0,0 +1,17 @@ +<%= content_for :title, build_page_title('Hlasovanie bez trvalého pobytu', 'Prezidentské voľby') %> +<%= content_for(:headerline, 'Prezidentské voľby') %> + +
+
+ <%= form_for 'apps_president_vote_app_application_form', :builder => AppFormBuilder, url: apps_president_vote_app_application_forms_path do |f| %> + <%= render 'apps/president_vote_app/application_forms/back', form: f %> + <%= f.hidden_field :step, :value => 'world_abroad_permanent_resident' %> + <% end %> + +

Ak máte odhlásený trvalý pobyt zo Slovenska, môžete voliť v ktoromkoľvek volebnom okrsku

+

Občan Slovenskej republiky, ktorý nemá trvalý pobyt na území Slovenskej republiky, môže svoj hlas uplatniť v ktorejkoľvek volebnej miestnosti. Preukáže svoju totožnosť predložením slovenského cestovného dokladu a vyplní čestné vyhlásenie, ktoré mu poskytne komisia.

+

Okrsková volebná komisia takéhoto voliča dopíše do zoznamu voličov, čo zaznamená v jeho slovenskom cestovnom doklade, a čestné vyhlásenie o trvalom pobyte v cudzine pripojí k zoznamu voličov.

+ + <%= render 'apps/president_vote_app/application_forms/subscribe' %> +
+
diff --git a/config/routes.rb b/config/routes.rb index eaa97608..c4c46b57 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -96,6 +96,20 @@ end end + if ENV['DISABLED_FEATURES'].to_s.exclude?('president_vote_app') + namespace :president_vote_app, path: 'prezidentske-volby' do + resource :application_forms, path: '' do + member do + get :end, path: 'volte-zodpovedne' + get :home, path: 'hlasovanie-v-mieste-trvaleho-bydliska' + get :world, path: 'hlasovanie-cestovny-doklad' + get :person, path: 'hlasovaci-preukaz-osobne' + get :non_sk_nationality, path: 'hlasovanie-neobcana' + end + end + end + end + namespace :child_birth_app, path: 'narodenie-dietata' do get :picking_up_protocol, to: 'picking_up_protocol#show', path: 'vyzdvihnutie-rodneho-listu' end From 0e88632140ca0ea662e4d3dcb24eec5e9a424d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Mon, 22 Jan 2024 09:34:15 +0100 Subject: [PATCH 06/19] udpate date calculation in president vote app --- .../president_vote_app/application_form.rb | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app/models/apps/president_vote_app/application_form.rb b/app/models/apps/president_vote_app/application_form.rb index 3f9c1f78..9fae08c5 100644 --- a/app/models/apps/president_vote_app/application_form.rb +++ b/app/models/apps/president_vote_app/application_form.rb @@ -1,8 +1,7 @@ module Apps module PresidentVoteApp class ApplicationForm - VOTE_DATE = Date.parse(ENV.fetch('APP_PRESIDENT_VOTE_DATE', '2023-09-30')) - PICKUP_DEADLINE_DATE = Date.parse(ENV.fetch('APP_PRESIDENT_PICKUP_DEADLINE_DATE', '2023-09-29')) + FIRST_ROUND_DATE = Date.parse(ENV.fetch('APP_PRESIDENT_VOTE_DATE', '2023-09-30')) REQUEST_SENDING_DEADLINE_DATE = Date.parse(ENV.fetch('APP_PRESIDENT_REQUEST_SENDING_DEADLINE_DATE', '2023-09-08')) include ActiveModel::Model @@ -72,7 +71,7 @@ class ApplicationForm if: -> (f) { f.custom_delivery_address? } def self.active? - VOTE_DATE >= Date.current + (Date.current - FIRST_ROUND_DATE).to_i < 14 end def minv_email @@ -80,7 +79,7 @@ def minv_email end def year - VOTE_DATE.year + FIRST_ROUND_DATE.year end def custom_delivery_address? @@ -112,15 +111,23 @@ def place_choice end def pickup_remaining_days - (PICKUP_DEADLINE_DATE - Date.current).to_i + if place_first_round == 'sk' + (FIRST_ROUND_DATE - Date.current).to_i - 1 + else + (FIRST_ROUND_DATE - Date.current).to_i + 13 + end end def request_sending_remaining_days - (REQUEST_SENDING_DEADLINE_DATE - Date.current).to_i + if place_first_round == 'sk' + (REQUEST_SENDING_DEADLINE_DATE - Date.current).to_i + else + (REQUEST_SENDING_DEADLINE_DATE - Date.current).to_i + 14 + end end def pickup_expired? - Date.current > PICKUP_DEADLINE_DATE + pickup_remaining_days < 1 end def request_sending_first_round_expired? From 594b05154dd958791c0a7f380f653f38cfd536ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Tue, 23 Jan 2024 09:35:00 +0100 Subject: [PATCH 07/19] change president election app email addresses sheet --- .../application_forms/_municipality_ui.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/apps/president_vote_app/application_forms/_municipality_ui.html.erb b/app/views/apps/president_vote_app/application_forms/_municipality_ui.html.erb index 7603e662..693744d3 100644 --- a/app/views/apps/president_vote_app/application_forms/_municipality_ui.html.erb +++ b/app/views/apps/president_vote_app/application_forms/_municipality_ui.html.erb @@ -56,7 +56,7 @@ /* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */ - var SPREADSHEET_JSON_URL = 'https://sheets.googleapis.com/v4/spreadsheets/1zGC07Zp77EF1lSFCITCWwXFOuNERMzkCrSLVeWzss-k/values/master!C2:G?alt=json&key=AIzaSyDEUeT4Ov9rkc6egolxX1ejoqqNwY7eAm8'; + var SPREADSHEET_JSON_URL = 'https://sheets.googleapis.com/v4/spreadsheets/1v8Is6cncwvFdpURYkQnqaFlMqEgNdHDQ1NkiffExdeg/values/master!C2:G?alt=json&key=AIzaSyDEUeT4Ov9rkc6egolxX1ejoqqNwY7eAm8'; function convertSourceDataToMunicipality(data) { var CONST_MUNICIPALITY = 0; From f8fdcda78442892f3f211b1ff6587702be3f6a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Wed, 24 Jan 2024 13:45:14 +0100 Subject: [PATCH 08/19] disable birth number validation --- app/models/apps/parliament_vote_app/application_form.rb | 2 +- app/models/apps/president_vote_app/application_form.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/apps/parliament_vote_app/application_form.rb b/app/models/apps/parliament_vote_app/application_form.rb index 0f52e4ef..ef903cf1 100644 --- a/app/models/apps/parliament_vote_app/application_form.rb +++ b/app/models/apps/parliament_vote_app/application_form.rb @@ -40,7 +40,7 @@ class ApplicationForm on: [:identity, :world_sk_permanent_resident, :world_abroad_permanent_resident, :authorized_person] validates_presence_of :pin, message: 'Rodné číslo je povinná položka', on: [:identity, :world_sk_permanent_resident, :world_abroad_permanent_resident, :authorized_person] - validate :pin_is_ok, on: [:identity, :world_sk_permanent_resident, :world_abroad_permanent_resident, :authorized_person] + # validate :pin_is_ok, on: [:identity, :world_sk_permanent_resident, :world_abroad_permanent_resident, :authorized_person] validates_presence_of :street, message: 'Zadajte ulicu alebo názov obce ak obec nemá ulice', on: [:identity, :world_sk_permanent_resident, :authorized_person] validates_presence_of :pobox, message: 'Zadajte poštové smerové čislo', diff --git a/app/models/apps/president_vote_app/application_form.rb b/app/models/apps/president_vote_app/application_form.rb index 9fae08c5..5693e3e9 100644 --- a/app/models/apps/president_vote_app/application_form.rb +++ b/app/models/apps/president_vote_app/application_form.rb @@ -42,7 +42,7 @@ class ApplicationForm on: [:identity, :world_abroad_permanent_resident, :authorized_person] validates_presence_of :pin, message: 'Rodné číslo je povinná položka', on: [:identity, :world_abroad_permanent_resident, :authorized_person] - validate :pin_is_ok, on: [:identity, :world_abroad_permanent_resident, :authorized_person] + # validate :pin_is_ok, on: [:identity, :world_abroad_permanent_resident, :authorized_person] validates_presence_of :street, message: 'Zadajte ulicu alebo názov obce ak obec nemá ulice', on: [:identity, :authorized_person] validates_presence_of :pobox, message: 'Zadajte poštové smerové čislo', From dfd0bbe432b873c6cf2ae50b6b601ac42cb83a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Thu, 25 Jan 2024 09:50:22 +0100 Subject: [PATCH 09/19] use checkboxes instead of radios on place selection --- .../president_vote_app/application_form.rb | 8 ++-- .../application_forms/place.html.erb | 41 +++++++++++-------- .../application_forms/start.html.erb | 3 +- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/app/models/apps/president_vote_app/application_form.rb b/app/models/apps/president_vote_app/application_form.rb index 5693e3e9..32a3716e 100644 --- a/app/models/apps/president_vote_app/application_form.rb +++ b/app/models/apps/president_vote_app/application_form.rb @@ -22,10 +22,10 @@ class ApplicationForm attr_accessor :municipality_email_verified attr_accessor :back - validates_presence_of :place_first_round, message: 'Vyberte si jednu z možností v prvom kole', - on: [:place, :identity, :delivery_address, :authorized_person] - validates_presence_of :place_second_round, message: 'Vyberte si jednu z možností v druhom kole', - on: [:place, :identity, :delivery_address, :authorized_person] + # validates_presence_of :place_first_round, message: 'Vyberte si jednu z možností v prvom kole', + # on: [:place, :identity, :delivery_address, :authorized_person] + # validates_presence_of :place_second_round, message: 'Vyberte si jednu z možností v druhom kole', + # on: [:place, :identity, :delivery_address, :authorized_person] validates_presence_of :sk_citizen, message: 'Vyberte áno pokiaľ ste občan Slovenskej republiky', on: :sk_citizen validates_presence_of :permanent_resident, message: 'Vyberte áno pokiaľ máte trvalý pobyt na Slovensku', on: :permanent_resident diff --git a/app/views/apps/president_vote_app/application_forms/place.html.erb b/app/views/apps/president_vote_app/application_forms/place.html.erb index dede9223..fbc9fa32 100644 --- a/app/views/apps/president_vote_app/application_forms/place.html.erb +++ b/app/views/apps/president_vote_app/application_forms/place.html.erb @@ -7,24 +7,33 @@ <%= render 'apps/president_vote_app/application_forms/back', form: f %> <%= render 'components/error_summary', form: @application_form %> <%= f.hidden_field :step %> - <% hint = 'Prezidentské voľby sa na Slovensku konajú v sobotu 23. marca 2024 (prvé kolo) a 6. apríla 2024 (druhé kolo), od 7:00 do 22:00. Hlasovať je možné jedine osobne na území Slovenska.' %> - <%= f.radios :place, 'Kde plánujete ísť voliť?', hint: hint do %> -

1. kolo

- <% if @application_form.request_sending_first_round_expired? %> - <%= f.hidden_field :place_first_round, :value => 'home' %> -

- Prvé kolo sa už konalo -

- <% else %> - <%= f.radio_button :place_first_round, 'sk', label: "Mimo trvalého bydliska", hint: "Ak ešte neviete, či budete počas volieb v mieste trvalého bydliska, zvoľte si túto možnosť. Budete tak môcť hlasovať kdekoľvek na Slovensku - aj v mieste trvalého bydliska." %> - <%= f.radio_button :place_first_round, 'home', label: "V mieste trvalého bydliska" %> + <% hint = 'Prezidentské voľby sa na Slovensku konajú od 7:00 do 22:00. Hlasovať je možné jedine osobne na území Slovenska.' %> + <% if @application_form.request_sending_first_round_expired? %> + <%= f.radios :place, 'V ktorých kolách plánujete hlasovať mimo trvalého bydliska?', hint: hint do %> +

1. kolo

+ <%= f.hidden_field :place_first_round, :value => 'home' %> +

+ Prvé kolo sa už konalo +

+

2. kolo

+ <%= f.radio_button :place_second_round, 'sk', label: "Mimo trvalého bydliska" %> + <%= f.radio_button :place_second_round, 'home', label: "V mieste trvalého bydliska" %> + + <%= f.submit 'Pokračovať' %> + <% end %> + <% else %> + <%= f.radios :place, 'V ktorých kolách plánujete hlasovať mimo trvalého bydliska?', hint: hint do %> +
+ + +
+
+ + +
+ <%= f.submit 'Pokračovať' %> <% end %> -

2. kolo

- <%= f.radio_button :place_second_round, 'sk', label: "Mimo trvalého bydliska", hint: "Ak ešte neviete, či budete počas volieb v mieste trvalého bydliska, zvoľte si túto možnosť. Budete tak môcť hlasovať kdekoľvek na Slovensku - aj v mieste trvalého bydliska." %> - <%= f.radio_button :place_second_round, 'home', label: "V mieste trvalého bydliska" %> - <%= f.radio_button :place_second_round, 'none', label: "Ešte neviem a nechcem teraz riešiť druhé kolo" %> <% end %> - <%= f.submit 'Pokračovať' %> <% end %>
diff --git a/app/views/apps/president_vote_app/application_forms/start.html.erb b/app/views/apps/president_vote_app/application_forms/start.html.erb index a59a6842..dbacc7a9 100644 --- a/app/views/apps/president_vote_app/application_forms/start.html.erb +++ b/app/views/apps/president_vote_app/application_forms/start.html.erb @@ -3,8 +3,9 @@

Prezidentské voľby

-

Prezidentské voľby na Slovensku budú 23. marca a 6. apríla 2024.

+

Prezidentské voľby na Slovensku budú 23. marca a prípadné druhé kolo 6. apríla 2024.

Ak budete počas volieb mimo trvalého bydliska, táto služba vám pomôže vytvoriť žiadosť o hlasovací preukaz tak, aby ste na nič dôležité nezabudli.

+

Emailovú žiadosť musíte odoslať do 8. marca.

Je to veľmi jednoduché a trvá to len pár minút.

Používaním tejto služby súhlasíte so spracovaním osobných údajov v rozsahu nevyhnutnom pre určenie spôsobu voľby a vytvorenie žiadosti o hlasovací preukaz. Následne sú všetky údaje nenávratne zmazané.

<%= form_for @application_form do |f| %> From 4a95b8666c10ebc6cfd15e8c8a3fc33ab212936d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Thu, 1 Feb 2024 10:02:13 +0100 Subject: [PATCH 10/19] update president app after testing --- .../president_vote_app/application_form.rb | 48 ++++++++++++------- .../application_forms/delivery.html.erb | 4 +- .../application_forms/end.html.erb | 9 +++- .../application_forms/place.html.erb | 11 +++-- .../application_forms/send.html.erb | 9 +--- .../application_forms/start.html.erb | 7 ++- .../application_forms/world.html.erb | 6 +-- 7 files changed, 53 insertions(+), 41 deletions(-) diff --git a/app/models/apps/president_vote_app/application_form.rb b/app/models/apps/president_vote_app/application_form.rb index 32a3716e..69148328 100644 --- a/app/models/apps/president_vote_app/application_form.rb +++ b/app/models/apps/president_vote_app/application_form.rb @@ -1,8 +1,7 @@ module Apps module PresidentVoteApp class ApplicationForm - FIRST_ROUND_DATE = Date.parse(ENV.fetch('APP_PRESIDENT_VOTE_DATE', '2023-09-30')) - REQUEST_SENDING_DEADLINE_DATE = Date.parse(ENV.fetch('APP_PRESIDENT_REQUEST_SENDING_DEADLINE_DATE', '2023-09-08')) + FIRST_ROUND_DATE = Date.parse('2024-03-23') include ActiveModel::Model @@ -22,10 +21,8 @@ class ApplicationForm attr_accessor :municipality_email_verified attr_accessor :back - # validates_presence_of :place_first_round, message: 'Vyberte si jednu z možností v prvom kole', - # on: [:place, :identity, :delivery_address, :authorized_person] - # validates_presence_of :place_second_round, message: 'Vyberte si jednu z možností v druhom kole', - # on: [:place, :identity, :delivery_address, :authorized_person] + validates_presence_of :place_second_round, message: 'Vyberte si jednu z možností v druhom kole', + on: [:place_second_round] validates_presence_of :sk_citizen, message: 'Vyberte áno pokiaľ ste občan Slovenskej republiky', on: :sk_citizen validates_presence_of :permanent_resident, message: 'Vyberte áno pokiaľ máte trvalý pobyt na Slovensku', on: :permanent_resident @@ -71,7 +68,7 @@ class ApplicationForm if: -> (f) { f.custom_delivery_address? } def self.active? - (Date.current - FIRST_ROUND_DATE).to_i < 14 + Date.current < Date.parse('2024-04-06') end def minv_email @@ -79,7 +76,7 @@ def minv_email end def year - FIRST_ROUND_DATE.year + Date.parse('2024-03-23').year end def custom_delivery_address? @@ -120,9 +117,9 @@ def pickup_remaining_days def request_sending_remaining_days if place_first_round == 'sk' - (REQUEST_SENDING_DEADLINE_DATE - Date.current).to_i + (Date.parse('2024-03-04') - Date.current).to_i else - (REQUEST_SENDING_DEADLINE_DATE - Date.current).to_i + 14 + (Date.parse('2024-03-14') - Date.current).to_i end end @@ -131,11 +128,11 @@ def pickup_expired? end def request_sending_first_round_expired? - false + (Date.parse('2024-03-04') - Date.current).to_i < 0 end def request_sending_expired? - Date.current > REQUEST_SENDING_DEADLINE_DATE + request_sending_remaining_days < 0 end def from_slovakia_email_body @@ -252,13 +249,28 @@ def run(listener) self.step = 'permanent_resident' listener.render :permanent_resident elsif valid?(:place) - if place_first_round == 'sk' || place_second_round == 'sk' - self.place_first_round = place_first_round - self.place_second_round = place_second_round - self.step = 'delivery' - listener.render :delivery + if request_sending_first_round_expired? + if valid?(:place_second_round) + if place_second_round == 'sk' + self.place_first_round = 'home' + self.place_second_round = place_second_round + self.step = 'delivery' + listener.render :delivery + else + listener.redirect_to action: :home + end + else + listener.render :place + end else - listener.redirect_to action: :home + if place_first_round == 'sk' || place_second_round == 'sk' + self.place_first_round = place_first_round + self.place_second_round = place_second_round + self.step = 'delivery' + listener.render :delivery + else + listener.redirect_to action: :home + end end else listener.render :place diff --git a/app/views/apps/president_vote_app/application_forms/delivery.html.erb b/app/views/apps/president_vote_app/application_forms/delivery.html.erb index fdf9af29..65f8e6a8 100644 --- a/app/views/apps/president_vote_app/application_forms/delivery.html.erb +++ b/app/views/apps/president_vote_app/application_forms/delivery.html.erb @@ -29,7 +29,7 @@ label: "Nechám si ho poslať poštou", disabled: @application_form.request_sending_expired?, hint: @application_form.request_sending_expired? ? - "Termín na zaslanie žiadosti o hlasovací preukaz uplynul 8.3.2024." : + "Termín na zaslanie žiadosti o hlasovací preukaz už uplynul." : "O hlasovací preukaz môžete požiadať elektronicky (emailom) a bude vám doručený na adresu uvedenú v žiadosti. #{format_remaining_days(@application_form.request_sending_remaining_days)}", strong_label: true %> @@ -37,7 +37,7 @@ label: "Vyzdvihne ho za mňa iná osoba", disabled: @application_form.request_sending_expired?, hint: @application_form.request_sending_expired? ? - "Termín na zaslanie žiadosti o hlasovací preukaz uplynul 22.3.2024." : + "Termín na zaslanie žiadosti o hlasovací preukaz už uplynul." : "Hlasovací preukaz za vás môže vyzdvihnúť aj iná osoba, ktorú uvediete v žiadosti. #{format_remaining_days(@application_form.request_sending_remaining_days)}", strong_label: true %> diff --git a/app/views/apps/president_vote_app/application_forms/end.html.erb b/app/views/apps/president_vote_app/application_forms/end.html.erb index 31a2cba0..059c1491 100644 --- a/app/views/apps/president_vote_app/application_forms/end.html.erb +++ b/app/views/apps/president_vote_app/application_forms/end.html.erb @@ -1,10 +1,12 @@ <%= content_for :title, build_page_title('Notifikácie', 'Prezidentské voľby') %> <%= content_for(:headerline, 'Prezidentské voľby') %> -
+

Počkajte na hlasovací preukaz

Nezabudnite voliť a voľte zodpovedne.

+

Ak ste odoslali žiadosť na úrad, do 3 dní by ste mali od obce dostať potvrdenie o prijatí.

+

Volebný preukaz si so sebou musíte vziať, aj keď sa nakoniec rozhodnete voliť v mieste trvalého bydliska.

@@ -13,8 +15,11 @@ Ak vám do 3 dní nepríde potvrdenie o prijatí žiadosti, kontaktujte obec telefonicky alebo osobne.
+
+
- +
+
<%= render 'apps/president_vote_app/application_forms/subscribe' %>
diff --git a/app/views/apps/president_vote_app/application_forms/place.html.erb b/app/views/apps/president_vote_app/application_forms/place.html.erb index fbc9fa32..600333ff 100644 --- a/app/views/apps/president_vote_app/application_forms/place.html.erb +++ b/app/views/apps/president_vote_app/application_forms/place.html.erb @@ -7,21 +7,22 @@ <%= render 'apps/president_vote_app/application_forms/back', form: f %> <%= render 'components/error_summary', form: @application_form %> <%= f.hidden_field :step %> - <% hint = 'Prezidentské voľby sa na Slovensku konajú od 7:00 do 22:00. Hlasovať je možné jedine osobne na území Slovenska.' %> <% if @application_form.request_sending_first_round_expired? %> - <%= f.radios :place, 'V ktorých kolách plánujete hlasovať mimo trvalého bydliska?', hint: hint do %> + <% hint = 'Druhé kolo prezidentských volieb sa na Slovensku koná 6. apríla od 7:00 do 22:00. Hlasovať je možné jedine osobne na území Slovenska.' %> + <%= f.radios :place, 'Kde plánujete ísť voliť?', hint: hint do %>

1. kolo

<%= f.hidden_field :place_first_round, :value => 'home' %> -

+

Prvé kolo sa už konalo

2. kolo

<%= f.radio_button :place_second_round, 'sk', label: "Mimo trvalého bydliska" %> <%= f.radio_button :place_second_round, 'home', label: "V mieste trvalého bydliska" %> - - <%= f.submit 'Pokračovať' %> <% end %> + + <%= f.submit 'Pokračovať' %> <% else %> + <% hint = 'Prezidentské voľby sa na Slovensku konajú od 7:00 do 22:00. Hlasovať je možné jedine osobne na území Slovenska.' %> <%= f.radios :place, 'V ktorých kolách plánujete hlasovať mimo trvalého bydliska?', hint: hint do %>
diff --git a/app/views/apps/president_vote_app/application_forms/send.html.erb b/app/views/apps/president_vote_app/application_forms/send.html.erb index 0570f56b..a6a09836 100644 --- a/app/views/apps/president_vote_app/application_forms/send.html.erb +++ b/app/views/apps/president_vote_app/application_forms/send.html.erb @@ -7,7 +7,7 @@
<% if @application_form.municipality_email.present? %> -

Vygenorovanú žiadosť potrebujete poslať z Vašej emailovej adresy na príslušnú adresu obce: +

Vygenerovanú žiadosť potrebujete poslať z Vašej emailovej adresy na príslušnú adresu obce: <%= mail_to @application_form.municipality_email, @application_form.municipality_email, target: '_blank', body: @application_form.from_slovakia_email_body, @@ -15,7 +15,7 @@ %>

<% else %> -

Vygenorovanú žiadosť potrebujete poslať z Vašej emailovej adresy na príslušnú emailovú adresu obce +

Vygenerovanú žiadosť potrebujete poslať z Vašej emailovej adresy na príslušnú emailovú adresu obce <%= @application_form.municipality %>

Emailovú adresu je možné nájsť na webovej stránke obce.

<% end %> @@ -35,11 +35,6 @@
<%= button_tag 'Skopírovať text', class: 'govuk-button light-button', onclick: 'copyToClipboard("emailContent")' %> - <%= mail_to @application_form.municipality_email, "Poslať emailovým klientom", - target: '_blank', - body: @application_form.from_slovakia_email_body, - subject: 'Žiadosť o hlasovací preukaz do prezidentských volieb.' - %>
diff --git a/app/views/apps/president_vote_app/application_forms/start.html.erb b/app/views/apps/president_vote_app/application_forms/start.html.erb index dbacc7a9..9efa0f4b 100644 --- a/app/views/apps/president_vote_app/application_forms/start.html.erb +++ b/app/views/apps/president_vote_app/application_forms/start.html.erb @@ -3,10 +3,9 @@

Prezidentské voľby

-

Prezidentské voľby na Slovensku budú 23. marca a prípadné druhé kolo 6. apríla 2024.

-

Ak budete počas volieb mimo trvalého bydliska, táto služba vám pomôže vytvoriť žiadosť o hlasovací preukaz tak, aby ste na nič dôležité nezabudli.

-

Emailovú žiadosť musíte odoslať do 8. marca.

-

Je to veľmi jednoduché a trvá to len pár minút.

+

Prezidentské voľby na Slovensku budú 23. marca a prípadné druhé kolo 6. apríla 2024. Hlasovať je možné jedine osobne na území Slovenska.

+

Ak budete počas volieb mimo trvalého bydliska, táto služba vám pomôže vytvoriť žiadosť o hlasovací preukaz tak, aby ste na nič dôležité nezabudli. Je to veľmi jednoduché a trvá to len pár minút.

+

Žiadosť musíte následne sami odoslať emailom do 4. marca.

Používaním tejto služby súhlasíte so spracovaním osobných údajov v rozsahu nevyhnutnom pre určenie spôsobu voľby a vytvorenie žiadosti o hlasovací preukaz. Následne sú všetky údaje nenávratne zmazané.

<%= form_for @application_form do |f| %>
diff --git a/app/views/apps/president_vote_app/application_forms/world.html.erb b/app/views/apps/president_vote_app/application_forms/world.html.erb index d41636f0..a53ab283 100644 --- a/app/views/apps/president_vote_app/application_forms/world.html.erb +++ b/app/views/apps/president_vote_app/application_forms/world.html.erb @@ -8,9 +8,9 @@ <%= f.hidden_field :step, :value => 'world_abroad_permanent_resident' %> <% end %> -

Ak máte odhlásený trvalý pobyt zo Slovenska, môžete voliť v ktoromkoľvek volebnom okrsku

-

Občan Slovenskej republiky, ktorý nemá trvalý pobyt na území Slovenskej republiky, môže svoj hlas uplatniť v ktorejkoľvek volebnej miestnosti. Preukáže svoju totožnosť predložením slovenského cestovného dokladu a vyplní čestné vyhlásenie, ktoré mu poskytne komisia.

-

Okrsková volebná komisia takéhoto voliča dopíše do zoznamu voličov, čo zaznamená v jeho slovenskom cestovnom doklade, a čestné vyhlásenie o trvalom pobyte v cudzine pripojí k zoznamu voličov.

+

Ak máte odhlásený trvalý pobyt, môžete voliť v ktoromkoľvek volebnom okrsku na Slovensku

+

Ak nemáte trvalý pobyt na Slovensku, môžete prísť voliť kdekoľvek na území Slovenska. Potrebujete sa preukázať slovenským pasom.

+

Okrsková volebná komisia takéhoto voliča dopíše do zoznamu voličov, čo zaznamená v jeho slovenskom cestovnom doklade a postkyne mu na podpis čestné vyhlásenie o trvalom pobyte v cudzine, ktoré pripojí k zoznamu voličov.

<%= render 'apps/president_vote_app/application_forms/subscribe' %>
From d36470b22143946b3f0cb5f3fc410fba2a688853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Thu, 1 Feb 2024 13:39:02 +0100 Subject: [PATCH 11/19] minor wording update --- .../president_vote_app/application_forms/start.html.erb | 2 +- .../president_vote_app/application_forms/world.html.erb | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/apps/president_vote_app/application_forms/start.html.erb b/app/views/apps/president_vote_app/application_forms/start.html.erb index 9efa0f4b..3d3f442f 100644 --- a/app/views/apps/president_vote_app/application_forms/start.html.erb +++ b/app/views/apps/president_vote_app/application_forms/start.html.erb @@ -5,7 +5,7 @@

Prezidentské voľby

Prezidentské voľby na Slovensku budú 23. marca a prípadné druhé kolo 6. apríla 2024. Hlasovať je možné jedine osobne na území Slovenska.

Ak budete počas volieb mimo trvalého bydliska, táto služba vám pomôže vytvoriť žiadosť o hlasovací preukaz tak, aby ste na nič dôležité nezabudli. Je to veľmi jednoduché a trvá to len pár minút.

-

Žiadosť musíte následne sami odoslať emailom do 4. marca.

+

Žiadosť musíte následne sami odoslať emailom do 4. marca.

Používaním tejto služby súhlasíte so spracovaním osobných údajov v rozsahu nevyhnutnom pre určenie spôsobu voľby a vytvorenie žiadosti o hlasovací preukaz. Následne sú všetky údaje nenávratne zmazané.

<%= form_for @application_form do |f| %>
diff --git a/app/views/apps/president_vote_app/application_forms/world.html.erb b/app/views/apps/president_vote_app/application_forms/world.html.erb index a53ab283..381e9486 100644 --- a/app/views/apps/president_vote_app/application_forms/world.html.erb +++ b/app/views/apps/president_vote_app/application_forms/world.html.erb @@ -10,8 +10,11 @@

Ak máte odhlásený trvalý pobyt, môžete voliť v ktoromkoľvek volebnom okrsku na Slovensku

Ak nemáte trvalý pobyt na Slovensku, môžete prísť voliť kdekoľvek na území Slovenska. Potrebujete sa preukázať slovenským pasom.

-

Okrsková volebná komisia takéhoto voliča dopíše do zoznamu voličov, čo zaznamená v jeho slovenskom cestovnom doklade a postkyne mu na podpis čestné vyhlásenie o trvalom pobyte v cudzine, ktoré pripojí k zoznamu voličov.

- +

Okrsková volebná komisia takéhoto voliča dopíše do zoznamu voličov, čo zaznamená v jeho slovenskom cestovnom doklade a poskytne mu na podpis čestné vyhlásenie o trvalom pobyte v cudzine, ktoré pripojí k zoznamu voličov.

+
+
+
+
<%= render 'apps/president_vote_app/application_forms/subscribe' %>
From 43fdea78ae18bec589c8a8f91cb94845fe971e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Thu, 8 Feb 2024 10:13:50 +0100 Subject: [PATCH 12/19] add minor text hint to place selection --- .../apps/president_vote_app/application_forms/place.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/apps/president_vote_app/application_forms/place.html.erb b/app/views/apps/president_vote_app/application_forms/place.html.erb index 600333ff..601b9e19 100644 --- a/app/views/apps/president_vote_app/application_forms/place.html.erb +++ b/app/views/apps/president_vote_app/application_forms/place.html.erb @@ -22,7 +22,7 @@ <%= f.submit 'Pokračovať' %> <% else %> - <% hint = 'Prezidentské voľby sa na Slovensku konajú od 7:00 do 22:00. Hlasovať je možné jedine osobne na území Slovenska.' %> + <% hint = 'Prezidentské voľby sa na Slovensku konajú od 7:00 do 22:00. Zvoľte, či budete hlasovať mimo trvalého bydliska v prvom, druhom, alebo v oboch kolách.' %> <%= f.radios :place, 'V ktorých kolách plánujete hlasovať mimo trvalého bydliska?', hint: hint do %>
From 43b07f8cf9a526c36330782c27f5387824a85efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Thu, 8 Feb 2024 10:57:35 +0100 Subject: [PATCH 13/19] revert unwanted changes --- .env.sample | 4 ---- Gemfile | 2 -- Gemfile.lock | 7 ------- 3 files changed, 13 deletions(-) diff --git a/.env.sample b/.env.sample index aa727517..85e7c2c9 100644 --- a/.env.sample +++ b/.env.sample @@ -15,10 +15,6 @@ APP_PARLIAMENT_PICKUP_DEADLINE_DATE= APP_PARLIAMENT_VOTE_BY_POST_DEADLINE_DATE= APP_PARLIAMENT_REQUEST_SENDING_DEADLINE_DATE= -APP_PRESIDENT_VOTE_DATE= -APP_PRESIDENT_PICKUP_DEADLINE_DATE= -APP_PRESIDENT_REQUEST_SENDING_DEADLINE_DATE= - DEFAULT_EMAIL_FROM=navody@digital AUTOFORM_URL= diff --git a/Gemfile b/Gemfile index 04ad906b..661419ff 100644 --- a/Gemfile +++ b/Gemfile @@ -94,8 +94,6 @@ group :development do gem 'spring-watcher-listen' gem 'letter_opener_web' gem 'wdm', '~> 0.1.0', platforms: [:mingw, :mswin, :x64_mingw] - gem 'ruby-debug-ide' - gem 'debase' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 6483518d..b98bce40 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -129,9 +129,6 @@ GEM css_parser (1.14.0) addressable date (3.3.3) - debase (0.2.5.beta2) - debase-ruby_core_source (>= 0.10.12) - debase-ruby_core_source (3.2.2) diff-lcs (1.5.0) docile (1.4.0) domain_name (0.5.20190701) @@ -369,8 +366,6 @@ GEM rspec-support (3.12.0) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - ruby-debug-ide (0.7.3) - rake (>= 0.8.1) ruby2_keywords (0.0.5) rubyzip (2.3.2) sass-rails (6.0.0) @@ -472,7 +467,6 @@ DEPENDENCIES byebug capybara (~> 3.39.2) clockwork - debase dotenv-rails exception_handler factory_bot_rails @@ -506,7 +500,6 @@ DEPENDENCIES rollbar rspec-rails (= 4.0.2) rspec_junit_formatter - ruby-debug-ide sass-rails selenium-webdriver (~> 4.9.0) show_me_the_cookies From 7340d0bd7811f55a917e2f86a1e6d40a2bf2469a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Thu, 8 Feb 2024 11:27:46 +0100 Subject: [PATCH 14/19] rm email client button from auth person send --- .../application_forms/authorized_person_send.html.erb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/views/apps/president_vote_app/application_forms/authorized_person_send.html.erb b/app/views/apps/president_vote_app/application_forms/authorized_person_send.html.erb index bad40a0b..e47ae8a5 100644 --- a/app/views/apps/president_vote_app/application_forms/authorized_person_send.html.erb +++ b/app/views/apps/president_vote_app/application_forms/authorized_person_send.html.erb @@ -40,11 +40,6 @@
<%= button_tag 'Skopírovať text', class: 'govuk-button light-button', onclick: 'copyToClipboard("emailContent")' %> - <%= mail_to @application_form.municipality_email, "Poslať emailovým klientom", - target: '_blank', - body: @application_form.from_slovakia_authorized_person_email_body, - subject: 'Žiadosť o hlasovací preukaz do prezidentských volieb.' - %>
From 08b639aad1072da1cb00fd41e43d2b1ff71ce22b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Thu, 8 Feb 2024 13:05:42 +0100 Subject: [PATCH 15/19] add tests and refactor a bit --- .../president_vote_app/application_form.rb | 18 +- .../application_forms/place.html.erb | 2 +- spec/features/apps/president_vote_app_spec.rb | 220 ++++++++++++++++++ 3 files changed, 233 insertions(+), 7 deletions(-) create mode 100644 spec/features/apps/president_vote_app_spec.rb diff --git a/app/models/apps/president_vote_app/application_form.rb b/app/models/apps/president_vote_app/application_form.rb index 69148328..70efb61b 100644 --- a/app/models/apps/president_vote_app/application_form.rb +++ b/app/models/apps/president_vote_app/application_form.rb @@ -2,6 +2,8 @@ module Apps module PresidentVoteApp class ApplicationForm FIRST_ROUND_DATE = Date.parse('2024-03-23') + FIRST_ROUND_REQUEST_SENDING_DEADLINE = FIRST_ROUND_DATE - 19.day + SECOND_ROUND_REQUEST_SENDING_DEADLINE = FIRST_ROUND_DATE - 9.day include ActiveModel::Model @@ -68,7 +70,7 @@ class ApplicationForm if: -> (f) { f.custom_delivery_address? } def self.active? - Date.current < Date.parse('2024-04-06') + Date.current < FIRST_ROUND_DATE + 14.day end def minv_email @@ -76,7 +78,7 @@ def minv_email end def year - Date.parse('2024-03-23').year + FIRST_ROUND_DATE.year end def custom_delivery_address? @@ -117,9 +119,9 @@ def pickup_remaining_days def request_sending_remaining_days if place_first_round == 'sk' - (Date.parse('2024-03-04') - Date.current).to_i + (FIRST_ROUND_REQUEST_SENDING_DEADLINE - Date.current).to_i else - (Date.parse('2024-03-14') - Date.current).to_i + (SECOND_ROUND_REQUEST_SENDING_DEADLINE - Date.current).to_i end end @@ -128,7 +130,11 @@ def pickup_expired? end def request_sending_first_round_expired? - (Date.parse('2024-03-04') - Date.current).to_i < 0 + (FIRST_ROUND_REQUEST_SENDING_DEADLINE - Date.current).to_i < 0 + end + + def first_round_expired? + (FIRST_ROUND_DATE - Date.current).to_i < 1 end def request_sending_expired? @@ -249,7 +255,7 @@ def run(listener) self.step = 'permanent_resident' listener.render :permanent_resident elsif valid?(:place) - if request_sending_first_round_expired? + if first_round_expired? if valid?(:place_second_round) if place_second_round == 'sk' self.place_first_round = 'home' diff --git a/app/views/apps/president_vote_app/application_forms/place.html.erb b/app/views/apps/president_vote_app/application_forms/place.html.erb index 601b9e19..428787a3 100644 --- a/app/views/apps/president_vote_app/application_forms/place.html.erb +++ b/app/views/apps/president_vote_app/application_forms/place.html.erb @@ -7,7 +7,7 @@ <%= render 'apps/president_vote_app/application_forms/back', form: f %> <%= render 'components/error_summary', form: @application_form %> <%= f.hidden_field :step %> - <% if @application_form.request_sending_first_round_expired? %> + <% if @application_form.first_round_expired? %> <% hint = 'Druhé kolo prezidentských volieb sa na Slovensku koná 6. apríla od 7:00 do 22:00. Hlasovať je možné jedine osobne na území Slovenska.' %> <%= f.radios :place, 'Kde plánujete ísť voliť?', hint: hint do %>

1. kolo

diff --git a/spec/features/apps/president_vote_app_spec.rb b/spec/features/apps/president_vote_app_spec.rb new file mode 100644 index 00000000..2f34c613 --- /dev/null +++ b/spec/features/apps/president_vote_app_spec.rb @@ -0,0 +1,220 @@ +require 'rails_helper' +require_relative '../../../app/models/apps/president_vote_app/application_form' + +def start + visit apps_president_vote_app_application_forms_path + click_button 'Súhlasím a chcem začať' +end + +RSpec.feature "President vote app", type: :feature do + before do + travel_to Apps::PresidentVoteApp::ApplicationForm::FIRST_ROUND_DATE - 2.months + end + + scenario 'As a citizen I want to vote in a different voting district in first round' do + start + + choose 'Áno' + click_button 'Pokračovať' + + choose 'Áno' + click_button 'Pokračovať' + + check 'apps_president_vote_app_application_form[place_first_round]' + click_button 'Pokračovať' + + expect(page).to have_content('Potrebujete požiadať o hlasovací preukaz pre prvé kolo volieb') + expect(page).to have_content('Aby ste mohli v deň volieb voliť mimo vášho trvalého bydliska, musíte požiadať vašu obec o vydanie hlasovacieho preukazu – osobne alebo elektronicky. Hlasovací preukaz vás oprávňuje voliť z ktoréhokoľvek volebného okrsku v SR.') + expect(page).to have_content('Ako prevezmete hlasovací preukaz?') + expect(page).to have_content('Nechám si ho poslať poštou') + expect(page).to have_content('Vyzdvihne ho za mňa iná osoba') + expect(page).to have_content('Vyzdvihnem ho osobne na úrade') + end + + scenario 'As a citizen I want to vote in a different voting district in second round' do + start + + choose 'Áno' + click_button 'Pokračovať' + + choose 'Áno' + click_button 'Pokračovať' + + check 'apps_president_vote_app_application_form[place_second_round]' + click_button 'Pokračovať' + + expect(page).to have_content('Potrebujete požiadať o hlasovací preukaz pre druhé kolo volieb') + expect(page).to have_content('Aby ste mohli v deň volieb voliť mimo vášho trvalého bydliska, musíte požiadať vašu obec o vydanie hlasovacieho preukazu – osobne alebo elektronicky. Hlasovací preukaz vás oprávňuje voliť z ktoréhokoľvek volebného okrsku v SR.') + expect(page).to have_content('Ako prevezmete hlasovací preukaz?') + expect(page).to have_content('Nechám si ho poslať poštou') + expect(page).to have_content('Vyzdvihne ho za mňa iná osoba') + expect(page).to have_content('Vyzdvihnem ho osobne na úrade') + end + + scenario 'As a citizen I want to vote in a different voting district in both rounds' do + start + + choose 'Áno' + click_button 'Pokračovať' + + choose 'Áno' + click_button 'Pokračovať' + + check 'apps_president_vote_app_application_form[place_first_round]' + check 'apps_president_vote_app_application_form[place_second_round]' + click_button 'Pokračovať' + + expect(page).to have_content('Potrebujete požiadať o hlasovací preukaz pre obe kolá volieb') + expect(page).to have_content('Aby ste mohli v deň volieb voliť mimo vášho trvalého bydliska, musíte požiadať vašu obec o vydanie hlasovacieho preukazu – osobne alebo elektronicky. Hlasovací preukaz vás oprávňuje voliť z ktoréhokoľvek volebného okrsku v SR.') + expect(page).to have_content('Ako prevezmete hlasovací preukaz?') + expect(page).to have_content('Nechám si ho poslať poštou') + expect(page).to have_content('Vyzdvihne ho za mňa iná osoba') + expect(page).to have_content('Vyzdvihnem ho osobne na úrade') + end + + scenario 'As a citizen I want to vote in a different voting district and it is already past first round' do + travel_to Apps::PresidentVoteApp::ApplicationForm::FIRST_ROUND_DATE + 8.day + start + + choose 'Áno' + click_button 'Pokračovať' + + choose 'Áno' + click_button 'Pokračovať' + + expect(page).to have_content('Prvé kolo sa už konalo') + choose 'Mimo trvalého bydliska' + click_button 'Pokračovať' + + expect(page).to have_content('Potrebujete požiadať o hlasovací preukaz pre druhé kolo volieb') + expect(page).to have_content('Aby ste mohli v deň volieb voliť mimo vášho trvalého bydliska, musíte požiadať vašu obec o vydanie hlasovacieho preukazu – osobne alebo elektronicky. Hlasovací preukaz vás oprávňuje voliť z ktoréhokoľvek volebného okrsku v SR.') + expect(page).to have_content('Ako prevezmete hlasovací preukaz?') + expect(page).to have_content('Nechám si ho poslať poštou') + expect(page).to have_content('Vyzdvihne ho za mňa iná osoba') + expect(page).to have_content('Vyzdvihnem ho osobne na úrade') + end + + scenario 'As a citizen I want to request voting permit personally after the deadline' do + travel_to Apps::PresidentVoteApp::ApplicationForm::FIRST_ROUND_DATE - 2.day + start + choose 'Áno' + click_button 'Pokračovať' + + choose 'Áno' + click_button 'Pokračovať' + + check 'apps_president_vote_app_application_form[place_first_round]' + click_button 'Pokračovať' + + expect(page).to have_field('Vyzdvihne ho za mňa iná osoba', disabled: true) + expect(page).to have_field('Vyzdvihnem ho osobne na úrade', disabled: false) + end + + scenario 'As a citizen I want to request voting permit by authorized person after the deadline' do + travel_to Apps::PresidentVoteApp::ApplicationForm::FIRST_ROUND_DATE + 1.day + start + choose 'Áno' + click_button 'Pokračovať' + + choose 'Áno' + click_button 'Pokračovať' + + choose 'Mimo trvalého bydliska' + click_button 'Pokračovať' + + expect(page).to have_field('Vyzdvihne ho za mňa iná osoba', disabled: true) + end + + scenario 'As a citizen I want to request voting permit by post after the deadline' do + travel_to Apps::PresidentVoteApp::ApplicationForm::FIRST_ROUND_DATE + 1.day + start + choose 'Áno' + click_button 'Pokračovať' + + choose 'Áno' + click_button 'Pokračovať' + + choose 'Mimo trvalého bydliska' + click_button 'Pokračovať' + + expect(page).to have_field('Nechám si ho poslať poštou', disabled: true) + end + + scenario 'As a citizen I want to request voting permit personally' do + start + choose 'Áno' + click_button 'Pokračovať' + + choose 'Áno' + click_button 'Pokračovať' + + check 'apps_president_vote_app_application_form[place_first_round]' + click_button 'Pokračovať' + + choose 'Vyzdvihnem ho osobne' + click_button 'Pokračovať' + + expect(page).to have_content('Prevzatie hlasovacieho preukazu osobne') + end + + scenario 'As a citizen I want to request voting permit via authorized person' do + start + choose 'Áno' + click_button 'Pokračovať' + + choose 'Áno' + click_button 'Pokračovať' + + check 'apps_president_vote_app_application_form[place_first_round]' + check 'apps_president_vote_app_application_form[place_second_round]' + click_button 'Pokračovať' + + choose 'Vyzdvihne ho za mňa iná osoba' + click_button 'Pokračovať' + + fill_in 'Meno, priezvisko, titul', with: 'Ferko Mrkva', class: 'person' + fill_in 'Rodné číslo', with: '600101/1973', class: 'person' + fill_in 'Ulica', with: 'Pupavova 31' + fill_in 'PSČ', with: '456' + fill_in 'Obec', with: 'Bratislava - Karlova ves' + fill_in 'Meno, priezvisko, titul', with: 'Jarko Mrkva', class: 'authorized-person' + fill_in 'Číslo občianskeho preukazu', with: '567', class: 'authorized-person' + click_button 'Pokračovať' + + expect(page).to have_content('Meno: Ferko Mrkva') + expect(page).to have_content('Rodné číslo: 600101/1973') + expect(page).to have_content('Trvalý pobyt: Pupavova 31, 456 Bratislava - Karlova ves') + expect(page).to have_content("Preukaz vyzdvihne splnomocnená osoba:\r \r Meno: Jarko Mrkva\r Číslo občianskeho preukazu: 567") + + check 'Poslal/a som žiadosť zo svojho emailu na úrad' + end + + scenario 'As a citizen I want to vote at home address' do + start + choose 'Áno' + click_button 'Pokračovať' + + choose 'Áno' + click_button 'Pokračovať' + + click_button 'Pokračovať' + + expect(page).to have_content('Nepotrebujete nič vybavovať') + end + + scenario "As a non-SK citizen I can't vote in president votes" do + start + choose 'Nie' + click_button 'Pokračovať' + + expect(page).to have_content('môžu voliť len občania Slovenskej republiky.') + end + + scenario 'As a citizen I want to see subscription options when vote is not active' do + travel_to Apps::PresidentVoteApp::ApplicationForm::FIRST_ROUND_DATE + 15.day + visit apps_president_vote_app_application_forms_path + + expect(page).to have_content('Prezidentské voľby sa už konali') + expect(page).to have_content('Chcem dostávať upozornenia k voľbám') + end +end From 48a7b6484f4dd538348d1dc0d7fa0090be6877ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Thu, 8 Feb 2024 13:08:31 +0100 Subject: [PATCH 16/19] rm unused code --- app/models/apps/president_vote_app/application_form.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/apps/president_vote_app/application_form.rb b/app/models/apps/president_vote_app/application_form.rb index 70efb61b..56a18ec6 100644 --- a/app/models/apps/president_vote_app/application_form.rb +++ b/app/models/apps/president_vote_app/application_form.rb @@ -129,10 +129,6 @@ def pickup_expired? pickup_remaining_days < 1 end - def request_sending_first_round_expired? - (FIRST_ROUND_REQUEST_SENDING_DEADLINE - Date.current).to_i < 0 - end - def first_round_expired? (FIRST_ROUND_DATE - Date.current).to_i < 1 end From 3746e635d86d5e6d898a342941e7ae530572a044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Thu, 8 Feb 2024 14:04:52 +0100 Subject: [PATCH 17/19] magically fix parliament vote app tests --- .../features/apps/parliament_vote_app_spec.rb | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/spec/features/apps/parliament_vote_app_spec.rb b/spec/features/apps/parliament_vote_app_spec.rb index a178efb0..c9fd624c 100644 --- a/spec/features/apps/parliament_vote_app_spec.rb +++ b/spec/features/apps/parliament_vote_app_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -require_relative '../../../app/models/apps/ep_vote_app/application_form' +require_relative '../../../app/models/apps/parliament_vote_app/application_form' -def start +def start_parliament_vote_app visit apps_parliament_vote_app_application_forms_path click_button 'Súhlasím a chcem začať' end @@ -12,7 +12,7 @@ def start end scenario 'As a citizen I want to vote in a different voting district' do - start + start_parliament_vote_app choose 'Áno' click_button 'Pokračovať' @@ -33,7 +33,7 @@ def start scenario 'As a citizen I want to request voting permit personally after the deadline' do travel_to Apps::ParliamentVoteApp::ApplicationForm::PICKUP_DEADLINE_DATE + 1.day - start + start_parliament_vote_app choose 'Áno' click_button 'Pokračovať' @@ -48,7 +48,7 @@ def start scenario 'As a citizen I want to request voting permit by authorized person after the deadline' do travel_to Apps::ParliamentVoteApp::ApplicationForm::PICKUP_DEADLINE_DATE + 1.day - start + start_parliament_vote_app choose 'Áno' click_button 'Pokračovať' @@ -63,7 +63,7 @@ def start scenario 'As a citizen I want to request voting permit by post after the deadline' do travel_to Apps::ParliamentVoteApp::ApplicationForm::DELIVERY_BY_POST_DEADLINE_DATE + 1.day - start + start_parliament_vote_app choose 'Áno' click_button 'Pokračovať' @@ -78,7 +78,7 @@ def start scenario 'As a pernament citizen with I want to vote by post after the deadline' do travel_to Apps::ParliamentVoteApp::ApplicationForm::VOTE_BY_POST_DEADLINE_DATE + 1.day - start + start_parliament_vote_app choose 'Áno' click_button 'Pokračovať' @@ -93,7 +93,7 @@ def start scenario 'As a abroad citizen I want to vote by post after the deadline' do travel_to Apps::ParliamentVoteApp::ApplicationForm::VOTE_BY_POST_DEADLINE_DATE + 1.day - start + start_parliament_vote_app choose 'Áno' click_button 'Pokračovať' @@ -104,7 +104,7 @@ def start end scenario 'As a citizen I want to request voting permit personally' do - start + start_parliament_vote_app choose 'Áno' click_button 'Pokračovať' @@ -121,7 +121,7 @@ def start end scenario 'As a citizen I want to request voting permit via authorized person' do - start + start_parliament_vote_app choose 'Áno' click_button 'Pokračovať' @@ -152,7 +152,7 @@ def start end scenario 'As a citizen I want to vote at home address' do - start + start_parliament_vote_app choose 'Áno' click_button 'Pokračovať' @@ -166,7 +166,7 @@ def start end scenario 'As a citizen I want to vote in foregin country with permanent residency in Slovakia' do - start + start_parliament_vote_app choose 'Áno' click_button 'Pokračovať' @@ -184,7 +184,7 @@ def start end scenario 'As a citizen I want to vote in foregin country with permanent residency outside Slovakia' do - start + start_parliament_vote_app choose 'Áno' click_button 'Pokračovať' @@ -199,7 +199,7 @@ def start end scenario "As a non-SK citizen I can't vote in parliament votes" do - start + start_parliament_vote_app choose 'Nie' click_button 'Pokračovať' From 167191b73ee0dd2116b6badc7c7464125b1ab3c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Thu, 8 Feb 2024 14:22:14 +0100 Subject: [PATCH 18/19] make checkbox labels clickable --- .../apps/president_vote_app/application_forms/place.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/apps/president_vote_app/application_forms/place.html.erb b/app/views/apps/president_vote_app/application_forms/place.html.erb index 428787a3..f61793ea 100644 --- a/app/views/apps/president_vote_app/application_forms/place.html.erb +++ b/app/views/apps/president_vote_app/application_forms/place.html.erb @@ -26,11 +26,11 @@ <%= f.radios :place, 'V ktorých kolách plánujete hlasovať mimo trvalého bydliska?', hint: hint do %>
- +
- +
<%= f.submit 'Pokračovať' %> <% end %> From 8da0cb2b38bc9d7fe09e8be2afd30aca06796a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Thu, 8 Feb 2024 14:46:58 +0100 Subject: [PATCH 19/19] fix conditionally revealing address option --- .../application_forms/delivery_address.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/apps/president_vote_app/application_forms/delivery_address.html.erb b/app/views/apps/president_vote_app/application_forms/delivery_address.html.erb index 0a8aea8c..4bf27233 100644 --- a/app/views/apps/president_vote_app/application_forms/delivery_address.html.erb +++ b/app/views/apps/president_vote_app/application_forms/delivery_address.html.erb @@ -22,7 +22,7 @@
<%= f.error_message :same_delivery_address %> -
+
<%= f.radio_button :same_delivery_address, '1', label: "Na adresu trvalého bydliska", hint: @application_form.full_address%> <%= f.radio_button :same_delivery_address, '0', label: "Na inú adresu", data: {'aria-controls' => 'conditional-delivery-address'}%>