| <%= t("admin.budget_investments.index.table_id") %> | +<%= t("admin.budget_investments.index.table_title") %> | +<%= t("admin.budget_investments.index.table_admin") %> | +<%= t("admin.budget_investments.index.table_valuator") %> | +<%= t("admin.budget_investments.index.table_geozone") %> | +<%= t("admin.budget_investments.index.table_feasibility") %> | +<%= t("admin.budget_investments.index.table_valuation_finished") %> | +<%= t("admin.budget_investments.index.table_selection") %> | +
|---|---|---|---|---|---|---|---|
| + <%= investment.id %> + | ++ <%= link_to investment.title, admin_budget_budget_investment_path(budget_id: @budget.id, id: investment.id, params: Budget::Investment.filter_params(params)) %> + | ++ <% if investment.administrator.present? %> + <%= investment.administrator.name %> + <% else %> + <%= t("admin.budget_investments.index.no_admin_assigned") %> + <% end %> + | ++ <% if investment.valuators.size == 0 %> + <%= t("admin.budget_investments.index.no_valuators_assigned") %> + <% else %> + <%= investment.valuators.collect(&:description_or_name).join(', ') %> + <% end %> + | ++ <%= investment.heading.name %> + | ++ <%= t("admin.budget_investments.index.feasibility.#{investment.feasibility}", + price: investment.formatted_price) + %> + | ++ <%= investment.valuation_finished? ? t('shared.yes'): t('shared.no') %> + | ++ <% if investment.selected? %> + <%= link_to toggle_selection_admin_budget_budget_investment_path(@budget, + investment, + filter: params[:filter], + page: params[:page]), + method: :patch, + remote: true, + class: "button small expanded" do %> + <%= t("admin.budget_investments.index.selected") %> + <% end %> + <% elsif investment.feasible? && investment.valuation_finished? %> + <%= link_to toggle_selection_admin_budget_budget_investment_path(@budget, + investment, + filter: params[:filter], + page: params[:page]), + method: :patch, + remote: true, + class: "button small hollow expanded" do %> + <%= t("admin.budget_investments.index.select") %> + <% end %> + <% end %> + | +
: <%= @investment.group.name %>"> + <%= t("admin.budget_investments.show.heading") %>: + <%= @investment.heading.name %> +
++ <%= t("admin.budget_investments.show.by") %>: + <%= link_to @investment.author.name, admin_user_path(@investment.author) %> +
++ <%= t("admin.budget_investments.show.sent") %>: + <%= l @investment.created_at, format: :datetime %> +
+<%= text_with_links @investment.external_url %>
+<% end %> + +<%= safe_html_with_links @investment.description %> diff --git a/app/views/admin/budget_investments/edit.html.erb b/app/views/admin/budget_investments/edit.html.erb new file mode 100644 index 000000000..17dd88665 --- /dev/null +++ b/app/views/admin/budget_investments/edit.html.erb @@ -0,0 +1,70 @@ +<%= link_to admin_budget_budget_investment_path(@budget, @investment, Budget::Investment.filter_params(params)), class: 'back' do %> + <%= t("shared.back") %> +<% end %> + +<%= form_for @investment, + url: admin_budget_budget_investment_path(@budget, @investment) do |f| %> + + <% Budget::Investment.filter_params(params).each do |filter_name, filter_value| %> + <%= hidden_field_tag filter_name, filter_value %> + <% end %> + ++ <%= f.submit(class: "button", value: t("admin.budget_investments.edit.submit_button")) %> +
+<% end %> + +<%= t("admin.budget_investments.show.assigned_admin") %>: + <%= @investment.administrator.try(:name_and_email) || t("admin.budget_investments.show.undefined") %> +
+ + + ++ <%= t("admin.budget_investments.show.assigned_valuators") %>: + <% if @investment.valuators.any? %> + <%= @investment.valuators.collect(&:name_and_email).join(', ') %> + <% else %> + <%= t("admin.budget_investments.show.undefined") %> + <% end %> +
+ ++ <%= link_to t("admin.budget_investments.show.edit_classification"), + edit_admin_budget_budget_investment_path(@budget, @investment, + {anchor: 'classification'}.merge(Budget::Investment.filter_params(params))) %> +
+ ++ <%= link_to t("admin.budget_investments.show.edit_dossier"), edit_valuation_budget_budget_investment_path(@budget, @investment) %> +
+ diff --git a/app/views/admin/budget_investments/toggle_selection.js.erb b/app/views/admin/budget_investments/toggle_selection.js.erb new file mode 100644 index 000000000..dc3a8d67a --- /dev/null +++ b/app/views/admin/budget_investments/toggle_selection.js.erb @@ -0,0 +1 @@ +$("#investments").html('<%= j render("admin/budget_investments/investments") %>'); diff --git a/app/views/admin/budgets/_form.html.erb b/app/views/admin/budgets/_form.html.erb new file mode 100644 index 000000000..5d323b45c --- /dev/null +++ b/app/views/admin/budgets/_form.html.erb @@ -0,0 +1,20 @@ +<%= form_for [:admin, @budget] do |f| %> + + <%= f.text_field :name, maxlength: Budget.title_max_length %> + + <% Budget::PHASES.each do |phase| %> +| + <%= group.name %> + <%= link_to t("admin.budgets.form.add_heading"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#group-#{group.id}-new-heading-form" } %> + | +||
|---|---|---|
|
+
+ <%= t("admin.budgets.form.no_heading") %>
+
+ |
+ ||
| <%= t("admin.budgets.form.table_heading") %> | +<%= t("admin.budgets.form.table_amount") %> | +|
| + <%= heading.name %> + | ++ <%= heading.price %> + | +|
| <%= t("admin.budgets.index.table_name") %> | +<%= t("admin.budgets.index.table_phase") %> | +<%= t("admin.budgets.index.table_investments") %> | +<%= t("admin.budgets.index.table_edit_groups") %> | +<%= t("admin.budgets.index.table_edit_budget") %> | +
|---|---|---|---|---|
| + <%= budget.name %> + | ++ <%= t("budgets.phase.#{budget.phase}") %> + | ++ <%= link_to t("admin.budgets.index.budget_investments"), admin_budget_budget_investments_path(budget_id: budget.id) %> + | ++ <%= link_to t("admin.budgets.index.edit_groups"), admin_budget_path(budget) %> + | ++ <%= link_to t("admin.budgets.index.edit_budget"), edit_admin_budget_path(budget) %> + | +
+ <%= t("budgets.ballots.show.zero") %>
+
+ <%= @ballot.formatted_amount_spent(@heading) %> + + <%= t("budgets.progress_bar.available") %> + <%= @ballot.formatted_amount_available(@heading) %> + +
+ +| <%= Budget.human_attribute_name(:name) %> | +<%= Budget.human_attribute_name(:phase) %> | + + + <% @budgets.each do |budget| %> +
|---|---|
| + <%= link_to budget.name, budget %> + | ++ <%= budget.translated_phase %> + | +
+ <%= investment.formatted_price %> +
+ <% if investment.should_show_ballots? %> + <%= link_to t('budgets.ballots.show.remove'), + budget_ballot_line_path(id: investment.id, + budget_id: investment.budget_id, + investments_ids: investment_ids), + class: "delete small expanded", + method: :delete, + remote: true %> + <% end %> ++ <%= investment.formatted_price %> +
+ <% if investment.should_show_ballots? %> + <%= link_to t("budgets.investments.investment.add"), + budget_ballot_lines_url(investment_id: investment.id, + budget_id: investment.budget_id, + investments_ids: investment_ids), + class: "button button-support small expanded", + title: t('budgets.investments.investment.support_title'), + method: :post, + remote: true %> + <% end %> +<%= t("budgets.investments.form.tags_instructions") %>
+ + + ++ + <%= l investment.created_at.to_date %> + + <% if investment.author.hidden? || investment.author.erased? %> + • + + <% else %> + • + + <% if investment.author.official? %> + • + + <% end %> + <% end %> + + • + <%= investment.heading.name %> +
+<%= investment.description %>
+ ++ <%= t("budgets.investments.show.code_html", code: investment.id) %> +
+ + <% if investment.location.present? %> ++ <%= t("budgets.investments.show.location_html", location: investment.location) %> +
+ <% end %> + + <% if investment.organization_name.present? %> ++ <%= t("budgets.investments.show.organization_name_html", name: investment.organization_name) %> +
+ <% end %> + + <%= render 'shared/tags', taggable: investment %> + + <%= safe_html_with_links investment.description.html_safe %> + + <% if investment.external_url.present? %> +<%= investment.unfeasibility_explanation %>
+ <% end %> + + <% if investment.feasible? && investment.price_explanation.present? %> +<%= investment.price_explanation %>
+ <% end %> ++ + <%= t("budgets.investments.index.sidebar.voted_html", + count: @ballot.investments.by_heading(@heading.id).count, + amount_spent: @ballot.formatted_amount_spent(@heading)) %> + +
+ <% else %> +<%= t("budgets.investments.index.sidebar.zero") %>
+ <% end %> + ++ <%= t("budgets.investments.index.sidebar.voted_info") %> +
+<% end %> diff --git a/app/views/budgets/investments/_votes.html.erb b/app/views/budgets/investments/_votes.html.erb new file mode 100644 index 000000000..c2870d76c --- /dev/null +++ b/app/views/budgets/investments/_votes.html.erb @@ -0,0 +1,46 @@ +<% reason = investment.reason_for_not_being_selectable_by(current_user) %> +<% voting_allowed = true unless reason.presence == :not_voting_allowed %> +<% user_voted_for = voted_for?(investment_votes, investment) %> + +| <%= t('budgets.show.group') %> | + + + <% @budget.groups.each do |group| %> +
|---|
|
+ <% if group.headings.count == 1 %>
+ <%= link_to group.name,
+ budget_investments_path(@budget,
+ heading_id: group.headings.first.id,
+ unfeasible: params[:unfeasible]),
+ data: { no_turbolink: true } %>
+ <% else %>
+ <%= link_to group.name,
+ budget_group_path(@budget, group,
+ unfeasible: params[:unfeasible]) %>
+ <% end %>
+ + |
+
+ <%= t("mailers.budget_investment_created.intro_html", + author: @investment.author.name).html_safe %> +
+ ++ <%= t("mailers.budget_investment_created.text_html", + investment: @investment.title, + budget: @investment.budget.name).html_safe %> +
+ ++ <%= t("mailers.budget_investment_created.follow_html", + link: link_to(t("mailers.budget_investment_created.follow_link"), budgets_url)).html_safe %> +
+ +| + <%= link_to budget_investment_url(@investment.budget, @investment, anchor: "social-share"), style: "font-family: 'Open Sans','Helvetica Neue',arial,sans-serif; background: #f7f5f2; border-radius: 6px; color: #3d3d66!important; font-weight: bold; margin: 0px; padding: 10px 15px; text-align: center; text-decoration: none; min-width: 160px; display: inline-block;" do %> + <%= image_tag('icon_mailer_share.png', style: "border: 0; display: inline-block; width: 100%; max-width: 16px", alt: "") %> + <%= t('mailers.budget_investment_created.share') %> + <% end %> + | +
+ <%= t("mailers.budget_investment_created.sincerely") %>
+
+
+ <%= t("mailers.budget_investment_created.signatory") %>
+
+
+ <%= t("mailers.budget_investment_unfeasible.hi") %> +
+ ++ <%= t("mailers.budget_investment_unfeasible.unfeasible_html", + title: @investment.title) %> +
+ ++ <%= @investment.unfeasibility_explanation %> +
+ ++ <%= t("mailers.budget_investment_unfeasible.new_html", + url: link_to(t("mailers.budget_investment_unfeasible.new_href"), + new_budget_investment_url(@investment.budget), style: "color: #2895F1; text-decoration: underline;")) %> +
+ ++ <%= t("mailers.budget_investment_unfeasible.reconsider_html", code: @investment.code) %> +
+ ++ <%= t("mailers.budget_investment_unfeasible.sorry") %> +
+ +
+ <%= t("mailers.budget_investment_unfeasible.sincerely") %>
+
+ <%= t("mailers.budget_investment_unfeasible.signatory") %>
+
| <%= budget.name %> | +<%= budget.translated_phase %> | ++ <%= link_to t("management.budgets.create_new_investment"), + new_management_budget_investment_path(budget) %> + | +
<%= t("management.print.budget_investments_info") %>
+ <%= t("management.print.budget_investments_note") %>
| <%= budget.name %> | +<%= budget.translated_phase %> | ++ <%= link_to t("management.budgets.print_investments"), + print_management_budget_investments_path(budget) %> + | +
| <%= budget.name %> | +<%= budget.translated_phase %> | ++ <%= link_to t("management.budgets.support_investments"), + management_budget_investments_path(budget) %> + | +
+ + <%= t("valuation.budget_investments.show.price") %> + (<%= t("valuation.budget_investments.show.currency") %>): + + <% if @investment.price.present? %> + <%= @investment.price %> + <% else %> + <%= t("valuation.budget_investments.show.undefined") %> + <% end %> +
+ ++ + <%= t("valuation.budget_investments.show.price_first_year") %> + (<%= t("valuation.budget_investments.show.currency") %>): + + + <% if @investment.price_first_year.present? %> + <%= @investment.price_first_year %> + <% else %> + <%= t("valuation.budget_investments.show.undefined") %> + <% end %> +
+ +<%= explanation_field @investment.price_explanation %> + ++ <%= t("valuation.budget_investments.show.duration") %>: + <% if @investment.duration.present? %> + <%= @investment.duration %> + <% else %> + <%= t("valuation.budget_investments.show.undefined") %> + <% end %> +
+ ++ <%= t("valuation.budget_investments.show.feasibility") %>: + <%= t("valuation.budget_investments.show.#{@investment.feasibility}") %> +
+ +<%= explanation_field @investment.unfeasibility_explanation %> + +<% if @investment.valuation_finished %> ++ <%= t("valuation.budget_investments.show.valuation_finished") %> +
+<% end %> + +<% if @investment.internal_comments.present? %> +<%= text_with_links @investment.external_url %>
+<% end %> + +<%= t("valuation.budget_investments.show.by") %>: + <%= link_to @investment.author.name, user_path(@investment.author) %> +
+ +<%= t("valuation.budget_investments.show.heading") %>: + <%= @investment.heading.name %> +
+ +<%= t("valuation.budget_investments.show.sent") %>: + <%= l @investment.created_at, format: :datetime %> +
+ +<%= t("valuation.budget_investments.show.assigned_admin") %>: + <% if @investment.administrator.present? %> + <%= @investment.administrator.name %> (<%= @investment.administrator.email %>) + <% else %> + <%= t("valuation.budget_investments.show.undefined") %> + <% end %> +
+ +<%= t("valuation.budget_investments.show.assigned_valuators") %>:
+| <%= t("valuation.budget_investments.index.table_id") %> | +<%= t("valuation.budget_investments.index.table_title") %> | +<%= t("valuation.budget_investments.index.table_heading_name") %> | +<%= t("valuation.budget_investments.index.table_actions") %> | +
|---|---|---|---|
| + <%= investment.id %> + | ++ <%= link_to investment.title, valuation_budget_budget_investment_path(@budget, investment) %> + | ++ <%= investment.heading.name %> + | ++ <%= link_to t("valuation.budget_investments.index.edit"), + edit_valuation_budget_budget_investment_path(@budget, investment), + class: "button hollow expanded" %> + | +
<%= text_with_links @investment.external_url %>
+<% end %> + +<%= t("valuation.budget_investments.show.by") %>: + <%= link_to @investment.author.name, user_path(@investment.author) %> +
+ +<%= t("valuation.budget_investments.show.heading") %>: + <%= @investment.heading.name %> +
+ +<%= t("valuation.budget_investments.show.sent") %>: + <%= l @investment.created_at, format: :datetime %> +
+ +<%= t("valuation.budget_investments.show.assigned_admin") %>: + <% if @investment.administrator.present? %> + <%= @investment.administrator.name_and_email %> + <% else %> + <%= t("valuation.budget_investments.show.undefined") %> + <% end %> +
+ +<%= t("valuation.budget_investments.show.assigned_valuators") %>:
++ <%= link_to t("valuation.budget_investments.show.edit_dossier"), edit_valuation_budget_budget_investment_path(@budget, @investment) %> +
+ +<%= render 'written_by_valuators' %> \ No newline at end of file diff --git a/app/views/valuation/budgets/index.html.erb b/app/views/valuation/budgets/index.html.erb new file mode 100644 index 000000000..6d65f9ee6 --- /dev/null +++ b/app/views/valuation/budgets/index.html.erb @@ -0,0 +1,36 @@ +| <%= t("valuation.budgets.index.table_name") %> | +<%= t("valuation.budgets.index.table_phase") %> | +<%= t("valuation.budgets.index.table_assigned_investments_valuation_open") %> | +<%= t("valuation.budgets.index.table_actions") %> | +
|---|---|---|---|
| + <%= budget.name %> + | ++ <%= t("budgets.phase.#{budget.phase}") %> + | ++ <%= @investments_with_valuation_open[budget.id] %> + | ++ <%= link_to t("valuation.budgets.index.evaluate"), + valuation_budget_budget_investments_path(budget_id: budget.id), + class: "button hollow expanded" %> + | +
#{Faker::Lorem.paragraphs(2).join('
')}
"] }] + budget = Budget.create!( + descriptions.merge( + name: (Date.current - 10 + i).to_s, + currency_symbol: "€", + phase: phase + ) + ) + + puts budget.name + + (1..([1, 2, 3].sample)).each do + group = budget.groups.create!(name: Faker::StarWars.planet) + + geozones = Geozone.reorder("RANDOM()").limit([2, 5, 6, 7].sample) + geozones.each do |geozone| + group.headings << group.headings.create!(name: geozone.name, + #geozone: geozone, + price: rand(1 .. 100) * 100000) + + end + print "#{group.name} " + end + puts "" +end + + +puts "Creating Investments" +tags = Faker::Lorem.words(10) +(1..100).each do |i| + heading = Budget::Heading.reorder("RANDOM()").first + + investment = Budget::Investment.create!( + author: User.reorder("RANDOM()").first, + heading: heading, + group: heading.group, + budget: heading.group.budget, + title: Faker::Lorem.sentence(3).truncate(60), + external_url: Faker::Internet.url, + description: "#{Faker::Lorem.paragraphs.join('
')}
", + created_at: rand((Time.now - 1.week) .. Time.now), + feasibility: %w{undecided unfeasible feasible feasible feasible feasible}.sample, + unfeasibility_explanation: Faker::Lorem.paragraph, + valuation_finished: [false, true].sample, + tag_list: tags.sample(3).join(','), + price: rand(1 .. 100) * 100000, + terms_of_service: "1") + puts " #{investment.title}" +end + +puts "Selecting Investments" +Budget.balloting.reorder("RANDOM()").limit(3).each do |budget| + budget.investments.feasible.reorder("RANDOM()").limit(10).update_all(selected: true) +end + +puts "Creating Valuation Assignments" + +(1..17).to_a.sample.times do + Budget::Investment.reorder("RANDOM()").first.valuators << valuator.valuator +end + + puts "Creating Legislation" Legislation.create!(title: 'Participatory Democracy', body: 'In order to achieve...') diff --git a/db/migrate/20160518142529_create_budgets.rb b/db/migrate/20160518142529_create_budgets.rb new file mode 100644 index 000000000..943038472 --- /dev/null +++ b/db/migrate/20160518142529_create_budgets.rb @@ -0,0 +1,15 @@ +class CreateBudgets < ActiveRecord::Migration + def change + create_table :budgets do |t| + t.string "name", limit: 30 + t.text "description" + t.string "currency_symbol", limit: 10 + + t.string "phase", default: "on_hold", limit: 15 + t.boolean "valuating", default: false + + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + end +end diff --git a/db/migrate/20160518151245_create_budget_investments.rb b/db/migrate/20160518151245_create_budget_investments.rb new file mode 100644 index 000000000..bdc77c967 --- /dev/null +++ b/db/migrate/20160518151245_create_budget_investments.rb @@ -0,0 +1,38 @@ +class CreateBudgetInvestments < ActiveRecord::Migration + def change + create_table :budget_investments do |t| + + t.references "geozone" + + t.integer "author_id", index: true + t.integer "administrator_id", index: true + + t.string "title" + t.text "description" + t.string "external_url" + + t.integer "price", limit: 8 + t.string "feasibility", default: "undecided", limit: 15 + t.text "price_explanation" + t.text "unfeasibility_explanation" + t.text "internal_comments" + t.boolean "valuation_finished", default: false + t.integer "valuation_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 + end + + add_index :budget_investments, :tsv, using: "gin" + end +end diff --git a/db/migrate/20160519144152_create_budget_ballots.rb b/db/migrate/20160519144152_create_budget_ballots.rb new file mode 100644 index 000000000..3131098b5 --- /dev/null +++ b/db/migrate/20160519144152_create_budget_ballots.rb @@ -0,0 +1,12 @@ +class CreateBudgetBallots < ActiveRecord::Migration + def change + create_table :budget_ballots do |t| + t.references :geozone + t.references :user + t.references :budget + + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + end +end diff --git a/db/migrate/20160520100347_create_budget_ballot_lines.rb b/db/migrate/20160520100347_create_budget_ballot_lines.rb new file mode 100644 index 000000000..07377234d --- /dev/null +++ b/db/migrate/20160520100347_create_budget_ballot_lines.rb @@ -0,0 +1,11 @@ +class CreateBudgetBallotLines < ActiveRecord::Migration + def change + create_table :budget_ballot_lines do |t| + t.integer :ballot_id, index: true + t.integer :investment_id, index: true + + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + end +end diff --git a/db/migrate/20160520111735_create_budget_heading.rb b/db/migrate/20160520111735_create_budget_heading.rb new file mode 100644 index 000000000..bd9291d2f --- /dev/null +++ b/db/migrate/20160520111735_create_budget_heading.rb @@ -0,0 +1,10 @@ +class CreateBudgetHeading < ActiveRecord::Migration + def change + create_table :budget_headings do |t| + t.references :group, index: true + t.references :geozone + t.string :name, limit: 50 + t.integer :price, limit: 8 + end + end +end diff --git a/db/migrate/20160520114820_replace_geozones_by_headings_in_budgets.rb b/db/migrate/20160520114820_replace_geozones_by_headings_in_budgets.rb new file mode 100644 index 000000000..60e1e4f6c --- /dev/null +++ b/db/migrate/20160520114820_replace_geozones_by_headings_in_budgets.rb @@ -0,0 +1,9 @@ +class ReplaceGeozonesByHeadingsInBudgets < ActiveRecord::Migration + def change + remove_column :budget_investments, :geozone_id + remove_column :budget_ballots, :geozone_id + + add_reference :budget_investments, :heading, index: true + add_reference :budget_ballots, :heading, index: true + end +end diff --git a/db/migrate/20160520151954_add_budget_id_to_investments.rb b/db/migrate/20160520151954_add_budget_id_to_investments.rb new file mode 100644 index 000000000..8860be67c --- /dev/null +++ b/db/migrate/20160520151954_add_budget_id_to_investments.rb @@ -0,0 +1,5 @@ +class AddBudgetIdToInvestments < ActiveRecord::Migration + def change + add_reference :budget_investments, :budget, index: true + end +end diff --git a/db/migrate/20160523095730_create_budget_valuator_assignments.rb b/db/migrate/20160523095730_create_budget_valuator_assignments.rb new file mode 100644 index 000000000..18686da0e --- /dev/null +++ b/db/migrate/20160523095730_create_budget_valuator_assignments.rb @@ -0,0 +1,9 @@ +class CreateBudgetValuatorAssignments < ActiveRecord::Migration + def change + create_table :budget_valuator_assignments, index: false do |t| + t.belongs_to :valuator + t.integer :investment_id, index: true + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160523143320_deletes_heading_id_from_ballot.rb b/db/migrate/20160523143320_deletes_heading_id_from_ballot.rb new file mode 100644 index 000000000..3a7d17e67 --- /dev/null +++ b/db/migrate/20160523143320_deletes_heading_id_from_ballot.rb @@ -0,0 +1,5 @@ +class DeletesHeadingIdFromBallot < ActiveRecord::Migration + def change + remove_column :budget_ballots, :heading_id + end +end diff --git a/db/migrate/20160523144313_add_budget_investments_count_to_valuators.rb b/db/migrate/20160523144313_add_budget_investments_count_to_valuators.rb new file mode 100644 index 000000000..9ec741951 --- /dev/null +++ b/db/migrate/20160523144313_add_budget_investments_count_to_valuators.rb @@ -0,0 +1,5 @@ +class AddBudgetInvestmentsCountToValuators < ActiveRecord::Migration + def change + add_column :valuators, :budget_investments_count, :integer, default: 0 + end +end diff --git a/db/migrate/20160523150146_rename_bi_valuation_count.rb b/db/migrate/20160523150146_rename_bi_valuation_count.rb new file mode 100644 index 000000000..b7b41e6e1 --- /dev/null +++ b/db/migrate/20160523150146_rename_bi_valuation_count.rb @@ -0,0 +1,5 @@ +class RenameBiValuationCount < ActiveRecord::Migration + def change + rename_column :budget_investments, :valuation_assignments_count, :valuator_assignments_count + end +end diff --git a/db/migrate/20160523164449_add_responsible_name_to_budget_investments.rb b/db/migrate/20160523164449_add_responsible_name_to_budget_investments.rb new file mode 100644 index 000000000..46576d059 --- /dev/null +++ b/db/migrate/20160523164449_add_responsible_name_to_budget_investments.rb @@ -0,0 +1,5 @@ +class AddResponsibleNameToBudgetInvestments < ActiveRecord::Migration + def change + add_column :budget_investments, :responsible_name, :string + end +end diff --git a/db/migrate/20160524143107_add_heading_id_to_budget_ballot.rb b/db/migrate/20160524143107_add_heading_id_to_budget_ballot.rb new file mode 100644 index 000000000..2bc254fbe --- /dev/null +++ b/db/migrate/20160524143107_add_heading_id_to_budget_ballot.rb @@ -0,0 +1,6 @@ +class AddHeadingIdToBudgetBallot < ActiveRecord::Migration + def change + add_column :budget_ballots, :heading_id, :integer + add_index :budget_ballots, :heading_id + end +end diff --git a/db/migrate/20160524144005_add_price_to_budget.rb b/db/migrate/20160524144005_add_price_to_budget.rb new file mode 100644 index 000000000..14c96dd7a --- /dev/null +++ b/db/migrate/20160524144005_add_price_to_budget.rb @@ -0,0 +1,5 @@ +class AddPriceToBudget < ActiveRecord::Migration + def change + add_column :budgets, :price, :integer + end +end diff --git a/db/migrate/20160531102008_add_budget_investments_count_to_tags.rb b/db/migrate/20160531102008_add_budget_investments_count_to_tags.rb new file mode 100644 index 000000000..256adcc0c --- /dev/null +++ b/db/migrate/20160531102008_add_budget_investments_count_to_tags.rb @@ -0,0 +1,5 @@ +class AddBudgetInvestmentsCountToTags < ActiveRecord::Migration + def change + add_column :tags, "budget/investments_count", :integer, default: 0 + end +end diff --git a/db/migrate/20160609110023_create_budget_group.rb b/db/migrate/20160609110023_create_budget_group.rb new file mode 100644 index 000000000..fb6cbcd1c --- /dev/null +++ b/db/migrate/20160609110023_create_budget_group.rb @@ -0,0 +1,10 @@ +class CreateBudgetGroup < ActiveRecord::Migration + def change + create_table :budget_groups do |t| + t.references :budget + t.string :name, limit: 50 + end + + add_index :budget_groups, :budget_id + end +end diff --git a/db/migrate/20160609142017_remove_price_from_budget.rb b/db/migrate/20160609142017_remove_price_from_budget.rb new file mode 100644 index 000000000..366fdef5f --- /dev/null +++ b/db/migrate/20160609142017_remove_price_from_budget.rb @@ -0,0 +1,5 @@ +class RemovePriceFromBudget < ActiveRecord::Migration + def change + remove_column :budgets, :price, :integer + end +end diff --git a/db/migrate/20160609152026_remove_budget_id_from_investments.rb b/db/migrate/20160609152026_remove_budget_id_from_investments.rb new file mode 100644 index 000000000..69890c2e9 --- /dev/null +++ b/db/migrate/20160609152026_remove_budget_id_from_investments.rb @@ -0,0 +1,5 @@ +class RemoveBudgetIdFromInvestments < ActiveRecord::Migration + def change + remove_column :budget_investments, :budget_id, :integer + end +end diff --git a/db/migrate/20160610094658_desnormalize_ballot_line.rb b/db/migrate/20160610094658_desnormalize_ballot_line.rb new file mode 100644 index 000000000..b4eee7dc2 --- /dev/null +++ b/db/migrate/20160610094658_desnormalize_ballot_line.rb @@ -0,0 +1,7 @@ +class DesnormalizeBallotLine < ActiveRecord::Migration + def change + add_column :budget_ballot_lines, :budget_id, :integer, index: true + add_column :budget_ballot_lines, :group_id, :integer, index: true + add_column :budget_ballot_lines, :heading_id, :integer, index: true + end +end diff --git a/db/migrate/20160614091639_remove_heading_id_from_ballot.rb b/db/migrate/20160614091639_remove_heading_id_from_ballot.rb new file mode 100644 index 000000000..f46b93424 --- /dev/null +++ b/db/migrate/20160614091639_remove_heading_id_from_ballot.rb @@ -0,0 +1,5 @@ +class RemoveHeadingIdFromBallot < ActiveRecord::Migration + def change + remove_column :budget_ballots, :heading_id, :integer + end +end diff --git a/db/migrate/20160905092539_denormalize_investments.rb b/db/migrate/20160905092539_denormalize_investments.rb new file mode 100644 index 000000000..d28291c4e --- /dev/null +++ b/db/migrate/20160905092539_denormalize_investments.rb @@ -0,0 +1,6 @@ +class DenormalizeInvestments < ActiveRecord::Migration + def change + add_column :budget_investments, :budget_id, :integer, index: true + add_column :budget_investments, :group_id, :integer, index: true + end +end diff --git a/db/migrate/20161221172447_add_selected_to_budget_investment.rb b/db/migrate/20161221172447_add_selected_to_budget_investment.rb new file mode 100644 index 000000000..de983aee4 --- /dev/null +++ b/db/migrate/20161221172447_add_selected_to_budget_investment.rb @@ -0,0 +1,5 @@ +class AddSelectedToBudgetInvestment < ActiveRecord::Migration + def change + add_column :budget_investments, :selected, :bool, default: false, index: true + end +end diff --git a/db/migrate/20161229153505_add_location_to_budget_investments.rb b/db/migrate/20161229153505_add_location_to_budget_investments.rb new file mode 100644 index 000000000..a58ee4fdd --- /dev/null +++ b/db/migrate/20161229153505_add_location_to_budget_investments.rb @@ -0,0 +1,5 @@ +class AddLocationToBudgetInvestments < ActiveRecord::Migration + def change + add_column :budget_investments, :location, :string + end +end diff --git a/db/migrate/20161230172816_remove_valuating_from_budgets.rb b/db/migrate/20161230172816_remove_valuating_from_budgets.rb new file mode 100644 index 000000000..4b6e97e7f --- /dev/null +++ b/db/migrate/20161230172816_remove_valuating_from_budgets.rb @@ -0,0 +1,5 @@ +class RemoveValuatingFromBudgets < ActiveRecord::Migration + def change + remove_column :budgets, :valuating, :bool + end +end diff --git a/db/migrate/20161230174744_change_budget_description.rb b/db/migrate/20161230174744_change_budget_description.rb new file mode 100644 index 000000000..80de9dcf4 --- /dev/null +++ b/db/migrate/20161230174744_change_budget_description.rb @@ -0,0 +1,12 @@ +class ChangeBudgetDescription < ActiveRecord::Migration + def change + remove_column :budgets, :description, :text + add_column :budgets, :description_accepting, :text + add_column :budgets, :description_reviewing, :text + add_column :budgets, :description_selecting, :text + add_column :budgets, :description_valuating, :text + add_column :budgets, :description_balloting, :text + add_column :budgets, :description_reviewing_ballots, :text + add_column :budgets, :description_finished, :text + end +end diff --git a/db/migrate/20170102080432_adjust_budget_fields.rb b/db/migrate/20170102080432_adjust_budget_fields.rb new file mode 100644 index 000000000..7517d6429 --- /dev/null +++ b/db/migrate/20170102080432_adjust_budget_fields.rb @@ -0,0 +1,5 @@ +class AdjustBudgetFields < ActiveRecord::Migration + def change + change_column :budgets, :phase, :string, limit: 40, default: 'accepting' + end +end diff --git a/db/migrate/20170103170147_remove_geozone_id_from_budget_headings.rb b/db/migrate/20170103170147_remove_geozone_id_from_budget_headings.rb new file mode 100644 index 000000000..bc8a9729c --- /dev/null +++ b/db/migrate/20170103170147_remove_geozone_id_from_budget_headings.rb @@ -0,0 +1,5 @@ +class RemoveGeozoneIdFromBudgetHeadings < ActiveRecord::Migration + def change + remove_column :budget_headings, :geozone_id + end +end diff --git a/db/migrate/20170106130838_add_organization_name_field_to_budget_investment.rb b/db/migrate/20170106130838_add_organization_name_field_to_budget_investment.rb new file mode 100644 index 000000000..dfe9eca06 --- /dev/null +++ b/db/migrate/20170106130838_add_organization_name_field_to_budget_investment.rb @@ -0,0 +1,5 @@ +class AddOrganizationNameFieldToBudgetInvestment < ActiveRecord::Migration + def change + add_column :budget_investments, :organization_name, :string + end +end diff --git a/db/migrate/20170114154421_add_unfeasible_email_sent_at_to_budget_investments.rb b/db/migrate/20170114154421_add_unfeasible_email_sent_at_to_budget_investments.rb new file mode 100644 index 000000000..dbd1a203b --- /dev/null +++ b/db/migrate/20170114154421_add_unfeasible_email_sent_at_to_budget_investments.rb @@ -0,0 +1,5 @@ +class AddUnfeasibleEmailSentAtToBudgetInvestments < ActiveRecord::Migration + def change + add_column :budget_investments, :unfeasible_email_sent_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 8195aa0cf..20744daeb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170105215410) do +ActiveRecord::Schema.define(version: 20170114154421) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -78,6 +78,103 @@ ActiveRecord::Schema.define(version: 20170105215410) 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 "group_id" + t.string "name", limit: 50 + t.integer "price", limit: 8 + end + + add_index "budget_headings", ["group_id"], name: "index_budget_headings_on_group_id", using: :btree + + 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" + t.integer "budget_id" + t.integer "group_id" + t.boolean "selected", default: false + t.string "location" + t.string "organization_name" + t.datetime "unfeasible_email_sent_at" + 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.string "currency_symbol", limit: 10 + t.string "phase", limit: 40, default: "accepting" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.text "description_accepting" + t.text "description_reviewing" + t.text "description_selecting" + t.text "description_valuating" + t.text "description_balloting" + t.text "description_reviewing_ballots" + t.text "description_finished" + end + create_table "campaigns", force: :cascade do |t| t.string "name" t.string "track_id" @@ -396,6 +493,7 @@ ActiveRecord::Schema.define(version: 20170105215410) 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 @@ -506,6 +604,7 @@ ActiveRecord::Schema.define(version: 20170105215410) 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 diff --git a/db/seeds.rb b/db/seeds.rb index d6f273d8b..41261d9d7 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -63,15 +63,16 @@ Setting["meta_keywords"] = nil # Feature flags Setting['feature.debates'] = true -Setting['feature.spending_proposals'] = true +Setting['feature.spending_proposals'] = nil Setting['feature.twitter_login'] = true Setting['feature.facebook_login'] = true Setting['feature.google_login'] = true Setting['feature.public_stats'] = true +Setting['feature.budgets'] = true Setting['feature.signature_sheets'] = true # Spending proposals feature flags -Setting['feature.spending_proposal_features.voting_allowed'] = true +Setting['feature.spending_proposal_features.voting_allowed'] = nil # Banner styles Setting['banner-style.banner-style-one'] = "Banner style 1" @@ -93,3 +94,4 @@ Setting['mailer_from_address'] = 'noreply@consul.dev' # Verification settings Setting['verification_offices_url'] = 'http://oficinas-atencion-ciudadano.url/' +Setting['min_age_to_participate'] = 16 diff --git a/knapsack_rspec_report.json b/knapsack_rspec_report.json index f31245481..938d9775f 100644 --- a/knapsack_rspec_report.json +++ b/knapsack_rspec_report.json @@ -1,132 +1,153 @@ { - "spec/features/admin/debates_spec.rb": 3.196030855178833, - "spec/lib/manager_authenticator_spec.rb": 0.7661557197570801, - "spec/helpers/geozones_helper_spec.rb": 0.3235890865325928, - "spec/features/valuation_spec.rb": 1.5787968635559082, - "spec/features/comments/proposals_spec.rb": 16.83220624923706, - "spec/helpers/verification_helper_spec.rb": 0.2460770606994629, - "spec/features/verification/level_three_verification_spec.rb": 2.016052007675171, - "spec/features/stats_spec.rb": 1.1409127712249756, - "spec/controllers/concerns/has_filters_spec.rb": 0.4043538570404053, - "spec/models/organization_spec.rb": 1.1652114391326904, - "spec/features/admin/users_spec.rb": 1.5635802745819092, - "spec/features/admin/proposals_spec.rb": 2.2328972816467285, - "spec/features/ckeditor_spec.rb": 0.7215390205383301, - "spec/features/users_auth_spec.rb": 5.428045988082886, - "spec/lib/wysiwyg_sanitizer_spec.rb": 0.31694674491882324, - "spec/helpers/orders_helper_spec.rb": 0.22522211074829102, - "spec/features/admin_spec.rb": 1.694303035736084, - "spec/features/admin/comments_spec.rb": 2.8705501556396484, - "spec/lib/tag_sanitizer_spec.rb": 0.3478989601135254, - "spec/features/votes_spec.rb": 13.293350458145142, - "spec/helpers/application_helper_spec.rb": 0.47275686264038086, - "spec/features/management/spending_proposals_spec.rb": 4.437402725219727, - "spec/features/users_spec.rb": 6.648370027542114, - "spec/models/abilities/moderator_spec.rb": 7.65787410736084, - "spec/features/welcome_spec.rb": 1.5993311405181885, - "spec/features/management/email_verifications_spec.rb": 0.3190898895263672, - "spec/features/localization_spec.rb": 0.8935031890869141, - "spec/mailers/mailer_spec.rb": 0.1826329231262207, - "spec/models/valuator_spec.rb": 0.2230076789855957, - "spec/features/organizations_spec.rb": 0.7282412052154541, - "spec/features/moderation/debates_spec.rb": 5.6599204540252686, - "spec/models/verification/management/email_spec.rb": 0.8871691226959229, - "spec/helpers/votes_helper_spec.rb": 0.8153252601623535, - "spec/lib/census_api_spec.rb": 0.8195827007293701, - "spec/lib/cache_spec.rb": 0.16429710388183594, - "spec/features/management/document_verifications_spec.rb": 1.4376773834228516, - "spec/controllers/management/base_controller_spec.rb": 0.3214681148529053, - "spec/features/management/account_spec.rb": 1.284877061843872, - "spec/features/tags_spec.rb": 5.2347259521484375, - "spec/features/management/users_spec.rb": 2.2339844703674316, - "spec/models/abilities/administrator_spec.rb": 4.104190111160278, - "spec/features/proposal_ballots_spec.rb": 1.0345211029052734, - "spec/models/abilities/organization_spec.rb": 1.2938573360443115, - "spec/features/spending_proposals_spec.rb": 3.00465989112854, - "spec/features/direct_messages_spec.rb": 1.7699065208435059, - "spec/features/proposal_notifications_spec.rb": 3.206688642501831, - "spec/features/admin/feature_flags_spec.rb": 0.7250113487243652, - "spec/features/valuation/spending_proposals_spec.rb": 9.08467411994934, - "spec/controllers/management/users_controller_spec.rb": 0.14328908920288086, - "spec/features/debates_spec.rb": 32.769495487213135, - "spec/lib/acts_as_paranoid_aliases_spec.rb": 0.672633171081543, - "spec/lib/acts_as_taggable_on_spec.rb": 0.4580230712890625, - "spec/models/proposal_notification_spec.rb": 0.8798811435699463, - "spec/models/abilities/everyone_spec.rb": 1.4743411540985107, - "spec/controllers/debates_controller_spec.rb": 0.597097635269165, - "spec/features/official_positions_spec.rb": 1.7662339210510254, - "spec/features/verification/verification_path_spec.rb": 1.8311583995819092, - "spec/models/notification_spec.rb": 1.6735141277313232, - "spec/features/tracks_spec.rb": 2.7991549968719482, - "spec/features/management/proposals_spec.rb": 4.453279733657837, - "spec/models/custom/residence_spec.rb": 0.26375889778137207, - "spec/features/admin/stats_spec.rb": 3.427401304244995, - "spec/controllers/management/sessions_controller_spec.rb": 0.6672155857086182, - "spec/features/comments/debates_spec.rb": 17.62152862548828, - "spec/features/admin/activity_spec.rb": 8.008464813232422, - "spec/models/residence_spec.rb": 1.7478408813476562, - "spec/features/moderation/comments_spec.rb": 6.95853328704834, - "spec/models/flag_spec.rb": 1.2313306331634521, - "spec/models/geozone_spec.rb": 0.21416401863098145, - "spec/models/debate_spec.rb": 13.919430494308472, - "spec/mailers/devise_mailer_spec.rb": 0.3003346920013428, - "spec/features/moderation/users_spec.rb": 1.304518222808838, - "spec/features/verification/residence_spec.rb": 2.4076998233795166, - "spec/features/admin/banners_spec.rb": 3.2043681144714355, - "spec/models/user_spec.rb": 8.115702629089355, - "spec/helpers/users_helper_spec.rb": 0.6146798133850098, - "spec/models/lock_spec.rb": 0.5752274990081787, - "spec/features/admin/officials_spec.rb": 1.1229417324066162, - "spec/features/legislation_spec.rb": 2.646373987197876, - "spec/features/management/localization_spec.rb": 1.276548147201538, - "spec/models/abilities/common_spec.rb": 8.870994567871094, - "spec/controllers/concerns/has_orders_spec.rb": 0.5060961246490479, - "spec/models/verification/management/document_spec.rb": 0.55743408203125, - "spec/models/letter_spec.rb": 0.73256516456604, - "spec/features/moderation/proposals_spec.rb": 5.034556865692139, - "spec/features/emails_spec.rb": 9.274869441986084, - "spec/features/verification/verified_user_spec.rb": 1.4910340309143066, - "spec/helpers/proposals_helper_spec.rb": 1.1765329837799072, - "spec/controllers/pages_controller_spec.rb": 1.35672926902771, - "spec/i18n_spec.rb": 27.789604902267456, - "spec/features/verification/sms_spec.rb": 1.5330836772918701, - "spec/lib/email_digests_spec.rb": 1.1210927963256836, - "spec/features/proposals_spec.rb": 43.270474910736084, - "spec/features/verification/level_two_verification_spec.rb": 0.5128798484802246, - "spec/models/comment_spec.rb": 2.6471173763275146, - "spec/models/identity_spec.rb": 0.08924984931945801, - "spec/models/vote_spec.rb": 0.6714668273925781, - "spec/models/spending_proposal_spec.rb": 6.144777774810791, - "spec/features/sessions_spec.rb": 0.6140999794006348, - "spec/features/registration_form_spec.rb": 1.3086371421813965, - "spec/features/admin/tags_spec.rb": 1.2578890323638916, - "spec/customization_engine_spec.rb": 0.9755609035491943, - "spec/features/admin/organizations_spec.rb": 4.552514553070068, - "spec/models/proposal_spec.rb": 14.755258560180664, - "spec/features/moderation_spec.rb": 1.702514410018921, - "spec/helpers/settings_helper_spec.rb": 0.22182989120483398, - "spec/models/tag_cloud_spec.rb": 2.6144700050354004, - "spec/features/user_invites_spec.rb": 0.22390198707580566, - "spec/models/activity_spec.rb": 1.5089714527130127, - "spec/controllers/admin/api/stats_controller_spec.rb": 0.6779742240905762, - "spec/features/management/managed_users_spec.rb": 1.556541919708252, - "spec/models/direct_message_spec.rb": 1.4555466175079346, - "spec/features/admin/spending_proposals_spec.rb": 16.1976478099823, - "spec/controllers/users/registrations_controller_spec.rb": 0.24361419677734375, - "spec/features/admin/moderators_spec.rb": 1.3666069507598877, - "spec/models/sms_spec.rb": 0.352916955947876, - "spec/models/setting_spec.rb": 1.2480311393737793, - "spec/features/verification/email_spec.rb": 0.6614222526550293, - "spec/features/admin/valuators_spec.rb": 0.9944217205047607, - "spec/models/ahoy/data_source_spec.rb": 0.4324939250946045, - "spec/features/account_spec.rb": 2.387765407562256, - "spec/features/notifications_spec.rb": 10.897897958755493, - "spec/features/campaigns_spec.rb": 1.1797480583190918, - "spec/features/home_spec.rb": 1.0699732303619385, - "spec/features/admin/verifications_spec.rb": 1.4650330543518066, - "spec/features/admin/managers_spec.rb": 1.3956513404846191, - "spec/models/abilities/valuator_spec.rb": 0.40586066246032715, - "spec/helpers/comments_helper_spec.rb": 0.7347445487976074, - "spec/features/admin/settings_spec.rb": 0.522209644317627, - "spec/features/verification/letter_spec.rb": 2.5052530765533447 + "spec/features/management/document_verifications_spec.rb": 54.17448377609253, + "spec/features/spending_proposals_spec.rb": 2.705125570297241, + "spec/features/admin/budget_investments_spec.rb": 19.896899700164795, + "spec/features/budgets/budgets_spec.rb": 0.4167191982269287, + "spec/features/management/users_spec.rb": 3.2355875968933105, + "spec/lib/spending_proposals_importer_spec.rb": 1.017453670501709, + "spec/features/account_spec.rb": 2.271092653274536, + "spec/helpers/votes_helper_spec.rb": 0.44858264923095703, + "spec/features/moderation/proposals_spec.rb": 4.742751836776733, + "spec/controllers/debates_controller_spec.rb": 0.2623593807220459, + "spec/features/user_invites_spec.rb": 0.21874594688415527, + "spec/features/tags_spec.rb": 2.881978988647461, + "spec/controllers/pages_controller_spec.rb": 0.10289263725280762, + "spec/features/admin/banners_spec.rb": 2.686169385910034, + "spec/features/valuation/spending_proposals_spec.rb": 8.130439519882202, + "spec/features/ckeditor_spec.rb": 1.0175442695617676, + "spec/features/valuation/budget_investments_spec.rb": 6.796356916427612, + "spec/features/verification/level_two_verification_spec.rb": 0.45789313316345215, + "spec/features/tags/budget_investments_spec.rb": 10.671012163162231, + "spec/models/signature_spec.rb": 1.0628974437713623, + "spec/features/management/managed_users_spec.rb": 1.5139601230621338, + "spec/models/letter_spec.rb": 0.1097867488861084, + "spec/features/comments/debates_spec.rb": 12.592287063598633, + "spec/features/sessions_spec.rb": 0.3503243923187256, + "spec/models/signature_sheet_spec.rb": 0.5397381782531738, + "spec/mailers/devise_mailer_spec.rb": 0.06376838684082031, + "spec/controllers/admin/api/stats_controller_spec.rb": 0.2264876365661621, + "spec/features/admin/feature_flags_spec.rb": 0.5853826999664307, + "spec/features/notifications_spec.rb": 12.585360765457153, + "spec/controllers/management/base_controller_spec.rb": 0.01735234260559082, + "spec/helpers/geozones_helper_spec.rb": 0.059060096740722656, + "spec/lib/cache_spec.rb": 0.057135581970214844, + "spec/features/admin/budgets_spec.rb": 3.47196888923645, + "spec/features/comments/proposals_spec.rb": 14.34140133857727, + "spec/i18n_spec.rb": 59.869616985321045, + "spec/controllers/users/registrations_controller_spec.rb": 0.027117013931274414, + "spec/models/ahoy/data_source_spec.rb": 0.046532630920410156, + "spec/lib/acts_as_taggable_on_spec.rb": 0.25763797760009766, + "spec/features/admin/verifications_spec.rb": 0.5322456359863281, + "spec/features/admin/activity_spec.rb": 6.245920419692993, + "spec/features/users_auth_spec.rb": 4.910919189453125, + "spec/features/admin/geozones_spec.rb": 1.1101677417755127, + "spec/features/verification/level_three_verification_spec.rb": 1.2446002960205078, + "spec/features/moderation/users_spec.rb": 1.0908584594726562, + "spec/features/localization_spec.rb": 0.6817822456359863, + "spec/features/votes_spec.rb": 10.293386220932007, + "spec/features/admin/comments_spec.rb": 2.4890687465667725, + "spec/features/management/account_spec.rb": 1.1203999519348145, + "spec/features/admin/moderators_spec.rb": 1.1019458770751953, + "spec/features/tags/debates_spec.rb": 2.828442335128784, + "spec/helpers/proposals_helper_spec.rb": 0.1567704677581787, + "spec/controllers/management/sessions_controller_spec.rb": 0.07266688346862793, + "spec/helpers/users_helper_spec.rb": 0.25275325775146484, + "spec/models/budget/investment_spec.rb": 2.8698906898498535, + "spec/features/verification/residence_spec.rb": 1.6340432167053223, + "spec/models/spending_proposal_spec.rb": 1.5339767932891846, + "spec/models/abilities/everyone_spec.rb": 0.048151493072509766, + "spec/mailers/mailer_spec.rb": 0.05180168151855469, + "spec/models/organization_spec.rb": 0.1083993911743164, + "spec/features/tracks_spec.rb": 1.8089509010314941, + "spec/models/abilities/common_spec.rb": 1.8844726085662842, + "spec/features/emails_spec.rb": 8.60808777809143, + "spec/features/verification/email_spec.rb": 0.4650886058807373, + "spec/lib/manager_authenticator_spec.rb": 0.0050716400146484375, + "spec/features/verification/letter_spec.rb": 1.5088157653808594, + "spec/features/verification/sms_spec.rb": 1.6104755401611328, + "spec/models/sms_spec.rb": 0.03068065643310547, + "spec/features/direct_messages_spec.rb": 1.2756364345550537, + "spec/lib/wysiwyg_sanitizer_spec.rb": 0.0025894641876220703, + "spec/features/admin/users_spec.rb": 1.343276023864746, + "spec/features/welcome_spec.rb": 1.378654956817627, + "spec/models/lock_spec.rb": 0.07993745803833008, + "spec/helpers/comments_helper_spec.rb": 0.010583639144897461, + "spec/features/users_spec.rb": 6.439063787460327, + "spec/features/admin/valuators_spec.rb": 1.0057058334350586, + "spec/features/proposals_spec.rb": 33.53970956802368, + "spec/features/stats_spec.rb": 0.7194232940673828, + "spec/features/admin/organizations_spec.rb": 2.7506325244903564, + "spec/features/management/spending_proposals_spec.rb": 4.820674657821655, + "spec/models/flag_spec.rb": 0.4751725196838379, + "spec/features/budgets/ballots_spec.rb": 20.3236243724823, + "spec/features/management/proposals_spec.rb": 4.8367063999176025, + "spec/features/admin/managers_spec.rb": 1.208801507949829, + "spec/models/proposal_notification_spec.rb": 0.21875619888305664, + "spec/models/abilities/valuator_spec.rb": 1.1417410373687744, + "spec/lib/census_api_spec.rb": 0.002756357192993164, + "spec/features/campaigns_spec.rb": 1.2990384101867676, + "spec/features/admin/signature_sheets_spec.rb": 1.008446216583252, + "spec/features/moderation/debates_spec.rb": 5.311923027038574, + "spec/features/moderation/comments_spec.rb": 7.027488470077515, + "spec/controllers/management/users_controller_spec.rb": 0.004802703857421875, + "spec/features/registration_form_spec.rb": 0.8641955852508545, + "spec/models/proposal_spec.rb": 5.7482664585113525, + "spec/models/identity_spec.rb": 0.0020508766174316406, + "spec/lib/acts_as_paranoid_aliases_spec.rb": 0.3309330940246582, + "spec/customization_engine_spec.rb": 1.4245245456695557, + "spec/models/user_spec.rb": 2.2354276180267334, + "spec/features/management/localization_spec.rb": 1.2131106853485107, + "spec/features/admin/debates_spec.rb": 1.9512214660644531, + "spec/models/budget_spec.rb": 0.11238622665405273, + "spec/helpers/verification_helper_spec.rb": 0.0013611316680908203, + "spec/models/abilities/administrator_spec.rb": 1.572779893875122, + "spec/features/valuation/budgets_spec.rb": 0.2885475158691406, + "spec/models/notification_spec.rb": 0.42080020904541016, + "spec/features/official_positions_spec.rb": 1.5759620666503906, + "spec/helpers/settings_helper_spec.rb": 0.026433467864990234, + "spec/features/comments/budget_investments_spec.rb": 14.936149597167969, + "spec/models/valuator_spec.rb": 0.036624908447265625, + "spec/features/debates_spec.rb": 26.954891443252563, + "spec/features/verification/verification_path_spec.rb": 1.300161361694336, + "spec/models/direct_message_spec.rb": 0.44811463356018066, + "spec/models/custom/residence_spec.rb": 0.059293270111083984, + "spec/features/admin/officials_spec.rb": 1.1048157215118408, + "spec/lib/email_digests_spec.rb": 0.4939093589782715, + "spec/models/verification/management/document_spec.rb": 0.021982908248901367, + "spec/features/proposal_notifications_spec.rb": 3.016808032989502, + "spec/features/proposal_ballots_spec.rb": 1.1181466579437256, + "spec/features/budgets/investments_spec.rb": 21.673389673233032, + "spec/features/admin_spec.rb": 1.0874137878417969, + "spec/models/activity_spec.rb": 1.0137333869934082, + "spec/models/geozone_spec.rb": 0.11485028266906738, + "spec/features/tags/proposals_spec.rb": 8.604074954986572, + "spec/features/admin/proposals_spec.rb": 2.0829906463623047, + "spec/models/setting_spec.rb": 0.08045053482055664, + "spec/models/debate_spec.rb": 5.072354555130005, + "spec/features/admin/settings_spec.rb": 0.6724460124969482, + "spec/models/budget/ballot/line_spec.rb": 0.4496328830718994, + "spec/models/vote_spec.rb": 0.5359287261962891, + "spec/features/management/budget_investments_spec.rb": 7.5624330043792725, + "spec/controllers/concerns/has_filters_spec.rb": 0.1893603801727295, + "spec/helpers/application_helper_spec.rb": 0.10230112075805664, + "spec/features/admin/spending_proposals_spec.rb": 20.87121033668518, + "spec/models/budget/ballot_spec.rb": 0.38541626930236816, + "spec/features/organizations_spec.rb": 0.48668909072875977, + "spec/features/management/email_verifications_spec.rb": 0.366025447845459, + "spec/features/verification/verified_user_spec.rb": 0.7837138175964355, + "spec/features/admin/tags_spec.rb": 1.063096523284912, + "spec/lib/tag_sanitizer_spec.rb": 0.0007655620574951172, + "spec/models/tag_cloud_spec.rb": 1.493929386138916, + "spec/models/verification/management/email_spec.rb": 0.06755900382995605, + "spec/controllers/concerns/has_orders_spec.rb": 0.260697603225708, + "spec/features/moderation_spec.rb": 1.4979455471038818, + "spec/features/home_spec.rb": 1.016045331954956, + "spec/features/admin/stats_spec.rb": 3.209017753601074, + "spec/models/abilities/moderator_spec.rb": 2.791966438293457, + "spec/models/residence_spec.rb": 0.25271034240722656, + "spec/models/comment_spec.rb": 1.5699236392974854, + "spec/features/valuation_spec.rb": 1.2200286388397217, + "spec/models/abilities/organization_spec.rb": 0.29455089569091797, + "spec/features/legislation_spec.rb": 2.8978617191314697, + "spec/features/budgets/votes_spec.rb": 4.397690534591675 } \ No newline at end of file diff --git a/lib/spending_proposals_importer.rb b/lib/spending_proposals_importer.rb new file mode 100644 index 000000000..72a3922b8 --- /dev/null +++ b/lib/spending_proposals_importer.rb @@ -0,0 +1,69 @@ +class SpendingProposalsImporter + + def import(sp) + budget = Budget.last || Budget.create!(name: Date.today.year.to_s, currency_symbol: "€") + + group = nil + heading = nil + + if sp.geozone_id.present? + group = budget.groups.find_or_create_by!(name: "Barrios") + heading = group.headings.find_or_create_by!(name: sp.geozone.name, price: 10000000) + else + group = budget.groups.find_or_create_by!(name: "Toda la ciudad") + heading = group.headings.find_or_create_by!(name: "Toda la ciudad", price: 10000000) + end + + feasibility = case sp.feasible + when FalseClass + 'unfeasible' + when TrueClass + 'feasible' + else + 'undecided' + end + + investment = Budget::Investment.create!( + heading_id: heading.id, + author_id: sp.author_id, + administrator_id: sp.administrator_id, + title: sp.title, + description: sp.description, + external_url: sp.external_url, + price: sp.price, + price_explanation: sp.price_explanation, + internal_comments: sp.internal_comments, + duration: sp.time_scope, + feasibility: feasibility, + unfeasibility_explanation: sp.feasible_explanation, + valuation_finished: sp.valuation_finished, + price_first_year: sp.price_first_year, + cached_votes_up: sp.cached_votes_up, + physical_votes: sp.physical_votes, + created_at: sp.created_at, + updated_at: sp.updated_at, + responsible_name: sp.responsible_name, + terms_of_service: "1" + ) + + investment.valuators = sp.valuation_assignments.map(&:valuator) + + votes = ActsAsVotable::Vote.where(votable_type: 'SpendingProposal', votable_id: sp.id) + + votes.each {|v| investment.vote_by({voter: v.voter, vote: 'yes'}) } + + # Spending proposals are not commentable in Consul so we can not test this + # + # Comment.where(commentable_type: 'SpendingProposal', commentable_id: sp.id).update_all( + # commentable_type: 'Budget::Investment', commentable_id: investment.id + # ) + # Budget::Investment.reset_counters(investment.id, :comments) + + # Spending proposals have ballot_lines in Madrid, but not in consul, so we + # can not test this either + + investment + end + +end + diff --git a/public/404.html b/public/404.html index cc6820bba..5b5362192 100644 --- a/public/404.html +++ b/public/404.html @@ -1,5 +1,5 @@ - +
+ <%= t("debates.show.comments_title") %> + (<%= commentable.comments_count %>) +
+ + <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> + + <% if user_signed_in? %> + <%= render 'comments/form', {commentable: commentable, parent_id: nil, toggeable: false} %> + <% else %> ++ +