From 345e34d4229d05cb783c4ad8ed35febc41bf6681 Mon Sep 17 00:00:00 2001 From: kikito Date: Mon, 29 Aug 2016 16:49:52 +0200 Subject: [PATCH 01/42] adds ckeditor config --- config/initializers/ckeditor.rb | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 config/initializers/ckeditor.rb diff --git a/config/initializers/ckeditor.rb b/config/initializers/ckeditor.rb new file mode 100644 index 000000000..58e119048 --- /dev/null +++ b/config/initializers/ckeditor.rb @@ -0,0 +1,4 @@ +Ckeditor.setup do |config| + config.assets_languages = I18n.available_locales.map(&:to_s) + config.assets_plugins = [] +end From 7ad4a212296caccd47495fa856c4877b1213edc3 Mon Sep 17 00:00:00 2001 From: kikito Date: Tue, 30 Aug 2016 12:05:46 +0200 Subject: [PATCH 02/42] Tries to make ckeditor work correctly with the asset pipeline Reference: https://github.com/galetahub/ckeditor/issues/519 --- app/assets/javascripts/application.js | 2 +- app/assets/javascripts/ckeditor/loader.js.erb | 3 +++ config/initializers/assets.rb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/ckeditor/loader.js.erb diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index ca79ceb8b..7fb92b5e3 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -16,7 +16,7 @@ //= require jquery-ui/datepicker-es //= require foundation //= require turbolinks -//= require ckeditor/init +//= require ckeditor/loader //= require_directory ./ckeditor //= require social-share-button //= require initial diff --git a/app/assets/javascripts/ckeditor/loader.js.erb b/app/assets/javascripts/ckeditor/loader.js.erb new file mode 100644 index 000000000..66e1d8347 --- /dev/null +++ b/app/assets/javascripts/ckeditor/loader.js.erb @@ -0,0 +1,3 @@ +//= require ckeditor/init + +CKEDITOR.config.customConfig = '<%= javascript_path 'ckeditor/config.js' %>'; diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 942ba99c8..e5fc916f0 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -9,7 +9,7 @@ Rails.application.config.assets.version = '1.0' # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # Rails.application.config.assets.precompile += %w( search.js ) -Rails.application.config.assets.precompile += %w( ckeditor/* ) +Rails.application.config.assets.precompile += %w( ckeditor/config.js ) Rails.application.config.assets.precompile += %w( ie_lt9.js ) Rails.application.config.assets.precompile += %w( stat_graphs.js ) Rails.application.config.assets.precompile += %w( print.css ) From fb31a4782f8eed7009db30f51c2a69627c9b3025 Mon Sep 17 00:00:00 2001 From: kikito Date: Tue, 30 Aug 2016 18:26:51 +0200 Subject: [PATCH 03/42] downgrades sprockets to 3.6.3 to avoid warnings --- Gemfile | 3 +++ Gemfile.lock | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3f3119770..1819992d3 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,9 @@ 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 'devise', '~> 3.5.7' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' diff --git a/Gemfile.lock b/Gemfile.lock index 103ec214d..121d7b86e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -375,7 +375,7 @@ GEM spring (1.7.2) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - sprockets (3.7.0) + sprockets (3.6.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-es6 (0.9.0) @@ -496,6 +496,7 @@ DEPENDENCIES social-share-button spring spring-commands-rspec + sprockets (~> 3.6.3) tolk turbolinks turnout From 2e6328d50235f4673df3b549860581fbc11a01b1 Mon Sep 17 00:00:00 2001 From: Jaime Iniesta Date: Tue, 6 Sep 2016 18:21:15 +0200 Subject: [PATCH 04/42] fixes a few typos --- config/locales/pages.es.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/pages.es.yml b/config/locales/pages.es.yml index c9f282a4f..3876e8a1b 100644 --- a/config/locales/pages.es.yml +++ b/config/locales/pages.es.yml @@ -33,13 +33,13 @@ es: Tanto los hilos, como los comentarios podrán ser valorados por cualquiera, de tal manera que será la propia ciudadanía, y nadie en su nombre, la que decida cuáles son los temas más importantes en cada momento. Estos serán presentados en la portada del espacio, pudiendo por supuesto accederse a todos los demás temas en páginas posteriores, o usando otros criterios de ordenación (los temas con más comentarios, los más nuevos, los más controvertidos, etc.). - Cada uno de los trabajadores del Ayuntamiento tiene un usuario propio, que será resaltado como tal, permitiendo que participen en los debates al mismo nivel que todos los demás ciudadanos. Esto permitirá crear espacios de comunicación directos entre unos y otros, evitando los inconvenientes que implica la comunicación medidada, y respondiendo a un planteamiento claro por parte del nuevo gobierno por el cual el Ayuntamiento trabaja para la ciudadanía, y ante ella debe responder. + Cada uno de los trabajadores del Ayuntamiento tiene un usuario propio, que será resaltado como tal, permitiendo que participen en los debates al mismo nivel que todos los demás ciudadanos. Esto permitirá crear espacios de comunicación directos entre unos y otros, evitando los inconvenientes que implica la comunicación mediada, y respondiendo a un planteamiento claro por parte del nuevo gobierno por el cual el Ayuntamiento trabaja para la ciudadanía, y ante ella debe responder. ## I.I. Espacio de propuestas - En este espacio, cualquier persona puede proponer una iniciativa con la intención de recabar los suficientes apoyos como para que la idea pase a ser consultada a toda la ciudadanía con caracter vinculante. + En este espacio, cualquier persona puede proponer una iniciativa con la intención de recabar los suficientes apoyos como para que la idea pase a ser consultada a toda la ciudadanía con carácter vinculante. Las propuestas pueden ser apoyadas por ciudadanos empadronados que hayan verificado su cuenta en la plataforma de participación, de tal manera que será la propia ciudadanía, y nadie en su nombre, la que decida cuáles son las propuestas que merecen la pena ser llevadas a cabo. - Una vez que una propuesta alcance una cantidad de apoyos equivalente al 2% del censo, automaticamente pasa a ser estudiada por un grupo de trabajo del Ayuntamiento y pasará a la siguiente fase de consulta popular, en la que la ciudadanía votará si se lleva a cabo o no. El plazo máximo para recabar los apoyos necesarios será de 12 meses. + Una vez que una propuesta alcance una cantidad de apoyos equivalente al 2% del censo, automáticamente pasa a ser estudiada por un grupo de trabajo del Ayuntamiento y pasará a la siguiente fase de consulta popular, en la que la ciudadanía votará si se lleva a cabo o no. El plazo máximo para recabar los apoyos necesarios será de 12 meses. how_to_use: text: |- Utilízalo en tu municipio libremente o ayúdanos a mejorarlo, es software libre. From a527de4f9224dc67a6da675a9d980f2dcc5de7b2 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Wed, 7 Sep 2016 12:43:12 +0200 Subject: [PATCH 05/42] Adds proposal ballots controller and views --- .../proposal_ballots_controller.rb | 8 ++ .../_featured_successfull_proposal.html.erb | 3 + .../_successfull_proposal.html.erb | 13 +++ app/views/proposal_ballots/index.html.erb | 36 ++++++++ config/routes.rb | 2 + db/schema.rb | 87 +++++++++++++++++++ 6 files changed, 149 insertions(+) create mode 100644 app/controllers/proposal_ballots_controller.rb create mode 100644 app/views/proposal_ballots/_featured_successfull_proposal.html.erb create mode 100644 app/views/proposal_ballots/_successfull_proposal.html.erb create mode 100644 app/views/proposal_ballots/index.html.erb diff --git a/app/controllers/proposal_ballots_controller.rb b/app/controllers/proposal_ballots_controller.rb new file mode 100644 index 000000000..4e3e99671 --- /dev/null +++ b/app/controllers/proposal_ballots_controller.rb @@ -0,0 +1,8 @@ +class ProposalBallotsController < ApplicationController + skip_authorization_check + + def index + @proposal_ballots = Proposal.successfull.sort_by_confidence_score + end + +end diff --git a/app/views/proposal_ballots/_featured_successfull_proposal.html.erb b/app/views/proposal_ballots/_featured_successfull_proposal.html.erb new file mode 100644 index 000000000..97754ce9c --- /dev/null +++ b/app/views/proposal_ballots/_featured_successfull_proposal.html.erb @@ -0,0 +1,3 @@ +
+

<%= link_to proposal.title, proposal_ballots_path %>

+
diff --git a/app/views/proposal_ballots/_successfull_proposal.html.erb b/app/views/proposal_ballots/_successfull_proposal.html.erb new file mode 100644 index 000000000..3a8c2a557 --- /dev/null +++ b/app/views/proposal_ballots/_successfull_proposal.html.erb @@ -0,0 +1,13 @@ +
+

<%= link_to proposal.title, proposal %>

+

<%= proposal.question %>

+
+ <% if proposal.author.hidden? || proposal.author.erased? %> + <%= t("proposals.show.author_deleted") %> + <% else %> + <%= proposal.author.name %> + <% end %> +  •  + <%= t("proposals.proposal.supports", count: proposal.total_votes) %> +
+
diff --git a/app/views/proposal_ballots/index.html.erb b/app/views/proposal_ballots/index.html.erb new file mode 100644 index 000000000..6206a856c --- /dev/null +++ b/app/views/proposal_ballots/index.html.erb @@ -0,0 +1,36 @@ +
+
+
+

+ <%= t("proposal_ballots.title") %> +

+

+ <%= t("proposal_ballots.description_html", + supports: Setting['votes_for_proposal_success'].to_i).html_safe %> +

+
+ +
+

 <%= t("proposal_ballots.date_title") %>

+

<%= t("proposal_ballots.date") %>

+
+
+
+ +
+
+
+ <% if @proposal_ballots.present? %> +
+ <% @proposal_ballots.each do |proposal_for_vote| %> + <%= render "successfull_proposal", proposal: proposal_for_vote %> + <% end %> +
+ <% else %> +

+ <%= t("proposal_ballots.nothing_to_vote") %> +

+ <% end %> +
+
+
diff --git a/config/routes.rb b/config/routes.rb index 4f3eb94ec..df1a7c6fb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -61,6 +61,8 @@ Rails.application.routes.draw do end end + resources :proposal_ballots, only: [:index] + resources :comments, only: [:create, :show], shallow: true do member do post :vote diff --git a/db/schema.rb b/db/schema.rb index becde4f8a..6124f31d0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -78,6 +78,91 @@ ActiveRecord::Schema.define(version: 20160803154011) do add_index "banners", ["hidden_at"], name: "index_banners_on_hidden_at", using: :btree + create_table "budget_ballot_lines", force: :cascade do |t| + t.integer "ballot_id" + t.integer "investment_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "budget_id" + t.integer "group_id" + t.integer "heading_id" + end + + add_index "budget_ballot_lines", ["ballot_id"], name: "index_budget_ballot_lines_on_ballot_id", using: :btree + add_index "budget_ballot_lines", ["investment_id"], name: "index_budget_ballot_lines_on_investment_id", using: :btree + + create_table "budget_ballots", force: :cascade do |t| + t.integer "user_id" + t.integer "budget_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "budget_groups", force: :cascade do |t| + t.integer "budget_id" + t.string "name", limit: 50 + end + + add_index "budget_groups", ["budget_id"], name: "index_budget_groups_on_budget_id", using: :btree + + create_table "budget_headings", force: :cascade do |t| + t.integer "budget_id" + t.integer "geozone_id" + t.string "name", limit: 50 + t.integer "price", limit: 8 + end + + create_table "budget_investments", force: :cascade do |t| + t.integer "author_id" + t.integer "administrator_id" + t.string "title" + t.text "description" + t.string "external_url" + t.integer "price", limit: 8 + t.string "feasibility", limit: 15, default: "undecided" + t.text "price_explanation" + t.text "unfeasibility_explanation" + t.text "internal_comments" + t.boolean "valuation_finished", default: false + t.integer "valuator_assignments_count", default: 0 + t.integer "price_first_year", limit: 8 + t.string "duration" + t.datetime "hidden_at" + t.integer "cached_votes_up", default: 0 + t.integer "comments_count", default: 0 + t.integer "confidence_score", default: 0, null: false + t.integer "physical_votes", default: 0 + t.tsvector "tsv" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "heading_id" + t.string "responsible_name" + end + + add_index "budget_investments", ["administrator_id"], name: "index_budget_investments_on_administrator_id", using: :btree + add_index "budget_investments", ["author_id"], name: "index_budget_investments_on_author_id", using: :btree + add_index "budget_investments", ["heading_id"], name: "index_budget_investments_on_heading_id", using: :btree + add_index "budget_investments", ["tsv"], name: "index_budget_investments_on_tsv", using: :gin + + create_table "budget_valuator_assignments", force: :cascade do |t| + t.integer "valuator_id" + t.integer "investment_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "budget_valuator_assignments", ["investment_id"], name: "index_budget_valuator_assignments_on_investment_id", using: :btree + + create_table "budgets", force: :cascade do |t| + t.string "name", limit: 30 + t.text "description" + t.string "currency_symbol", limit: 10 + t.string "phase", limit: 15, default: "on_hold" + t.boolean "valuating", default: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "campaigns", force: :cascade do |t| t.string "name" t.string "track_id" @@ -378,6 +463,7 @@ ActiveRecord::Schema.define(version: 20160803154011) do t.integer "proposals_count", default: 0 t.integer "spending_proposals_count", default: 0 t.string "kind" + t.integer "budget/investments_count", default: 0 end add_index "tags", ["debates_count"], name: "index_tags_on_debates_count", using: :btree @@ -484,6 +570,7 @@ ActiveRecord::Schema.define(version: 20160803154011) do t.integer "user_id" t.string "description" t.integer "spending_proposals_count", default: 0 + t.integer "budget_investments_count", default: 0 end add_index "valuators", ["user_id"], name: "index_valuators_on_user_id", using: :btree From b107790039bddd175eb98df13be7b03089832792 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Wed, 7 Sep 2016 12:46:29 +0200 Subject: [PATCH 06/42] Adds links, texts and i18n --- app/controllers/proposals_controller.rb | 5 +++++ app/models/proposal.rb | 5 +++++ app/views/proposals/_proposal.html.erb | 24 ++++++++++++++++++------ app/views/proposals/index.html.erb | 16 ++++++++++++++-- app/views/proposals/show.html.erb | 18 +++++++++++++----- app/views/shared/_subnavigation.html.erb | 3 +++ config/locales/en.yml | 10 ++++++++++ config/locales/es.yml | 10 ++++++++++ 8 files changed, 78 insertions(+), 13 deletions(-) diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 578395ab3..898ad9949 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -28,6 +28,7 @@ class ProposalsController < ApplicationController def index_customization load_retired load_featured + load_proposal_ballots end def vote @@ -97,4 +98,8 @@ class ProposalsController < ApplicationController end end + def load_proposal_ballots + @proposal_ballots = Proposal.successfull.sort_by_confidence_score + end + end diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 9a92a8d18..4c3cc9e40 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -47,6 +47,7 @@ class Proposal < ActiveRecord::Base scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)} scope :retired, -> { where.not(retired_at: nil) } scope :not_retired, -> { where(retired_at: nil) } + scope :successfull, -> { where("cached_votes_up + physical_votes >= ?", Proposal.votes_needed_for_success)} def to_param "#{id}-#{title}".parameterize @@ -155,6 +156,10 @@ class Proposal < ActiveRecord::Base Setting['votes_for_proposal_success'].to_i end + def successfull? + total_votes >= Proposal.votes_needed_for_success + end + def notifications proposal_notifications end diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb index 70c2b9c89..464710493 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -1,10 +1,12 @@ -
+
Proposal.votes_needed_for_success) %>" + data-type="proposal">
+
- <% cache [locale_and_user_status(proposal), 'index', proposal, proposal.author] do %> <%= t("proposals.proposal.proposal") %> @@ -50,11 +52,21 @@
-
- <%= render 'votes', - { proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %> +
+ <% if proposal.successfull? %> +
+

+ <%= t("proposal_ballots.successfull", + voting: link_to(t("proposal_ballots.voting"), proposal_ballots_path)).html_safe %> +

+
+ <% else %> +
+ <%= render 'votes', + { proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %> +
+ <% end %>
-
diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb index 6f6516890..ff9c23d08 100644 --- a/app/views/proposals/index.html.erb +++ b/app/views/proposals/index.html.erb @@ -30,8 +30,20 @@ <% if has_banners %> <%= render "shared/banner" %> <% end %> - - <% if @featured_proposals.present? %> + + <% if @proposal_ballots.present? %> + + <% elsif @featured_proposals.present? %>