decidim-proposals 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/decidim/proposals/icon.svg +1 -1
  3. data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +2 -0
  4. data/app/commands/decidim/proposals/admin/create_proposal.rb +44 -3
  5. data/app/commands/decidim/proposals/create_proposal.rb +43 -2
  6. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +3 -1
  7. data/app/controllers/decidim/proposals/proposals_controller.rb +3 -1
  8. data/app/forms/decidim/proposals/admin/proposal_form.rb +2 -1
  9. data/app/forms/decidim/proposals/proposal_form.rb +2 -1
  10. data/app/models/decidim/proposals/proposal.rb +1 -0
  11. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +19 -2
  12. data/app/views/decidim/proposals/admin/proposals/index.html.erb +12 -8
  13. data/app/views/decidim/proposals/proposals/_filters.html.erb +2 -2
  14. data/app/views/decidim/proposals/proposals/_filters_small_view.html.erb +1 -1
  15. data/app/views/decidim/proposals/proposals/_proposal.html.erb +1 -1
  16. data/app/views/decidim/proposals/proposals/index.html.erb +2 -0
  17. data/app/views/decidim/proposals/proposals/index.js.erb +1 -1
  18. data/app/views/decidim/proposals/proposals/new.html.erb +22 -2
  19. data/app/views/decidim/proposals/proposals/show.html.erb +2 -1
  20. data/config/i18n-tasks.yml +1 -1
  21. data/config/locales/ca.yml +2 -1
  22. data/config/locales/en.yml +7 -0
  23. data/config/locales/es.yml +2 -1
  24. data/config/locales/eu.yml +1 -1
  25. data/config/locales/fi.yml +1 -1
  26. data/config/locales/fr.yml +1 -1
  27. data/config/locales/it.yml +1 -1
  28. data/config/locales/nl.yml +1 -1
  29. data/config/locales/pl.yml +5 -0
  30. data/lib/decidim/proposals/feature.rb +13 -3
  31. data/lib/decidim/proposals/test/factories.rb +8 -0
  32. metadata +17 -17
  33. data/app/views/decidim/proposals/proposals/_tags.html.erb +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f5ede39ced3c1e0de38bf979f3a1ef578c6a88d
4
- data.tar.gz: 70f31bf53bdcf9808b17924a7873c8a1ba73d913
3
+ metadata.gz: 5e46ca0aaa9b501474fe72bbbfefa15288155832
4
+ data.tar.gz: 076163c0d2fe44654b06cb85309627af691ab243
5
5
  SHA512:
6
- metadata.gz: 40a1c20970581db8bf5849b7e1080b1951bb03edc5a8b1c9a2c2cea9b4668563b806645d69788cfd28f678064a461a3affec496a719678ba733b09c65b6e5d18
7
- data.tar.gz: 6f6078e4b9a93ed927f510291aaeb84d0543e0b2272232e253785dcc243e48f9aee61c76268128a0fb12606710f89f8a0b95fa26e525ba9e1c7fbb423408769a
6
+ metadata.gz: 62ace44ca224fcaff3920ff0e68945d3998fb453b989a4158ed7f1a29a85b9953d7b4f6f13be0b3345c7a26cddef1db49929dda0c004d642400bf101f65cad27
7
+ data.tar.gz: 5e2ba3f6ff312ad90c236867e258db1463c7806ea155b9444171851f1979861650de2d2b773d8f45e5468c925c9dcc39f6873d5e1152cd9d11f2539f9ce6adc7
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35 35"><path d="M17.5 35A17.5 17.5 0 1 1 35 17.5 17.52 17.52 0 0 1 17.5 35zm0-33.06A15.56 15.56 0 1 0 33.06 17.5 15.57 15.57 0 0 0 17.5 1.94zm9.5 13.7H8a1 1 0 0 1 0-1.94h19a1 1 0 0 1 0 1.94zm0 3.68H8a1 1 0 0 1 0-1.94h19a1 1 0 0 1 0 1.94zM22.26 23H8a1 1 0 0 1 0-1.94h14.26a1 1 0 0 1 0 1.94z"/></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35 35"><path d="M17.5 35A17.5 17.5 0 1 1 35 17.5 17.52 17.52 0 0 1 17.5 35zm0-33.06A15.56 15.56 0 1 0 33.06 17.5 15.57 15.57 0 0 0 17.5 1.94zm9.5 13.7H8a1 1 0 0 1 0-1.94h19a1 1 0 0 1 0 1.94zm0 3.68H8a1 1 0 0 1 0-1.94h19a1 1 0 0 1 0 1.94zM22.26 23H8a1 1 0 0 1 0-1.94h14.26a1 1 0 0 1 0 1.94z"/></svg>
@@ -16,6 +16,8 @@ $(() => {
16
16
  toggleInput();
17
17
  $checkbox.on('change', toggleInput);
18
18
  }
19
+
20
+ new window.Decidim.Select2Field($('#proposal_scope_id')); // eslint-disable-line no-new
19
21
  };
20
22
 
21
23
  window.DecidimProposals.bindProposalAddress();
@@ -21,13 +21,22 @@ module Decidim
21
21
  def call
22
22
  return broadcast(:invalid) if form.invalid?
23
23
 
24
- create_proposal
25
- broadcast(:ok)
24
+ if process_attachments?
25
+ build_attachment
26
+ return broadcast(:invalid) if attachment_invalid?
27
+ end
28
+
29
+ transaction do
30
+ create_proposal
31
+ create_attachment if process_attachments?
32
+ end
33
+
34
+ broadcast(:ok, proposal)
26
35
  end
27
36
 
28
37
  private
29
38
 
30
- attr_reader :form, :proposal
39
+ attr_reader :form, :proposal, :attachment
31
40
 
32
41
  def create_proposal
33
42
  @proposal = Proposal.create!(
@@ -41,6 +50,38 @@ module Decidim
41
50
  longitude: form.longitude
42
51
  )
43
52
  end
53
+
54
+ def build_attachment
55
+ @attachment = Attachment.new(
56
+ title: form.attachment.title,
57
+ file: form.attachment.file,
58
+ attached_to: @proposal
59
+ )
60
+ end
61
+
62
+ def attachment_invalid?
63
+ if attachment.invalid? && attachment.errors.has_key?(:file)
64
+ form.attachment.errors.add :file, attachment.errors[:file]
65
+ true
66
+ end
67
+ end
68
+
69
+ def attachment_present?
70
+ form.attachment.file.present?
71
+ end
72
+
73
+ def create_attachment
74
+ attachment.attached_to = proposal
75
+ attachment.save!
76
+ end
77
+
78
+ def attachments_allowed?
79
+ form.current_feature.settings.attachments_allowed?
80
+ end
81
+
82
+ def process_attachments?
83
+ attachments_allowed? && attachment_present?
84
+ end
44
85
  end
45
86
  end
46
87
  end
@@ -22,13 +22,22 @@ module Decidim
22
22
  def call
23
23
  return broadcast(:invalid) if form.invalid?
24
24
 
25
- create_proposal
25
+ if process_attachments?
26
+ build_attachment
27
+ return broadcast(:invalid) if attachment_invalid?
28
+ end
29
+
30
+ transaction do
31
+ create_proposal
32
+ create_attachment if process_attachments?
33
+ end
34
+
26
35
  broadcast(:ok, proposal)
27
36
  end
28
37
 
29
38
  private
30
39
 
31
- attr_reader :form, :proposal
40
+ attr_reader :form, :proposal, :attachment
32
41
 
33
42
  def create_proposal
34
43
  @proposal = Proposal.create!(
@@ -44,6 +53,38 @@ module Decidim
44
53
  longitude: form.longitude
45
54
  )
46
55
  end
56
+
57
+ def build_attachment
58
+ @attachment = Attachment.new(
59
+ title: form.attachment.title,
60
+ file: form.attachment.file,
61
+ attached_to: @proposal
62
+ )
63
+ end
64
+
65
+ def attachment_invalid?
66
+ if attachment.invalid? && attachment.errors.has_key?(:file)
67
+ form.attachment.errors.add :file, attachment.errors[:file]
68
+ true
69
+ end
70
+ end
71
+
72
+ def attachment_present?
73
+ form.attachment.file.present?
74
+ end
75
+
76
+ def create_attachment
77
+ attachment.attached_to = proposal
78
+ attachment.save!
79
+ end
80
+
81
+ def attachments_allowed?
82
+ form.current_feature.settings.attachments_allowed?
83
+ end
84
+
85
+ def process_attachments?
86
+ attachments_allowed? && attachment_present?
87
+ end
47
88
  end
48
89
  end
49
90
  end
@@ -10,7 +10,9 @@ module Decidim
10
10
 
11
11
  def new
12
12
  authorize! :create, Proposal
13
- @form = form(Admin::ProposalForm).from_params({})
13
+ @form = form(Admin::ProposalForm).from_params(
14
+ attachment: form(AttachmentForm).from_params({})
15
+ )
14
16
  end
15
17
 
16
18
  def create
@@ -43,7 +43,9 @@ module Decidim
43
43
  def new
44
44
  authorize! :create, Proposal
45
45
 
46
- @form = form(ProposalForm).from_params({})
46
+ @form = form(ProposalForm).from_params(
47
+ attachment: form(AttachmentForm).from_params({})
48
+ )
47
49
  end
48
50
 
49
51
  def create
@@ -14,6 +14,7 @@ module Decidim
14
14
  attribute :longitude, Float
15
15
  attribute :category_id, Integer
16
16
  attribute :scope_id, Integer
17
+ attribute :attachment, AttachmentForm
17
18
 
18
19
  validates :title, :body, presence: true
19
20
  validates :address, geocoding: true, if: -> { current_feature.settings.geocoding_enabled? }
@@ -49,7 +50,7 @@ module Decidim
49
50
  #
50
51
  # Returns a Decidim::Scope
51
52
  def scope
52
- @scope ||= process_scope || organization_scopes.where(id: scope_id).first
53
+ @scope ||= organization_scopes.where(id: scope_id).first || process_scope
53
54
  end
54
55
  end
55
56
  end
@@ -15,6 +15,7 @@ module Decidim
15
15
  attribute :scope_id, Integer
16
16
  attribute :user_group_id, Integer
17
17
  attribute :has_address, Boolean
18
+ attribute :attachment, AttachmentForm
18
19
 
19
20
  validates :title, :body, presence: true, etiquette: true
20
21
  validates :title, length: { maximum: 150 }
@@ -53,7 +54,7 @@ module Decidim
53
54
  #
54
55
  # Returns a Decidim::Scope
55
56
  def scope
56
- @scope ||= process_scope || organization_scopes.where(id: scope_id).first
57
+ @scope ||= organization_scopes.where(id: scope_id).first || process_scope
57
58
  end
58
59
 
59
60
  def has_address?
@@ -11,6 +11,7 @@ module Decidim
11
11
  include Decidim::HasReference
12
12
  include Decidim::HasCategory
13
13
  include Decidim::Reportable
14
+ include Decidim::HasAttachments
14
15
  include Decidim::Comments::Commentable
15
16
 
16
17
  feature_manifest_name "proposals"
@@ -24,9 +24,26 @@
24
24
  </div>
25
25
  <% end %>
26
26
 
27
- <% if !@form.process_scope %>
27
+ <% if current_participatory_process.has_subscopes? %>
28
28
  <div class="row column">
29
- <%= form.collection_select :scope_id, organization_scopes, :id, :name %>
29
+ <%= form.scopes_select :scope_id, prompt: I18n.t("decidim.scopes.global"), remote_path: decidim.scopes_search_path(root: current_participatory_process.scope) %>
30
+ </div>
31
+ <% end %>
32
+
33
+ <% if feature_settings.attachments_allowed? %>
34
+ <div class="row column">
35
+ <fieldset>
36
+ <legend><%= t('.attachment_legend') %></legend>
37
+ <%= form.fields_for :attachment, @form.attachment do |form| %>
38
+ <div class="row column">
39
+ <%= form.text_field :title %>
40
+ </div>
41
+
42
+ <div class="row column">
43
+ <%= form.upload :file, optional: false %>
44
+ </div>
45
+ <% end %>
46
+ </fieldset>
30
47
  </div>
31
48
  <% end %>
32
49
  </div>
@@ -21,7 +21,9 @@
21
21
  <tr>
22
22
  <th><%= t("models.proposal.fields.title", scope: "decidim.proposals") %></th>
23
23
  <th><%= t("models.proposal.fields.category", scope: "decidim.proposals") %></th>
24
- <th><%= t("models.proposal.fields.scope", scope: "decidim.proposals") %></th>
24
+ <% if scopes_enabled?(current_participatory_process) %>
25
+ <th><%= t("models.proposal.fields.scope", scope: "decidim.proposals") %></th>
26
+ <% end %>
25
27
  <th><%= t("models.proposal.fields.state", scope: "decidim.proposals") %></th>
26
28
  <th class="actions"><%= t("actions.title", scope: "decidim.proposals") %></th>
27
29
  </tr>
@@ -37,13 +39,15 @@
37
39
  <%= translated_attribute proposal.category.name %>
38
40
  <% end %>
39
41
  </td>
40
- <td>
41
- <% if proposal.scope %>
42
- <%= proposal.scope.name %>
43
- <% else %>
44
- <%= t("decidim.participatory_processes.scopes.global") %>
45
- <% end %>
46
- </td>
42
+ <% if scopes_enabled?(current_participatory_process) %>
43
+ <td>
44
+ <% if proposal.scope %>
45
+ <%= translated_attribute proposal.scope.name %>
46
+ <% else %>
47
+ <%= t("decidim.scopes.global") %>
48
+ <% end %>
49
+ </td>
50
+ <% end %>
47
51
  <td>
48
52
  <strong class="<%= proposal_state_css_class proposal.state %>">
49
53
  <%= humanize_proposal_state proposal.state %>
@@ -28,8 +28,8 @@
28
28
  <%= form.collection_check_boxes :activity, [["voted", t('.voted')]], :first, :last, legend_title: t('.activity') %>
29
29
  <% end %>
30
30
 
31
- <% if current_organization.scopes.any? && !current_participatory_process.scope %>
32
- <%= form.collection_check_boxes :scope_id, search_organization_scopes, lambda {|scope| scope.id.to_s}, :name, legend_title: t('.scopes') %>
31
+ <% if current_participatory_process.has_subscopes? %>
32
+ <%= form.scopes_select :scope_id, legend_title: t(".scopes"), label: false, prompt: t('.scope_prompt'), remote_path: decidim.scopes_search_path(root: current_participatory_process.scope, include_root: true), multiple: true %>
33
33
  <% end %>
34
34
 
35
35
  <% if current_feature.categories.any? %>
@@ -15,4 +15,4 @@
15
15
  <div class="filters">
16
16
  <%= render partial: "filters" %>
17
17
  </div>
18
- </div>
18
+ </div>
@@ -12,7 +12,7 @@
12
12
  </div>
13
13
  <%= render partial: "proposal_badge", locals: { proposal: proposal } %>
14
14
  <p><%= truncate(proposal.body, length: 100) %></p>
15
- <%= render partial: "tags", locals: { proposal: proposal } %>
15
+ <%= render partial: "decidim/shared/tags", locals: { resource: proposal, tags_class_extra: "tags--proposal" } %>
16
16
  </div>
17
17
  <div class="card__footer">
18
18
  <div class="card__support">
@@ -1,3 +1,5 @@
1
+ <%= render partial: "decidim/shared/feature_announcement" %>
2
+
1
3
  <% if feature_settings.geocoding_enabled? %>
2
4
  <%= dynamic_map_for proposals_data_for_map(geocoded_proposals) do %>
3
5
  <template id="marker-popup">
@@ -6,5 +6,5 @@ $proposals.html('<%= j(render partial: "proposals") %>');
6
6
  $proposalsCount.html('<%= j(render partial: "count") %>');
7
7
  $orderFilterInput.val('<%= order %>');
8
8
 
9
- var $dropdownMenu = $('.dropdown.menu:last');
9
+ var $dropdownMenu = $('.dropdown.menu', $proposals);
10
10
  $dropdownMenu.foundation();
@@ -5,9 +5,14 @@
5
5
  <% end %>
6
6
  <h2 class="section-heading"><%= t(".title") %></h2>
7
7
  </div>
8
+
8
9
  <div class="row">
9
10
  <div class="columns large-6 medium-centered">
10
11
  <div class="card">
12
+ <% if translated_attribute(feature_settings.new_proposal_help_text).present? %>
13
+ <%= render partial: "decidim/shared/announcement", locals: { announcement: feature_settings.new_proposal_help_text } %>
14
+ <% end %>
15
+
11
16
  <div class="card__content">
12
17
  <%= decidim_form_for(@form) do |form| %>
13
18
  <div class="field">
@@ -33,9 +38,9 @@
33
38
  </div>
34
39
  <% end %>
35
40
 
36
- <% if !@form.process_scope %>
41
+ <% if current_participatory_process.has_subscopes? %>
37
42
  <div class="field">
38
- <%= form.collection_select :scope_id, organization_scopes, :id, :name %>
43
+ <%= form.scopes_select :scope_id, prompt: I18n.t("decidim.scopes.global"), remote_path: decidim.scopes_search_path(root: current_participatory_process.scope) %>
39
44
  </div>
40
45
  <% end %>
41
46
 
@@ -45,6 +50,21 @@
45
50
  </div>
46
51
  <% end %>
47
52
 
53
+ <% if feature_settings.attachments_allowed? %>
54
+ <fieldset>
55
+ <legend><%= t('.attachment_legend') %></legend>
56
+ <%= form.fields_for :attachment, @form.attachment do |form| %>
57
+ <div class="field">
58
+ <%= form.text_field :title %>
59
+ </div>
60
+
61
+ <div class="field">
62
+ <%= form.upload :file, optional: false %>
63
+ </div>
64
+ <% end %>
65
+ </fieldset>
66
+ <% end %>
67
+
48
68
  <div class="actions">
49
69
  <%= form.submit t(".send"), class: "button expanded", "data-disable-with" => "#{t('.send')}..." %>
50
70
  </div>
@@ -37,7 +37,7 @@
37
37
  <% if feature_settings.geocoding_enabled? %>
38
38
  <%= render partial: "decidim/shared/static_map", locals: { icon_name: "proposals", geolocalizable: @proposal } %>
39
39
  <% end %>
40
- <%= render partial: "tags", locals: { proposal: @proposal } %>
40
+ <%= render partial: "decidim/shared/tags", locals: { resource: @proposal, tags_class_extra: "tags--proposal" } %>
41
41
  </div>
42
42
  <% if @proposal.answered? && translated_attribute(@proposal.answer).present? %>
43
43
  <% if @proposal.accepted? %>
@@ -61,6 +61,7 @@
61
61
  <%= linked_resources_for @proposal, :meetings, "proposals_from_meeting" %>
62
62
  </div>
63
63
  </div>
64
+ <%= attachments_for @proposal %>
64
65
 
65
66
  <%= comments_for @proposal %>
66
67
 
@@ -10,6 +10,6 @@ ignore_unused:
10
10
  - "decidim.proposals.admin.exports.proposals"
11
11
  - "decidim.proposals.admin.exports.comments"
12
12
  ignore_missing:
13
- - decidim.participatory_processes.scopes.global
13
+ - decidim.scopes.global
14
14
  search:
15
15
  strict: false
@@ -104,6 +104,7 @@ ca:
104
104
  origin: Origen
105
105
  rejected: Rebutjades
106
106
  related_to: Relacionat amb
107
+ scope_prompt: Seleccioneu un àmbit
107
108
  scopes: Àmbits
108
109
  search: Cerca
109
110
  state: Estat
@@ -156,4 +157,4 @@ ca:
156
157
  proposal_projects: 'Proposta formulada en aquests projectes:'
157
158
  proposal_results: 'La proposta apareix en aquests resultats:'
158
159
  proposals_from_meeting:
159
- proposal_meetings: Trobades relacionades
160
+ proposal_meetings: Trobades relacionades
@@ -19,12 +19,16 @@ en:
19
19
  name: Proposals
20
20
  settings:
21
21
  global:
22
+ announcement: Announcement
23
+ attachments_allowed: Allow attachments
22
24
  comments_enabled: Comments enabled
23
25
  geocoding_enabled: Geocoding enabled
26
+ new_proposal_help_text: New proposal help text
24
27
  official_proposals_enabled: Official proposals enabled
25
28
  proposal_answering_enabled: Proposal answering enabled
26
29
  vote_limit: Vote limit
27
30
  step:
31
+ announcement: Announcement
28
32
  comments_blocked: Comments blocked
29
33
  creation_enabled: Proposal creation enabled
30
34
  proposal_answering_enabled: Proposal answering enabled
@@ -61,6 +65,7 @@ en:
61
65
  invalid: There's been a problem creating this proposal
62
66
  success: Proposal successfully created
63
67
  form:
68
+ attachment_legend: "(Optional) Add an attachment"
64
69
  select_a_category: Select a category
65
70
  index:
66
71
  title: Proposals
@@ -106,6 +111,7 @@ en:
106
111
  origin: Origin
107
112
  rejected: Rejected
108
113
  related_to: Related to
114
+ scope_prompt: Select a scope
109
115
  scopes: Scopes
110
116
  search: Search
111
117
  state: State
@@ -123,6 +129,7 @@ en:
123
129
  one: <span class="card--list__data__number">1</span>vote
124
130
  other: <span class="card--list__data__number">%{count}</span>votes
125
131
  new:
132
+ attachment_legend: "(Optional) Add an attachment"
126
133
  back: Back
127
134
  select_a_category: Please select a category
128
135
  send: Send
@@ -104,6 +104,7 @@ es:
104
104
  origin: Origen
105
105
  rejected: Rechazadas
106
106
  related_to: Relacionado con
107
+ scope_prompt: Seleccione un ámbito
107
108
  scopes: Ámbitos
108
109
  search: Buscar
109
110
  state: Estado
@@ -156,4 +157,4 @@ es:
156
157
  proposal_projects: 'Propuesta formulada en estos proyectos:'
157
158
  proposal_results: 'Propuesta formulada en estos resultados:'
158
159
  proposals_from_meeting:
159
- proposal_meetings: Encuentros relacionados
160
+ proposal_meetings: Encuentros relacionados
@@ -145,4 +145,4 @@ eu:
145
145
  proposal_projects: 'Proiektu hauetatik sortutako proposamena:'
146
146
  proposal_results: 'Emaitza hauetatik sortutako proposamena:'
147
147
  proposals_from_meeting:
148
- proposal_meetings: Proposamenarekin lotutako topaketak
148
+ proposal_meetings: Proposamenarekin lotutako topaketak
@@ -132,4 +132,4 @@ fi:
132
132
  proposal_projects: 'Ehdotus esiintyy näissä projekteissa:'
133
133
  proposal_results: 'Ehdotus esiintyy näissä tuloksissa:'
134
134
  proposals_from_meeting:
135
- proposal_meetings: Liittyvät tapaamiset
135
+ proposal_meetings: Liittyvät tapaamiset
@@ -142,4 +142,4 @@ fr:
142
142
  proposal_projects: 'Proposition figurant dans ces projets :'
143
143
  proposal_results: 'Proposition figurant dans ces résultats :'
144
144
  proposals_from_meeting:
145
- proposal_meetings: Rencontres connexes
145
+ proposal_meetings: Rencontres connexes
@@ -144,4 +144,4 @@ it:
144
144
  proposal_projects: 'Le proposte compaiono nei seguenti progetti:'
145
145
  proposal_results: 'Le proposte compaiono nei seguenti risultati:'
146
146
  proposals_from_meeting:
147
- proposal_meetings: Meeting associati alla proposta
147
+ proposal_meetings: Meeting associati alla proposta
@@ -2,4 +2,4 @@ nl:
2
2
  activemodel:
3
3
  attributes:
4
4
  proposal:
5
- title: Titel
5
+ title: Titel
@@ -0,0 +1,5 @@
1
+ pl:
2
+ activemodel:
3
+ attributes:
4
+ proposal:
5
+ title: Tytuł
@@ -21,6 +21,9 @@ Decidim.register_feature(:proposals) do |feature|
21
21
  settings.attribute :official_proposals_enabled, type: :boolean, default: true
22
22
  settings.attribute :comments_enabled, type: :boolean, default: true
23
23
  settings.attribute :geocoding_enabled, type: :boolean, default: false
24
+ settings.attribute :attachments_allowed, type: :boolean, default: false
25
+ settings.attribute :announcement, type: :text, translated: true, editor: true
26
+ settings.attribute :new_proposal_help_text, type: :text, translated: true, editor: true
24
27
  end
25
28
 
26
29
  feature.settings(:step) do |settings|
@@ -30,6 +33,7 @@ Decidim.register_feature(:proposals) do |feature|
30
33
  settings.attribute :comments_blocked, type: :boolean, default: false
31
34
  settings.attribute :creation_enabled, type: :boolean
32
35
  settings.attribute :proposal_answering_enabled, type: :boolean, default: true
36
+ settings.attribute :announcement, type: :text, translated: true, editor: true
33
37
  end
34
38
 
35
39
  feature.register_resource do |resource|
@@ -84,8 +88,14 @@ Decidim.register_feature(:proposals) do |feature|
84
88
  process.active_step.id => { votes_enabled: true, votes_blocked: false, creation_enabled: true }
85
89
  }
86
90
  )
87
- # So that we have some with global scope
88
- scopes = feature.organization.scopes + [nil]
91
+
92
+ if process.scope
93
+ scopes = process.scope.descendants
94
+ global = process.scope
95
+ else
96
+ scopes = process.organization.scopes
97
+ global = nil
98
+ end
89
99
 
90
100
  20.times do |n|
91
101
  author = Decidim::User.where(organization: feature.organization).all.sample
@@ -103,7 +113,7 @@ Decidim.register_feature(:proposals) do |feature|
103
113
  proposal = Decidim::Proposals::Proposal.create!(
104
114
  feature: feature,
105
115
  category: process.categories.sample,
106
- scope: scopes.sample,
116
+ scope: Faker::Boolean.boolean(0.5) ? global : scopes.sample,
107
117
  title: Faker::Lorem.sentence(2),
108
118
  body: Faker::Lorem.paragraphs(2).join("\n"),
109
119
  author: author,
@@ -60,6 +60,14 @@ FactoryGirl.define do
60
60
  }
61
61
  end
62
62
  end
63
+
64
+ trait :with_attachments_allowed do
65
+ settings do
66
+ {
67
+ attachments_allowed: true
68
+ }
69
+ end
70
+ end
63
71
  end
64
72
 
65
73
  factory :proposal, class: Decidim::Proposals::Proposal do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-proposals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-08-02 00:00:00.000000000 Z
13
+ date: 2017-08-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: decidim-core
@@ -18,28 +18,28 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.4.4
21
+ version: 0.5.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 0.4.4
28
+ version: 0.5.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: decidim-comments
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 0.4.4
35
+ version: 0.5.0
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 0.4.4
42
+ version: 0.5.0
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: rectify
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -88,70 +88,70 @@ dependencies:
88
88
  requirements:
89
89
  - - '='
90
90
  - !ruby/object:Gem::Version
91
- version: 0.4.4
91
+ version: 0.5.0
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - '='
97
97
  - !ruby/object:Gem::Version
98
- version: 0.4.4
98
+ version: 0.5.0
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: decidim-admin
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
103
  - - '='
104
104
  - !ruby/object:Gem::Version
105
- version: 0.4.4
105
+ version: 0.5.0
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - '='
111
111
  - !ruby/object:Gem::Version
112
- version: 0.4.4
112
+ version: 0.5.0
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: decidim-meetings
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - '='
118
118
  - !ruby/object:Gem::Version
119
- version: 0.4.4
119
+ version: 0.5.0
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
124
  - - '='
125
125
  - !ruby/object:Gem::Version
126
- version: 0.4.4
126
+ version: 0.5.0
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: decidim-results
129
129
  requirement: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - '='
132
132
  - !ruby/object:Gem::Version
133
- version: 0.4.4
133
+ version: 0.5.0
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
138
  - - '='
139
139
  - !ruby/object:Gem::Version
140
- version: 0.4.4
140
+ version: 0.5.0
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: decidim-budgets
143
143
  requirement: !ruby/object:Gem::Requirement
144
144
  requirements:
145
145
  - - '='
146
146
  - !ruby/object:Gem::Version
147
- version: 0.4.4
147
+ version: 0.5.0
148
148
  type: :development
149
149
  prerelease: false
150
150
  version_requirements: !ruby/object:Gem::Requirement
151
151
  requirements:
152
152
  - - '='
153
153
  - !ruby/object:Gem::Version
154
- version: 0.4.4
154
+ version: 0.5.0
155
155
  description: A proposals component for decidim's participatory processes.
156
156
  email:
157
157
  - josepjaume@gmail.com
@@ -213,7 +213,6 @@ files:
213
213
  - app/views/decidim/proposals/proposals/_proposal_badge.html.erb
214
214
  - app/views/decidim/proposals/proposals/_proposals.html.erb
215
215
  - app/views/decidim/proposals/proposals/_remaining_votes_count.html.erb
216
- - app/views/decidim/proposals/proposals/_tags.html.erb
217
216
  - app/views/decidim/proposals/proposals/_vote_button.html.erb
218
217
  - app/views/decidim/proposals/proposals/_votes_count.html.erb
219
218
  - app/views/decidim/proposals/proposals/_votes_limit.html.erb
@@ -231,6 +230,7 @@ files:
231
230
  - config/locales/fr.yml
232
231
  - config/locales/it.yml
233
232
  - config/locales/nl.yml
233
+ - config/locales/pl.yml
234
234
  - db/migrate/20161212110850_create_decidim_proposals.rb
235
235
  - db/migrate/20170112115253_create_proposal_votes.rb
236
236
  - db/migrate/20170113114245_add_text_search_indexes.rb
@@ -1,10 +0,0 @@
1
- <% if proposal.category.present? || proposal.scope.present? %>
2
- <ul class="tags tags--proposal" >
3
- <% if proposal.category.present? %>
4
- <li><%= link_to translated_attribute(proposal.category.name), resource_locator(proposal).index(filter: { category_id: proposal.category.id }) %></li>
5
- <% end %>
6
- <% if proposal.scope.present? && !current_participatory_process.scope %>
7
- <li><%= link_to proposal.scope.name, resource_locator(proposal).index(filter: { scope_id: [proposal.scope.id] }) %></li>
8
- <% end %>
9
- </ul>
10
- <% end %>