decidim-sortitions 0.9.0 → 0.11.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -8
  3. data/app/assets/config/decidim_sortitions_manifest.css +1 -1
  4. data/app/assets/stylesheets/decidim/sortitions/_sortitions.scss +13 -9
  5. data/app/assets/stylesheets/decidim/sortitions/social_share.css.scss +8 -4
  6. data/app/commands/decidim/sortitions/admin/create_sortition.rb +5 -3
  7. data/app/commands/decidim/sortitions/admin/destroy_sortition.rb +11 -5
  8. data/app/commands/decidim/sortitions/admin/update_sortition.rb +3 -1
  9. data/app/controllers/decidim/sortitions/admin/application_controller.rb +3 -3
  10. data/app/controllers/decidim/sortitions/admin/sortitions_controller.rb +3 -3
  11. data/app/controllers/decidim/sortitions/application_controller.rb +2 -2
  12. data/app/controllers/decidim/sortitions/sortition_widgets_controller.rb +1 -1
  13. data/app/forms/decidim/sortitions/admin/destroy_sortition_form.rb +1 -1
  14. data/app/forms/decidim/sortitions/admin/edit_sortition_form.rb +1 -1
  15. data/app/forms/decidim/sortitions/admin/sortition_form.rb +3 -3
  16. data/app/helpers/decidim/sortitions/admin/sortitions_helper.rb +3 -3
  17. data/app/helpers/decidim/sortitions/sortitions_helper.rb +1 -1
  18. data/app/models/decidim/sortitions/sortition.rb +14 -8
  19. data/app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb +50 -0
  20. data/app/queries/decidim/sortitions/admin/{participatory_space_proposal_features.rb → participatory_space_proposal_components.rb} +4 -4
  21. data/app/queries/decidim/sortitions/admin/participatory_space_proposals.rb +2 -2
  22. data/app/queries/decidim/sortitions/filtered_sortitions.rb +9 -9
  23. data/app/services/decidim/sortitions/sortition_search.rb +1 -1
  24. data/app/views/decidim/sortitions/admin/sortitions/_form.html.erb +3 -3
  25. data/app/views/decidim/sortitions/admin/sortitions/index.html.erb +2 -2
  26. data/app/views/decidim/sortitions/admin/sortitions/new.html.erb +1 -1
  27. data/app/views/decidim/sortitions/admin/sortitions/show.html.erb +4 -4
  28. data/app/views/decidim/sortitions/sortition_widgets/show.html.erb +1 -1
  29. data/app/views/decidim/sortitions/sortitions/_filters.html.erb +6 -6
  30. data/app/views/decidim/sortitions/sortitions/_filters_small_view.html.erb +1 -1
  31. data/app/views/decidim/sortitions/sortitions/_proposal.html.erb +1 -1
  32. data/app/views/decidim/sortitions/sortitions/_results_count.html.erb +1 -1
  33. data/app/views/decidim/sortitions/sortitions/_sortition.html.erb +4 -4
  34. data/app/views/decidim/sortitions/sortitions/_sortition_author.html.erb +1 -1
  35. data/app/views/decidim/sortitions/sortitions/_sortition_cancel_author.html.erb +1 -1
  36. data/app/views/decidim/sortitions/sortitions/_tags.html.erb +1 -1
  37. data/app/views/decidim/sortitions/sortitions/index.html.erb +1 -1
  38. data/app/views/decidim/sortitions/sortitions/show.html.erb +12 -12
  39. data/config/locales/ca.yml +99 -109
  40. data/config/locales/en.yml +90 -94
  41. data/config/locales/es.yml +97 -107
  42. data/config/locales/eu.yml +145 -0
  43. data/config/locales/fi.yml +145 -0
  44. data/config/locales/fr.yml +145 -0
  45. data/config/locales/gl.yml +145 -0
  46. data/config/locales/it.yml +145 -0
  47. data/config/locales/nl.yml +145 -0
  48. data/config/locales/pl.yml +155 -0
  49. data/config/locales/pt-BR.yml +145 -0
  50. data/config/locales/pt.yml +145 -0
  51. data/config/locales/ru.yml +13 -0
  52. data/config/locales/sv.yml +145 -0
  53. data/config/locales/uk.yml +13 -0
  54. data/db/migrate/20180322082150_fix_sortitions_feature.rb +11 -0
  55. data/db/migrate/20180322085145_fix_sortitions_proposal_feature.rb +11 -0
  56. data/lib/decidim/sortitions.rb +1 -1
  57. data/lib/decidim/sortitions/component.rb +38 -0
  58. data/lib/decidim/sortitions/test/factories.rb +7 -7
  59. data/lib/decidim/sortitions/version.rb +3 -1
  60. metadata +46 -33
  61. data/LICENSE-AGPLv3.txt +0 -661
  62. data/app/views/decidim/sortitions/sortitions/_filters_small_view0.html.erb +0 -18
  63. data/lib/decidim/sortitions/feature.rb +0 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0201c8215bdeaa94eb0432c3d45c2c7aba8e14cf97d6c4c95828b95b67174b8a
4
- data.tar.gz: f404e63fccf8f883a2e4fef1bde10f0a2361e86b7602c0390f848bc33fbea0e4
3
+ metadata.gz: 24db428f20272b36ec8566a34250338db326a1031dd8e0d221a70ab549e9699a
4
+ data.tar.gz: 826a675e56d01daec292af92d75d5cc77d54f7bd84bf684aac7e489e22e5ba69
5
5
  SHA512:
6
- metadata.gz: ce85cd7cc7a571f14e912c9b317122bafbb215c74ee9d7ba6aeee8118b11434f37c83ff1f93bc7eeb96b169a26a847effc80451d9ec51cfc231608a69f669adb
7
- data.tar.gz: 5495ab01398af063aa02623e578c831359efa846a548458784631abe05f65fcf44d96065c29a8421656f1fed9d7b4f5fd1aed71950e2fa445ea13fd7780bfc43
6
+ metadata.gz: 2b5e4f34fccfe94473cf0af575d50f2e39e96ae384162af82293d95a1aed5d55754dc6c187ccc35f1bc2bd7db86a7b163cc1683457a53e9ef97110c936dd98fe
7
+ data.tar.gz: e721500c11fe706d9c755272bddfdf77602b682dfef72039fc7ee0eae1c347f1a874ff6666556757f306cafe9bc8310ddf4424ea22c5e7842f0ec7d98311525d
data/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # Decidim::Sortitions
2
- This module makes possible to select amont a set of proposal by sortition.
2
+
3
+ This module makes possible to select among a set of proposals by sortition.
3
4
 
4
5
  ## Usage
6
+
5
7
  Simply include it in your Decidim instance.
6
8
 
7
9
  ## Installation
10
+
8
11
  Add this line to your application's Gemfile:
9
12
 
10
13
  ```ruby
@@ -12,13 +15,9 @@ gem 'decidim-sortitions'
12
15
  ```
13
16
 
14
17
  And then execute:
15
- ```bash
16
- $ bundle
17
- ```
18
18
 
19
- Or install it yourself as:
20
19
  ```bash
21
- $ gem install decidim-sortitions
20
+ bundle
22
21
  ```
23
22
 
24
23
  ## Import migrations
@@ -26,6 +25,14 @@ $ gem install decidim-sortitions
26
25
  After installing the gem you must import and execute the migrations bundled with the gem:
27
26
 
28
27
  ```bash
29
- $ bundle exec rails decidim_sortitions:install:migrations
30
- $ bundle exec rails db:migrate
28
+ bundle exec rails decidim_sortitions:install:migrations
29
+ bundle exec rails db:migrate
31
30
  ```
31
+
32
+ ## Contributing
33
+
34
+ See [Decidim](https://github.com/decidim/decidim).
35
+
36
+ ## License
37
+
38
+ See [Decidim](https://github.com/decidim/decidim).
@@ -1 +1 @@
1
- /*= link decidim/sortitions/social_share.css.scss */
1
+ /* = link decidim/sortitions/social_share.css.scss */
@@ -1,41 +1,45 @@
1
- #sortition-details {
1
+ #sortition-details{
2
2
  margin-bottom: 1.5rem;
3
3
  }
4
4
 
5
- .sortition-details {
5
+ .sortition-details{
6
6
  padding: 0;
7
7
  display: flex;
8
- flex-direction: row;
9
- flex-wrap: wrap;
8
+ flex-flow: row wrap;
10
9
  justify-content: flex-start;
11
10
  align-items: stretch;
12
11
  align-content: stretch;
13
12
 
14
- .sortition-details-item {
13
+ .sortition-details-item{
15
14
  width: 33.3%;
15
+
16
16
  @include breakpoint(large down){
17
17
  width: 33.3%;
18
18
  }
19
+
19
20
  @include breakpoint(medium down){
20
21
  width: 49.9%;
21
22
  }
23
+
22
24
  @include breakpoint(smallmedium down){
23
25
  width: 100%;
24
26
  }
27
+
25
28
  display: inline-block;
26
29
  padding: 1em;
27
30
  border: $border;
28
31
  background: $white;
29
- .sortition-details-title {
30
- margin-right: 0.5rem;
32
+
33
+ .sortition-details-title{
34
+ margin-right: .5rem;
31
35
  font-weight: bolder;
32
36
  }
33
37
 
34
38
  .sortition-details-text{
35
39
  text-transform: uppercase;
36
- letter-spacing: 0.03em;
40
+ letter-spacing: .03em;
37
41
  font-size: 90%;
38
- color: #3D393C;
42
+ color: #3d393c;
39
43
  font-weight: 600;
40
44
  line-height: 1;
41
45
  vertical-align: middle;
@@ -1,15 +1,19 @@
1
- /*= require social-share-button */
1
+ /*
2
+ *= require social-share-button
3
+ */
4
+
2
5
  $size: 45px;
3
6
 
4
- .share-link:hover {
7
+ .share-link:hover{
5
8
  text-decoration: underline;
6
9
  cursor: pointer;
7
10
  }
8
11
 
9
- .social-share-button {
12
+ .social-share-button{
10
13
  display: inline-block;
11
14
  vertical-align: top;
12
- .ssb-icon {
15
+
16
+ .ssb-icon{
13
17
  margin-right: 5px;
14
18
  background-size: $size $size;
15
19
  height: $size;
@@ -36,10 +36,12 @@ module Decidim
36
36
  attr_reader :form
37
37
 
38
38
  def create_sortition
39
- Sortition.create!(
40
- feature: form.current_feature,
39
+ Decidim.traceability.create!(
40
+ Sortition,
41
+ form.current_user,
42
+ component: form.current_component,
41
43
  title: form.title,
42
- decidim_proposals_feature_id: form.decidim_proposals_feature_id,
44
+ decidim_proposals_component_id: form.decidim_proposals_component_id,
43
45
  request_timestamp: Time.now.utc,
44
46
  author: form.current_user,
45
47
  dice: form.dice,
@@ -29,11 +29,17 @@ module Decidim
29
29
  attr_reader :form
30
30
 
31
31
  def destroy_sortition
32
- sortition.update(
33
- cancel_reason: form.cancel_reason,
34
- cancelled_on: Time.now.utc,
35
- cancelled_by_user: form.current_user
36
- )
32
+ Decidim.traceability.perform_action!(
33
+ :delete,
34
+ sortition,
35
+ form.current_user
36
+ ) do
37
+ sortition.update(
38
+ cancel_reason: form.cancel_reason,
39
+ cancelled_on: Time.now.utc,
40
+ cancelled_by_user: form.current_user
41
+ )
42
+ end
37
43
  end
38
44
 
39
45
  def sortition
@@ -30,7 +30,9 @@ module Decidim
30
30
  attr_reader :form
31
31
 
32
32
  def update_sortition
33
- sortition.update(
33
+ Decidim.traceability.update!(
34
+ sortition,
35
+ form.current_user,
34
36
  title: form.title,
35
37
  additional_info: form.additional_info
36
38
  )
@@ -6,14 +6,14 @@ module Decidim
6
6
  # This controller is the abstract class from which all other controllers of
7
7
  # this engine inherit.
8
8
  #
9
- # Note that it inherits from `Decidim::Features::BaseController`, which
9
+ # Note that it inherits from `Decidim::Components::BaseController`, which
10
10
  # override its layout and provide all kinds of useful methods.
11
- class ApplicationController < Decidim::Admin::Features::BaseController
11
+ class ApplicationController < Decidim::Admin::Components::BaseController
12
12
  helper_method :sortitions, :sortition
13
13
 
14
14
  def sortitions
15
15
  @sortitions ||= Decidim::Sortitions::FilteredSortitions
16
- .for(current_feature)
16
+ .for(current_component)
17
17
  .order(created_at: :desc)
18
18
  .page(params[:page])
19
19
  .per(Decidim::Sortitions.items_per_page)
@@ -6,7 +6,7 @@ module Decidim
6
6
  # Controller responsible of the sortition that selects proposals from
7
7
  # a participatory space.
8
8
  class SortitionsController < Admin::ApplicationController
9
- helper_method :proposal_features
9
+ helper_method :proposal_components
10
10
 
11
11
  def index; end
12
12
 
@@ -91,8 +91,8 @@ module Decidim
91
91
  form(DestroySortitionForm)
92
92
  end
93
93
 
94
- def proposal_features
95
- ParticipatorySpaceProposalFeatures.for(current_participatory_space)
94
+ def proposal_components
95
+ ParticipatorySpaceProposalComponents.for(current_participatory_space)
96
96
  end
97
97
 
98
98
  def ability_context
@@ -5,9 +5,9 @@ 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::Features::BaseController`, which
8
+ # Note that it inherits from `Decidim::Components::BaseController`, which
9
9
  # override its layout and provide all kinds of useful methods.
10
- class ApplicationController < Decidim::Features::BaseController
10
+ class ApplicationController < Decidim::Components::BaseController
11
11
  end
12
12
  end
13
13
  end
@@ -9,7 +9,7 @@ module Decidim
9
9
  private
10
10
 
11
11
  def model
12
- @model ||= Sortition.where(feature: params[:feature_id]).find(params[:sortition_id])
12
+ @model ||= Sortition.where(component: params[:component_id]).find(params[:sortition_id])
13
13
  end
14
14
 
15
15
  def iframe_url
@@ -13,7 +13,7 @@ module Decidim
13
13
  validates :cancel_reason, translatable_presence: true
14
14
 
15
15
  delegate :current_participatory_space, to: :context
16
- delegate :current_feature, to: :context
16
+ delegate :current_component, to: :context
17
17
  end
18
18
  end
19
19
  end
@@ -15,7 +15,7 @@ module Decidim
15
15
  validates :additional_info, translatable_presence: true
16
16
 
17
17
  delegate :current_participatory_space, to: :context
18
- delegate :current_feature, to: :context
18
+ delegate :current_component, to: :context
19
19
  end
20
20
  end
21
21
  end
@@ -9,7 +9,7 @@ module Decidim
9
9
  mimic :sortition
10
10
 
11
11
  translatable_attribute :title, String
12
- attribute :decidim_proposals_feature_id, Integer
12
+ attribute :decidim_proposals_component_id, Integer
13
13
  attribute :decidim_category_id, Integer
14
14
  attribute :dice, Integer
15
15
  attribute :target_items, Integer
@@ -17,7 +17,7 @@ module Decidim
17
17
  translatable_attribute :additional_info, String
18
18
 
19
19
  validates :title, translatable_presence: true
20
- validates :decidim_proposals_feature_id, presence: true
20
+ validates :decidim_proposals_component_id, presence: true
21
21
  validates :witnesses, translatable_presence: true
22
22
  validates :additional_info, translatable_presence: true
23
23
  validates :dice,
@@ -37,7 +37,7 @@ module Decidim
37
37
 
38
38
  delegate :categories, to: :current_participatory_space
39
39
  delegate :current_participatory_space, to: :context
40
- delegate :current_feature, to: :context
40
+ delegate :current_component, to: :context
41
41
  end
42
42
  end
43
43
  end
@@ -6,9 +6,9 @@ module Decidim
6
6
  module SortitionsHelper
7
7
  include Decidim::TranslationsHelper
8
8
 
9
- # Converst a list of features into a list of selectable options
10
- def features_options(features)
11
- features.map do |f|
9
+ # Converst a list of components into a list of selectable options
10
+ def components_options(components)
11
+ components.map do |f|
12
12
  [translated_attribute(f.name), f.id]
13
13
  end
14
14
  end
@@ -6,7 +6,7 @@ module Decidim
6
6
  include Decidim::TranslationsHelper
7
7
 
8
8
  def proposal_path(proposal)
9
- EngineRouter.main_proxy(proposal.feature).proposal_path(proposal)
9
+ EngineRouter.main_proxy(proposal.component).proposal_path(proposal)
10
10
  end
11
11
 
12
12
  # Generates the sortition category label
@@ -7,15 +7,17 @@ module Decidim
7
7
  include Decidim::Resourceable
8
8
  include Decidim::HasCategory
9
9
  include Decidim::Authorable
10
- include Decidim::HasFeature
10
+ include Decidim::HasComponent
11
11
  include Decidim::HasReference
12
+ include Decidim::Traceable
13
+ include Decidim::Loggable
12
14
  include Decidim::Comments::Commentable
13
15
 
14
- feature_manifest_name "sortitions"
16
+ component_manifest_name "sortitions"
15
17
 
16
- belongs_to :decidim_proposals_feature,
17
- foreign_key: "decidim_proposals_feature_id",
18
- class_name: "Decidim::Feature"
18
+ belongs_to :decidim_proposals_component,
19
+ foreign_key: "decidim_proposals_component_id",
20
+ class_name: "Decidim::Component"
19
21
 
20
22
  belongs_to :cancelled_by_user,
21
23
  foreign_key: "cancelled_by_user_id",
@@ -30,13 +32,17 @@ module Decidim
30
32
  scope :active, -> { where(cancelled_on: nil) }
31
33
  scope :cancelled, -> { where.not(cancelled_on: nil) }
32
34
 
35
+ def self.log_presenter_class_for(_log)
36
+ Decidim::Sortitions::AdminLog::SortitionPresenter
37
+ end
38
+
33
39
  def proposals
34
40
  Decidim::Proposals::Proposal.where(id: selected_proposals)
35
41
  end
36
42
 
37
43
  def similar_count
38
- Sortition.where(feature: feature)
39
- .where(decidim_proposals_feature: decidim_proposals_feature)
44
+ Sortition.where(component: component)
45
+ .where(decidim_proposals_component: decidim_proposals_component)
40
46
  .categorized_as(category&.id)
41
47
  .where(target_items: target_items)
42
48
  .count
@@ -52,7 +58,7 @@ module Decidim
52
58
 
53
59
  # Public: Overrides the `commentable?` Commentable concern method.
54
60
  def commentable?
55
- feature.settings.comments_enabled?
61
+ component.settings.comments_enabled?
56
62
  end
57
63
 
58
64
  # Public: Overrides the `accepts_new_comments?` Commentable concern method.
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Sortitions
5
+ module AdminLog
6
+ # This class holds the logic to present a `Decidim::Sortitions::Sortition`
7
+ # for the `AdminLog` log.
8
+ #
9
+ # Usage should be automatic and you shouldn't need to call this class
10
+ # directly, but here's an example:
11
+ #
12
+ # action_log = Decidim::ActionLog.last
13
+ # view_helpers # => this comes from the views
14
+ # SortitionPresenter.new(action_log, view_helpers).present
15
+ class SortitionPresenter < Decidim::Log::BasePresenter
16
+ private
17
+
18
+ def action_string
19
+ case action
20
+ when "create", "delete", "update"
21
+ "decidim.sortitions.admin_log.sortition.#{action}"
22
+ else
23
+ super
24
+ end
25
+ end
26
+
27
+ def diff_fields_mapping
28
+ {
29
+ cancel_reason: :i18n,
30
+ dice: :integer,
31
+ request_timestamp: :date,
32
+ witnesses: :i18n,
33
+ additional_info: :i18n,
34
+ title: :i18n,
35
+ reference: :string,
36
+ decidim_proposals_component_id: :component
37
+ }
38
+ end
39
+
40
+ def i18n_labels_scope
41
+ "activemodel.attributes.sortition"
42
+ end
43
+
44
+ def has_diff?
45
+ action == "delete" || super
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -3,11 +3,11 @@
3
3
  module Decidim
4
4
  module Sortitions
5
5
  module Admin
6
- # Query that retrieves a list of proposal features
7
- class ParticipatorySpaceProposalFeatures < Rectify::Query
6
+ # Query that retrieves a list of proposal components
7
+ class ParticipatorySpaceProposalComponents < Rectify::Query
8
8
  attr_reader :participatory_space
9
9
 
10
- # Sugar syntax. Allow retrieving all proposal features for the
10
+ # Sugar syntax. Allow retrieving all proposal components for the
11
11
  # given participatory space.
12
12
  def self.for(participatory_space)
13
13
  new(participatory_space).query
@@ -19,7 +19,7 @@ module Decidim
19
19
  end
20
20
 
21
21
  def query
22
- Feature
22
+ Component
23
23
  .where(participatory_space: participatory_space, manifest_name: "proposals")
24
24
  .published
25
25
  end