decidim-sortitions 0.18.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b50e775b1ca8007aad074d1b0cecf9e203f179daf9832f353909cd370e86a9d4
4
- data.tar.gz: 670acdc7e067b9e13b7c8d41c814fc640f966bdd850ae034ce26951dacc5f617
3
+ metadata.gz: 6b07ede6673cb3573653ce8dc00c008564ccea3fb6dc2f44108fb7978aa7286e
4
+ data.tar.gz: '02928a5f7d5b6bc4ed06bb25d402567fa7fce23fca3e30eaf9fc5bc94b94936e'
5
5
  SHA512:
6
- metadata.gz: 83dc42ebe1959ff8ad9c867d9def603ce6779aea8ed2af4790b89f8908cd3824e878a435f8b114e33d69e38573f26be49f98d678aa484257ac988e625f308041
7
- data.tar.gz: 8fdf97681c479cb4937021c67e73a23543728c38a3087e2244410ef00774201ac16bea70c9769fe4cb1d846b453ea4912f5613c22f913d0e6f7f02e764486d24
6
+ metadata.gz: 55992f82ad07b6671b8d7290ed81e0a906bd61d8d61b78e033b0102500179b589289ca27b5d1b519d0d078a753c3005f72ed5e446c464a98bc61f75df2bff680
7
+ data.tar.gz: acb31598de2b07bb4d4a100360802a46a0a07dac05d430288c18807113a5f1ec1a3604a642948af7ea7be04334eb050641a723fcb5e34aef5b9a8475181551da
@@ -28,11 +28,13 @@ module Decidim
28
28
 
29
29
  def badge_name
30
30
  return t("filters.cancelled", scope: "decidim.sortitions.sortitions") if model.cancelled?
31
+
31
32
  t("filters.active", scope: "decidim.sortitions.sortitions")
32
33
  end
33
34
 
34
35
  def state_classes
35
36
  return ["muted"] if model.cancelled?
37
+
36
38
  ["success"]
37
39
  end
38
40
 
@@ -23,7 +23,6 @@ module Decidim
23
23
 
24
24
  ActiveRecord::Base.transaction do
25
25
  sortition = create_sortition
26
- categorize(sortition) if form.decidim_category_id.present?
27
26
  select_proposals_for(sortition)
28
27
  send_notification(sortition)
29
28
 
@@ -49,15 +48,13 @@ module Decidim
49
48
  witnesses: form.witnesses,
50
49
  additional_info: form.additional_info,
51
50
  selected_proposals: [],
52
- candidate_proposals: []
51
+ candidate_proposals: [],
52
+ category: category
53
53
  )
54
54
  end
55
55
 
56
- def categorize(sortition)
57
- Decidim::Categorization.create!(
58
- decidim_category_id: form.decidim_category_id,
59
- categorizable: sortition
60
- )
56
+ def category
57
+ Decidim::Category.find(form.decidim_category_id) if form.decidim_category_id.present?
61
58
  end
62
59
 
63
60
  def select_proposals_for(sortition)
@@ -20,6 +20,7 @@ module Decidim
20
20
  # Returns nothing.
21
21
  def call
22
22
  return broadcast(:invalid) if form.invalid?
23
+
23
24
  destroy_sortition
24
25
  broadcast(:ok, sortition)
25
26
  end
@@ -9,15 +9,10 @@ module Decidim
9
9
  extend ActiveSupport::Concern
10
10
 
11
11
  included do
12
- helper_method :order, :available_orders, :random_seed
12
+ include Decidim::Orderable
13
13
 
14
14
  private
15
15
 
16
- # Gets how the proposals should be ordered based on the choice made by the user.
17
- def order
18
- @order ||= detect_order(params[:order]) || default_order
19
- end
20
-
21
16
  # Available orders based on enabled settings
22
17
  def available_orders
23
18
  %w(random recent)
@@ -27,15 +22,6 @@ module Decidim
27
22
  "recent"
28
23
  end
29
24
 
30
- # Returns: A random float number between -1 and 1 to be used as a random seed at the database.
31
- def random_seed
32
- @random_seed ||= (params[:random_seed] ? params[:random_seed].to_f : (rand * 2 - 1))
33
- end
34
-
35
- def detect_order(candidate)
36
- available_orders.detect { |order| order == candidate }
37
- end
38
-
39
25
  def reorder(sortitions)
40
26
  case order
41
27
  when "random"
@@ -6,7 +6,7 @@ module Decidim
6
6
  class SortitionsController < Decidim::Sortitions::ApplicationController
7
7
  helper Decidim::WidgetUrlsHelper
8
8
  include FilterResource
9
- include Orderable
9
+ include Decidim::Sortitions::Orderable
10
10
  include Paginable
11
11
 
12
12
  helper_method :sortition
@@ -12,6 +12,7 @@ module Decidim
12
12
  include Decidim::Traceable
13
13
  include Decidim::Loggable
14
14
  include Decidim::Comments::Commentable
15
+ include Decidim::Randomable
15
16
 
16
17
  component_manifest_name "sortitions"
17
18
 
@@ -76,13 +77,6 @@ module Decidim
76
77
  true
77
78
  end
78
79
 
79
- def self.order_randomly(seed)
80
- transaction do
81
- connection.execute("SELECT setseed(#{connection.quote(seed)})")
82
- order(Arel.sql("RANDOM()")).load
83
- end
84
- end
85
-
86
80
  # Public: Whether the object can have new comments or not.
87
81
  def user_allowed_to_comment?(user)
88
82
  can_participate_in_space?(user)
@@ -11,4 +11,4 @@
11
11
  <div class="row small-up-1 medium-up-2 card-grid">
12
12
  <%= render @sortitions %>
13
13
  </div>
14
- <%= decidim_paginate @sortitions, random_seed: random_seed %>
14
+ <%= decidim_paginate @sortitions %>
@@ -101,7 +101,7 @@
101
101
  </div>
102
102
 
103
103
  <div class="sortition-details-item">
104
- <span class="sortition-details-title sortition-details-text"><%= t ".algorithm" %></span><br />
104
+ <span class="sortition-details-title sortition-details-text"><%= t ".algorithm" %></span><br>
105
105
  <span class=sortition-details-text>
106
106
  <%= link_to Decidim::Sortitions.sortition_algorithm,
107
107
  Decidim::Sortitions.sortition_algorithm,
@@ -129,6 +129,3 @@
129
129
  </div>
130
130
 
131
131
  <%= comments_for sortition %>
132
-
133
- <%= javascript_include_tag "decidim/sortitions/social_share" %>
134
- <%= stylesheet_link_tag "decidim/sortitions/social_share" %>
@@ -147,5 +147,5 @@ nl:
147
147
  deleted: Verwijderde gebruiker
148
148
  sortitions_count:
149
149
  count:
150
- one: 1 sortering
150
+ one: 1 loting
151
151
  other: "%{count} lotingen"
@@ -18,10 +18,6 @@ module Decidim
18
18
  root to: "sortitions#index"
19
19
  end
20
20
 
21
- initializer "decidim_sorititions.assets" do |app|
22
- app.config.assets.precompile += %w(decidim_sortitions_manifest.js decidim_sortitions_manifest.css)
23
- end
24
-
25
21
  initializer "decidim_sortitions.add_cells_view_paths" do
26
22
  Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Sortitions::Engine.root}/app/cells")
27
23
  Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Sortitions::Engine.root}/app/views") # for proposal partials
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Sortitions
5
5
  def self.version
6
- "0.18.1"
6
+ "0.19.0"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-sortitions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Salvador Perez Garcia
@@ -16,84 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.18.1
19
+ version: 0.19.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.18.1
26
+ version: 0.19.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: decidim-comments
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.18.1
33
+ version: 0.19.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.18.1
40
+ version: 0.19.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: decidim-core
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.18.1
47
+ version: 0.19.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.18.1
54
+ version: 0.19.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: decidim-proposals
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.18.1
61
+ version: 0.19.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.18.1
69
- - !ruby/object:Gem::Dependency
70
- name: social-share-button
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.0'
68
+ version: 0.19.0
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: decidim-dev
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - '='
88
74
  - !ruby/object:Gem::Version
89
- version: 0.18.1
75
+ version: 0.19.0
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - '='
95
81
  - !ruby/object:Gem::Version
96
- version: 0.18.1
82
+ version: 0.19.0
97
83
  description: This module makes possible to select amont a set of proposal by sortition
98
84
  email:
99
85
  - jsperezg@gmail.com
@@ -103,13 +89,9 @@ extra_rdoc_files: []
103
89
  files:
104
90
  - README.md
105
91
  - Rakefile
106
- - app/assets/config/decidim_sortitions_manifest.css
107
- - app/assets/config/decidim_sortitions_manifest.js
108
92
  - app/assets/images/decidim/sortitions/icon.svg
109
93
  - app/assets/javascripts/decidim/sortitions/admin/sortitions.js
110
- - app/assets/javascripts/decidim/sortitions/social_share.js
111
94
  - app/assets/stylesheets/decidim/sortitions/_sortitions.scss
112
- - app/assets/stylesheets/decidim/sortitions/social_share.css.scss
113
95
  - app/cells/decidim/sortitions/sortition_cell.rb
114
96
  - app/cells/decidim/sortitions/sortition_m/data.erb
115
97
  - app/cells/decidim/sortitions/sortition_m/footer.erb
@@ -162,7 +144,6 @@ files:
162
144
  - app/views/decidim/sortitions/sortitions/index.html.erb
163
145
  - app/views/decidim/sortitions/sortitions/index.js.erb
164
146
  - app/views/decidim/sortitions/sortitions/show.html.erb
165
- - config/initializers/social_share_button.rb
166
147
  - config/locales/ar-SA.yml
167
148
  - config/locales/ar.yml
168
149
  - config/locales/ca.yml
@@ -1 +0,0 @@
1
- /* = link decidim/sortitions/social_share.css.scss */
@@ -1 +0,0 @@
1
- //= link decidim/sortitions/social_share.js
@@ -1,2 +0,0 @@
1
- // = require social-share-button
2
- // = require_self
@@ -1,22 +0,0 @@
1
- /*
2
- *= require social-share-button
3
- */
4
-
5
- $size: 45px;
6
-
7
- .share-link:hover{
8
- text-decoration: underline;
9
- cursor: pointer;
10
- }
11
-
12
- .social-share-button{
13
- display: inline-block;
14
- vertical-align: top;
15
-
16
- .ssb-icon{
17
- margin-right: 5px;
18
- background-size: $size $size;
19
- height: $size;
20
- width: $size;
21
- }
22
- }
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- SocialShareButton.configure do |config|
4
- config.allow_sites = %w(twitter facebook google_plus)
5
- end