From 1a143dfe0f894bbd8651e1d2273072ce23175048 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Tue, 25 Oct 2016 16:21:52 +0200 Subject: [PATCH 01/56] adds style for selection --- app/assets/stylesheets/layout.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index c180735eb..d850454d6 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -23,6 +23,11 @@ // 01. Global styles // ----------------- +::selection { + color: white; + background-color: $brand; +} + body { font-size: $base-font-size; } From 5c1e1f96ea4981ae0bbfe342ec53db6786ba981c Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Tue, 25 Oct 2016 16:23:45 +0200 Subject: [PATCH 02/56] deletes unused wrap class --- app/assets/stylesheets/layout.scss | 4 ---- app/views/debates/index.html.erb | 2 +- app/views/management/proposals/index.html.erb | 2 +- app/views/management/spending_proposals/index.html.erb | 2 +- app/views/proposals/index.html.erb | 2 +- app/views/proposals/summary.html.erb | 2 +- app/views/spending_proposals/index.html.erb | 2 +- 7 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index d850454d6..8052513fc 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -153,10 +153,6 @@ a { height: 100%; } -.wrap { - background: white; -} - .footer, .push { clear: both; min-height: $line-height*12; diff --git a/app/views/debates/index.html.erb b/app/views/debates/index.html.erb index 22d628c65..2cd3f2d53 100644 --- a/app/views/debates/index.html.erb +++ b/app/views/debates/index.html.erb @@ -6,7 +6,7 @@ <% end %>
-
+
diff --git a/app/views/management/proposals/index.html.erb b/app/views/management/proposals/index.html.erb index e7966f0c5..fde056902 100644 --- a/app/views/management/proposals/index.html.erb +++ b/app/views/management/proposals/index.html.erb @@ -1,7 +1,7 @@
<%= render 'admin/shared/proposal_search', url: management_proposals_path %> -
+
diff --git a/app/views/management/spending_proposals/index.html.erb b/app/views/management/spending_proposals/index.html.erb index 49e4151d2..2178caf71 100644 --- a/app/views/management/spending_proposals/index.html.erb +++ b/app/views/management/spending_proposals/index.html.erb @@ -3,7 +3,7 @@ <%= render 'admin/shared/spending_proposal_search', url: management_spending_proposals_path %> -
+
diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb index 5efa3e24c..df9339619 100644 --- a/app/views/proposals/index.html.erb +++ b/app/views/proposals/index.html.erb @@ -6,7 +6,7 @@ <% end %>
-
+
diff --git a/app/views/proposals/summary.html.erb b/app/views/proposals/summary.html.erb index 38c56c963..d5bc22196 100644 --- a/app/views/proposals/summary.html.erb +++ b/app/views/proposals/summary.html.erb @@ -1,5 +1,5 @@
-
+
<%= render "shared/back_link" %> diff --git a/app/views/spending_proposals/index.html.erb b/app/views/spending_proposals/index.html.erb index 563b84e23..4e95fd8db 100644 --- a/app/views/spending_proposals/index.html.erb +++ b/app/views/spending_proposals/index.html.erb @@ -6,7 +6,7 @@ <% end %>
-
+
From 08db2faf86ef12238f9cfd28ae63077a6a42e445 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Tue, 25 Oct 2016 16:30:36 +0200 Subject: [PATCH 03/56] fixes breakpoint on mixins --- app/assets/stylesheets/mixins.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/mixins.scss b/app/assets/stylesheets/mixins.scss index d772b8ace..5ffc534cb 100644 --- a/app/assets/stylesheets/mixins.scss +++ b/app/assets/stylesheets/mixins.scss @@ -13,7 +13,7 @@ font-size: rem-calc(24); font-weight: lighter; - @include breakpoint(small) { + @include breakpoint(medium) { line-height: $line-height*2; margin-top: 0; } @@ -22,7 +22,7 @@ height: 48px; width: 48px; - @include breakpoint(small) { + @include breakpoint(medium) { height: 80px; margin-right: $line-height/2; margin-top: 0; From 4979b6859a24ce00eb8849e7968914c76b8f3c26 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 26 Oct 2016 00:34:23 +0200 Subject: [PATCH 04/56] updates minor version dependencies --- Gemfile | 32 ++++++++++----------- Gemfile.lock | 81 ++++++++++++++++++++++++++-------------------------- 2 files changed, 56 insertions(+), 57 deletions(-) diff --git a/Gemfile b/Gemfile index e61e92e25..665421ce2 100644 --- a/Gemfile +++ b/Gemfile @@ -3,24 +3,24 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.7.1' # Use PostgreSQL -gem 'pg' +gem 'pg', '0.19.0' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0', '>= 5.0.4' # Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' +gem 'uglifier', '>= 3.0.3' # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2.1' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library -gem 'jquery-rails' +gem 'jquery-rails', '4.2.1' gem 'jquery-ui-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' # Fix sprockets on the -gem 'sprockets', '~> 3.6.3' +gem 'sprockets', '~> 3.7.0' gem 'devise', '~> 3.5.7' gem 'devise_security_extension' @@ -32,11 +32,11 @@ gem 'omniauth-facebook', '~> 3.0.0' gem 'omniauth-google-oauth2', '~> 0.4.0' gem 'kaminari' -gem 'ancestry' +gem 'ancestry', '2.2.1' gem 'acts-as-taggable-on' -gem 'responders' -gem 'foundation-rails' -gem 'foundation_rails_helper' +gem 'responders', '2.3.0' +gem 'foundation-rails', '6.2.4.0' +gem 'foundation_rails_helper', '2.0.0' gem 'acts_as_votable' gem 'ckeditor', '~> 4.2.0' gem 'invisible_captcha', '~> 0.9.1' @@ -44,24 +44,24 @@ gem 'cancancan' gem 'social-share-button' gem 'initialjs-rails', '0.2.0.4' gem 'unicorn', '~> 5.1.0' -gem 'paranoia' -gem 'rinku', require: 'rails_rinku' +gem 'paranoia', '2.2.0' +gem 'rinku', '2.0.2', require: 'rails_rinku' gem 'savon' gem 'dalli' -gem 'rollbar', '~> 2.12.0' +gem 'rollbar', '~> 2.13.3' gem 'delayed_job_active_record', '~> 4.1.0' gem 'daemons' gem 'devise-async' -gem 'newrelic_rpm', '~> 3.16' +gem 'newrelic_rpm', '~> 3.17.0.325' gem 'whenever', require: false gem 'pg_search' -gem 'ahoy_matey', '~> 1.4.0' -gem 'groupdate' # group temporary data -gem 'tolk' # Web interface for translations +gem 'ahoy_matey', '~> 1.4.2' +gem 'groupdate', '3.1.0' # group temporary data +gem 'tolk', '2.0.0' # Web interface for translations gem 'browser' -gem 'turnout' +gem 'turnout', '2.4.0' gem 'redcarpet' group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 68570d756..00780d8c2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -56,7 +56,7 @@ GEM akami (1.3.1) gyoku (>= 0.4.0) nokogiri - ancestry (2.1.0) + ancestry (2.2.1) activerecord (>= 3.0.0) arel (6.0.3) ast (2.2.0) @@ -163,11 +163,11 @@ GEM i18n (~> 0.5) faraday (0.9.2) multipart-post (>= 1.2, < 3) - foundation-rails (6.2.3.0) + foundation-rails (6.2.4.0) railties (>= 3.1.0) sass (>= 3.3.0, < 3.5) sprockets-es6 (>= 0.9.0) - foundation_rails_helper (1.2.1) + foundation_rails_helper (2.0.0) actionpack (>= 4.1) activemodel (>= 4.1) activesupport (>= 4.1) @@ -176,10 +176,10 @@ GEM fuubar (2.1.1) rspec (~> 3.0) ruby-progressbar (~> 1.4) - geocoder (1.3.7) + geocoder (1.4.0) globalid (0.3.7) activesupport (>= 4.1.0) - groupdate (3.0.2) + groupdate (3.1.0) activesupport (>= 3) gyoku (1.3.1) builder (>= 2.1.2) @@ -203,7 +203,7 @@ GEM railties (>= 3.1, < 6.0) invisible_captcha (0.9.1) rails - jquery-rails (4.1.1) + jquery-rails (4.2.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) @@ -238,10 +238,9 @@ GEM net-scp (1.2.1) net-ssh (>= 2.6.5) net-ssh (3.2.0) - newrelic_rpm (3.16.3.323) - nokogiri (1.6.8) + newrelic_rpm (3.17.0.325) + nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) - pkg-config (~> 1.1.7) nori (2.6.0) oauth (0.5.0) oauth2 (1.0.0) @@ -270,16 +269,15 @@ GEM json (~> 1.3) omniauth-oauth (~> 1.1) orm_adapter (0.5.0) - paranoia (2.1.5) - activerecord (~> 4.0) + paranoia (2.2.0) + activerecord (>= 4.0, < 5.1) parser (2.3.0.6) ast (~> 2.2) - pg (0.18.4) + pg (0.19.0) pg_search (1.0.6) activerecord (>= 3.1) activesupport (>= 3.1) arel - pkg-config (1.1.7) poltergeist (1.10.0) capybara (~> 2.1) cliver (~> 0.3.1) @@ -289,7 +287,7 @@ GEM rack (1.6.4) rack-accept (0.4.5) rack (>= 0.4) - rack-attack (4.4.1) + rack-attack (5.0.1) rack rack-test (0.6.3) rack (>= 1.0) @@ -322,10 +320,10 @@ GEM redcarpet (3.3.4) referer-parser (0.3.0) request_store (1.3.1) - responders (2.2.0) + responders (2.3.0) railties (>= 4.2.0, < 5.1) - rinku (2.0.0) - rollbar (2.12.0) + rinku (2.0.2) + rollbar (2.13.3) multi_json rspec (3.5.0) rspec-core (~> 3.5.0) @@ -378,14 +376,14 @@ GEM spring (1.7.2) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - sprockets (3.6.3) + sprockets (3.7.0) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-es6 (0.9.0) + sprockets-es6 (0.9.2) babel-source (>= 5.8.11) babel-transpiler sprockets (>= 3.0.0) - sprockets-rails (3.1.1) + sprockets-rails (3.2.0) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) @@ -400,18 +398,19 @@ GEM thread_safe (0.3.5) tilt (2.0.5) tins (1.11.0) - tolk (1.9.3) - rails (>= 4.0, < 4.3) + tolk (2.0.0) + rails (>= 4.0) safe_yaml (>= 0.8.6) turbolinks (2.5.3) coffee-rails - turnout (2.3.1) - rack (~> 1.3) + turnout (2.4.0) + i18n (~> 0.7) + rack (>= 1.3, < 3) rack-accept (~> 0.4) tilt (>= 1.4, < 3) tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (3.0.2) + uglifier (3.0.3) execjs (>= 0.3.0, < 3) unicorn (5.1.0) kgio (~> 2.6) @@ -442,8 +441,8 @@ PLATFORMS DEPENDENCIES acts-as-taggable-on acts_as_votable - ahoy_matey (~> 1.4.0) - ancestry + ahoy_matey (~> 1.4.2) + ancestry (= 2.2.1) browser bullet byebug @@ -467,44 +466,44 @@ DEPENDENCIES email_spec factory_girl_rails faker - foundation-rails - foundation_rails_helper + foundation-rails (= 6.2.4.0) + foundation_rails_helper (= 2.0.0) fuubar - groupdate + groupdate (= 3.1.0) i18n-tasks initialjs-rails (= 0.2.0.4) invisible_captcha (~> 0.9.1) - jquery-rails + jquery-rails (= 4.2.1) jquery-ui-rails kaminari launchy letter_opener_web (~> 1.3.0) - newrelic_rpm (~> 3.16) + newrelic_rpm (~> 3.17.0.325) omniauth omniauth-facebook (~> 3.0.0) omniauth-google-oauth2 (~> 0.4.0) omniauth-twitter - paranoia - pg + paranoia (= 2.2.0) + pg (= 0.19.0) pg_search poltergeist quiet_assets rails (= 4.2.7.1) redcarpet - responders - rinku - rollbar (~> 2.12.0) + responders (= 2.3.0) + rinku (= 2.0.2) + rollbar (~> 2.13.3) rspec-rails (~> 3.5) sass-rails (~> 5.0, >= 5.0.4) savon social-share-button spring spring-commands-rspec - sprockets (~> 3.6.3) - tolk + sprockets (~> 3.7.0) + tolk (= 2.0.0) turbolinks - turnout - uglifier (>= 1.3.0) + turnout (= 2.4.0) + uglifier (>= 3.0.3) unicorn (~> 5.1.0) web-console (= 3.3.0) whenever From fe3451b4ba71054e25662d958e04dfe2db404180 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 26 Oct 2016 10:31:05 +0200 Subject: [PATCH 05/56] fixes specs --- spec/models/proposal_spec.rb | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/spec/models/proposal_spec.rb b/spec/models/proposal_spec.rb index d98392eaa..39c052861 100644 --- a/spec/models/proposal_spec.rb +++ b/spec/models/proposal_spec.rb @@ -793,54 +793,50 @@ describe Proposal do end describe "retired" do - before(:all) do - @proposal1 = create(:proposal) - @proposal2 = create(:proposal, retired_at: Time.now) - end + let!(:proposal1) { create(:proposal) } + let!(:proposal2) { create(:proposal, retired_at: Time.now) } it "retired? is true" do - expect(@proposal1.retired?).to eq false - expect(@proposal2.retired?).to eq true + expect(proposal1.retired?).to eq false + expect(proposal2.retired?).to eq true end it "scope retired" do retired = Proposal.retired expect(retired.size).to eq(1) - expect(retired.first).to eq(@proposal2) + expect(retired.first).to eq(proposal2) end it "scope not_retired" do not_retired = Proposal.not_retired expect(not_retired.size).to eq(1) - expect(not_retired.first).to eq(@proposal1) + expect(not_retired.first).to eq(proposal1) end end describe "archived" do - before(:each) do - @new_proposal = create(:proposal) - @archived_proposal = create(:proposal, :archived) - end + let!(:new_proposal) { create(:proposal) } + let!(:archived_proposal) { create(:proposal, :archived) } it "archived? is true only for proposals created more than n (configured months) ago" do - expect(@new_proposal.archived?).to eq false - expect(@archived_proposal.archived?).to eq true + expect(new_proposal.archived?).to eq false + expect(archived_proposal.archived?).to eq true end it "scope archived" do archived = Proposal.archived expect(archived.size).to eq(1) - expect(archived.first).to eq(@archived_proposal) + expect(archived.first).to eq(archived_proposal) end it "scope archived" do not_archived = Proposal.not_archived expect(not_archived.size).to eq(1) - expect(not_archived.first).to eq(@new_proposal) + expect(not_archived.first).to eq(new_proposal) end end From 29905b61b72d371d02c079d493f5c0581716cb7a Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 28 Oct 2016 12:36:58 +0200 Subject: [PATCH 06/56] Sets gem versions to equal to or greater than in the last digit --- Gemfile | 22 +++++++++++----------- Gemfile.lock | 24 ++++++++++++------------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Gemfile b/Gemfile index 665421ce2..a57c2a7f1 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.7.1' # Use PostgreSQL -gem 'pg', '0.19.0' +gem 'pg', '~> 0.19.0' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0', '>= 5.0.4' # Use Uglifier as compressor for JavaScript assets @@ -14,7 +14,7 @@ gem 'coffee-rails', '~> 4.2.1' # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library -gem 'jquery-rails', '4.2.1' +gem 'jquery-rails', '~> 4.2.1' gem 'jquery-ui-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' @@ -32,11 +32,11 @@ gem 'omniauth-facebook', '~> 3.0.0' gem 'omniauth-google-oauth2', '~> 0.4.0' gem 'kaminari' -gem 'ancestry', '2.2.1' +gem 'ancestry', '~> 2.2.1' gem 'acts-as-taggable-on' -gem 'responders', '2.3.0' -gem 'foundation-rails', '6.2.4.0' -gem 'foundation_rails_helper', '2.0.0' +gem 'responders', '~> 2.3.0' +gem 'foundation-rails', '~> 6.2.4.0' +gem 'foundation_rails_helper', '~> 2.0.0' gem 'acts_as_votable' gem 'ckeditor', '~> 4.2.0' gem 'invisible_captcha', '~> 0.9.1' @@ -44,8 +44,8 @@ gem 'cancancan' gem 'social-share-button' gem 'initialjs-rails', '0.2.0.4' gem 'unicorn', '~> 5.1.0' -gem 'paranoia', '2.2.0' -gem 'rinku', '2.0.2', require: 'rails_rinku' +gem 'paranoia', '~> 2.2.0' +gem 'rinku', '~> 2.0.2', require: 'rails_rinku' gem 'savon' gem 'dalli' gem 'rollbar', '~> 2.13.3' @@ -57,11 +57,11 @@ gem 'whenever', require: false gem 'pg_search' gem 'ahoy_matey', '~> 1.4.2' -gem 'groupdate', '3.1.0' # group temporary data -gem 'tolk', '2.0.0' # Web interface for translations +gem 'groupdate', '~> 3.1.0' # group temporary data +gem 'tolk', '~> 2.0.0' # Web interface for translations gem 'browser' -gem 'turnout', '2.4.0' +gem 'turnout', '~> 2.4.0' gem 'redcarpet' group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 00780d8c2..5e99a8030 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -179,7 +179,7 @@ GEM geocoder (1.4.0) globalid (0.3.7) activesupport (>= 4.1.0) - groupdate (3.1.0) + groupdate (3.1.1) activesupport (>= 3) gyoku (1.3.1) builder (>= 2.1.2) @@ -442,7 +442,7 @@ DEPENDENCIES acts-as-taggable-on acts_as_votable ahoy_matey (~> 1.4.2) - ancestry (= 2.2.1) + ancestry (~> 2.2.1) browser bullet byebug @@ -466,14 +466,14 @@ DEPENDENCIES email_spec factory_girl_rails faker - foundation-rails (= 6.2.4.0) - foundation_rails_helper (= 2.0.0) + foundation-rails (~> 6.2.4.0) + foundation_rails_helper (~> 2.0.0) fuubar - groupdate (= 3.1.0) + groupdate (~> 3.1.0) i18n-tasks initialjs-rails (= 0.2.0.4) invisible_captcha (~> 0.9.1) - jquery-rails (= 4.2.1) + jquery-rails (~> 4.2.1) jquery-ui-rails kaminari launchy @@ -483,15 +483,15 @@ DEPENDENCIES omniauth-facebook (~> 3.0.0) omniauth-google-oauth2 (~> 0.4.0) omniauth-twitter - paranoia (= 2.2.0) - pg (= 0.19.0) + paranoia (~> 2.2.0) + pg (~> 0.19.0) pg_search poltergeist quiet_assets rails (= 4.2.7.1) redcarpet - responders (= 2.3.0) - rinku (= 2.0.2) + responders (~> 2.3.0) + rinku (~> 2.0.2) rollbar (~> 2.13.3) rspec-rails (~> 3.5) sass-rails (~> 5.0, >= 5.0.4) @@ -500,9 +500,9 @@ DEPENDENCIES spring spring-commands-rspec sprockets (~> 3.7.0) - tolk (= 2.0.0) + tolk (~> 2.0.0) turbolinks - turnout (= 2.4.0) + turnout (~> 2.4.0) uglifier (>= 3.0.3) unicorn (~> 5.1.0) web-console (= 3.3.0) From 04ca5f7ae8f5faf1db5a9bb390473149c97eb04b Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 31 Oct 2016 11:50:07 +0100 Subject: [PATCH 07/56] adds french and brazilian portuguese locales --- config/application.rb | 6 +++--- doc/locales/{fr.yaml => fr.yml} | 0 doc/locales/{pt-br.yaml => pt-br.yml} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename doc/locales/{fr.yaml => fr.yml} (100%) rename doc/locales/{pt-br.yaml => pt-br.yml} (100%) diff --git a/config/application.rb b/config/application.rb index 2b842992b..0da522fcf 100644 --- a/config/application.rb +++ b/config/application.rb @@ -20,10 +20,11 @@ module Consul # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] config.i18n.default_locale = :es - - config.i18n.available_locales = [:en, :es] + config.i18n.available_locales = [:en, :es, :fr, 'pt-BR'] + config.i18n.fallbacks = {'fr' => 'en', 'pt-br' => 'en'} # Add the new directories to the locales load path + config.i18n.load_path += Dir[Rails.root.join('doc', 'locales', '*.yml')] config.assets.paths << Rails.root.join("app", "assets", "fonts") @@ -44,7 +45,6 @@ module Consul config.autoload_paths << "#{Rails.root}/app/models/custom" config.paths['app/views'].unshift(Rails.root.join('app', 'views', 'custom')) config.i18n.load_path += Dir[Rails.root.join('config', 'locales', 'custom', '*.{rb,yml}')] - end end diff --git a/doc/locales/fr.yaml b/doc/locales/fr.yml similarity index 100% rename from doc/locales/fr.yaml rename to doc/locales/fr.yml diff --git a/doc/locales/pt-br.yaml b/doc/locales/pt-br.yml similarity index 100% rename from doc/locales/pt-br.yaml rename to doc/locales/pt-br.yml From aeec264b8b5b3616d30c888a8068e5fdd749015d Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 26 Oct 2016 11:21:51 +0200 Subject: [PATCH 08/56] makes fallback locale spanish --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 0da522fcf..8465f081a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -21,7 +21,7 @@ module Consul # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] config.i18n.default_locale = :es config.i18n.available_locales = [:en, :es, :fr, 'pt-BR'] - config.i18n.fallbacks = {'fr' => 'en', 'pt-br' => 'en'} + config.i18n.fallbacks = {'fr' => 'es', 'pt-br' => 'es'} # Add the new directories to the locales load path config.i18n.load_path += Dir[Rails.root.join('doc', 'locales', '*.yml')] From c0f400a4d99622b99e7f5f748b5f9c4ca17926a2 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 31 Oct 2016 11:14:05 +0100 Subject: [PATCH 09/56] =?UTF-8?q?Adds=20custom=20locale=20name=20for=20Por?= =?UTF-8?q?tugu=C3=AAs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/locales_helper.rb | 8 ++++++++ app/views/shared/_locale_switcher.html.erb | 2 +- doc/locales/pt-br.yml | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 app/helpers/locales_helper.rb diff --git a/app/helpers/locales_helper.rb b/app/helpers/locales_helper.rb new file mode 100644 index 000000000..7954cc908 --- /dev/null +++ b/app/helpers/locales_helper.rb @@ -0,0 +1,8 @@ +module LocalesHelper + + def name_for_locale(locale) + default = I18n.t("locale", locale: locale) + I18n.backend.translate(locale, "i18n.language.name", default: default) + end + +end diff --git a/app/views/shared/_locale_switcher.html.erb b/app/views/shared/_locale_switcher.html.erb index f29defcbd..af184fe48 100644 --- a/app/views/shared/_locale_switcher.html.erb +++ b/app/views/shared/_locale_switcher.html.erb @@ -8,7 +8,7 @@ <% I18n.available_locales.map do |loc| %> <% end %> diff --git a/doc/locales/pt-br.yml b/doc/locales/pt-br.yml index 9d2b3ee46..f3159cdc2 100644 --- a/doc/locales/pt-br.yml +++ b/doc/locales/pt-br.yml @@ -1,5 +1,8 @@ --- pt-BR: + i18n: + language: + name: Português account: show: change_credentials_link: Alterar meus dados pessoais From d540be333a1090dd6c17fbf8ece7156f91a487e8 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 31 Oct 2016 11:45:14 +0100 Subject: [PATCH 10/56] Makes tolk aware of french and portuguese translations --- config/application.rb | 3 --- {doc => config}/locales/fr.yml | 0 doc/locales/pt-br.yml => config/locales/pt-BR.yml | 0 3 files changed, 3 deletions(-) rename {doc => config}/locales/fr.yml (100%) rename doc/locales/pt-br.yml => config/locales/pt-BR.yml (100%) diff --git a/config/application.rb b/config/application.rb index 8465f081a..ea799001e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,9 +23,6 @@ module Consul config.i18n.available_locales = [:en, :es, :fr, 'pt-BR'] config.i18n.fallbacks = {'fr' => 'es', 'pt-br' => 'es'} - # Add the new directories to the locales load path - config.i18n.load_path += Dir[Rails.root.join('doc', 'locales', '*.yml')] - config.assets.paths << Rails.root.join("app", "assets", "fonts") # Do not swallow errors in after_commit/after_rollback callbacks. diff --git a/doc/locales/fr.yml b/config/locales/fr.yml similarity index 100% rename from doc/locales/fr.yml rename to config/locales/fr.yml diff --git a/doc/locales/pt-br.yml b/config/locales/pt-BR.yml similarity index 100% rename from doc/locales/pt-br.yml rename to config/locales/pt-BR.yml From 028cc4362d45d2ae961b1aae952b5ccaf03ac0d1 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 31 Oct 2016 11:45:37 +0100 Subject: [PATCH 11/56] Makes i18n-tasks only aware of english and spanish locales --- config/i18n-tasks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 9cf9f8137..edaaa0958 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -3,7 +3,7 @@ # The "main" locale. base_locale: en ## All available locales are inferred from the data by default. Alternatively, specify them explicitly: -# locales: [es, fr] +locales: [en, es] ## Reporting locale, default: en. Available: en, ru. # internal_locale: en From 6d9ced63a2d12cfa2e894f97c97c69d4ce16d6d6 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Mon, 31 Oct 2016 13:10:15 +0100 Subject: [PATCH 12/56] renames and removes unused variables --- app/assets/stylesheets/_settings.scss | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/app/assets/stylesheets/_settings.scss b/app/assets/stylesheets/_settings.scss index 44433938b..242a03b82 100644 --- a/app/assets/stylesheets/_settings.scss +++ b/app/assets/stylesheets/_settings.scss @@ -48,37 +48,32 @@ // -------------------- $base-font-size: rem-calc(17); -$base-line-height: rem-calc(26); +$base-line: rem-calc(26); $small-font-size: rem-calc(14); $line-height: rem-calc(24); $brand: #004A83; -$body: #E9E9E9; -$background: #EDEFF0; -$border: #DEE0E3; $dark: darken($brand, 10%); $text: #222222; $text-medium: #999999; $text-light: #CCCCCC; +$border: #DEE0E3; + $link: #2895F1; -$link-hover: #2178BF; +$link-hover: darken($link, 20%); $debates: #008CCF; -$votes-bg: #26AEEE; -$votes-border: #1F94CB; -$votes-like: #7BD2A8; -$votes-like-act: #5D9E7F; -$votes-unlike: #EF8585; -$votes-unlike-act: #BD6A6A; +$votes: #26AEEE; +$like: #7BD2A8; +$unlike: #EF8585; $delete: #F04124; $check: #46DB91; $proposals: #FFA42D; -$proposals-border: #CC8425; $budget: #454372; $budget-hover: #7571BF; @@ -86,9 +81,6 @@ $budget-hover: #7571BF; $highlight: #E7F2FC; $featured: #FED900; -$footer-bg: #DEE0E2; -$footer-color: #171819; -$footer-link: #454A4C; $footer-border: #BFC1C3; $success-bg: #DFF0D8; From 7d4f92f10ad26c4afa8aa60bbcd1aede8a4def36 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Mon, 31 Oct 2016 13:11:23 +0100 Subject: [PATCH 13/56] unifies styles of page forms --- app/assets/stylesheets/admin.scss | 2 +- app/views/debates/edit.html.erb | 2 +- app/views/debates/new.html.erb | 2 +- app/views/management/proposals/new.html.erb | 2 +- app/views/management/spending_proposals/new.html.erb | 2 +- app/views/proposals/new.html.erb | 2 +- app/views/spending_proposals/new.html.erb | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index cd8241fca..4968983f0 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -82,7 +82,7 @@ body.admin { .admin-content { - .proposal-new, .proposal-edit { + .proposal-form { padding-top: 0; } diff --git a/app/views/debates/edit.html.erb b/app/views/debates/edit.html.erb index eea353438..13a2aa625 100644 --- a/app/views/debates/edit.html.erb +++ b/app/views/debates/edit.html.erb @@ -1,4 +1,4 @@ -
+
<%= render "shared/back_link" %> diff --git a/app/views/debates/new.html.erb b/app/views/debates/new.html.erb index 65d47bbcd..cd4a92cc6 100644 --- a/app/views/debates/new.html.erb +++ b/app/views/debates/new.html.erb @@ -1,4 +1,4 @@ -
+
<%= render "shared/back_link" %> diff --git a/app/views/management/proposals/new.html.erb b/app/views/management/proposals/new.html.erb index e3e2087e9..07c7e734a 100644 --- a/app/views/management/proposals/new.html.erb +++ b/app/views/management/proposals/new.html.erb @@ -1,4 +1,4 @@ -
+
<%= render '/shared/print' %> diff --git a/app/views/management/spending_proposals/new.html.erb b/app/views/management/spending_proposals/new.html.erb index e036a04cb..b4cc82cf2 100644 --- a/app/views/management/spending_proposals/new.html.erb +++ b/app/views/management/spending_proposals/new.html.erb @@ -1,4 +1,4 @@ -
+
<%= render '/shared/print' %> diff --git a/app/views/proposals/new.html.erb b/app/views/proposals/new.html.erb index 2887cd97a..fb9bcaf38 100644 --- a/app/views/proposals/new.html.erb +++ b/app/views/proposals/new.html.erb @@ -1,4 +1,4 @@ -
+
<%= render "shared/back_link" %> diff --git a/app/views/spending_proposals/new.html.erb b/app/views/spending_proposals/new.html.erb index 219444857..6c962c482 100644 --- a/app/views/spending_proposals/new.html.erb +++ b/app/views/spending_proposals/new.html.erb @@ -1,4 +1,4 @@ -
+
<%= render "shared/back_link" %> From d771b739bf2e932beb5ffde8bd9572c446b3093c Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Mon, 31 Oct 2016 13:25:48 +0100 Subject: [PATCH 14/56] renames variables, removes unused styles --- app/assets/stylesheets/layout.scss | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 8052513fc..1b186d438 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -40,7 +40,7 @@ h1, h2, h3, h4, h5, h6 { p { font-size: $base-font-size; font-weight: 400; - line-height: $base-line-height; + line-height: $base-line; } a { @@ -487,7 +487,7 @@ header { // ---------- footer { - color: $footer-color; + color: $text; .logo a { font-family: 'Lato' !important; @@ -507,10 +507,11 @@ footer { } a, a:active, a:focus { - color: $footer-link; + color: $text; + text-decoration: underline; &:hover { - color: $footer-color; + color: $text-medium; } } @@ -519,7 +520,7 @@ footer { } h2 a { - border-bottom: 1px solid $footer-border; + border-bottom: 1px solid $text-light; display: block; font-size: rem-calc(24); line-height: rem-calc(31); @@ -529,14 +530,14 @@ footer { } .footer { - background: $footer-bg; + background: $border; border-top: 6px solid $brand; margin-top: $line-height*2; padding-top: $line-height; } .subfooter { - border-top: 1px solid $footer-border; + border-top: 1px solid $text-light; padding-top: $line-height/2; } @@ -563,8 +564,8 @@ footer { color: $link; &:hover { - background: $highlight; - color: $link-hover; + background: $brand; + color: white; } } @@ -1002,15 +1003,6 @@ img.avatar, img.admin-avatar, img.moderator-avatar, img.initialjs-avatar { // 09. Search // ---------- -.search-form h3 { - border-top: 1px solid $votes-border; - display: inline-block; - font-size: rem-calc(16); - margin: -1px 0 $line-height/2; - padding-top: $line-height/4; - text-transform: uppercase; -} - .search-results h2 { margin-bottom: 0; } From 6fd5e6a67acc50d443a5b6c3339f710a3d0d3a95 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Mon, 31 Oct 2016 16:50:13 +0100 Subject: [PATCH 15/56] unifies styles for participation not allowed --- app/assets/javascripts/votes.js.coffee | 14 +- app/assets/stylesheets/layout.scss | 1 + app/assets/stylesheets/participation.scss | 239 ++++++------------- app/views/comments/_votes.html.erb | 4 +- app/views/debates/_votes.html.erb | 32 +-- app/views/proposals/_featured_votes.html.erb | 32 +-- app/views/proposals/_votes.html.erb | 32 +-- app/views/spending_proposals/_votes.html.erb | 2 +- spec/support/common_actions.rb | 4 +- 9 files changed, 125 insertions(+), 235 deletions(-) diff --git a/app/assets/javascripts/votes.js.coffee b/app/assets/javascripts/votes.js.coffee index 030b9cf46..b842c3ffc 100644 --- a/app/assets/javascripts/votes.js.coffee +++ b/app/assets/javascripts/votes.js.coffee @@ -3,17 +3,11 @@ App.Votes = hoverize: (votes) -> $(document).on { 'mouseenter focus': -> - $("div.anonymous-votes", this).show(); - $("div.organizations-votes", this).show(); - $("div.not-logged", this).show(); - $("div.no-supports-allowed", this).show(); - $("div.logged", this).hide(); + $("div.participation-not-allowed", this).show(); + $("div.participation-allowed", this).hide(); mouseleave: -> - $("div.anonymous-votes", this).hide(); - $("div.organizations-votes", this).hide(); - $("div.not-logged", this).hide(); - $("div.no-supports-allowed", this).hide(); - $("div.logged", this).show(); + $("div.participation-not-allowed", this).hide(); + $("div.participation-allowed", this).show(); }, votes initialize: -> diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 1b186d438..c3dded973 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -1580,6 +1580,7 @@ table { font-size: $small-font-size; margin: rem-calc(6) 0; padding: rem-calc(6); + position: relative; [class^="icon-arrow"] { font-size: rem-calc(18); diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index efd385c19..1ab1eb726 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -12,15 +12,14 @@ // ---------------------- @mixin votes { - background: $votes-bg; - border-top: 1px solid $votes-border; + background: $votes; margin: 0 rem-calc(-12); padding: rem-calc(14) rem-calc(12); position: relative; - .icon-like { + .icon-like, .icon-unlike { background: white; - border: 2px solid $votes-border; + border: 2px solid $votes; border-radius: rem-calc(3); color: $text-light; display: inline-block; @@ -29,40 +28,25 @@ padding: rem-calc(3) rem-calc(6); position: relative; - &:hover { - background: $votes-like; + &:hover, &:active { border-color: white; color: white; cursor: pointer; opacity: 1 !important; } + } - &:active { - border-color: $votes-like-act; + .icon-like { + + &:hover, &:active { + background: $like; } } .icon-unlike { - background: white; - border: 2px solid $votes-border; - border-radius: rem-calc(3); - color: $text-light; - display: inline-block; - font-size: rem-calc(30); - line-height: rem-calc(30); - padding: rem-calc(3) rem-calc(6); - position: relative; - &:hover { - background: $votes-unlike; - border-color: white; - color: white; - cursor: pointer; - opacity: 1 !important; - } - - &:active { - border-color: $votes-unlike-act; + &:hover, &:active { + background: $unlike; } } @@ -81,20 +65,23 @@ } .voted { - .icon-like { - background: $votes-like; + + .icon-like, .icon-unlike { border-color: white; color: white; } + .icon-like { + background: $like; + } + .icon-unlike { - background: $votes-unlike; - border-color: white; - color: white; + background: $unlike; } } .no-voted { + .icon-like, .icon-unlike { opacity: .5; } @@ -109,54 +96,10 @@ .divider { margin: 0 rem-calc(6); } - - .not-logged { - background: rgba(22,99,135,.9); - color: white; - font-size: $small-font-size; - height: 100%; - left: 0; - position: absolute; - text-align: center; - top: 0; - width: 100%; - filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#222222', endColorstr='#222222'); /* IE */ - - a { - color: white; - text-decoration: underline; - } - } - - .anonymous-votes, .organizations-votes { - background: $warning-bg; - color: $color-warning; - height: 100%; - left: 0; - line-height: $line-height; - padding-top: rem-calc(12); - position: absolute; - text-align: center; - top: 0; - width: 100%; - - p { - color: $color-warning; - margin: 0 rem-calc(12); - text-align: left; - } - - a { - color: $color-warning; - font-weight: bold; - text-decoration: underline; - } - } } @mixin supports { background: $proposals; - border-top: 1px solid $proposals-border; margin: 0 rem-calc(-12); padding: rem-calc(14) rem-calc(12); position: relative; @@ -166,7 +109,7 @@ height: $line-height/2; .meter { - background: $votes-like; + background: $like; display: block; height: $line-height/2; } @@ -197,7 +140,7 @@ margin-top: rem-calc(12); &:hover { - background: $proposals-border; + background: darken($proposals, 35%); color: white; cursor: pointer; } @@ -221,49 +164,6 @@ margin: 0 rem-calc(6); } - .not-logged { - background: rgba(255,164,45,.9); - color: white; - font-size: $small-font-size; - height: 100%; - left: 0; - position: absolute; - text-align: center; - top: 0; - width: 100%; - filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#222222', endColorstr='#222222'); /* IE */ - - a { - color: white; - text-decoration: underline; - } - } - - .anonymous-votes, .organizations-votes, .no-supports-allowed { - background: $warning-bg; - color: $color-warning; - height: 100%; - left: 0; - line-height: $line-height; - padding-top: rem-calc(12); - position: absolute; - text-align: center; - top: 0; - width: 100%; - - p { - color: $color-warning; - margin: 0 rem-calc(12); - text-align: left; - } - - a { - color: $color-warning; - font-weight: bold; - text-decoration: underline; - } - } - .supported { color: white; margin-top: rem-calc(12); @@ -285,32 +185,61 @@ } } +.participation-not-allowed { + background: $warning-bg; + color: $color-warning; + height: 100%; + left: 0; + line-height: $line-height; + padding: $line-height $line-height/2; + position: absolute; + text-align: center; + top: 0; + width: 100%; + z-index: 2; + + p { + color: $color-warning !important; + margin: 0 rem-calc(12); + text-align: left; + } + + a { + color: $color-warning !important; + font-weight: bold; + text-decoration: underline; + } +} + +.reply .participation-not-allowed { + padding-right: $line-height/2; + padding-top: $line-height/6; + text-align: right; +} + // 02. New participation // --------------------- -.debate-new, .debate-edit, -.proposal-new, .proposal-edit, -.spending-proposal-new, .spending-proposal-edit { +.debate-form, +.proposal-form, +.spending-proposal-form { + + .icon-debates, .icon-proposals, .icon-budget { + font-size: rem-calc(50); + line-height: $line-height; + opacity: .5; + } .icon-debates { color: $debates; - font-size: rem-calc(60); - line-height: $line-height; - opacity: .5; } .icon-proposals { color: $proposals; - font-size: rem-calc(50); - line-height: $line-height; - opacity: .5; } .icon-budget { color: $budget; - font-size: rem-calc(50); - line-height: $line-height; - opacity: .5; } .recommendations { @@ -330,14 +259,14 @@ } } -.debate-new, .debate-edit { +.debate-form { .recommendations li:before { color: $debates; } } -.proposal-new, .proposal-edit { +.proposal-form { .recommendations li:before { color: $proposals; @@ -496,11 +425,6 @@ line-height: $line-height; } - .not-logged { - line-height: $line-height; - padding: rem-calc(24); - } - @include breakpoint(small + rem-calc(1) and medium down) { .in-favor, .against { text-align: left; @@ -530,11 +454,6 @@ float: none; line-height: $line-height; } - - .not-logged { - line-height: $line-height; - padding: rem-calc(24); - } } .leave-comment { @@ -711,15 +630,6 @@ } } - .not-logged { - line-height: $line-height; - padding-top: rem-calc(24); - } - - .anonymous-votes, .organizations-votes { - padding-top: rem-calc(24); - } - .divider { display: none; } @@ -745,7 +655,7 @@ .votes { @include votes; - border: 1px solid $votes-border; + border: 1px solid $votes; margin: 0 rem-calc(-12); @include breakpoint(medium) { @@ -803,7 +713,7 @@ .supports { @include supports; - border: 1px solid $proposals-border; + border: 1px solid $proposals; margin: 0 rem-calc(-12); @include breakpoint(medium) { @@ -904,16 +814,6 @@ line-height: rem-calc(70); } - .no-supports-allowed { - background: rgba(69,67,114,.96); - color: white; - padding: rem-calc(12); - } - - .no-supports-allowed p, .no-supports-allowed a { - color: white; - } - .share-supported { .ssb-twitter, @@ -1006,18 +906,13 @@ margin-top: 0; } - .not-logged, - .organizations-votes, - .anonymous-votes { + .participation-not-allowed { background: $featured; - color: $color-warning; font-size: $small-font-size; - line-height: $line-height; padding-top: 0; a { color: $color-warning; - font-weight: bold; } p { diff --git a/app/views/comments/_votes.html.erb b/app/views/comments/_votes.html.erb index 8ee315e35..0de92a675 100644 --- a/app/views/comments/_votes.html.erb +++ b/app/views/comments/_votes.html.erb @@ -33,7 +33,7 @@ <% elsif !user_signed_in? %> -
+
<%= t('comments.comment.votes', count: comment.total_votes) %>  |  @@ -60,7 +60,7 @@ <%= comment.total_dislikes %>
- <% if user_signed_in? && current_user.organization? %> - + <% elsif user_signed_in? && !proposal.votable_by?(current_user)%> - + <% elsif !user_signed_in? %> - + <% end %> <% if voted_for?(@featured_proposals_votes, proposal) %> diff --git a/app/views/proposals/_votes.html.erb b/app/views/proposals/_votes.html.erb index 0c572e71f..198bf5d07 100644 --- a/app/views/proposals/_votes.html.erb +++ b/app/views/proposals/_votes.html.erb @@ -31,24 +31,24 @@
<% if user_signed_in? && current_user.organization? %> - + <% elsif user_signed_in? && !proposal.votable_by?(current_user)%> - + <% elsif !user_signed_in? %> - + <% end %> <% if voted_for?(@proposal_votes, proposal) && setting['twitter_handle'] %> diff --git a/app/views/spending_proposals/_votes.html.erb b/app/views/spending_proposals/_votes.html.erb index a4fd43993..9ef7e75b3 100644 --- a/app/views/spending_proposals/_votes.html.erb +++ b/app/views/spending_proposals/_votes.html.erb @@ -24,7 +24,7 @@
<% if reason.present? && !user_voted_for %> - -<%= link_to t("admin.booths.show.add_officer"), "#", class: "button success" %> +<%= link_to t("admin.booths.show.assign_officer"), "#", class: "button success" %> + +
+ + <%# f.label :valuator_ids, t("admin.spending_proposals.edit.assigned_valuators") %> + + <%# f.collection_check_boxes :valuator_ids, @valuators, :id, :email do |b| %> + <%# b.label(title: valuator_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %> + <%# end %> +
<%# @officers.each do |officer| %> diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 40822778f..40f959a3a 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -188,7 +188,7 @@ en: add_booth: "Add booth" name: "Name" location: "Location" - add_officer: "Add officer" + officers: "Officers" new: title: "Poll %{poll}" subtitle: "New booth" @@ -205,7 +205,7 @@ en: submit_button: "Update booth" show: location: "Location" - add_officer: "Add officer" + assign_officer: "Assign officer" officers_list: "List of officers" no_officers: "There is no officers in this booth." officials: diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 4c807e454..6023da712 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -188,7 +188,7 @@ es: add_booth: "Añadir urna" name: "Nombre" location: "Ubicación" - add_officer: "Añadir presidente" + officers: "Presidentes de mesa" new: title: "Votación %{poll}" subtitle: "Nueva urna" @@ -196,9 +196,16 @@ es: reference: "Número de referencia" location: "Ubicación" submit_button: "Crear urna" + edit: + title: "Votación %{poll}" + subtitle: "Editar urna" + name: "Nombre" + reference: "Número de referencia" + location: "Ubicación" + submit_button: "Actualizar urna" show: location: "Ubicación" - add_officer: "Añadir presidente de mesa" + assign_officer: "Asignar presidente de mesa" officers_list: "Lista de presidentes de mesa" no_officers: "No hay presidentes de mesa en esta urna." officials: From ebb9a5fa1d74b78947289e71ac7492dde38ca7a1 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 20 Sep 2016 13:49:48 +0200 Subject: [PATCH 34/56] fixes specs --- spec/features/management/document_verifications_spec.rb | 4 ++-- spec/features/management/email_verifications_spec.rb | 4 ++-- spec/features/management/managed_users_spec.rb | 4 ++-- spec/features/management/users_spec.rb | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/features/management/document_verifications_spec.rb b/spec/features/management/document_verifications_spec.rb index 674349815..130630762 100644 --- a/spec/features/management/document_verifications_spec.rb +++ b/spec/features/management/document_verifications_spec.rb @@ -47,7 +47,7 @@ feature 'DocumentVerifications' do scenario 'Verifying a user which does exists in the census but not in the db redirects allows sending an email' do visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '1234' + fill_in 'document_verification_document_number', with: '12345678Z' click_button 'Check' expect(page).to have_content "Please introduce the email used on the account" @@ -66,7 +66,7 @@ feature 'DocumentVerifications' do expect_any_instance_of(Verification::Management::Document).to receive(:under_sixteen?).and_return(true) visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '1234' + fill_in 'document_verification_document_number', with: '12345678Z' click_button 'Check' expect(page).to have_content "You must be over 16 to verify your account." diff --git a/spec/features/management/email_verifications_spec.rb b/spec/features/management/email_verifications_spec.rb index 22987f317..d68d9bd5f 100644 --- a/spec/features/management/email_verifications_spec.rb +++ b/spec/features/management/email_verifications_spec.rb @@ -8,7 +8,7 @@ feature 'EmailVerifications' do user = create(:user) visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '1234' + fill_in 'document_verification_document_number', with: '12345678Z' click_button 'Check' expect(page).to have_content "Please introduce the email used on the account" @@ -30,7 +30,7 @@ feature 'EmailVerifications' do expect(page).to_not have_link "Verify my account" expect(page).to have_content "Account verified" - expect(user.reload.document_number).to eq('1234') + expect(user.reload.document_number).to eq('12345678Z') expect(user).to be_level_three_verified end diff --git a/spec/features/management/managed_users_spec.rb b/spec/features/management/managed_users_spec.rb index 78010bc39..6ac04b137 100644 --- a/spec/features/management/managed_users_spec.rb +++ b/spec/features/management/managed_users_spec.rb @@ -57,7 +57,7 @@ feature 'Managed User' do user = create(:user) visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '1234' + fill_in 'document_verification_document_number', with: '12345678Z' click_button 'Check' within(".account-info") do @@ -88,7 +88,7 @@ feature 'Managed User' do login_as_manager visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '1234' + fill_in 'document_verification_document_number', with: '12345678Z' click_button 'Check' expect(page).to have_content "Please introduce the email used on the account" diff --git a/spec/features/management/users_spec.rb b/spec/features/management/users_spec.rb index 1a0618e60..694720cc0 100644 --- a/spec/features/management/users_spec.rb +++ b/spec/features/management/users_spec.rb @@ -9,7 +9,7 @@ feature 'Users' do scenario 'Create a level 3 user from scratch' do visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '1234' + fill_in 'document_verification_document_number', with: '12345678Z' click_button 'Check' expect(page).to have_content "Please introduce the email used on the account" @@ -45,10 +45,10 @@ feature 'Users' do end scenario 'Delete a level 2 user account from document verification page', :js do - level_2_user = create(:user, :level_two, document_number: 13579) + level_2_user = create(:user, :level_two, document_number: "12345678Z") visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '13579' + fill_in 'document_verification_document_number', with: '12345678Z' click_button 'Check' expect(page).to_not have_content "This user account is already verified." @@ -62,7 +62,7 @@ feature 'Users' do expect(level_2_user.reload.erase_reason).to eq "Deleted by manager: manager_user_#{Manager.last.user_id}" visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '13579' + fill_in 'document_verification_document_number', with: '12345678Z' click_button 'Check' expect(page).to have_content "no user account associated to it" From 304743f64e712042b0b299c18338bce5a43d237d Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 23 Sep 2016 09:13:02 +0200 Subject: [PATCH 35/56] tmp commit poll index, show and new --- .../admin/poll/polls_controller.rb | 2 +- app/models/abilities/administrator.rb | 2 + app/views/admin/poll/polls/_poll.html.erb | 16 ++++++++ app/views/admin/poll/polls/index.html.erb | 17 +------- app/views/admin/poll/polls/show.html.erb | 6 ++- spec/features/admin/poll/polls_spec.rb | 40 +++++++++++++++++++ 6 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 app/views/admin/poll/polls/_poll.html.erb create mode 100644 spec/features/admin/poll/polls_spec.rb diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index b90fd2c11..eb8b417b8 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -1,5 +1,5 @@ class Admin::Poll::PollsController < Admin::BaseController - skip_authorization_check + load_and_authorize_resource def index end diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 0f1100137..bd74e1be9 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -40,6 +40,8 @@ module Abilities can [:search, :create, :index, :destroy], ::Manager can [:search, :create, :index, :destroy], ::Poll::Officer + can [:manage], Poll + can :manage, Annotation can [:read, :update, :destroy, :summary], SpendingProposal diff --git a/app/views/admin/poll/polls/_poll.html.erb b/app/views/admin/poll/polls/_poll.html.erb new file mode 100644 index 000000000..a9f2dcd1b --- /dev/null +++ b/app/views/admin/poll/polls/_poll.html.erb @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/app/views/admin/poll/polls/index.html.erb b/app/views/admin/poll/polls/index.html.erb index c260ab255..b24cc10f6 100644 --- a/app/views/admin/poll/polls/index.html.erb +++ b/app/views/admin/poll/polls/index.html.erb @@ -16,21 +16,6 @@ - - - - - - - + <%= render @polls %>
+ + <%= link_to poll.name, admin_poll_path(poll) %> + ß + + Próximamente +
(15/12/2016 - 15/02/2017) +
+ <%= link_to t("admin.actions.edit"), + edit_admin_poll_path(poll), + class: "button hollow" %> +
 
- - <%= link_to "Votación de propuestas 2016 (REFNUM)", "polls/3" %> - - - Próximamente -
(15/12/2016 - 15/02/2017) -
- <%= link_to t("admin.actions.edit"), "polls/3/edit", class: "button hollow" %> -
diff --git a/app/views/admin/poll/polls/show.html.erb b/app/views/admin/poll/polls/show.html.erb index 9b4971214..105cf2fe6 100644 --- a/app/views/admin/poll/polls/show.html.erb +++ b/app/views/admin/poll/polls/show.html.erb @@ -1,8 +1,12 @@ <%= render "shared/back_link" %>
-

Votación de propuestas 2016

+

+ <%= @poll.name %> +

+ <%= link_to t("admin.actions.edit"), "#", class: "button hollow float-right" %> +

(REFNUM)

Próximamente (15/12/2016 - 15/02/2017)

<%= link_to t("admin.polls.show.add_booth"), "#", class: "button success" %> diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb new file mode 100644 index 000000000..a94c81cc9 --- /dev/null +++ b/spec/features/admin/poll/polls_spec.rb @@ -0,0 +1,40 @@ +require 'rails_helper' + +feature 'Admin polls' do + + background do + admin = create(:administrator) + login_as(admin.user) + end + + scenario 'Index' do + 3.times { create(:poll) } + + visit admin_root_path + + within('#side_menu') do + click_link "Polls" + end + + expect(page).to have_css ".poll", count: 3 + + Poll.all.each do |poll| + within("#poll_#{poll.id}") do + expect(page).to have_content poll.name +#expect(page).to have_content "Status/Dates" - Hardcoded + end + end + end + + scenario 'Show', :focus do + poll = create(:poll) + + visit admin_polls_path + click_link poll.name + + expect(page).to have_content poll.name +#expect(page).to have_content "Status/Dates" - Hardcoded +#expect(page).to have_content "REFNUM" - Hardcoded + end + +end \ No newline at end of file From c1a9caeab0a9273df0585bad23dbd785bb9feaae Mon Sep 17 00:00:00 2001 From: rgarcia Date: Sun, 25 Sep 2016 10:20:38 +0200 Subject: [PATCH 36/56] adds poll CRU actions --- .../admin/poll/polls_controller.rb | 22 ++++++++ app/models/poll.rb | 4 +- app/views/admin/poll/polls/_form.html.erb | 34 ++++++++++++ app/views/admin/poll/polls/_poll.html.erb | 2 +- app/views/admin/poll/polls/edit.html.erb | 5 +- app/views/admin/poll/polls/index.html.erb | 37 ++++++------- app/views/admin/poll/polls/new.html.erb | 33 +----------- app/views/admin/poll/polls/show.html.erb | 6 +-- config/locales/admin.en.yml | 2 +- config/locales/responders.en.yml | 3 +- config/locales/responders.es.yml | 1 + spec/features/admin/poll/polls_spec.rb | 53 ++++++++++++++++++- spec/models/poll_spec.rb | 16 ++++++ 13 files changed, 158 insertions(+), 60 deletions(-) create mode 100644 app/views/admin/poll/polls/_form.html.erb create mode 100644 spec/models/poll_spec.rb diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index eb8b417b8..2a7c1e730 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -10,7 +10,29 @@ class Admin::Poll::PollsController < Admin::BaseController def new end + def create + if @poll.save + redirect_to [:admin, @poll], notice: t("flash.actions.create.poll") + else + render :new + end + end + def edit end + def update + if @poll.update(poll_params) + redirect_to [:admin, @poll], notice: t("flash.actions.update.poll") + else + render :edit + end + end + + private + + def poll_params + params.require(:poll).permit(:name) + end + end \ No newline at end of file diff --git a/app/models/poll.rb b/app/models/poll.rb index 5a429c49d..4543a2544 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -1,4 +1,6 @@ class Poll < ActiveRecord::Base has_many :booths has_many :voters, through: :booths, class_name: "Poll::Voter" -end + + validates :name, presence: true +end \ No newline at end of file diff --git a/app/views/admin/poll/polls/_form.html.erb b/app/views/admin/poll/polls/_form.html.erb new file mode 100644 index 000000000..64d7177a6 --- /dev/null +++ b/app/views/admin/poll/polls/_form.html.erb @@ -0,0 +1,34 @@ +<%= form_for [:admin, @poll] do |f| %> +
+
+ <%= f.text_field :name, + placeholder: t('admin.polls.new.name'), + label: t("admin.polls.new.name") %> +
+ +
+ + +
+
+ +
+
+ + +
+ +
+ + +
+
+ +
+
+ +
+
+<% end %> \ No newline at end of file diff --git a/app/views/admin/poll/polls/_poll.html.erb b/app/views/admin/poll/polls/_poll.html.erb index a9f2dcd1b..4128ad222 100644 --- a/app/views/admin/poll/polls/_poll.html.erb +++ b/app/views/admin/poll/polls/_poll.html.erb @@ -2,7 +2,7 @@ <%= link_to poll.name, admin_poll_path(poll) %> - ß + Próximamente diff --git a/app/views/admin/poll/polls/edit.html.erb b/app/views/admin/poll/polls/edit.html.erb index 68eb7cc3b..0158655a5 100644 --- a/app/views/admin/poll/polls/edit.html.erb +++ b/app/views/admin/poll/polls/edit.html.erb @@ -1,8 +1,9 @@ <%= render 'shared/back_link' %>

<%= t("admin.polls.edit.title") %>

+<%= render "form" %> -
+
\ No newline at end of file diff --git a/app/views/admin/poll/polls/index.html.erb b/app/views/admin/poll/polls/index.html.erb index b24cc10f6..2954e44b8 100644 --- a/app/views/admin/poll/polls/index.html.erb +++ b/app/views/admin/poll/polls/index.html.erb @@ -1,21 +1,22 @@

<%= t("admin.polls.index.title") %>

-<%= link_to t("admin.polls.index.create"), new_admin_poll_path, class: "button success float-right" %> +<%= link_to t("admin.polls.index.create"), + new_admin_poll_path, + class: "button success float-right" %> - -
- <%= t("admin.polls.index.no_polls") %> -
- - - - - - - - - - - <%= render @polls %> - -
<%= t("admin.polls.index.name") %><%= t("admin.polls.index.status") %> 
+<% if Poll.any? %> + + + + + + + + <%= render @polls %> + +
<%= t("admin.polls.index.name") %><%= t("admin.polls.index.status") %> 
+<% else %> +
+ <%= t("admin.polls.index.no_polls") %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/poll/polls/new.html.erb b/app/views/admin/poll/polls/new.html.erb index b2d74cffc..ba1ae7260 100644 --- a/app/views/admin/poll/polls/new.html.erb +++ b/app/views/admin/poll/polls/new.html.erb @@ -2,35 +2,4 @@

<%= t("admin.polls.new.title") %>

-
-
-
- - -
- -
- - -
-
- -
-
- - -
- -
- - -
-
- -
-
- -
-
- -
\ No newline at end of file +<%= render "form" %> \ No newline at end of file diff --git a/app/views/admin/poll/polls/show.html.erb b/app/views/admin/poll/polls/show.html.erb index 105cf2fe6..1b0d1e198 100644 --- a/app/views/admin/poll/polls/show.html.erb +++ b/app/views/admin/poll/polls/show.html.erb @@ -5,7 +5,7 @@ <%= @poll.name %> -<%= link_to t("admin.actions.edit"), "#", class: "button hollow float-right" %> +<%= link_to t("admin.actions.edit"), edit_admin_poll_path(@poll), class: "button hollow float-right" %>

(REFNUM)

Próximamente (15/12/2016 - 15/02/2017)

@@ -26,7 +26,7 @@   - + <%= @poll.booths.each do |booth| %> @@ -40,6 +40,6 @@ <%= link_to t("admin.actions.edit"), "#", class: "button hollow" %> - + <% end %> diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 40f959a3a..bb8093b03 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -155,7 +155,7 @@ en: polls: index: title: "List of polls" - no_polls: "There are any poll." + no_polls: "There are no polls." create: "Create poll" name: "Name" status: "Status" diff --git a/config/locales/responders.en.yml b/config/locales/responders.en.yml index ab1641799..422a59e0c 100755 --- a/config/locales/responders.en.yml +++ b/config/locales/responders.en.yml @@ -6,15 +6,16 @@ en: notice: "%{resource_name} created successfully." debate: "Debate created successfully." direct_message: "You message has been sent successfully." + poll: "Poll created successfully." proposal: "Proposal created successfully." proposal_notification: "Your message has been sent correctly." spending_proposal: "Spending proposal created successfully. You can access it from %{activity}" - save_changes: notice: Changes saved update: notice: "%{resource_name} updated successfully." debate: "Debate updated successfully." + poll: "Poll updated successfully." proposal: "Proposal updated successfully." spending_proposal: "Investment project updated succesfully." destroy: diff --git a/config/locales/responders.es.yml b/config/locales/responders.es.yml index 387085d69..c9292b187 100644 --- a/config/locales/responders.es.yml +++ b/config/locales/responders.es.yml @@ -6,6 +6,7 @@ es: notice: "%{resource_name} creado correctamente." debate: "Debate creado correctamente." direct_message: "Tu mensaje ha sido enviado correctamente." + poll: "Votación presencial creada correctamente." proposal: "Propuesta creada correctamente." proposal_notification: "Tu message ha sido enviado correctamente." spending_proposal: "Propuesta de inversión creada correctamente. Puedes acceder a ella desde %{activity}" diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb index a94c81cc9..8d130e67a 100644 --- a/spec/features/admin/poll/polls_spec.rb +++ b/spec/features/admin/poll/polls_spec.rb @@ -7,6 +7,15 @@ feature 'Admin polls' do login_as(admin.user) end + scenario 'Index empty' do + visit admin_root_path + within('#side_menu') do + click_link "Polls" + end + + expect(page).to have_content "There are no polls" + end + scenario 'Index' do 3.times { create(:poll) } @@ -24,9 +33,10 @@ feature 'Admin polls' do #expect(page).to have_content "Status/Dates" - Hardcoded end end + expect(page).to_not have_content "There are no polls" end - scenario 'Show', :focus do + scenario 'Show' do poll = create(:poll) visit admin_polls_path @@ -37,4 +47,45 @@ feature 'Admin polls' do #expect(page).to have_content "REFNUM" - Hardcoded end + scenario "Create" do + visit admin_polls_path + click_link "Create poll" + + fill_in "poll_name", with: "Upcoming poll" +#fill_in reference_number - Hardcoded +#fill_in open_date - Hardcoded +#fill_in close_date - Hardcoded + click_button "Create poll" + expect(page).to have_content "Poll created successfully" + + expect(page).to have_content "Upcoming poll" + end + + scenario "Edit" do + poll = create(:poll) + + visit admin_poll_path(poll) + click_link "Edit" +save_and_open_page + fill_in "poll_name", with: "Next Poll" +#fill_in reference_number - Hardcoded +#fill_in open_date - Hardcoded +#fill_in close_date - Hardcoded + click_button "Update poll" + expect(page).to have_content "Poll updated successfully" + + expect(page).to have_content "Next Poll" + end + + scenario 'Edit from index' do + poll = create(:poll) + visit admin_polls_path + + within("#poll_#{poll.id}") do + click_link "Edit" + end + + expect(current_path).to eq(edit_admin_poll_path(poll)) + end + end \ No newline at end of file diff --git a/spec/models/poll_spec.rb b/spec/models/poll_spec.rb new file mode 100644 index 000000000..7442cdc5a --- /dev/null +++ b/spec/models/poll_spec.rb @@ -0,0 +1,16 @@ +require 'rails_helper' + +describe :poll do + + let(:poll) { build(:poll) } + + it "should be valid" do + expect(poll).to be_valid + end + + it "should not be valid without a name" do + poll.name = nil + expect(poll).to_not be_valid + end + +end \ No newline at end of file From fda2f3c89ef76582a8ab6d06d8c7a13309a265cf Mon Sep 17 00:00:00 2001 From: rgarcia Date: Sun, 25 Sep 2016 10:21:34 +0200 Subject: [PATCH 37/56] adds admin submit button helper --- app/helpers/admin_helper.rb | 4 ++++ spec/helpers/admin_helper_spec.rb | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 spec/helpers/admin_helper_spec.rb diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 39ab74b96..f14269fb3 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -16,6 +16,10 @@ module AdminHelper Administrator.all.order('users.username asc').includes(:user).collect { |v| [ v.name, v.id ] } end + def admin_submit_action(resource) + resource.persisted? ? "edit" : "new" + end + private def namespace diff --git a/spec/helpers/admin_helper_spec.rb b/spec/helpers/admin_helper_spec.rb new file mode 100644 index 000000000..0239f1926 --- /dev/null +++ b/spec/helpers/admin_helper_spec.rb @@ -0,0 +1,19 @@ +require 'rails_helper' + +describe AdminHelper do + + describe "#admin_submit_action" do + + it "returns new when the the resource has not been persisted" do + poll = build(:poll) + expect(admin_submit_action(poll)).to eq("new") + end + + it "returns edit when the the resource has been persisted" do + poll = create(:poll) + expect(admin_submit_action(poll)).to eq("edit") + end + + end + +end \ No newline at end of file From 3251e4944e7a93b3b042f3a81a87b4eedcaf1487 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Sun, 25 Sep 2016 10:21:58 +0200 Subject: [PATCH 38/56] allow officers to be created without a poll --- app/controllers/admin/poll/officers_controller.rb | 4 ++-- app/views/admin/_menu.html.erb | 14 ++++++++------ app/views/admin/poll/officers/index.html.erb | 4 ++-- config/routes.rb | 6 +++--- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/controllers/admin/poll/officers_controller.rb b/app/controllers/admin/poll/officers_controller.rb index 7f6f918d7..2641a12b5 100644 --- a/app/controllers/admin/poll/officers_controller.rb +++ b/app/controllers/admin/poll/officers_controller.rb @@ -22,12 +22,12 @@ class Admin::Poll::OfficersController < Admin::BaseController @officer.user_id = params[:user_id] @officer.save - redirect_to admin_poll_officers_path + redirect_to admin_officers_path end def destroy @officer.destroy - redirect_to admin_poll_officers_path + redirect_to admin_officers_path end def show diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 48736c378..0661a3bb6 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -84,7 +84,7 @@
  • > - <%= link_to admin_poll_officers_path(Poll.last) do %> + <%= link_to admin_officers_path do %> <%= t('admin.menu.poll_officers') %> <% end %>
  • @@ -95,11 +95,13 @@ <% end %> -
  • > - <%= link_to admin_poll_booths_url(Poll.last) do %> - <%= t('admin.menu.booths') %> - <% end %> -
  • + <% if Poll.any? %> +
  • > + <%= link_to admin_poll_booths_url(Poll.last) do %> + <%= t('admin.menu.booths') %> + <% end %> +
  • + <% end %>
  • > <%= link_to admin_activity_path do %> diff --git a/app/views/admin/poll/officers/index.html.erb b/app/views/admin/poll/officers/index.html.erb index 56daabb94..cc6393204 100644 --- a/app/views/admin/poll/officers/index.html.erb +++ b/app/views/admin/poll/officers/index.html.erb @@ -1,7 +1,7 @@

    <%= t("admin.poll_officers.index.title") %>

    - <%= form_tag search_admin_poll_officers_path, method: :get, remote: true do %> + <%= form_tag search_admin_officers_path, method: :get, remote: true do %>
    <%= text_field_tag :email, '', placeholder: t('admin.poll_officers.search.email_placeholder') %>
    @@ -27,7 +27,7 @@ <% if officer.persisted? %> <%= link_to t('admin.poll_officers.officer.delete'), - admin_poll_officer_path(Poll.last, officer), + admin_officer_path(officer), method: :delete, class: "button hollow alert" %> diff --git a/config/routes.rb b/config/routes.rb index 2b223b46b..9de943f7d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -180,11 +180,11 @@ Rails.application.routes.draw do end scope module: 'poll' do + resources :officers do + get :search, on: :collection + end resources :polls do resources :booths - resources :officers do - get :search, on: :collection - end end end From daac86a7a835163f2a2ea476f3304f98ca816dda Mon Sep 17 00:00:00 2001 From: rgarcia Date: Sun, 25 Sep 2016 10:26:32 +0200 Subject: [PATCH 39/56] removes poll unused attributes --- app/views/admin/poll/polls/_form.html.erb | 22 ++------------- app/views/admin/poll/polls/edit.html.erb | 34 +---------------------- spec/features/admin/poll/polls_spec.rb | 19 ++++--------- 3 files changed, 8 insertions(+), 67 deletions(-) diff --git a/app/views/admin/poll/polls/_form.html.erb b/app/views/admin/poll/polls/_form.html.erb index 64d7177a6..77961912c 100644 --- a/app/views/admin/poll/polls/_form.html.erb +++ b/app/views/admin/poll/polls/_form.html.erb @@ -5,30 +5,12 @@ placeholder: t('admin.polls.new.name'), label: t("admin.polls.new.name") %>
    - -
    - - -
    -
  • - -
    -
    - - -
    - -
    - - -
    - + <%= f.submit t("admin.polls.#{admin_submit_action(@poll)}.submit_button"), + class: "button success expanded" %>
    <% end %> \ No newline at end of file diff --git a/app/views/admin/poll/polls/edit.html.erb b/app/views/admin/poll/polls/edit.html.erb index 0158655a5..cf131203f 100644 --- a/app/views/admin/poll/polls/edit.html.erb +++ b/app/views/admin/poll/polls/edit.html.erb @@ -1,37 +1,5 @@ <%= render 'shared/back_link' %>

    <%= t("admin.polls.edit.title") %>

    -<%= render "form" %> - - - \ No newline at end of file +<%= render "form" %> \ No newline at end of file diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb index 8d130e67a..bab7b5847 100644 --- a/spec/features/admin/poll/polls_spec.rb +++ b/spec/features/admin/poll/polls_spec.rb @@ -30,7 +30,6 @@ feature 'Admin polls' do Poll.all.each do |poll| within("#poll_#{poll.id}") do expect(page).to have_content poll.name -#expect(page).to have_content "Status/Dates" - Hardcoded end end expect(page).to_not have_content "There are no polls" @@ -43,8 +42,6 @@ feature 'Admin polls' do click_link poll.name expect(page).to have_content poll.name -#expect(page).to have_content "Status/Dates" - Hardcoded -#expect(page).to have_content "REFNUM" - Hardcoded end scenario "Create" do @@ -52,12 +49,9 @@ feature 'Admin polls' do click_link "Create poll" fill_in "poll_name", with: "Upcoming poll" -#fill_in reference_number - Hardcoded -#fill_in open_date - Hardcoded -#fill_in close_date - Hardcoded click_button "Create poll" - expect(page).to have_content "Poll created successfully" + expect(page).to have_content "Poll created successfully" expect(page).to have_content "Upcoming poll" end @@ -66,14 +60,11 @@ feature 'Admin polls' do visit admin_poll_path(poll) click_link "Edit" -save_and_open_page - fill_in "poll_name", with: "Next Poll" -#fill_in reference_number - Hardcoded -#fill_in open_date - Hardcoded -#fill_in close_date - Hardcoded - click_button "Update poll" - expect(page).to have_content "Poll updated successfully" + fill_in "poll_name", with: "Next Poll" + click_button "Update poll" + + expect(page).to have_content "Poll updated successfully" expect(page).to have_content "Next Poll" end From 6e6d2ac753fa1efd2009b45e02cb400f2817b013 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 28 Sep 2016 11:53:46 +0200 Subject: [PATCH 40/56] moves poll spec to poll folder --- spec/models/{ => poll}/poll_spec.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spec/models/{ => poll}/poll_spec.rb (100%) diff --git a/spec/models/poll_spec.rb b/spec/models/poll/poll_spec.rb similarity index 100% rename from spec/models/poll_spec.rb rename to spec/models/poll/poll_spec.rb From c4bc484afb287741b3bbaf6dc499df12592f4f9c Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 28 Sep 2016 11:54:29 +0200 Subject: [PATCH 41/56] updates dev seeds with booths --- db/dev_seeds.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index d3d9749b3..51f46b3c6 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -363,4 +363,8 @@ puts "Creating polls" 3.times.each_with_index do |i| Poll.create(name: "Poll #{i}") +end + +10.times.each_with_index do |i| + Poll::Booth.create(name: "Booth #{i}", poll: Poll.all.sample) end \ No newline at end of file From 6d7d6e67eae55d9433ceec527b0262d535c6f819 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 28 Sep 2016 11:55:11 +0200 Subject: [PATCH 42/56] adds consistency to syntax --- app/views/admin/poll/polls/index.html.erb | 2 +- config/routes.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/poll/polls/index.html.erb b/app/views/admin/poll/polls/index.html.erb index 2954e44b8..b4c18d21b 100644 --- a/app/views/admin/poll/polls/index.html.erb +++ b/app/views/admin/poll/polls/index.html.erb @@ -4,7 +4,7 @@ new_admin_poll_path, class: "button success float-right" %> -<% if Poll.any? %> +<% if @polls.any? %> diff --git a/config/routes.rb b/config/routes.rb index 9de943f7d..16625aa7c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -179,7 +179,7 @@ Rails.application.routes.draw do get :search, on: :collection end - scope module: 'poll' do + scope module: :poll do resources :officers do get :search, on: :collection end From 63ccac963a3b21be201a4a5608a46dd9bb826c52 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 28 Sep 2016 11:56:19 +0200 Subject: [PATCH 43/56] adds booth backend for index, show, create and edit actions --- .../admin/poll/booths_controller.rb | 31 +++- app/models/abilities/administrator.rb | 5 +- app/models/poll/booth.rb | 2 + app/views/admin/poll/booths/_form.html.erb | 20 +++ app/views/admin/poll/booths/edit.html.erb | 29 +--- app/views/admin/poll/booths/index.html.erb | 49 +++--- app/views/admin/poll/booths/new.html.erb | 29 +--- app/views/admin/poll/booths/show.html.erb | 13 +- app/views/admin/poll/polls/show.html.erb | 4 +- config/locales/admin.en.yml | 4 +- config/locales/responders.en.yml | 2 + config/locales/responders.es.yml | 3 + .../20160926090107_add_location_to_booths.rb | 5 + db/schema.rb | 5 + spec/factories.rb | 1 + spec/features/admin/poll/booths_spec.rb | 146 ++++++++++++++++++ spec/models/abilities/administrator_spec.rb | 3 + spec/models/poll/booth_spec.rb | 16 ++ 18 files changed, 287 insertions(+), 80 deletions(-) create mode 100644 app/views/admin/poll/booths/_form.html.erb create mode 100644 db/migrate/20160926090107_add_location_to_booths.rb create mode 100644 spec/features/admin/poll/booths_spec.rb create mode 100644 spec/models/poll/booth_spec.rb diff --git a/app/controllers/admin/poll/booths_controller.rb b/app/controllers/admin/poll/booths_controller.rb index 9b1e62f8f..95057ce2f 100644 --- a/app/controllers/admin/poll/booths_controller.rb +++ b/app/controllers/admin/poll/booths_controller.rb @@ -1,5 +1,8 @@ class Admin::Poll::BoothsController < Admin::BaseController - skip_authorization_check + load_and_authorize_resource :poll + load_and_authorize_resource class: 'Poll::Booth', through: :poll + + before_action :load_polls, only: :index def index end @@ -10,7 +13,33 @@ class Admin::Poll::BoothsController < Admin::BaseController def new end + def create + if @booth.save + redirect_to admin_poll_booth_path(@poll, @booth), notice: t("flash.actions.create.poll_booth") + else + render :new + end + end + def edit end + def update + if @booth.update(booth_params) + redirect_to admin_poll_booth_path(@poll, @booth), notice: t("flash.actions.update.poll_booth") + else + render :edit + end + end + + private + + def booth_params + params.require(:poll_booth).permit(:name, :location) + end + + def load_polls + @polls = Poll.all + end + end \ No newline at end of file diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index bd74e1be9..a0e040ab3 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -40,12 +40,13 @@ module Abilities can [:search, :create, :index, :destroy], ::Manager can [:search, :create, :index, :destroy], ::Poll::Officer - can [:manage], Poll - can :manage, Annotation can [:read, :update, :destroy, :summary], SpendingProposal can [:search, :edit, :update, :create, :index, :destroy], Banner + + can [:manage], Poll + can [:manage], Poll::Booth end end end diff --git a/app/models/poll/booth.rb b/app/models/poll/booth.rb index a05f3d547..eb7d81b8c 100644 --- a/app/models/poll/booth.rb +++ b/app/models/poll/booth.rb @@ -2,5 +2,7 @@ class Poll class Booth < ActiveRecord::Base belongs_to :poll has_many :voters + + validates :name, presence: true end end \ No newline at end of file diff --git a/app/views/admin/poll/booths/_form.html.erb b/app/views/admin/poll/booths/_form.html.erb new file mode 100644 index 000000000..31d60c0f0 --- /dev/null +++ b/app/views/admin/poll/booths/_form.html.erb @@ -0,0 +1,20 @@ +
    +
    + <%= f.text_field :name, + placeholder: t('admin.booths.new.name'), + label: t("admin.booths.new.name") %> +
    + +
    + <%= f.text_field :location, + placeholder: t("admin.booths.new.location"), + label: t("admin.booths.new.location") %> +
    +
    + +
    +
    + <%= f.submit t("admin.booths.#{admin_submit_action(@booth)}.submit_button"), + class: "button success expanded" %> +
    +
    \ No newline at end of file diff --git a/app/views/admin/poll/booths/edit.html.erb b/app/views/admin/poll/booths/edit.html.erb index e48db9cdd..23d825b91 100644 --- a/app/views/admin/poll/booths/edit.html.erb +++ b/app/views/admin/poll/booths/edit.html.erb @@ -1,28 +1,7 @@ <%= render 'shared/back_link' %> -

    <%= t("admin.booths.edit.title") %>: <%= t("admin.booths.edit.subtitle") %>

    +

    <%= t("admin.booths.edit.title", poll: @poll.name) %>: <%= t("admin.booths.edit.subtitle") %>

    -
    -
    -
    - - -
    - -
    - - -
    - -
    - - "> -
    -
    - -
    -
    - -
    -
    - +<%= form_for @booth, url: admin_poll_booth_path(@poll, @booth) do |f| %> + <%= render "form", f: f %> +<% end %> diff --git a/app/views/admin/poll/booths/index.html.erb b/app/views/admin/poll/booths/index.html.erb index 918479f38..b3733670d 100644 --- a/app/views/admin/poll/booths/index.html.erb +++ b/app/views/admin/poll/booths/index.html.erb @@ -1,22 +1,27 @@

    <%= t("admin.booths.index.title") %>

    -
    -
    - -
    - - -

    <%= t("admin.booths.index.title_list") %>

    - - -
    - <%= t("admin.booths.index.no_booths") %> +
    + <%= form_tag '', method: :get do %> + <%= select_tag "poll_id", + options_for_select(@polls.collect {|poll| + [poll.name, admin_poll_booths_path(poll)] + }), + prompt: t("admin.booths.index.select_poll"), + class: "js-location-changer" %> + <% end %>
    - -<%= link_to t("admin.booths.index.add_booth"), new_admin_poll_booth_path, class: "button success" %> +

    <%= t("admin.booths.index.title_list", poll: @poll.name) %>

    + +<% if @booths.empty? %> +
    + <%= t("admin.booths.index.no_booths") %> +
    +<% end %> + +<%= link_to t("admin.booths.index.add_booth"), + new_admin_poll_booth_path, + class: "button success" %>
    <%= t("admin.polls.index.name") %>
    @@ -26,23 +31,25 @@ - - + <% @booths.each do |booth| %> + - + <% end %>
     
    - <%= link_to "Urna Moncloa (REFNUM)", "booths/1" %> + <%= link_to booth.name, admin_poll_booth_path(@poll, booth) %> - C/ Isaac Peral, 25. 28003, Madrid + <%= booth.location %> N <%= t("admin.booths.index.officers") %> - <%= link_to t("admin.actions.edit"), "booths/1/edit", class: "button hollow" %> + <%= link_to t("admin.actions.edit"), + edit_admin_poll_booth_path(@poll, booth), + class: "button hollow" %>
    diff --git a/app/views/admin/poll/booths/new.html.erb b/app/views/admin/poll/booths/new.html.erb index e83d2f47c..cffcfab72 100644 --- a/app/views/admin/poll/booths/new.html.erb +++ b/app/views/admin/poll/booths/new.html.erb @@ -1,28 +1,7 @@ <%= render 'shared/back_link' %> -

    <%= t("admin.booths.new.title") %>: <%= t("admin.booths.new.subtitle") %>

    +

    <%= t("admin.booths.new.title", poll: @poll.name) %>: <%= t("admin.booths.new.subtitle") %>

    -
    -
    -
    - - -
    - -
    - - -
    - -
    - - "> -
    -
    - -
    -
    - -
    -
    -
    +<%= form_for @booth, url: admin_poll_booths_path(@poll) do |f| %> + <%= render "form", f: f %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/poll/booths/show.html.erb b/app/views/admin/poll/booths/show.html.erb index 34e1a4465..55f7d5504 100644 --- a/app/views/admin/poll/booths/show.html.erb +++ b/app/views/admin/poll/booths/show.html.erb @@ -1,10 +1,17 @@ <%= render 'shared/back_link' %>
    -

    Urna Moncloa (REFNUM)

    -<%= link_to t("admin.actions.edit"), "1/edit", class: "button hollow float-right" %> +

    + <%= @booth.name %> +

    +<%= link_to t("admin.actions.edit"), + edit_admin_poll_booth_path(@poll, @booth), + class: "button hollow float-right" %> -

    <%= t("admin.booths.show.location") %>: C/ Isaac Peral, 25. 28003, Madrid

    +

    + <%= t("admin.booths.show.location") %>: + <%= @booth.location %> +

    <%= t("admin.booths.show.officers_list") %>

    diff --git a/app/views/admin/poll/polls/show.html.erb b/app/views/admin/poll/polls/show.html.erb index 1b0d1e198..17248d4b9 100644 --- a/app/views/admin/poll/polls/show.html.erb +++ b/app/views/admin/poll/polls/show.html.erb @@ -5,7 +5,9 @@ <%= @poll.name %> -<%= link_to t("admin.actions.edit"), edit_admin_poll_path(@poll), class: "button hollow float-right" %> +<%= link_to t("admin.actions.edit"), + edit_admin_poll_path(@poll), + class: "button hollow float-right" %>

    (REFNUM)

    Próximamente (15/12/2016 - 15/02/2017)

    diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index bb8093b03..db4cf34ca 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -174,7 +174,7 @@ en: close_date: "Close date" submit_button: "Update poll" show: - no_booths: "There is no booths in this poll." + no_booths: "There are no booths in this poll." add_booth: "Add booth" booths_title: "List of booths" name: "Name" @@ -184,7 +184,7 @@ en: title: "List of booths" select_poll: "Select a poll" title_list: "List of booths of poll %{poll}" - no_booths: "There is no booths in this poll." + no_booths: "There are no booths in this poll." add_booth: "Add booth" name: "Name" location: "Location" diff --git a/config/locales/responders.en.yml b/config/locales/responders.en.yml index 422a59e0c..68d77b0d2 100755 --- a/config/locales/responders.en.yml +++ b/config/locales/responders.en.yml @@ -7,6 +7,7 @@ en: debate: "Debate created successfully." direct_message: "You message has been sent successfully." poll: "Poll created successfully." + poll_booth: "Booth created successfully." proposal: "Proposal created successfully." proposal_notification: "Your message has been sent correctly." spending_proposal: "Spending proposal created successfully. You can access it from %{activity}" @@ -16,6 +17,7 @@ en: notice: "%{resource_name} updated successfully." debate: "Debate updated successfully." poll: "Poll updated successfully." + poll_booth: "Booth updated successfully." proposal: "Proposal updated successfully." spending_proposal: "Investment project updated succesfully." destroy: diff --git a/config/locales/responders.es.yml b/config/locales/responders.es.yml index c9292b187..105b00903 100644 --- a/config/locales/responders.es.yml +++ b/config/locales/responders.es.yml @@ -7,6 +7,7 @@ es: debate: "Debate creado correctamente." direct_message: "Tu mensaje ha sido enviado correctamente." poll: "Votación presencial creada correctamente." + poll_booth: "Urna creada correctamente." proposal: "Propuesta creada correctamente." proposal_notification: "Tu message ha sido enviado correctamente." spending_proposal: "Propuesta de inversión creada correctamente. Puedes acceder a ella desde %{activity}" @@ -16,6 +17,8 @@ es: notice: "%{resource_name} actualizado correctamente." debate: "Debate actualizado correctamente." proposal: "Propuesta actualizada correctamente." + poll: "Votación presencial actualizada correctamente." + poll_booth: "Urna actualizada correctamente." spending_proposal: "Propuesta de inversión actualizada correctamente." destroy: spending_proposal: "Propuesta de inversión eliminada." \ No newline at end of file diff --git a/db/migrate/20160926090107_add_location_to_booths.rb b/db/migrate/20160926090107_add_location_to_booths.rb new file mode 100644 index 000000000..146f55d41 --- /dev/null +++ b/db/migrate/20160926090107_add_location_to_booths.rb @@ -0,0 +1,5 @@ +class AddLocationToBooths < ActiveRecord::Migration + def change + add_column :poll_booths, :location, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 75ef4d02c..2da00cfe2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -273,6 +273,11 @@ ActiveRecord::Schema.define(version: 20161102133838) do create_table "poll_booths", force: :cascade do |t| t.string "name" t.integer "poll_id" + t.string "location" + end + + create_table "poll_officers", force: :cascade do |t| + t.integer "user_id" end create_table "poll_officers", force: :cascade do |t| diff --git a/spec/factories.rb b/spec/factories.rb index 7e09fab89..2ef46540e 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -269,6 +269,7 @@ FactoryGirl.define do factory :poll_booth, class: 'Poll::Booth' do sequence(:name) { |n| "Booth #{n}" } + sequence(:location) { |n| "Street #{n}" } poll end diff --git a/spec/features/admin/poll/booths_spec.rb b/spec/features/admin/poll/booths_spec.rb new file mode 100644 index 000000000..ad46c67fb --- /dev/null +++ b/spec/features/admin/poll/booths_spec.rb @@ -0,0 +1,146 @@ +require 'rails_helper' + +feature 'Admin booths' do + + let!(:poll) { create(:poll) } + + background do + admin = create(:administrator) + login_as(admin.user) + end + + scenario 'Index empty' do + visit admin_root_path + + within('#side_menu') do + click_link "Booths" + end + + expect(page).to have_content "There are no booths in this poll" + end + + scenario 'No link to booths when no polls' do + Poll.destroy_all + + visit admin_root_path + + within('#side_menu') do + expect(page).to_not have_link "Booths" + end + end + + scenario 'Index' do + 3.times { create(:poll_booth, poll: poll) } + + visit admin_root_path + + within('#side_menu') do + click_link "Booths" + end + + expect(page).to have_css ".booth", count: 3 + + booths = Poll::Booth.all + booths.each do |booth| + within("#booth_#{booth.id}") do + expect(page).to have_content booth.name + expect(page).to have_content booth.location + end + end + expect(page).to_not have_content "There are no booths" + end + + scenario "Index default to last poll" do + poll1 = create(:poll) + poll2 = create(:poll) + + booth1 = create(:poll_booth, poll: poll1) + booth2 = create(:poll_booth, poll: poll2) + + visit admin_root_path + + within('#side_menu') do + click_link "Booths" + end + + expect(page).to have_css ".booth", count: 1 + expect(page).to have_content booth2.name + expect(page).to_not have_content booth1.name + end + + scenario "Index select poll", :js do + poll1 = create(:poll) + poll2 = create(:poll) + + booth1 = create(:poll_booth, poll: poll1) + booth2 = create(:poll_booth, poll: poll2) + + visit admin_root_path + + within('#side_menu') do + click_link "Booths" + end + + select poll1.name, from: "poll_id" + + expect(page).to have_content "List of booths of poll #{poll1.name}" + expect(page).to have_css ".booth", count: 1 + expect(page).to have_content booth1.name + expect(page).to_not have_content booth2.name + end + + scenario 'Show' do + booth = create(:poll_booth, poll: poll) + + visit admin_poll_booths_path(poll) + click_link booth.name + + expect(page).to have_content booth.name + expect(page).to have_content booth.location + end + + scenario "Create" do + visit admin_poll_booths_path(poll) + click_link "Add booth" + + expect(page).to have_content "Poll #{poll.name}" + + fill_in "poll_booth_name", with: "Upcoming booth" + fill_in "poll_booth_location", with: "39th Street, number 2, ground floor" + click_button "Create booth" + + expect(page).to have_content "Booth created successfully" + expect(page).to have_content "Upcoming booth" + expect(page).to have_content "39th Street, number 2, ground floor" + end + + scenario "Edit" do + booth = create(:poll_booth, poll: poll) + + visit admin_poll_booths_path(poll) + + click_link "Edit" + + expect(page).to have_content "Poll #{poll.name}" + + fill_in "poll_booth_name", with: "Next booth" + fill_in "poll_booth_location", with: "40th Street, number 1, firts floor" + click_button "Update booth" + + expect(page).to have_content "Booth updated successfully" + expect(page).to have_content "Next booth" + expect(page).to have_content "40th Street, number 1, firts floor" + end + + scenario 'Edit from index' do + booth = create(:poll_booth, poll: poll) + visit admin_poll_booths_path(poll) + + within("#booth_#{booth.id}") do + click_link "Edit" + end + + expect(current_path).to eq(edit_admin_poll_booth_path(poll, booth)) + end + +end \ No newline at end of file diff --git a/spec/models/abilities/administrator_spec.rb b/spec/models/abilities/administrator_spec.rb index f9ed7a0c5..04fd199f0 100644 --- a/spec/models/abilities/administrator_spec.rb +++ b/spec/models/abilities/administrator_spec.rb @@ -56,4 +56,7 @@ describe "Abilities::Administrator" do it { should be_able_to(:update, SpendingProposal) } it { should be_able_to(:valuate, SpendingProposal) } it { should be_able_to(:destroy, SpendingProposal) } + + it { should be_able_to(:manage, Poll) } + it { should be_able_to(:manage, Poll::Booth) } end diff --git a/spec/models/poll/booth_spec.rb b/spec/models/poll/booth_spec.rb new file mode 100644 index 000000000..2fabb9c12 --- /dev/null +++ b/spec/models/poll/booth_spec.rb @@ -0,0 +1,16 @@ +require 'rails_helper' + +describe :booth do + + let(:booth) { build(:poll_booth) } + + it "should be valid" do + expect(booth).to be_valid + end + + it "should not be valid without a name" do + booth.name = nil + expect(booth).to_not be_valid + end + +end \ No newline at end of file From 963bb4b60210924a38f8be43279a34ee4d355fc9 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 28 Sep 2016 11:56:48 +0200 Subject: [PATCH 44/56] removes unused attributes from poll show --- app/views/admin/poll/polls/_poll.html.erb | 4 ---- app/views/admin/poll/polls/show.html.erb | 2 -- 2 files changed, 6 deletions(-) diff --git a/app/views/admin/poll/polls/_poll.html.erb b/app/views/admin/poll/polls/_poll.html.erb index 4128ad222..d90fed14a 100644 --- a/app/views/admin/poll/polls/_poll.html.erb +++ b/app/views/admin/poll/polls/_poll.html.erb @@ -4,10 +4,6 @@ <%= link_to poll.name, admin_poll_path(poll) %>
    - - Próximamente -
    (15/12/2016 - 15/02/2017) - <%= link_to t("admin.actions.edit"), edit_admin_poll_path(poll), diff --git a/app/views/admin/poll/polls/show.html.erb b/app/views/admin/poll/polls/show.html.erb index 17248d4b9..8a02ebfd7 100644 --- a/app/views/admin/poll/polls/show.html.erb +++ b/app/views/admin/poll/polls/show.html.erb @@ -9,8 +9,6 @@ edit_admin_poll_path(@poll), class: "button hollow float-right" %> -

    (REFNUM)

    -

    Próximamente (15/12/2016 - 15/02/2017)

    <%= link_to t("admin.polls.show.add_booth"), "#", class: "button success" %> From e810fe3e341040d80e3cef46dee9019b636c031f Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 28 Sep 2016 12:01:58 +0200 Subject: [PATCH 45/56] maintains poll date and status in index for demo --- app/views/admin/poll/polls/_poll.html.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/admin/poll/polls/_poll.html.erb b/app/views/admin/poll/polls/_poll.html.erb index d90fed14a..4128ad222 100644 --- a/app/views/admin/poll/polls/_poll.html.erb +++ b/app/views/admin/poll/polls/_poll.html.erb @@ -4,6 +4,10 @@ <%= link_to poll.name, admin_poll_path(poll) %> + + Próximamente +
    (15/12/2016 - 15/02/2017) + <%= link_to t("admin.actions.edit"), edit_admin_poll_path(poll), From de330b1c0262760a0d9e3e736dd7d372d7ba9504 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 28 Sep 2016 12:34:24 +0200 Subject: [PATCH 46/56] adds booth info to poll show --- app/views/admin/poll/booths/_booth.html.erb | 18 +++++++ app/views/admin/poll/booths/index.html.erb | 21 +------- app/views/admin/poll/polls/show.html.erb | 55 +++++++++------------ config/locales/admin.en.yml | 1 + config/locales/admin.es.yml | 1 + spec/features/admin/poll/polls_spec.rb | 44 ++++++++++++++++- 6 files changed, 88 insertions(+), 52 deletions(-) create mode 100644 app/views/admin/poll/booths/_booth.html.erb diff --git a/app/views/admin/poll/booths/_booth.html.erb b/app/views/admin/poll/booths/_booth.html.erb new file mode 100644 index 000000000..ff1683867 --- /dev/null +++ b/app/views/admin/poll/booths/_booth.html.erb @@ -0,0 +1,18 @@ + + + + <%= link_to booth.name, admin_poll_booth_path(@poll, booth) %> + + + + <%= booth.location %> + + + N <%= t("admin.booths.index.officers") %> + + + <%= link_to t("admin.actions.edit"), + edit_admin_poll_booth_path(@poll, booth), + class: "button hollow" %> + + \ No newline at end of file diff --git a/app/views/admin/poll/booths/index.html.erb b/app/views/admin/poll/booths/index.html.erb index b3733670d..d2a9a7e5a 100644 --- a/app/views/admin/poll/booths/index.html.erb +++ b/app/views/admin/poll/booths/index.html.erb @@ -20,7 +20,7 @@ <% end %> <%= link_to t("admin.booths.index.add_booth"), - new_admin_poll_booth_path, + new_admin_poll_booth_path(@poll), class: "button success" %> @@ -32,24 +32,7 @@ <% @booths.each do |booth| %> - - - - - - + <%= render partial: "booth", locals: { booth: booth } %> <% end %>
    - - <%= link_to booth.name, admin_poll_booth_path(@poll, booth) %> - - - <%= booth.location %> - - N <%= t("admin.booths.index.officers") %> - - <%= link_to t("admin.actions.edit"), - edit_admin_poll_booth_path(@poll, booth), - class: "button hollow" %> -
    diff --git a/app/views/admin/poll/polls/show.html.erb b/app/views/admin/poll/polls/show.html.erb index 8a02ebfd7..bed01af41 100644 --- a/app/views/admin/poll/polls/show.html.erb +++ b/app/views/admin/poll/polls/show.html.erb @@ -9,37 +9,28 @@ edit_admin_poll_path(@poll), class: "button hollow float-right" %> -<%= link_to t("admin.polls.show.add_booth"), "#", class: "button success" %> +<%= link_to t("admin.polls.show.add_booth"), + new_admin_poll_booth_path(@poll), + class: "button success" %> - -
    - <%= t("admin.polls.show.no_booths") %> -
    - +<% if @poll.booths.empty? %> +
    + <%= t("admin.polls.show.no_booths") %> +
    +<% else %> +

    <%= t("admin.polls.show.booths_title") %>

    -

    <%= t("admin.polls.show.booths_title") %>

    - - - - - - - - - <%= @poll.booths.each do |booth| %> - - - - - - <% end %> - -
    <%= t("admin.polls.show.name") %><%= t("admin.polls.show.location") %> 
    - - <%= link_to "Urna Moncloa (REFNUM)", "#" %> - - - C/ Isaac Peral, 25. 28003, Madrid - - <%= link_to t("admin.actions.edit"), "#", class: "button hollow" %> -
    + + + + + + + + + <% @poll.booths.each do |booth| %> + <%= render partial: "admin/poll/booths/booth", locals: { booth: booth } %> + <% end %> + +
    <%= t("admin.polls.show.name") %><%= t("admin.polls.show.location") %><%= t("admin.polls.show.officers") %> 
    +<% end %> \ No newline at end of file diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index db4cf34ca..ef294262d 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -179,6 +179,7 @@ en: booths_title: "List of booths" name: "Name" location: "Location" + officers: "Officers" booths: index: title: "List of booths" diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 6023da712..48dfe2959 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -179,6 +179,7 @@ es: booths_title: "Listado de urnas" name: "Nombre" location: "Ubicación" + officers: "Presidentes de mesa" booths: index: title: "Lista de urnas" diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb index bab7b5847..80f875567 100644 --- a/spec/features/admin/poll/polls_spec.rb +++ b/spec/features/admin/poll/polls_spec.rb @@ -27,7 +27,8 @@ feature 'Admin polls' do expect(page).to have_css ".poll", count: 3 - Poll.all.each do |poll| + polls = Poll.all + polls.each do |poll| within("#poll_#{poll.id}") do expect(page).to have_content poll.name end @@ -79,4 +80,45 @@ feature 'Admin polls' do expect(current_path).to eq(edit_admin_poll_path(poll)) end + context "Booths" do + + context "Poll show" do + + scenario "No booths" do + poll = create(:poll) + visit admin_poll_path(poll) + + expect(page).to have_content "There are no booths in this poll." + end + + scenario "Booth list" do + poll = create(:poll) + 3.times { create(:poll_booth, poll: poll) } + + visit admin_poll_path(poll) + + expect(page).to have_css ".booth", count: 3 + + booths = Poll::Booth.all + booths.each do |booth| + within("#booth_#{booth.id}") do + expect(page).to have_content booth.name + expect(page).to have_content booth.location + end + end + expect(page).to_not have_content "There are no booths" + end + + scenario "Add booth" do + poll = create(:poll) + visit admin_poll_path(poll) + + click_link "Add booth" + + expect(current_path).to eq(new_admin_poll_booth_path(poll)) + expect(page).to have_content poll.name + end + end + end + end \ No newline at end of file From 5ba72f0fe3bd7aee202c9827ee74cff34f5ab4c4 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 28 Sep 2016 18:39:01 +0200 Subject: [PATCH 47/56] assigns officers to booths --- .../admin/poll/booths_controller.rb | 3 +- app/helpers/officers_helper.rb | 7 + app/models/poll/booth.rb | 2 + app/models/poll/officing_booth.rb | 6 + app/views/admin/poll/booths/show.html.erb | 40 +++--- config/locales/admin.en.yml | 2 +- .../20160928113143_create_officing_booths.rb | 9 ++ db/schema.rb | 7 +- spec/factories.rb | 12 ++ spec/features/admin/poll/officers_spec.rb | 129 +++++++++++++++++- 10 files changed, 189 insertions(+), 28 deletions(-) create mode 100644 app/helpers/officers_helper.rb create mode 100644 app/models/poll/officing_booth.rb create mode 100644 db/migrate/20160928113143_create_officing_booths.rb diff --git a/app/controllers/admin/poll/booths_controller.rb b/app/controllers/admin/poll/booths_controller.rb index 95057ce2f..1d05ddab5 100644 --- a/app/controllers/admin/poll/booths_controller.rb +++ b/app/controllers/admin/poll/booths_controller.rb @@ -8,6 +8,7 @@ class Admin::Poll::BoothsController < Admin::BaseController end def show + @officers = Poll::Officer.all end def new @@ -35,7 +36,7 @@ class Admin::Poll::BoothsController < Admin::BaseController private def booth_params - params.require(:poll_booth).permit(:name, :location) + params.require(:poll_booth).permit(:name, :location, officer_ids: []) end def load_polls diff --git a/app/helpers/officers_helper.rb b/app/helpers/officers_helper.rb new file mode 100644 index 000000000..f29bcf728 --- /dev/null +++ b/app/helpers/officers_helper.rb @@ -0,0 +1,7 @@ +module OfficersHelper + + def officer_label(officer) + truncate([officer.name, officer.email].compact.join(' - '), length: 100) + end + +end \ No newline at end of file diff --git a/app/models/poll/booth.rb b/app/models/poll/booth.rb index eb7d81b8c..74c4c3edb 100644 --- a/app/models/poll/booth.rb +++ b/app/models/poll/booth.rb @@ -2,6 +2,8 @@ class Poll class Booth < ActiveRecord::Base belongs_to :poll has_many :voters + has_many :officing_booths, dependent: :destroy + has_many :officers, through: :officing_booths validates :name, presence: true end diff --git a/app/models/poll/officing_booth.rb b/app/models/poll/officing_booth.rb new file mode 100644 index 000000000..f0a64721a --- /dev/null +++ b/app/models/poll/officing_booth.rb @@ -0,0 +1,6 @@ +class Poll + class OfficingBooth < ActiveRecord::Base + belongs_to :officer + belongs_to :booth + end +end diff --git a/app/views/admin/poll/booths/show.html.erb b/app/views/admin/poll/booths/show.html.erb index 55f7d5504..cce704d2c 100644 --- a/app/views/admin/poll/booths/show.html.erb +++ b/app/views/admin/poll/booths/show.html.erb @@ -15,34 +15,32 @@

    <%= t("admin.booths.show.officers_list") %>

    - -
    - <%= t("admin.booths.show.no_officers") %> -
    - - -<%= link_to t("admin.booths.show.assign_officer"), "#", class: "button success" %> +<% if @booth.officers.empty? %> +
    + <%= t("admin.booths.show.no_officers") %> +
    +<% end %>
    - - <%# f.label :valuator_ids, t("admin.spending_proposals.edit.assigned_valuators") %> + <%= form_for @booth, url: admin_poll_booth_path(@poll, @booth) do |f| %> - <%# f.collection_check_boxes :valuator_ids, @valuators, :id, :email do |b| %> - <%# b.label(title: valuator_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %> - <%# end %> + <%= f.label :officer_ids, t("admin.spending_proposals.edit.assigned_valuators") %> + <%= f.collection_check_boxes :officer_ids, @officers, :id, :email do |b| %> + <% b.label { b.check_box + truncate(officer_label(b.object), length: 60) } %> + <% end %> + + <%= f.submit t("admin.booths.show.assign_officer"), class: "button success" %> + <% end %>
    - - <%# @officers.each do |officer| %> - +
    + <% @booth.officers.each do |officer| %> + - <%# end %> + <% end %>
    - <%# officer.name %> - Admin + <%= officer.name %> - admin@consul.dev - <%# officer.email %> + <%= officer.email %> <%= link_to t('admin.poll_officers.officer.delete'), "#", class: "button hollow alert" %> @@ -53,5 +51,5 @@ %>
    \ No newline at end of file diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index ef294262d..c4a94a86e 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -208,7 +208,7 @@ en: location: "Location" assign_officer: "Assign officer" officers_list: "List of officers" - no_officers: "There is no officers in this booth." + no_officers: "There are no officers assigned to this booth" officials: edit: destroy: Remove 'Official' status diff --git a/db/migrate/20160928113143_create_officing_booths.rb b/db/migrate/20160928113143_create_officing_booths.rb new file mode 100644 index 000000000..00483fe00 --- /dev/null +++ b/db/migrate/20160928113143_create_officing_booths.rb @@ -0,0 +1,9 @@ +class CreateOfficingBooths < ActiveRecord::Migration + def change + create_table :poll_officing_booths do |t| + t.belongs_to :officer + t.belongs_to :booth + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 2da00cfe2..313c6d1f1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -280,8 +280,11 @@ ActiveRecord::Schema.define(version: 20161102133838) do t.integer "user_id" end - create_table "poll_officers", force: :cascade do |t| - t.integer "user_id" + create_table "poll_officing_booths", force: :cascade do |t| + t.integer "officer_id" + t.integer "booth_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "poll_voters", force: :cascade do |t| diff --git a/spec/factories.rb b/spec/factories.rb index 2ef46540e..b88af100c 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -267,6 +267,18 @@ FactoryGirl.define do sequence(:name) { |n| "Poll #{n}" } end +<<<<<<< HEAD +======= + factory :poll_officer, class: 'Poll::Officer' do + user + end + + factory :officing_booth, class: 'Poll::OfficingBooth' do + association :officer, factory: :poll_officer + association :booth, factory: :poll_booth + end + +>>>>>>> assigns officers to booths factory :poll_booth, class: 'Poll::Booth' do sequence(:name) { |n| "Booth #{n}" } sequence(:location) { |n| "Street #{n}" } diff --git a/spec/features/admin/poll/officers_spec.rb b/spec/features/admin/poll/officers_spec.rb index ed9ec545d..981b17f13 100644 --- a/spec/features/admin/poll/officers_spec.rb +++ b/spec/features/admin/poll/officers_spec.rb @@ -1,12 +1,13 @@ require 'rails_helper' feature 'Admin poll officers' do + background do @admin = create(:administrator) @user = create(:user, username: 'Pedro Jose Garcia') @officer = create(:poll_officer) login_as(@admin.user) - visit admin_poll_officers_path + visit admin_officers_path end scenario 'Index' do @@ -15,7 +16,7 @@ feature 'Admin poll officers' do expect(page).to_not have_content @user.name end - scenario 'Create poll officer', :js do + scenario 'Create', :js do fill_in 'email', with: @user.email click_button 'Search' @@ -26,11 +27,133 @@ feature 'Admin poll officers' do end end - scenario 'Delete poll officer' do + scenario 'Delete' do click_link 'Delete' within("#officers") do expect(page).to_not have_content @officer.name end end + + context "Booth" do + + scenario 'No officers assigned to booth' do + poll = create(:poll) + booth = create(:poll_booth, poll: poll) + + visit admin_poll_booth_path(poll, booth) + + within("#assigned_officers") do + expect(page).to have_css ".officer", count: 0 + end + + expect(page).to have_content "There are no officers assigned to this booth" + end + + scenario "Assigned to booth" do + john = create(:poll_officer) + isabel = create(:poll_officer) + eve = create(:poll_officer) + + poll = create(:poll) + booth = create(:poll_booth, poll: poll) + + officing_booth1 = create(:officing_booth, officer: john, booth: booth) + officing_booth2 = create(:officing_booth, officer: isabel, booth: booth) + + visit admin_poll_booth_path(poll, booth) + + within("#assigned_officers") do + expect(page).to have_css ".officer", count: 2 + expect(page).to have_content john.name + expect(page).to have_content isabel.name + + expect(page).to_not have_content eve.name + end + + expect(page).to_not have_content "There are no officers assigned to this booth" + end + + scenario 'Assign to booth' do + john = create(:poll_officer) + isabel = create(:poll_officer) + + poll = create(:poll) + booth = create(:poll_booth, poll: poll) + + visit admin_poll_booth_path(poll, booth) + + check "#{john.name} - #{john.email}" + click_button "Assign officer" + + expect(page).to have_content "Booth updated successfully." + within("#assigned_officers") do + expect(page).to have_css ".officer", count: 1 + expect(page).to have_content john.name + end + end + + scenario "Unassign from booth" do + john = create(:poll_officer) + isabel = create(:poll_officer) + + poll = create(:poll) + booth = create(:poll_booth, poll: poll) + + officing_booth = create(:officing_booth, officer: john, booth: booth) + officing_booth = create(:officing_booth, officer: isabel, booth: booth) + + visit admin_poll_booth_path(poll, booth) + + uncheck "#{john.name} - #{john.email}" + click_button "Assign officer" + + expect(page).to have_content "Booth updated successfully." + within("#assigned_officers") do + expect(page).to have_css ".officer", count: 1 + expect(page).to have_content isabel.name + + expect(page).to_not have_content john.name + end + end + + scenario "Assigned multiple officers to different booths" do + john = create(:poll_officer) + isabel = create(:poll_officer) + eve = create(:poll_officer) + peter = create(:poll_officer) + + poll1 = create(:poll) + poll2 = create(:poll) + + booth1 = create(:poll_booth, poll: poll1) + booth2 = create(:poll_booth, poll: poll1) + booth3 = create(:poll_booth, poll: poll2) + + officing_booth = create(:officing_booth, officer: john, booth: booth1) + officing_booth = create(:officing_booth, officer: isabel, booth: booth1) + officing_booth = create(:officing_booth, officer: eve, booth: booth2) + officing_booth = create(:officing_booth, officer: peter, booth: booth3) + + visit admin_poll_booth_path(poll1, booth1) + within("#assigned_officers") do + expect(page).to have_css ".officer", count: 2 + expect(page).to have_content john.name + expect(page).to have_content isabel.name + end + + visit admin_poll_booth_path(poll1, booth2) + within("#assigned_officers") do + expect(page).to have_css ".officer", count: 1 + expect(page).to have_content eve.name + end + + visit admin_poll_booth_path(poll2, booth3) + within("#assigned_officers") do + expect(page).to have_css ".officer", count: 1 + expect(page).to have_content peter.name + end + end + end + end \ No newline at end of file From 70752e217d13b7515b6a718152e3eee76cf2fc53 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Fri, 14 Oct 2016 19:00:58 +0200 Subject: [PATCH 48/56] adds styles for offering voters views --- app/views/officing/dashboard/index.html.erb | 1 - app/views/officing/voters/new.html.erb | 21 +++++++++++++++- app/views/officing/voters/show.html.erb | 26 +++++++++++++++++++- config/locales/officing.en.yml | 18 ++++++++++++-- config/locales/officing.es.yml | 27 +++++++++++++++++++-- 5 files changed, 86 insertions(+), 7 deletions(-) diff --git a/app/views/officing/dashboard/index.html.erb b/app/views/officing/dashboard/index.html.erb index cf014d719..861a39b1a 100644 --- a/app/views/officing/dashboard/index.html.erb +++ b/app/views/officing/dashboard/index.html.erb @@ -2,5 +2,4 @@

    <%= t("officing.dashboard.index.title") %>

    <%= t("officing.dashboard.index.info") %>

    -
    diff --git a/app/views/officing/voters/new.html.erb b/app/views/officing/voters/new.html.erb index 0fb4c6bc3..37edfd788 100644 --- a/app/views/officing/voters/new.html.erb +++ b/app/views/officing/voters/new.html.erb @@ -1 +1,20 @@ -voters new +

    <%= t("officing.voters.new.title") %>

    + +
    +
    +
    + + + + + + "> + + " class="button"> +
    +
    +
    diff --git a/app/views/officing/voters/show.html.erb b/app/views/officing/voters/show.html.erb index fd8c83123..3de9d9651 100644 --- a/app/views/officing/voters/show.html.erb +++ b/app/views/officing/voters/show.html.erb @@ -1 +1,25 @@ -voters show \ No newline at end of file +

    <%= t("officing.voters.show.title") %>

    + + + +
    + <%= t("officing.voters.show.error_verifying_census") %> +
    + + + +
    + <%= t("officing.voters.show.error_already_voted") %> +
    + + + +
    + <%= t("officing.voters.show.success") %> +
    + +
    +
    + " class="button success expanded"> +
    +
    diff --git a/config/locales/officing.en.yml b/config/locales/officing.en.yml index 532d18498..c8989dfc6 100644 --- a/config/locales/officing.en.yml +++ b/config/locales/officing.en.yml @@ -6,5 +6,19 @@ en: title: Poll officing info: Here you can validate user documents and store voting results menu: - voters: Validate citizen document - results: Store voting results \ No newline at end of file + voters: Validate document + results: Store results + voters: + new: + title: Validate document + document_number: Document number + document_type: + passport: Passport + residence_card: Residence card + spanish_id: DNI + document_type_label: Document type + submit: Validate document + show: + title: Validate document + error_verifying_census: "The Census was unable to verify your information." + error_already_voted: "La persona asociada al documento ya ha participado en la votación." \ No newline at end of file diff --git a/config/locales/officing.es.yml b/config/locales/officing.es.yml index baa60b106..8ab0dc384 100644 --- a/config/locales/officing.es.yml +++ b/config/locales/officing.es.yml @@ -6,5 +6,28 @@ es: title: Presidir mesa de votaciones info: Aquí puedes validar documentos de ciudadanos y guardar los resultados de las urnas menu: - voters: Validar documento de identidad - results: Guardar resultados de la votación \ No newline at end of file + voters: Validar documento + results: Guardar resultados + voters: + new: + title: Validar documento + document_number: Número de documento + document_type: + passport: Pasaporte + residence_card: Tarjeta de residencia + spanish_id: DNI + document_type_label: Tipo de documento + submit: Validar documento + show: + title: Validar documento + error_verifying_census: "El Padrón no pudo verificar tu información." + error_already_voted: "La persona asociada al documento ya ha participado en la votación." + success: "La persona asociada al documento puede participar en la votación." + submit: Validar voto + results: + index: + title: "Resultados de la votación" + new: + title: "Añadir resultados" + show: + title: "Resultados" \ No newline at end of file From 1a56d5bbe6dd954e2341cdaf73cfcd91d57f2b63 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Mon, 17 Oct 2016 16:42:50 +0200 Subject: [PATCH 49/56] adds styles to officing voters views --- app/assets/stylesheets/admin.scss | 4 ++ app/views/officing/_menu.html.erb | 2 +- app/views/officing/results/index.html.erb | 55 ++++++++++++++++++++++- app/views/officing/results/new.html.erb | 39 +++++++++++++++- app/views/officing/results/show.html.erb | 51 ++++++++++++++++++++- app/views/officing/voters/new.html.erb | 2 +- app/views/officing/voters/show.html.erb | 7 ++- config/locales/officing.en.yml | 24 +++++++++- config/locales/officing.es.yml | 19 ++++++-- 9 files changed, 191 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index 4968983f0..ee16c798c 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -42,6 +42,10 @@ body.admin { th { text-align: left; + + &.text-center { + text-align: center; + } } tr { diff --git a/app/views/officing/_menu.html.erb b/app/views/officing/_menu.html.erb index 81734d99f..f051b5940 100644 --- a/app/views/officing/_menu.html.erb +++ b/app/views/officing/_menu.html.erb @@ -14,5 +14,5 @@ <%= t("officing.menu.results") %> <% end %> - +
    diff --git a/app/views/officing/results/index.html.erb b/app/views/officing/results/index.html.erb index 8e9faa1ab..8e50de625 100644 --- a/app/views/officing/results/index.html.erb +++ b/app/views/officing/results/index.html.erb @@ -1 +1,54 @@ -results index \ No newline at end of file +

    <%= t("officing.results.index.title") %>

    + +
    +
    + +
    + +
    + +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    <%= t("officing.shared.booth") %><%= t("officing.shared.date") %><%= t("officing.shared.officer") %><%= t("officing.shared.votes_number") %>
    <%= link_to "Urna Moncloa (1)", officing_poll_result_path(Poll.last, 1) %>14/10/2016Officer Name (officer@email.com)124
    <%= link_to "Urna Cahamartín (6)", officing_poll_result_path(Poll.last, 1) %>17/10/2016Other Officer (otherofficer@email.com)350
    <%= t("officing.results.index.total_votes") %>474
    diff --git a/app/views/officing/results/new.html.erb b/app/views/officing/results/new.html.erb index bb40dff9e..178efbadd 100644 --- a/app/views/officing/results/new.html.erb +++ b/app/views/officing/results/new.html.erb @@ -1 +1,38 @@ -results new \ No newline at end of file +

    <%= t("officing.results.new.title") %>

    + +
    + +
    +
    + + +
    + +
    + + +
    +
    + +
    +
    + + +
    +
    + +
    + +
    +
    + + "> +
    +
    + +
    +
    + " class="button expanded"> +
    +
    +
    diff --git a/app/views/officing/results/show.html.erb b/app/views/officing/results/show.html.erb index b3ca8e29c..4c7b88e00 100644 --- a/app/views/officing/results/show.html.erb +++ b/app/views/officing/results/show.html.erb @@ -1 +1,50 @@ -results show \ No newline at end of file +<%= render 'shared/back_link' %> + +

    <%= t("officing.results.show.title", booth: "Booth Name (1)") %>

    + +
    +
    + +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    <%= t("officing.shared.date") %><%= t("officing.shared.officer") %><%= t("officing.shared.votes_number") %>
    14/10/2016Officer Name (officer@email.com)124
    17/10/2016Other Officer (otherofficer@email.com)350
    18/10/2016Officer number 3 (officer3@email.com)100
    <%= t("officing.results.index.total_votes") %>574
    diff --git a/app/views/officing/voters/new.html.erb b/app/views/officing/voters/new.html.erb index 37edfd788..2042f7acb 100644 --- a/app/views/officing/voters/new.html.erb +++ b/app/views/officing/voters/new.html.erb @@ -1,7 +1,7 @@

    <%= t("officing.voters.new.title") %>

    -
    +
    diff --git a/app/views/officing/voters/show.html.erb b/app/views/officing/voters/show.html.erb index 3de9d9651..523e0e0d4 100644 --- a/app/views/officing/voters/show.html.erb +++ b/app/views/officing/voters/show.html.erb @@ -15,7 +15,7 @@
    - <%= t("officing.voters.show.success") %> + <%= t("officing.voters.show.can_participate") %>
    @@ -23,3 +23,8 @@ " class="button success expanded">
    + + +
    + <%= t("officing.voters.show.success") %> +
    \ No newline at end of file diff --git a/config/locales/officing.en.yml b/config/locales/officing.en.yml index c8989dfc6..20cd8fcfc 100644 --- a/config/locales/officing.en.yml +++ b/config/locales/officing.en.yml @@ -20,5 +20,25 @@ en: submit: Validate document show: title: Validate document - error_verifying_census: "The Census was unable to verify your information." - error_already_voted: "La persona asociada al documento ya ha participado en la votación." \ No newline at end of file + error_verifying_census: "The Census was unable to verify the information of this document." + error_already_voted: "The person associated with the document has already participated in the vote." + can_participate: "The person associated with the document can participate in the vote." + submit: Validate vote + success: "Vote validated correctly." + results: + index: + title: "Vote results" + total_votes: "Total number of votes" + new: + title: Save results + submit: Save + show: + title: "%{booth} results" + shared: + filter_booth: All booths + filter_date: All dates + filter_officer: All officers + booth: Booth + date: Date + officer: Officer + votes_number: Number of votes diff --git a/config/locales/officing.es.yml b/config/locales/officing.es.yml index 8ab0dc384..e187365f1 100644 --- a/config/locales/officing.es.yml +++ b/config/locales/officing.es.yml @@ -20,14 +20,25 @@ es: submit: Validar documento show: title: Validar documento - error_verifying_census: "El Padrón no pudo verificar tu información." + error_verifying_census: "El Padrón no pudo verificar la información de este documento." error_already_voted: "La persona asociada al documento ya ha participado en la votación." - success: "La persona asociada al documento puede participar en la votación." + can_participate: "La persona asociada al documento puede participar en la votación." submit: Validar voto + success: "Voto validado correctamente." results: index: title: "Resultados de la votación" + total_votes: "Número total de votos" new: - title: "Añadir resultados" + title: Guardar resultados + submit: Guardar show: - title: "Resultados" \ No newline at end of file + title: "Resultados de %{booth}" + shared: + filter_booth: Todas las urnas + filter_date: Todas las fechas + filter_officer: Todos los presidentes de mesa + booth: Urna + date: Fecha + officer: Presidente de mesa + votes_number: Número de votos From 96cf578259f0a2cc5be930828414c3233cbdea2f Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Mon, 17 Oct 2016 16:43:11 +0200 Subject: [PATCH 50/56] add officing to i18n tasks --- config/i18n-tasks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index edaaa0958..2008f02e1 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -32,6 +32,7 @@ data: - config/locales/devise_views.%{locale}.yml - config/locales/responders.%{locale}.yml - config/locales/kaminari.%{locale}.yml + - config/locales/officing.%{locale}.yml # Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom: # `i18n-tasks normalize -p` will force move the keys according to these rules From 0dd122833a6f71403af30f5c6be2873bf3d145b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Wed, 19 Oct 2016 13:44:05 +0200 Subject: [PATCH 51/56] removes booths link from admin menu --- app/views/admin/_menu.html.erb | 8 ---- spec/features/admin/poll/booths_spec.rb | 57 +++---------------------- 2 files changed, 5 insertions(+), 60 deletions(-) diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 0661a3bb6..11e46814d 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -95,14 +95,6 @@ <% end %> - <% if Poll.any? %> -
  • > - <%= link_to admin_poll_booths_url(Poll.last) do %> - <%= t('admin.menu.booths') %> - <% end %> -
  • - <% end %> -
  • > <%= link_to admin_activity_path do %> <%= t('admin.menu.activity') %> diff --git a/spec/features/admin/poll/booths_spec.rb b/spec/features/admin/poll/booths_spec.rb index ad46c67fb..eff653dfe 100644 --- a/spec/features/admin/poll/booths_spec.rb +++ b/spec/features/admin/poll/booths_spec.rb @@ -13,32 +13,24 @@ feature 'Admin booths' do visit admin_root_path within('#side_menu') do - click_link "Booths" + click_link "Polls" end + click_link poll.name + expect(page).to have_content "There are no booths in this poll" end - scenario 'No link to booths when no polls' do - Poll.destroy_all - - visit admin_root_path - - within('#side_menu') do - expect(page).to_not have_link "Booths" - end - end - scenario 'Index' do 3.times { create(:poll_booth, poll: poll) } visit admin_root_path within('#side_menu') do - click_link "Booths" + click_link "Polls" end - expect(page).to have_css ".booth", count: 3 + click_link poll.name booths = Poll::Booth.all booths.each do |booth| @@ -50,45 +42,6 @@ feature 'Admin booths' do expect(page).to_not have_content "There are no booths" end - scenario "Index default to last poll" do - poll1 = create(:poll) - poll2 = create(:poll) - - booth1 = create(:poll_booth, poll: poll1) - booth2 = create(:poll_booth, poll: poll2) - - visit admin_root_path - - within('#side_menu') do - click_link "Booths" - end - - expect(page).to have_css ".booth", count: 1 - expect(page).to have_content booth2.name - expect(page).to_not have_content booth1.name - end - - scenario "Index select poll", :js do - poll1 = create(:poll) - poll2 = create(:poll) - - booth1 = create(:poll_booth, poll: poll1) - booth2 = create(:poll_booth, poll: poll2) - - visit admin_root_path - - within('#side_menu') do - click_link "Booths" - end - - select poll1.name, from: "poll_id" - - expect(page).to have_content "List of booths of poll #{poll1.name}" - expect(page).to have_css ".booth", count: 1 - expect(page).to have_content booth1.name - expect(page).to_not have_content booth2.name - end - scenario 'Show' do booth = create(:poll_booth, poll: poll) From 6e3da012e5adedcdf8e3a4b0fe86a3a9871549e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Thu, 20 Oct 2016 12:31:06 +0200 Subject: [PATCH 52/56] removes unused i18n key --- config/locales/admin.en.yml | 1 - config/locales/admin.es.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index c4a94a86e..6c42ac23e 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -106,7 +106,6 @@ en: valuators: Valuators poll_officers: Poll officers polls: Polls - booths: Booths officials: Officials organizations: Organisations settings: Configuration settings diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 48dfe2959..55991e056 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -106,7 +106,6 @@ es: valuators: Evaluadores poll_officers: Presidentes de mesa polls: Votaciones - booths: Urnas officials: Cargos públicos organizations: Organizaciones settings: Configuración global From b8302b6fa86ea3c847910ab279e423980e94b755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Thu, 20 Oct 2016 16:14:03 +0200 Subject: [PATCH 53/56] adds dates to polls --- db/migrate/20161020112156_add_dates_to_polls.rb | 6 ++++++ db/schema.rb | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20161020112156_add_dates_to_polls.rb diff --git a/db/migrate/20161020112156_add_dates_to_polls.rb b/db/migrate/20161020112156_add_dates_to_polls.rb new file mode 100644 index 000000000..d504930ae --- /dev/null +++ b/db/migrate/20161020112156_add_dates_to_polls.rb @@ -0,0 +1,6 @@ +class AddDatesToPolls < ActiveRecord::Migration + def change + add_column :polls, :starts_at, :datetime + add_column :polls, :ends_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 313c6d1f1..b5891df82 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -294,7 +294,9 @@ ActiveRecord::Schema.define(version: 20161102133838) do end create_table "polls", force: :cascade do |t| - t.string "name" + t.string "name" + t.datetime "starts_at" + t.datetime "ends_at" end create_table "proposal_notifications", force: :cascade do |t| From 76a4f420eb6e12ad1d22acf77d075b5520547516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Thu, 20 Oct 2016 16:25:02 +0200 Subject: [PATCH 54/56] changes menu name --- config/locales/admin.es.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 55991e056..024f6abe2 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -105,7 +105,7 @@ es: moderators: Moderadores valuators: Evaluadores poll_officers: Presidentes de mesa - polls: Votaciones + polls: Votaciones físicas officials: Cargos públicos organizations: Organizaciones settings: Configuración global From 7b3c9b725cf2634778e4ca6d7a4e13e954835ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Thu, 20 Oct 2016 16:25:36 +0200 Subject: [PATCH 55/56] fights a flaky spec --- spec/features/account_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb index d1c547185..5561e89d4 100644 --- a/spec/features/account_spec.rb +++ b/spec/features/account_spec.rb @@ -112,7 +112,11 @@ feature 'Account' do end scenario 'Errors editing credentials' do - visit account_path + visit root_path + + click_link "My account" + + expect(current_path).to eq(account_path) click_link 'Change my credentials' click_button 'Update' From c1336ccc139251d48b03d40921e6064f3daa69f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Thu, 27 Oct 2016 15:52:07 +0200 Subject: [PATCH 56/56] adds fields and i18n keys to admin poll form --- app/views/admin/poll/polls/_form.html.erb | 16 ++++++++++++++-- config/i18n-tasks.yml | 1 + config/locales/admin.en.yml | 12 ++++-------- config/locales/admin.es.yml | 14 +++++--------- config/locales/responders.es.yml | 4 ++-- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/app/views/admin/poll/polls/_form.html.erb b/app/views/admin/poll/polls/_form.html.erb index 77961912c..9926c679a 100644 --- a/app/views/admin/poll/polls/_form.html.erb +++ b/app/views/admin/poll/polls/_form.html.erb @@ -2,8 +2,20 @@
    <%= f.text_field :name, - placeholder: t('admin.polls.new.name'), - label: t("admin.polls.new.name") %> + placeholder: t('admin.polls.form.name'), + label: t("admin.polls.form.name") %> +
    +
    + +
    +
    + + +
    + +
    + +
    diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 2008f02e1..0b1e932df 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -120,6 +120,7 @@ ignore_unused: - 'admin.activity.show.filter*' - 'admin.comments.index.hidden_*' - 'admin.settings.index.features.*' + - 'admin.polls.*.submit_button' - 'moderation.comments.index.filter*' - 'moderation.comments.index.order*' - 'moderation.debates.index.filter*' diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 6c42ac23e..1d80aa4cd 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -160,18 +160,14 @@ en: status: "Status" new: title: "New poll" - name: "Name" - reference: "Reference number" - open_date: "Open date" - close_date: "Close date" submit_button: "Create poll" edit: title: "Edit poll" - name: "Name" - reference: "Reference number" - open_date: "Open date" - close_date: "Close date" submit_button: "Update poll" + form: + name: "Name" + starts_at: "Open date" + ends_at: "Close date" show: no_booths: "There are no booths in this poll." add_booth: "Add booth" diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 024f6abe2..cce743dcc 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -105,7 +105,7 @@ es: moderators: Moderadores valuators: Evaluadores poll_officers: Presidentes de mesa - polls: Votaciones físicas + polls: Votaciones officials: Cargos públicos organizations: Organizaciones settings: Configuración global @@ -160,18 +160,14 @@ es: status: "Estado" new: title: "Nueva votación" - name: "Nombre" - reference: "Número de referencia" - open_date: "Fecha de apertura" - close_date: "Fecha de cierre" submit_button: "Crear votación" edit: title: "Editar votación" - name: "Nombre" - reference: "Número de referencia" - open_date: "Fecha de apertura" - close_date: "Fecha de cierre" submit_button: "Actualizar votación" + form: + name: "Nombre" + starts_at: "Fecha de apertura" + ends_at: "Fecha de cierre" show: no_booths: "No hay urnas en esta votación." add_booth: "Añadir urna" diff --git a/config/locales/responders.es.yml b/config/locales/responders.es.yml index 105b00903..54c4c7035 100644 --- a/config/locales/responders.es.yml +++ b/config/locales/responders.es.yml @@ -6,7 +6,7 @@ es: notice: "%{resource_name} creado correctamente." debate: "Debate creado correctamente." direct_message: "Tu mensaje ha sido enviado correctamente." - poll: "Votación presencial creada correctamente." + poll: "Votación creada correctamente." poll_booth: "Urna creada correctamente." proposal: "Propuesta creada correctamente." proposal_notification: "Tu message ha sido enviado correctamente." @@ -17,7 +17,7 @@ es: notice: "%{resource_name} actualizado correctamente." debate: "Debate actualizado correctamente." proposal: "Propuesta actualizada correctamente." - poll: "Votación presencial actualizada correctamente." + poll: "Votación actualizada correctamente." poll_booth: "Urna actualizada correctamente." spending_proposal: "Propuesta de inversión actualizada correctamente." destroy: