decidim-initiatives 0.13.1 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/decidim_initiatives_manifest.js +2 -1
  3. data/app/assets/images/decidim/gamification/badges/initiatives.svg +87 -0
  4. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives/show.erb +29 -0
  5. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_cell.rb +27 -0
  6. data/app/cells/decidim/initiatives/initiative_cell.rb +1 -1
  7. data/app/cells/decidim/initiatives/initiative_m/author.erb +1 -1
  8. data/app/commands/decidim/initiatives/admin/publish_initiative.rb +5 -0
  9. data/app/commands/decidim/initiatives/admin/update_initiative.rb +7 -5
  10. data/app/controllers/decidim/initiatives/admin/initiative_attachments_controller.rb +0 -4
  11. data/app/controllers/decidim/initiatives/committee_requests_controller.rb +1 -0
  12. data/app/forms/decidim/initiatives/admin/initiative_form.rb +6 -6
  13. data/app/models/decidim/initiative.rb +9 -9
  14. data/app/permissions/decidim/initiatives/admin/permissions.rb +3 -3
  15. data/app/presenters/decidim/initiatives/admin_log/initiative_presenter.rb +2 -2
  16. data/app/queries/decidim/initiatives/outdated_validating_initiatives.rb +1 -1
  17. data/app/queries/decidim/initiatives/support_period_finished_initiatives.rb +1 -1
  18. data/app/views/decidim/initiatives/admin/initiatives/_form.html.erb +2 -2
  19. data/app/views/decidim/initiatives/committee_requests/new.html.erb +3 -7
  20. data/app/views/decidim/initiatives/initiatives/_filters.html.erb +6 -5
  21. data/app/views/decidim/initiatives/initiatives/index.html.erb +8 -0
  22. data/app/views/decidim/initiatives/initiatives/show.html.erb +9 -0
  23. data/app/views/layouts/decidim/_initiative_header_steps.html.erb +2 -2
  24. data/config/locales/ca.yml +15 -2
  25. data/config/locales/en.yml +15 -2
  26. data/config/locales/es-PY.yml +15 -2
  27. data/config/locales/es.yml +15 -2
  28. data/config/locales/eu.yml +15 -2
  29. data/config/locales/fi.yml +179 -166
  30. data/config/locales/fr.yml +15 -2
  31. data/config/locales/gl.yml +15 -2
  32. data/config/locales/hu.yml +363 -0
  33. data/config/locales/it.yml +15 -2
  34. data/config/locales/nl.yml +15 -2
  35. data/config/locales/pl.yml +15 -2
  36. data/config/locales/pt-BR.yml +21 -8
  37. data/config/locales/pt.yml +15 -2
  38. data/config/locales/ru.yml +7 -4
  39. data/config/locales/sv.yml +15 -2
  40. data/config/locales/uk.yml +7 -4
  41. data/db/migrate/20180726071704_rename_signature_time_fields_to_signature_date.rb +9 -0
  42. data/lib/decidim/initiatives/admin_engine.rb +1 -0
  43. data/lib/decidim/initiatives/engine.rb +16 -12
  44. data/lib/decidim/initiatives/initiatives_filter_form_builder.rb +3 -3
  45. data/lib/decidim/initiatives/participatory_space.rb +11 -3
  46. data/lib/decidim/initiatives/test/factories.rb +29 -29
  47. data/lib/decidim/initiatives/version.rb +1 -1
  48. metadata +18 -14
  49. data/app/views/decidim/initiatives/pages/home/_highlighted_initiatives.html.erb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 047e5ee9f4359e17b6bd4da8c60e178b76931e12f01194cc85222f8075086d2b
4
- data.tar.gz: ef5ead0df996c89a2eed12e46921dac30f125cb7441fd2ebaa34107dc2d44965
3
+ metadata.gz: adfe7c6668efe76c842ee7f7a0ce24a1a4a64b6f56906fe86e96eab66994a93f
4
+ data.tar.gz: 649ea6a9334368175ddaf00ba151439558e27dc6f977d87bb4882180eae4e385
5
5
  SHA512:
6
- metadata.gz: ec5558f86e78d672fab1291521578eb443f8cd8c9af5f26ba9b6c495cd28096a631c039532fe28ad45274912fa9ade00add187deb80494b0135ad4814db4516f
7
- data.tar.gz: 748bcaa4a6f9a2becf85419181b2dc85c8760a8b46a892dc52c17be451c08e26f026d19839f8c376054d42c95a588d572d46621c00127ef216a11da4695cfe6f
6
+ metadata.gz: 586cac78793a6e61df618dc59d51929358b874a22098d5c8e94036777961533432a9b9f59c04b7971a55948a8c2dfafa2963ebd219d1132d32b6425d13f6ed09
7
+ data.tar.gz: 234cdcefbd6160674b92873e8759df8e2338e44affb7815242d721820a98010b2034f3879a4455aad57a1849484bc535faf0ec55e83ab9c1d9f288e72df043bb
@@ -2,4 +2,5 @@
2
2
  //= link decidim/initiatives/application.js
3
3
  //= link decidim/initiatives/identity_selector_dialog.js
4
4
  //= link decidim/initiatives/scoped_type.js
5
- //= link decidim/initiatives/admin/invite_users.js
5
+ //= link decidim/initiatives/admin/invite_users.js
6
+ //= link_tree ../images/decidim
@@ -0,0 +1,87 @@
1
+ <svg version="1.1" id="initiatives-svg"
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
4
+ y="0px" width="1080px" height="1080px" viewBox="0 0 1080 1080" enable-background="new 0 0 1080 1080" xml:space="preserve">
5
+ <g id="initiatives" class="stroke-primary">
6
+ <polygon class="fill-primary" id="contact" fill="#31536E" points="500.5,967.5 580.5,967.5 610.5,911.5 470.5,911.5 "/>
7
+ <g id="cap">
8
+ <path class="fill-primary" id="_x35_0-pct_4_" fill="#31536E" fill-opacity="0.5" stroke="#31536E" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
9
+ M687.5,682.054c0,14.054-11.393,25.446-25.446,25.446H418.946c-14.054,0-25.446-11.393-25.446-25.446v-0.106
10
+ c0-14.055,11.393-25.447,25.446-25.447h243.106c14.055,0,25.447,11.393,25.447,25.446V682.054z"/>
11
+ <path class="fill-primary" id="_x32_5-pct_6_" fill="#31536E" fill-opacity="0.25" stroke="#31536E" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
12
+ M687.5,733.054c0,14.054-11.393,25.446-25.446,25.446H418.946c-14.054,0-25.446-11.393-25.446-25.446v-0.106
13
+ c0-14.055,11.393-25.447,25.446-25.447h243.106c14.055,0,25.447,11.393,25.447,25.446V733.054z"/>
14
+ <path class="fill-primary" id="_x35_0-pct_5_" fill="#31536E" fill-opacity="0.5" stroke="#31536E" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
15
+ M687.5,784.054c0,14.054-11.393,25.446-25.446,25.446H418.946c-14.054,0-25.446-11.393-25.446-25.446v-0.106
16
+ c0-14.055,11.393-25.447,25.446-25.447h243.106c14.055,0,25.447,11.393,25.447,25.446V784.054z"/>
17
+ <path class="fill-primary" id="_x32_5-pct_5_" fill="#31536E" fill-opacity="0.25" stroke="#31536E" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
18
+ M687.5,835.054c0,14.054-11.393,25.446-25.446,25.446H418.946c-14.054,0-25.446-11.393-25.446-25.446v-0.106
19
+ c0-14.055,11.393-25.447,25.446-25.447h243.106c14.055,0,25.447,11.393,25.447,25.446V835.054z"/>
20
+ <path class="fill-primary" id="_x35_0-pct_6_" fill="#31536E" fill-opacity="0.5" stroke="#31536E" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
21
+ M687.5,886.054c0,14.054-11.393,25.446-25.446,25.446H418.946c-14.054,0-25.446-11.393-25.446-25.446v-0.106
22
+ c0-14.055,11.393-25.447,25.446-25.447h243.106c14.055,0,25.447,11.393,25.447,25.446V886.054z"/>
23
+ </g>
24
+ <path id="glass" fill="none" stroke="#31536E" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
25
+ M789.571,371.337c0-137.578-111.529-249.079-249.107-249.079S291.357,233.801,291.357,371.379
26
+ c0,80.795,38.475,152.121,98.09,198.121h-0.022c27.35,24,47.839,54.127,58.972,87.004l183.387-0.06
27
+ c10.664-31.493,29.915-59.944,55.556-83.944h-0.022C749.299,527.5,789.571,453.998,789.571,371.337z"/>
28
+ <g id="filament">
29
+ <path class="fill-primary" id="_x35_0-pct_7_" fill="#31536E" fill-opacity="0.5" stroke="#31536E" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
30
+ M491.354,656.5c0,0,28.136-43.203,34.573-59.054c5.723-14.089,14.573-59.054,14.573-59.054s8.851,44.966,14.573,59.055
31
+ c6.438,15.85,34.573,59.053,34.573,59.053H540.5H491.354z"/>
32
+ <path class="fill-primary" id="_x32_5-pct_7_" fill="#31536E" fill-opacity="0.25" stroke="#31536E" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
33
+ M496.393,407.685c28.994,28.995,44.37,131.34,44.37,131.34s-102.346-15.375-131.34-44.37
34
+ c-28.995-28.995-33.032-71.969-9.016-95.985C424.423,374.653,467.396,378.69,496.393,407.685z"/>
35
+ <path class="fill-primary" id="_x32_5-pct_8_" fill="#31536E" fill-opacity="0.25" stroke="#31536E" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
36
+ M671.747,494.655c-28.994,28.995-131.34,44.371-131.34,44.371s15.375-102.346,44.37-131.34
37
+ c28.994-28.996,71.97-33.032,95.984-9.016C704.779,422.686,700.742,465.66,671.747,494.655z"/>
38
+ <line fill="none" stroke="#31536E" stroke-width="8" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="462.749" y1="461.011" x2="540.5" y2="538.393"/>
39
+ <line fill="none" stroke="#31536E" stroke-width="8" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="540.5" y1="538.393" x2="618.421" y2="461.011"/>
40
+ </g>
41
+ <g id="stars_4" class="stars">
42
+ <path fill="#FFD92B" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
43
+ M130.5,374.396c0-14.688-18.667-35.355-35.355-35.355c15.355,0,35.355-20.333,35.355-35.355c0,15.022,16.666,35.355,35.355,35.355
44
+ C146.833,339.041,130.5,359.708,130.5,374.396z"/>
45
+ <g>
46
+ <circle fill="#FFD92B" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="919.852" cy="859.217" r="13.5"/>
47
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="903.353" y1="842.481" x2="882.14" y2="821.269"/>
48
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="937.294" y1="876.423" x2="958.507" y2="897.636"/>
49
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="936.587" y1="843.188" x2="957.8" y2="821.976"/>
50
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="903.353" y1="876.423" x2="882.14" y2="897.636"/>
51
+ </g>
52
+ <g>
53
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="885.448" y1="566.135" x2="859.286" y2="592.299"/>
54
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="850.094" y1="601.49" x2="823.931" y2="627.654"/>
55
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="884.741" y1="627.654" x2="858.578" y2="601.49"/>
56
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="849.387" y1="592.299" x2="823.224" y2="566.135"/>
57
+ </g>
58
+ <path fill="#FFD92B" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
59
+ M945.602,73.542c0,0-21.564,4.034-26.516,8.981c-4.948,4.948-8.982,26.516-8.982,26.516s-4.035-21.565-8.982-26.516
60
+ c-4.948-4.947-26.516-8.981-26.516-8.981s22.077-4.547,26.516-8.983c4.438-4.438,8.982-26.515,8.982-26.515
61
+ s4.034,21.564,8.982,26.515C924.035,69.506,945.602,73.542,945.602,73.542z"/>
62
+ <g>
63
+ <circle fill="#FFD92B" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="962.656" cy="362.498" r="16.604"/>
64
+ <circle fill="#FFD92B" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="926.755" cy="362.498" r="6.432"/>
65
+ <circle fill="#FFD92B" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="962.656" cy="398.399" r="6.432"/>
66
+ <circle fill="#FFD92B" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="998.558" cy="362.498" r="6.432"/>
67
+ <circle fill="#FFD92B" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="962.656" cy="326.597" r="6.432"/>
68
+ </g>
69
+ <g>
70
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="108.246" y1="727.014" x2="163.149" y2="781.919"/>
71
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="163.149" y1="727.014" x2="108.246" y2="781.919"/>
72
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="117.5" y1="754.041" x2="90.5" y2="754.041"/>
73
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="155.5" y1="754.041" x2="182.5" y2="754.041"/>
74
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="136.5" y1="773.041" x2="136.5" y2="800.041"/>
75
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="136.5" y1="735.041" x2="136.5" y2="708.041"/>
76
+ </g>
77
+ <g>
78
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="320" y1="54.041" x2="320" y2="133.041"/>
79
+ <line fill="none" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="359" y1="94.041" x2="280" y2="94.041"/>
80
+ <circle fill="#FFD92B" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="300" cy="113.541" r="7.039"/>
81
+ <circle fill="#FFD92B" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="300" cy="73.541" r="7.039"/>
82
+ <circle fill="#FFD92B" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="340" cy="113.541" r="7.039"/>
83
+ <circle fill="#FFD92B" stroke="#31536E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="340" cy="73.541" r="7.039"/>
84
+ </g>
85
+ </g>
86
+ </g>
87
+ </svg>
@@ -0,0 +1,29 @@
1
+ <section class="wrapper-home home-section">
2
+ <div class="row" id="highlighted-initiatives">
3
+ <h3 class="section-heading"><%= t("active_initiatives", scope: i18n_scope) %></h3>
4
+ <div class="row collapse">
5
+ <div class="row small-up-1 smallmedium-up-2 mediumlarge-up-3 large-up-4 card-grid">
6
+ <% highlighted_initiatives.each do |initiative| %>
7
+ <div class="column">
8
+ <article class="card card--initiative card--mini">
9
+ <%= link_to decidim_initiatives.initiative_path(initiative), class: "card__link" do %>
10
+ <% end %>
11
+ <div class="card__content">
12
+ <%= link_to decidim_initiatives.initiative_path(initiative), class: "card__link" do %>
13
+ <h4 class="card__title"><%= translated_attribute initiative.title %></h4>
14
+ <% end %>
15
+ </div>
16
+ </article>
17
+ </div>
18
+ <% end %>
19
+ </div>
20
+ </div>
21
+ </div>
22
+
23
+ <div class="row" id="see-all-initiatives">
24
+ <div class="columns small-centered small-12 smallmedium-8 medium-6 large-4">
25
+ <%= link_to t("see_all_initiatives", scope: i18n_scope), decidim_initiatives.initiatives_path,
26
+ class: "button expanded hollow button--sc home-section__cta" %>
27
+ </div>
28
+ </div>
29
+ </section>
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ module ContentBlocks
6
+ class HighlightedInitiativesCell < Decidim::ViewModel
7
+ delegate :current_organization, to: :controller
8
+
9
+ def show
10
+ render if highlighted_initiatives.any?
11
+ end
12
+
13
+ def highlighted_initiatives
14
+ OrganizationPrioritizedInitiatives.new(current_organization)
15
+ end
16
+
17
+ def i18n_scope
18
+ "decidim.initiatives.pages.home.highlighted_initiatives"
19
+ end
20
+
21
+ def decidim_initiatives
22
+ Decidim::Initiatives::Engine.routes.url_helpers
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -6,7 +6,7 @@ module Decidim
6
6
  # the default size is the Medium Card (:m)
7
7
  class InitiativeCell < Decidim::ViewModel
8
8
  def show
9
- cell card_size, model
9
+ cell card_size, model, options
10
10
  end
11
11
 
12
12
  private
@@ -2,7 +2,7 @@
2
2
  <%= cell(
3
3
  "decidim/collapsible_list",
4
4
  authors,
5
- size: :small,
5
+ size: 3,
6
6
  cell_name: "decidim/author",
7
7
  hidden_elements_count_i18n_key: "decidim.initiatives.initiatives.author_list.hidden_authors_count",
8
8
  cell_options: { extra_classes: ["author-data--small"] }
@@ -30,6 +30,7 @@ module Decidim
30
30
  current_user
31
31
  ) do
32
32
  initiative.publish!
33
+ increment_score
33
34
  initiative
34
35
  end
35
36
  broadcast(:ok, initiative)
@@ -38,6 +39,10 @@ module Decidim
38
39
  private
39
40
 
40
41
  attr_reader :initiative, :current_user
42
+
43
+ def increment_score
44
+ Decidim::Gamification.increment_score(initiative.author, :initiatives)
45
+ end
41
46
  end
42
47
  end
43
48
  end
@@ -50,15 +50,17 @@ module Decidim
50
50
  answer_url: form.answer_url
51
51
  }
52
52
 
53
- attrs[:answered_at] = DateTime.current if form.answer.present?
53
+ attrs[:answered_at] = Time.current if form.answer.present?
54
54
 
55
55
  if current_user.admin?
56
- attrs[:signature_start_time] = form.signature_start_time
57
- attrs[:signature_end_time] = form.signature_end_time
56
+ attrs[:signature_start_date] = form.signature_start_date
57
+ attrs[:signature_end_date] = form.signature_end_date
58
58
  attrs[:offline_votes] = form.offline_votes
59
59
 
60
- @notify_extended = true if form.signature_end_time != initiative.signature_end_time &&
61
- form.signature_end_time > initiative.signature_end_time
60
+ if initiative.published?
61
+ @notify_extended = true if form.signature_end_date != initiative.signature_end_date &&
62
+ form.signature_end_date > initiative.signature_end_date
63
+ end
62
64
  end
63
65
 
64
66
  attrs
@@ -15,10 +15,6 @@ module Decidim
15
15
  def attached_to
16
16
  current_initiative
17
17
  end
18
-
19
- def authorization_object
20
- collection.find_by(id: params[:id]) || Decidim::Attachment
21
- end
22
18
  end
23
19
  end
24
20
  end
@@ -7,6 +7,7 @@ module Decidim
7
7
  include Decidim::Initiatives::NeedsInitiative
8
8
 
9
9
  helper InitiativeHelper
10
+ helper Decidim::ActionAuthorizationHelper
10
11
 
11
12
  layout "layouts/decidim/application"
12
13
 
@@ -15,8 +15,8 @@ module Decidim
15
15
  attribute :type_id, Integer
16
16
  attribute :decidim_scope_id, Integer
17
17
  attribute :signature_type, String
18
- attribute :signature_start_time, Date
19
- attribute :signature_end_time, Date
18
+ attribute :signature_start_date, Date
19
+ attribute :signature_end_date, Date
20
20
  attribute :hashtag, String
21
21
  attribute :offline_votes, Integer
22
22
 
@@ -25,10 +25,10 @@ module Decidim
25
25
 
26
26
  validates :title, :description, presence: true
27
27
  validates :signature_type, presence: true
28
- validates :signature_start_time, presence: true, if: ->(form) { form.context.initiative.published? }
29
- validates :signature_end_time, presence: true, if: ->(form) { form.context.initiative.published? }
30
- validates :signature_end_time, date: { after: :signature_start_time }, if: lambda { |form|
31
- form.signature_start_time.present? && form.signature_end_time.present?
28
+ validates :signature_start_date, presence: true, if: ->(form) { form.context.initiative.published? }
29
+ validates :signature_end_date, presence: true, if: ->(form) { form.context.initiative.published? }
30
+ validates :signature_end_date, date: { after: :signature_start_date }, if: lambda { |form|
31
+ form.signature_start_date.present? && form.signature_end_date.present?
32
32
  }
33
33
 
34
34
  validates :answer, translatable_presence: true, if: ->(form) { form.context.initiative.accepted? }
@@ -64,14 +64,14 @@ module Decidim
64
64
  scope :open, lambda {
65
65
  published
66
66
  .where.not(state: [:discarded, :rejected, :accepted])
67
- .where("signature_start_time <= ?", Time.now.utc)
68
- .where("signature_end_time >= ?", Time.now.utc)
67
+ .where("signature_start_date <= ?", Date.current)
68
+ .where("signature_end_date >= ?", Date.current)
69
69
  }
70
70
  scope :closed, lambda {
71
71
  published
72
72
  .where(state: [:discarded, :rejected, :accepted])
73
- .or(where("signature_start_time > ?", Time.now.utc))
74
- .or(where("signature_end_time < ?", Time.now.utc))
73
+ .or(where("signature_start_date > ?", Date.current))
74
+ .or(where("signature_end_date < ?", Date.current))
75
75
  }
76
76
  scope :published, -> { where.not(published_at: nil) }
77
77
  scope :with_state, ->(state) { where(state: state) if state.present? }
@@ -165,8 +165,8 @@ module Decidim
165
165
 
166
166
  def votes_enabled?
167
167
  published? &&
168
- signature_start_time <= Time.zone.today &&
169
- signature_end_time >= Time.zone.today
168
+ signature_start_date <= Date.current &&
169
+ signature_end_date >= Date.current
170
170
  end
171
171
 
172
172
  # Public: Checks if the organization has given an answer for the initiative.
@@ -198,8 +198,8 @@ module Decidim
198
198
  update(
199
199
  published_at: Time.current,
200
200
  state: "published",
201
- signature_start_time: DateTime.now.utc,
202
- signature_end_time: DateTime.now.utc + Decidim::Initiatives.default_signature_time_period_length
201
+ signature_start_date: Date.current,
202
+ signature_end_date: Date.current + Decidim::Initiatives.default_signature_time_period_length
203
203
  )
204
204
  end
205
205
 
@@ -214,7 +214,7 @@ module Decidim
214
214
 
215
215
  # Public: Returns wether the signature interval is already defined or not.
216
216
  def has_signature_interval_defined?
217
- signature_end_time.present? && signature_start_time.present?
217
+ signature_end_date.present? && signature_start_date.present?
218
218
  end
219
219
 
220
220
  # Public: Returns the hashtag for the initiative.
@@ -140,12 +140,12 @@ module Decidim
140
140
  toggle_allow(initiative.offline? || initiative.any?)
141
141
  when :accept
142
142
  allowed = initiative.published? &&
143
- initiative.signature_end_time < Time.zone.today &&
143
+ initiative.signature_end_date < Date.current &&
144
144
  initiative.percentage >= 100
145
145
  toggle_allow(allowed)
146
146
  when :reject
147
147
  allowed = initiative.published? &&
148
- initiative.signature_end_time < Time.zone.today &&
148
+ initiative.signature_end_date < Date.current &&
149
149
  initiative.percentage < 100
150
150
  toggle_allow(allowed)
151
151
  else
@@ -173,7 +173,7 @@ module Decidim
173
173
  allowed = initiative.created? && (
174
174
  !initiative.decidim_user_group_id.nil? ||
175
175
  initiative.committee_members.approved.count >= Decidim::Initiatives.minimum_committee_members
176
- )
176
+ )
177
177
 
178
178
  toggle_allow(allowed)
179
179
  when :manage_membership
@@ -28,8 +28,8 @@ module Decidim
28
28
  {
29
29
  state: :string,
30
30
  published_at: :date,
31
- signature_start_time: :date,
32
- signature_end_time: :date,
31
+ signature_start_date: :date,
32
+ signature_end_date: :date,
33
33
  description: :i18n,
34
34
  title: :i18n,
35
35
  hashtag: :string
@@ -16,7 +16,7 @@ module Decidim
16
16
  #
17
17
  # period_length - Maximum time in validating state
18
18
  def initialize(period_length)
19
- @period_length = DateTime.current - period_length
19
+ @period_length = Time.current - period_length
20
20
  end
21
21
 
22
22
  # Retrieves the available initiative types for the given organization.
@@ -12,7 +12,7 @@ module Decidim
12
12
  .includes(:scoped_type)
13
13
  .where(state: "published")
14
14
  .where(signature_type: "online")
15
- .where("signature_end_time < ?", DateTime.current)
15
+ .where("signature_end_date < ?", Date.current)
16
16
  end
17
17
  end
18
18
  end
@@ -33,11 +33,11 @@
33
33
  <% if current_initiative.published? && current_user.admin? %>
34
34
  <div class="row">
35
35
  <div class="columns xlarge-6">
36
- <%= form.date_field :signature_start_time %>
36
+ <%= form.date_field :signature_start_date %>
37
37
  </div>
38
38
 
39
39
  <div class="columns xlarge-6">
40
- <%= form.date_field :signature_end_time %>
40
+ <%= form.date_field :signature_end_date %>
41
41
  </div>
42
42
  </div>
43
43
  <% end %>
@@ -23,13 +23,9 @@
23
23
 
24
24
  <div class="section">
25
25
  <p><%= t ".help_text" %></p>
26
- <%= link_to t(".continue"),
27
- spawn_initiative_committee_requests_path(current_initiative),
28
- class: "title-action__action button small hollow" if current_user %>
29
-
30
- <%= link_to t(".continue"),
31
- spawn_initiative_committee_requests_path(current_initiative),
32
- class: "title-action__action button small hollow" unless current_user %>
26
+ <%= logged_link_to t(".continue"),
27
+ spawn_initiative_committee_requests_path(current_initiative),
28
+ class: "title-action__action button small hollow" %>
33
29
  </div>
34
30
  </div>
35
31
  </div>
@@ -30,11 +30,12 @@
30
30
  <fieldset>
31
31
  <legend><h6 class="heading6"><%= t ".type" %></h6></legend>
32
32
  <%= form.initiative_types_select :type,
33
- legend_title: t(".type"),
34
- label: false,
35
- prompt: t(".type_prompt"),
36
- remote_path: initiative_types_search_path,
37
- multiple: true %>
33
+ Decidim::InitiativesType.where(organization: current_organization),
34
+ legend_title: t(".type"),
35
+ label: false,
36
+ prompt: t(".type_prompt"),
37
+ remote_path: initiative_types_search_path,
38
+ multiple: true %>
38
39
  </fieldset>
39
40
  </div>
40
41
 
@@ -1,3 +1,11 @@
1
+ <%
2
+ edit_link(
3
+ decidim_admin_initiatives.initiatives_path,
4
+ :list,
5
+ :initiative
6
+ )
7
+ %>
8
+
1
9
  <% provide :meta_title, t("initiatives.index.title", scope: "decidim") %>
2
10
  <main class="wrapper">
3
11
  <div class="row columns">