decidim-accountability 0.1.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -21
  3. data/app/assets/javascripts/decidim/accountability/accountability.js.es6 +3 -3
  4. data/app/assets/javascripts/decidim/accountability/admin/accountability_admin.js +3 -2
  5. data/app/assets/stylesheets/decidim/accountability/accountability/_categories.scss +13 -13
  6. data/app/assets/stylesheets/decidim/accountability/accountability/_lines_breadcrumb.scss +5 -5
  7. data/app/assets/stylesheets/decidim/accountability/accountability/_results.scss +5 -5
  8. data/app/commands/decidim/accountability/admin/create_result.rb +0 -1
  9. data/app/commands/decidim/accountability/admin/update_result.rb +0 -5
  10. data/app/controllers/decidim/accountability/application_controller.rb +1 -1
  11. data/app/controllers/decidim/accountability/results_controller.rb +1 -12
  12. data/app/forms/decidim/accountability/admin/result_form.rb +0 -11
  13. data/app/helpers/decidim/accountability/application_helper.rb +8 -6
  14. data/app/models/decidim/accountability/result.rb +3 -10
  15. data/app/services/decidim/accountability/result_search.rb +6 -3
  16. data/app/services/decidim/accountability/result_stats_calculator.rb +2 -6
  17. data/app/services/decidim/accountability/results_calculator.rb +1 -1
  18. data/app/views/decidim/accountability/admin/results/_form.html.erb +0 -4
  19. data/app/views/decidim/accountability/admin/results/index.html.erb +5 -2
  20. data/app/views/decidim/accountability/admin/shared/_extra.html.erb +1 -0
  21. data/app/views/decidim/accountability/admin/shared/_subnav.html.erb +1 -3
  22. data/app/views/decidim/accountability/results/_home_categories.html.erb +15 -9
  23. data/app/views/decidim/accountability/results/_home_header.html.erb +12 -13
  24. data/app/views/decidim/accountability/results/_linked_results.html.erb +1 -1
  25. data/app/views/decidim/accountability/results/_results_leaf.html.erb +5 -3
  26. data/app/views/decidim/accountability/results/_results_parent.html.erb +5 -3
  27. data/app/views/decidim/accountability/results/_show_leaf.html.erb +14 -14
  28. data/app/views/decidim/accountability/results/_show_parent.html.erb +1 -1
  29. data/config/locales/ca.yml +9 -41
  30. data/config/locales/en.yml +8 -40
  31. data/config/locales/es.yml +9 -41
  32. data/config/locales/eu.yml +99 -21
  33. data/config/locales/fi.yml +101 -21
  34. data/config/locales/fr.yml +157 -0
  35. data/config/locales/it.yml +157 -0
  36. data/config/locales/nl.yml +157 -0
  37. data/config/locales/pl.yml +158 -0
  38. data/config/locales/ru.yml +159 -0
  39. data/config/locales/uk.yml +159 -0
  40. data/db/migrate/20170426104125_create_accountability_results.rb +0 -1
  41. data/db/migrate/20170508104902_add_description_and_progress_to_statuses.rb +2 -0
  42. data/db/migrate/20170623094200_migrate_accountability_results_category.rb +2 -0
  43. data/db/migrate/20170623144902_add_children_counter_cache_to_results.rb +2 -0
  44. data/db/migrate/20170928073905_migrate_old_results.rb +53 -0
  45. data/lib/decidim/accountability.rb +2 -1
  46. data/lib/decidim/accountability/admin_engine.rb +0 -2
  47. data/lib/decidim/accountability/{list_engine.rb → engine.rb} +1 -2
  48. data/lib/decidim/accountability/feature.rb +53 -19
  49. data/lib/decidim/accountability/result_serializer.rb +66 -0
  50. data/lib/decidim/accountability/test/factories.rb +16 -16
  51. data/lib/decidim/accountability/version.rb +10 -0
  52. metadata +111 -53
  53. data/app/commands/decidim/accountability/admin/update_template_texts.rb +0 -47
  54. data/app/controllers/decidim/accountability/admin/imports_controller.rb +0 -30
  55. data/app/controllers/decidim/accountability/admin/template_texts_controller.rb +0 -38
  56. data/app/forms/decidim/accountability/admin/template_texts_form.rb +0 -19
  57. data/app/models/decidim/accountability/template_texts.rb +0 -17
  58. data/app/services/decidim/accountability/csv_exporter.rb +0 -77
  59. data/app/services/decidim/accountability/csv_importer.rb +0 -106
  60. data/app/views/decidim/accountability/admin/imports/new.html.erb +0 -47
  61. data/app/views/decidim/accountability/admin/template_texts/_form.html.erb +0 -30
  62. data/app/views/decidim/accountability/admin/template_texts/edit.html.erb +0 -8
  63. data/app/views/decidim/accountability/results/_tags.html.erb +0 -10
  64. data/config/i18n-tasks.yml +0 -10
  65. data/db/migrate/20170508161109_create_template_texts.rb +0 -14
  66. data/db/migrate/20170606102902_add_index_to_accountability_results_on_external_id.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d991e91f98dd70d9e581a95c8d09fcd3a01cc313
4
- data.tar.gz: f4a462988114f23d035f702996d03079e36bb25c
3
+ metadata.gz: 0b787657f5b6b2118664acf3b7f0acbd065134c7
4
+ data.tar.gz: f341192e05929606d81304f08b84150fd51e667d
5
5
  SHA512:
6
- metadata.gz: c653cad7b9950eae4ef3ba16962f9ca806fe2a165c208f4741a0907ff8e1b068198affef6f169d15f8294a0b39fa527096fa6a0d56b161f77f12590aa01b402a
7
- data.tar.gz: b4a0c193586373ba14615f18d007aef3423c6b95a32fc14b4ba56b68486b211f6af08a17b92bbca82c27a164b9d9f0e182d65143104665d4692e183f319eb560
6
+ metadata.gz: 4f62563f678f48c654cdeb7874eab17b5aee5f973a9bd069819e7a8f1595bf69e6bd762ce2e83e643af38cee001516e52eb9d4b0b1a0106744012dc8def41982
7
+ data.tar.gz: 4dd031a50587ec0cc06432965b04e9950fc5aa01b5866ef08f3fb822df3a756e6bc6ac7ee3b34b787bf7ed4452912c91468227023bc86af3380d65ec5fdc28bf
data/README.md CHANGED
@@ -1,13 +1,10 @@
1
1
  # Decidim::Accountability
2
2
 
3
- [![Build Status](https://www.travis-ci.org/decidim/decidim-accountability.svg?branch=master)](https://www.travis-ci.org/decidim/decidim-accountability)
4
-
5
-
6
3
  The Accountability module adds results to any participatory process. It adds a CRUD engine to the admin and public views scoped inside the participatory process. Accountability will link to related meetings and proposals and will be used to show the progress on the related proposals.
7
4
 
8
- It also has a CSV importer for results, you can read [here](doc/csv_importer.md) about how it works, the CSV columns and what they mean.
9
5
 
10
6
  ## Usage
7
+
11
8
  Accountability will be available as a Feature for a Participatory Process.
12
9
 
13
10
  ## Installation
@@ -22,23 +19,6 @@ And then execute:
22
19
  $ bundle
23
20
  ```
24
21
 
25
- ## Migration from `Decidim::Results` module
26
- To migrate results from Decidim::Results to Decidim::Accountability you can use a rake task like [this one in decidim-barcelona](https://github.com/PopulateTools/decidim-barcelona/blob/accountability/lib/tasks/migrate_results_to_accountability.rake). The task asumes that the accountability feature for the process has already been created. It takes a process ID as an argument, and defaults to 1 if none is provided:
27
- ```bash
28
- $ bundle exec rake migrate:results_to_accountability[PROCESS_ID]
29
- ```
30
-
31
-
32
- ## Local development setup
33
- Clone [decidim-barcelona](https://github.com/PopulateTools/decidim-barcelona), at the same directory level as this `decidim-accountability` clone, and then checkout the `accountability-localdev` branch.
34
-
35
- Inside the `decidim-barcelona` directory run:
36
-
37
- - `bundle exec rake db:setup`
38
- - `bundle exec rake test_data:load`
39
-
40
- Now you should be able to start a local server with `bundle exec rails s`.
41
-
42
22
  ## Contributing
43
23
  See [Decidim](https://github.com/AjuntamentdeBarcelona/decidim).
44
24
 
@@ -1,10 +1,10 @@
1
1
  // = require_self
2
2
 
3
3
  $(() => {
4
- /* Show category list on click when we are on a small scren */
4
+ // Show category list on click when we are on a small scren
5
5
  if ($(window).width() < 768) {
6
- $('.category--section').click((e) => {
7
- $(e.currentTarget).next('.category--elements').toggleClass('active');
6
+ $('.category--section').click((event) => {
7
+ $(event.currentTarget).next('.category--elements').toggleClass('active');
8
8
  });
9
9
  }
10
10
  })
@@ -1,8 +1,9 @@
1
1
  // = require_self
2
2
 
3
3
  $("#result_decidim_accountability_status_id").change(function () {
4
- progress = $(this).find(':selected').data('progress')
5
- if (progress || progress == 0) {
4
+ /* eslint-disable no-invalid-this */
5
+ const progress = $(this).find(':selected').data('progress')
6
+ if (progress || progress === 0) {
6
7
  $("#result_progress").val(progress);
7
8
  }
8
9
  });
@@ -4,35 +4,35 @@
4
4
  border-bottom: 1px solid $medium-gray;
5
5
  padding-bottom: 1rem;
6
6
  margin-bottom: 1rem;
7
-
7
+
8
8
  .icon--arrow-bottom {
9
9
  fill: lighten($dark-gray, 50);
10
10
  }
11
-
11
+
12
12
  span {
13
13
  text-transform: uppercase;
14
14
  font-size: 1.15rem;
15
15
  color: lighten($dark-gray, 50);
16
16
  }
17
17
  }
18
-
18
+
19
19
  .categories--group {
20
20
  margin-bottom: 2rem;
21
-
21
+
22
22
  @include breakpoint(medium) {
23
23
  display: flex;
24
24
  margin-bottom: 4rem;
25
25
  }
26
-
26
+
27
27
  .category--title {
28
28
  background: $white;
29
29
  padding: 1.5rem 2rem;
30
30
  min-height: 9rem;
31
-
31
+
32
32
  @include breakpoint(medium) {
33
33
  height: calc(100% - 1.875rem);
34
34
  }
35
-
35
+
36
36
  p {
37
37
  font-weight: 600;
38
38
  margin-bottom: 0.75rem;
@@ -44,7 +44,7 @@
44
44
  .progress-info {
45
45
  position: relative;
46
46
  margin-bottom: 1.5rem;
47
-
47
+
48
48
  .progress-figure {
49
49
  display: inline-block;
50
50
  }
@@ -56,7 +56,7 @@
56
56
  }
57
57
  }
58
58
  }
59
-
59
+
60
60
  .card__link {
61
61
  .category--line {
62
62
  background: $light-gray-dark;
@@ -65,12 +65,12 @@
65
65
  padding: 1rem;
66
66
  margin-bottom: 1.875rem;
67
67
  position: relative;
68
-
68
+
69
69
  strong {
70
70
  font-weight: 600;
71
71
  color: $secondary;
72
72
  }
73
-
73
+
74
74
  .progress-figure {
75
75
  position: absolute;
76
76
  bottom: 1rem;
@@ -96,12 +96,12 @@
96
96
 
97
97
  .category--elements.active {
98
98
  display: block !important;
99
-
99
+
100
100
  .medium-4:first-child {
101
101
  margin-top: 1rem;
102
102
  }
103
103
  }
104
-
104
+
105
105
  .progress-figure {
106
106
  color: lighten($dark-gray, 50);
107
107
  }
@@ -1,25 +1,25 @@
1
1
  .lines-breadcrumb {
2
2
  margin-bottom: 2rem;
3
-
3
+
4
4
  .breadcrumb--separator {
5
5
  color: darken($light-gray, 40);
6
6
  padding: 0 0.25rem;
7
7
  }
8
-
8
+
9
9
  div {
10
10
  display: inline-block;
11
11
  }
12
-
12
+
13
13
  a {
14
14
  font-weight: 600;
15
15
  color: $dark-gray;
16
16
  }
17
-
17
+
18
18
  ul {
19
19
  list-style: none;
20
20
  margin-left: 0;
21
21
  }
22
-
22
+
23
23
  .percentage {
24
24
  color: darken($light-gray, 40);
25
25
  font-weight: 400;
@@ -32,7 +32,7 @@
32
32
  font-size: 2.5rem;
33
33
  font-weight: 300;
34
34
  color: lighten($dark-gray, 50);
35
-
35
+
36
36
  @include breakpoint(medium) {
37
37
  font-size: 4rem;
38
38
  }
@@ -77,13 +77,13 @@
77
77
  min-width: 1.5rem;
78
78
  min-height: 1.5rem;
79
79
  margin-bottom: 0.5rem;
80
-
80
+
81
81
  @include breakpoint(medium) {
82
82
  margin-right: 0.75rem;
83
83
  margin-top: 0.5rem;
84
84
  }
85
85
  }
86
-
86
+
87
87
  @include breakpoint(medium) {
88
88
  flex-direction: row;
89
89
  }
@@ -112,7 +112,7 @@
112
112
  }
113
113
  }
114
114
  }
115
-
115
+
116
116
  .result-description div {
117
117
  margin-bottom: 1rem;
118
118
  }
@@ -134,7 +134,7 @@
134
134
  width: 100%;
135
135
  margin: 0 0 3rem 0;
136
136
  }
137
-
137
+
138
138
  .timeline {
139
139
  .timeline__info {
140
140
  background-color: transparent;
@@ -37,7 +37,6 @@ module Decidim
37
37
  parent_id: @form.parent_id,
38
38
  title: @form.title,
39
39
  description: @form.description,
40
- external_id: @form.external_id,
41
40
  start_date: @form.start_date,
42
41
  end_date: @form.end_date,
43
42
  progress: @form.progress,
@@ -21,12 +21,8 @@ module Decidim
21
21
  def call
22
22
  return broadcast(:invalid) if form.invalid?
23
23
 
24
- current_proposal_ids = result.linked_resources(:proposals, "included_proposals").pluck(:id).sort
25
- form_proposal_ids = form.proposal_ids.reject(&:blank?).sort
26
-
27
24
  transaction do
28
25
  update_result
29
- result.touch if form_proposal_ids != current_proposal_ids
30
26
  link_proposals
31
27
  link_meetings
32
28
  end
@@ -45,7 +41,6 @@ module Decidim
45
41
  parent_id: @form.parent_id,
46
42
  title: @form.title,
47
43
  description: @form.description,
48
- external_id: @form.external_id,
49
44
  start_date: @form.start_date,
50
45
  end_date: @form.end_date,
51
46
  progress: @form.progress,
@@ -5,7 +5,7 @@ module Decidim
5
5
  # This controller is the abstract class from which all other controllers of
6
6
  # this engine inherit.
7
7
  #
8
- # Note that it inherits from `Decidim::Components::BaseController`, which
8
+ # Note that it inherits from `Decidim::Features::BaseController`, which
9
9
  # override its layout and provide all kinds of useful methods.
10
10
  class ApplicationController < Decidim::Features::BaseController
11
11
  end
@@ -7,14 +7,7 @@ module Decidim
7
7
  include FilterResource
8
8
  helper Decidim::WidgetUrlsHelper
9
9
 
10
- helper_method :results, :result, :stats_calculator, :first_class_categories, :category, :progress_calculator, :count_calculator, :current_scope, :template_texts
11
-
12
- def home
13
- end
14
-
15
- def csv
16
- send_data CSVExporter.new(current_feature).export, filename: "results.csv", disposition: "attachment"
17
- end
10
+ helper_method :results, :result, :stats_calculator, :first_class_categories, :category, :progress_calculator, :count_calculator, :current_scope
18
11
 
19
12
  private
20
13
 
@@ -68,10 +61,6 @@ module Decidim
68
61
  def current_scope
69
62
  params[:filter][:scope_id] if params[:filter]
70
63
  end
71
-
72
- def template_texts
73
- Decidim::Accountability::TemplateTexts.for(current_feature)
74
- end
75
64
  end
76
65
  end
77
66
  end
@@ -17,7 +17,6 @@ module Decidim
17
17
  attribute :start_date, Date
18
18
  attribute :end_date, Date
19
19
  attribute :progress, Float
20
- attribute :external_id, String
21
20
  attribute :decidim_accountability_status_id, Integer
22
21
  attribute :parent_id, Integer
23
22
 
@@ -30,8 +29,6 @@ module Decidim
30
29
  validates :parent, presence: true, if: ->(form) { form.parent_id.present? }
31
30
  validates :status, presence: true, if: ->(form) { form.decidim_accountability_status_id.present? }
32
31
 
33
- validate :external_id_uniqueness
34
-
35
32
  def map_model(model)
36
33
  self.proposal_ids = model.linked_resources(:proposals, "included_proposals").pluck(:id)
37
34
  self.decidim_category_id = model.category.try(:id)
@@ -60,14 +57,6 @@ module Decidim
60
57
  def status
61
58
  @status ||= Decidim::Accountability::Status.where(feature: current_feature, id: decidim_accountability_status_id).first
62
59
  end
63
-
64
- private
65
-
66
- def external_id_uniqueness
67
- return if external_id.blank?
68
- existing_with_external_id = Decidim::Accountability::Result.find_by(feature: current_feature, external_id: external_id)
69
- errors.add(:external_id, :taken) if existing_with_external_id && existing_with_external_id.id != id
70
- end
71
60
  end
72
61
  end
73
62
  end
@@ -9,7 +9,7 @@ module Decidim
9
9
  include Decidim::Comments::CommentsHelper
10
10
 
11
11
  def display_percentage(number)
12
- return unless number.present?
12
+ return if number.blank?
13
13
 
14
14
  number_to_percentage(number, precision: 1, strip_insignificant_zeros: true, locale: I18n.locale)
15
15
  end
@@ -19,19 +19,20 @@ module Decidim
19
19
  end
20
20
 
21
21
  def active_class_if_current(scope)
22
- %Q{class=active} if scope.to_s == current_scope.to_s
22
+ "class=active" if scope.to_s == current_scope.to_s
23
23
  end
24
24
 
25
25
  def categories_label
26
- translated_attribute(template_texts.categories_label).presence || t("results.home.categories_label", scope: "decidim.accountability")
26
+ translated_attribute(feature_settings.categories_label).presence || t("results.home.categories_label", scope: "decidim.accountability")
27
27
  end
28
28
 
29
29
  def subcategories_label
30
- translated_attribute(template_texts.subcategories_label).presence || t("results.home.subcategories_label", scope: "decidim.accountability")
30
+ translated_attribute(feature_settings.subcategories_label).presence || t("results.home.subcategories_label", scope: "decidim.accountability")
31
31
  end
32
32
 
33
33
  def heading_parent_level_results(count)
34
- if text = translated_attribute(template_texts.heading_parent_level_results).presence
34
+ text = translated_attribute(feature_settings.heading_parent_level_results).presence
35
+ if text
35
36
  "#{count} #{text}"
36
37
  else
37
38
  t("results.count.results_count", scope: "decidim.accountability", count: count)
@@ -39,7 +40,8 @@ module Decidim
39
40
  end
40
41
 
41
42
  def heading_leaf_level_results(count)
42
- if text = translated_attribute(template_texts.heading_leaf_level_results).presence
43
+ text = translated_attribute(feature_settings.heading_leaf_level_results).presence
44
+ if text
43
45
  "#{count} #{text}"
44
46
  else
45
47
  t("results.count.results_count", scope: "decidim.accountability", count: count)
@@ -19,14 +19,13 @@ module Decidim
19
19
 
20
20
  belongs_to :status, foreign_key: "decidim_accountability_status_id", class_name: "Decidim::Accountability::Status", inverse_of: :results, optional: true
21
21
 
22
- has_many :timeline_entries, -> { order(:entry_date) }, foreign_key: "decidim_accountability_result_id", class_name: "Decidim::Accountability::TimelineEntry", inverse_of: :result, dependent: :destroy
23
-
24
- before_validation :remove_blank_values
22
+ has_many :timeline_entries, -> { order(:entry_date) }, foreign_key: "decidim_accountability_result_id",
23
+ class_name: "Decidim::Accountability::TimelineEntry", inverse_of: :result, dependent: :destroy
25
24
 
26
25
  after_save :update_parent_progress, if: -> { parent_id.present? }
27
26
 
28
27
  def update_parent_progress
29
- return unless parent.present?
28
+ return if parent.blank?
30
29
 
31
30
  parent.update_progress!
32
31
  end
@@ -55,12 +54,6 @@ module Decidim
55
54
  def comments_have_votes?
56
55
  true
57
56
  end
58
-
59
- private
60
-
61
- def remove_blank_values
62
- self.external_id = nil if external_id.blank?
63
- end
64
57
  end
65
58
  end
66
59
  end
@@ -7,9 +7,12 @@ module Decidim
7
7
  # find the results.
8
8
  class ResultSearch < ResourceSearch
9
9
  # Public: Initializes the service.
10
- # feature - A Decidim::Feature to get the results from.
11
- # page - The page number to paginate the results.
12
- # per_page - The number of proposals to return per page.
10
+ #
11
+ # options - A hash of options to modify the search. These options will be
12
+ # converted to methods by SearchLight so they can be used on filter
13
+ # methods. (Default {})
14
+ # * feature - A Decidim::Feature to get the results from.
15
+ # * organization - A Decidim::Organization object.
13
16
  def initialize(options = {})
14
17
  super(Result.all, options)
15
18
  end
@@ -11,9 +11,7 @@ module Decidim
11
11
  @result = result
12
12
  end
13
13
 
14
- def proposals_count
15
- proposals.count
16
- end
14
+ delegate :count, to: :proposals, prefix: true
17
15
 
18
16
  def votes_count
19
17
  return 0 unless proposals
@@ -32,9 +30,7 @@ module Decidim
32
30
  meetings.where("contributions_count > 0").sum(:contributions_count)
33
31
  end
34
32
 
35
- def meetings_count
36
- meetings.count
37
- end
33
+ delegate :count, to: :meetings, prefix: true
38
34
 
39
35
  private
40
36