decidim-initiatives 0.27.4 → 0.28.0.rc5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_cell.rb +17 -18
- data/app/cells/decidim/initiatives/initiative_cell.rb +6 -1
- data/app/cells/decidim/initiatives/initiative_dropdown_metadata_cell.rb +19 -0
- data/app/cells/decidim/initiatives/initiative_g_cell.rb +31 -0
- data/app/cells/decidim/initiatives/initiative_metadata_g_cell.rb +62 -0
- data/app/cells/decidim/initiatives/initiative_s_cell.rb +15 -0
- data/app/cells/decidim/initiatives_votes/vote/show.erb +25 -19
- data/app/cells/decidim/initiatives_votes/vote_cell.rb +3 -1
- data/app/commands/decidim/initiatives/admin/accept_initiative.rb +40 -0
- data/app/commands/decidim/initiatives/admin/create_initiative_type.rb +1 -1
- data/app/commands/decidim/initiatives/admin/create_initiative_type_scope.rb +1 -1
- data/app/commands/decidim/initiatives/admin/discard_initiative.rb +40 -0
- data/app/commands/decidim/initiatives/admin/publish_initiative.rb +1 -1
- data/app/commands/decidim/initiatives/admin/reject_initiative.rb +40 -0
- data/app/commands/decidim/initiatives/admin/send_initiative_to_technical_validation.rb +2 -2
- data/app/commands/decidim/initiatives/admin/unpublish_initiative.rb +1 -1
- data/app/commands/decidim/initiatives/admin/update_initiative.rb +1 -1
- data/app/commands/decidim/initiatives/admin/update_initiative_answer.rb +1 -1
- data/app/commands/decidim/initiatives/admin/update_initiative_type.rb +1 -1
- data/app/commands/decidim/initiatives/admin/update_initiative_type_scope.rb +1 -1
- data/app/commands/decidim/initiatives/admin/update_initiatives_settings.rb +1 -1
- data/app/commands/decidim/initiatives/attachment_methods.rb +2 -24
- data/app/commands/decidim/initiatives/create_initiative.rb +19 -14
- data/app/commands/decidim/initiatives/send_initiative_to_technical_validation.rb +2 -2
- data/app/commands/decidim/initiatives/spawn_committee_request.rb +1 -1
- data/app/commands/decidim/initiatives/unvote_initiative.rb +1 -1
- data/app/commands/decidim/initiatives/update_initiative.rb +9 -2
- data/app/commands/decidim/initiatives/validate_mobile_phone.rb +2 -2
- data/app/commands/decidim/initiatives/vote_initiative.rb +5 -5
- data/app/constraints/decidim/initiatives/current_initiative.rb +1 -1
- data/app/controllers/concerns/decidim/initiatives/admin/filterable.rb +2 -2
- data/app/controllers/concerns/decidim/initiatives/needs_initiative.rb +1 -1
- data/app/controllers/decidim/initiatives/admin/answers_controller.rb +3 -0
- data/app/controllers/decidim/initiatives/admin/committee_requests_controller.rb +2 -0
- data/app/controllers/decidim/initiatives/admin/components_controller.rb +3 -0
- data/app/controllers/decidim/initiatives/admin/initiative_attachments_controller.rb +2 -0
- data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +17 -6
- data/app/controllers/decidim/initiatives/admin/initiatives_permissions_controller.rb +3 -0
- data/app/controllers/decidim/initiatives/admin/initiatives_settings_controller.rb +2 -0
- data/app/controllers/decidim/initiatives/admin/initiatives_type_scopes_controller.rb +30 -0
- data/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb +14 -0
- data/app/controllers/decidim/initiatives/admin/initiatives_types_permissions_controller.rb +21 -0
- data/app/controllers/decidim/initiatives/admin/moderations/reports_controller.rb +2 -2
- data/app/controllers/decidim/initiatives/admin/moderations_controller.rb +4 -2
- data/app/controllers/decidim/initiatives/application_controller.rb +0 -1
- data/app/controllers/decidim/initiatives/authorization_create_modals_controller.rb +25 -0
- data/app/controllers/decidim/initiatives/authorization_sign_modals_controller.rb +2 -2
- data/app/controllers/decidim/initiatives/committee_requests_controller.rb +0 -2
- data/app/controllers/decidim/initiatives/create_initiative_controller.rb +62 -115
- data/app/controllers/decidim/initiatives/initiative_signatures_controller.rb +113 -81
- data/app/controllers/decidim/initiatives/initiative_types_controller.rb +7 -0
- data/app/controllers/decidim/initiatives/initiatives_controller.rb +37 -17
- data/app/controllers/decidim/initiatives/versions_controller.rb +0 -1
- data/app/events/decidim/initiatives/admin/initiative_sent_to_technical_validation_event.rb +1 -1
- data/app/events/decidim/initiatives/admin/support_threshold_reached_event.rb +1 -1
- data/app/events/decidim/initiatives/approve_membership_request_event.rb +12 -12
- data/app/events/decidim/initiatives/create_initiative_event.rb +6 -6
- data/app/events/decidim/initiatives/endorse_initiative_event.rb +1 -1
- data/app/events/decidim/initiatives/extend_initiative_event.rb +1 -1
- data/app/events/decidim/initiatives/initiative_sent_to_technical_validation_event.rb +1 -1
- data/app/events/decidim/initiatives/milestone_completed_event.rb +1 -1
- data/app/events/decidim/initiatives/revoke_membership_request_event.rb +12 -12
- data/app/events/decidim/initiatives/spawn_committee_request_event.rb +12 -12
- data/app/forms/decidim/initiatives/admin/initiative_form.rb +1 -1
- data/app/forms/decidim/initiatives/initiative_form.rb +22 -31
- data/app/forms/decidim/initiatives/previous_form.rb +4 -0
- data/app/forms/decidim/initiatives/vote_form.rb +11 -11
- data/app/helpers/decidim/initiatives/admin/initiatives_helper.rb +1 -1
- data/app/helpers/decidim/initiatives/application_helper.rb +4 -61
- data/app/helpers/decidim/initiatives/initiative_helper.rb +48 -5
- data/app/helpers/decidim/initiatives/initiatives_helper.rb +33 -12
- data/app/jobs/decidim/initiatives/export_initiatives_job.rb +1 -1
- data/app/models/decidim/initiative.rb +17 -20
- data/app/models/decidim/initiatives_vote.rb +1 -1
- data/app/packs/entrypoints/decidim_initiatives.js +3 -0
- data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_initiatives.svg +42 -1
- data/app/packs/src/decidim/initiatives/application.js +0 -1
- data/app/packs/src/decidim/initiatives/scoped_type.js +1 -1
- data/app/packs/stylesheets/decidim/initiatives/initiatives-votes.scss +21 -21
- data/app/packs/stylesheets/decidim/initiatives/print-initiative.scss +59 -31
- data/app/packs/stylesheets/initiatives.scss +171 -0
- data/app/permissions/decidim/initiatives/permissions.rb +3 -3
- data/app/presenters/decidim/initiatives/admin_log/initiative_presenter.rb +2 -2
- data/app/presenters/decidim/initiatives/admin_log/initiatives_settings_presenter.rb +2 -2
- data/app/presenters/decidim/initiatives/admin_log/initiatives_type_presenter.rb +2 -2
- data/app/queries/decidim/initiatives/organization_prioritized_initiatives.rb +1 -1
- data/app/queries/decidim/initiatives/similar_initiatives.rb +2 -2
- data/app/queries/decidim/initiatives/support_period_finished_initiatives.rb +1 -1
- data/app/queries/decidim/initiatives/user_authorizations.rb +1 -1
- data/app/services/decidim/initiatives/pdf_signature_example.rb +44 -52
- data/app/views/decidim/initiatives/_modal.html.erb +15 -0
- data/app/views/decidim/initiatives/admin/answers/_info_initiative.html.erb +21 -19
- data/app/views/decidim/initiatives/admin/answers/edit.html.erb +41 -27
- data/app/views/decidim/initiatives/admin/committee_requests/index.html.erb +41 -48
- data/app/views/decidim/initiatives/admin/exports/_dropdown.html.erb +8 -7
- data/app/views/decidim/initiatives/admin/initiatives/_form.html.erb +111 -95
- data/app/views/decidim/initiatives/admin/initiatives/_initiative_attachments.erb +7 -7
- data/app/views/decidim/initiatives/admin/initiatives/_signatures.html.erb +87 -0
- data/app/views/decidim/initiatives/admin/initiatives/edit.html.erb +72 -60
- data/app/views/decidim/initiatives/admin/initiatives/export_pdf_signatures.html.erb +8 -0
- data/app/views/decidim/initiatives/admin/initiatives/export_pdf_signatures.pdf.erb +5 -78
- data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +76 -75
- data/app/views/decidim/initiatives/admin/initiatives_settings/_form.html.erb +7 -8
- data/app/views/decidim/initiatives/admin/initiatives_settings/edit.html.erb +17 -5
- data/app/views/decidim/initiatives/admin/initiatives_type_scopes/_form.html.erb +11 -6
- data/app/views/decidim/initiatives/admin/initiatives_type_scopes/edit.html.erb +16 -22
- data/app/views/decidim/initiatives/admin/initiatives_type_scopes/new.html.erb +17 -15
- data/app/views/decidim/initiatives/admin/initiatives_types/_form.html.erb +93 -76
- data/app/views/decidim/initiatives/admin/initiatives_types/_initiative_type_scopes.html.erb +35 -33
- data/app/views/decidim/initiatives/admin/initiatives_types/edit.html.erb +16 -12
- data/app/views/decidim/initiatives/admin/initiatives_types/index.html.erb +39 -48
- data/app/views/decidim/initiatives/admin/initiatives_types/new.html.erb +16 -9
- data/app/views/decidim/initiatives/committee_requests/new.html.erb +21 -19
- data/app/views/decidim/initiatives/create_initiative/_share_committee_link.html.erb +15 -20
- data/app/views/decidim/initiatives/create_initiative/fill_data.html.erb +62 -100
- data/app/views/decidim/initiatives/create_initiative/finish.html.erb +24 -28
- data/app/views/decidim/initiatives/create_initiative/promotal_committee.html.erb +15 -17
- data/app/views/decidim/initiatives/create_initiative/select_initiative_type.html.erb +32 -46
- data/app/views/decidim/initiatives/initiative_signatures/_wizard_steps.html.erb +15 -19
- data/app/views/decidim/initiatives/initiative_signatures/fill_personal_data.html.erb +25 -36
- data/app/views/decidim/initiatives/initiative_signatures/finish.html.erb +5 -16
- data/app/views/decidim/initiatives/initiative_signatures/sms_code.html.erb +8 -19
- data/app/views/decidim/initiatives/initiative_signatures/sms_phone_number.html.erb +8 -20
- data/app/views/decidim/initiatives/initiatives/_committee_members.html.erb +48 -66
- data/app/views/decidim/initiatives/initiatives/_form.html.erb +49 -95
- data/app/views/decidim/initiatives/initiatives/_initiative_badge.html.erb +3 -5
- data/app/views/decidim/initiatives/initiatives/_initiative_hero.html.erb +13 -0
- data/app/views/decidim/initiatives/initiatives/_initiatives.html.erb +6 -15
- data/app/views/decidim/initiatives/initiatives/_interactions.html.erb +1 -1
- data/app/views/decidim/initiatives/initiatives/_new_initiative_button.html.erb +28 -0
- data/app/views/decidim/initiatives/initiatives/_progress_bar.html.erb +2 -6
- data/app/views/decidim/initiatives/initiatives/_result.html.erb +15 -21
- data/app/views/decidim/initiatives/initiatives/_send_to_technical_validation.html.erb +3 -3
- data/app/views/decidim/initiatives/initiatives/_tags_type.html.erb +1 -0
- data/app/views/decidim/initiatives/initiatives/_vote_button.html.erb +9 -9
- data/app/views/decidim/initiatives/initiatives/_vote_cabin.html.erb +7 -7
- data/app/views/decidim/initiatives/initiatives/edit.html.erb +63 -68
- data/app/views/decidim/initiatives/initiatives/index.html.erb +17 -18
- data/app/views/decidim/initiatives/initiatives/index.js.erb +0 -5
- data/app/views/decidim/initiatives/initiatives/print.html.erb +123 -120
- data/app/views/decidim/initiatives/initiatives/show.html.erb +188 -70
- data/app/views/decidim/initiatives/initiatives_mailer/notify_creation.html.erb +2 -2
- data/app/views/decidim/initiatives/initiatives_type_scopes/search.html.erb +2 -1
- data/app/views/decidim/initiatives/versions/show.html.erb +14 -5
- data/app/views/layouts/decidim/_initiative_creation_header.html.erb +17 -28
- data/app/views/layouts/decidim/_initiative_header.html.erb +3 -23
- data/app/views/layouts/decidim/_initiative_header_steps.html.erb +4 -12
- data/app/views/layouts/decidim/_initiative_signature_creation_header.html.erb +5 -26
- data/app/views/layouts/decidim/admin/initiative.html.erb +12 -13
- data/app/views/layouts/decidim/admin/initiatives.html.erb +40 -11
- data/app/views/layouts/decidim/initiative.html.erb +16 -11
- data/app/views/layouts/decidim/initiative_creation.html.erb +7 -18
- data/app/views/layouts/decidim/initiative_head.html.erb +15 -0
- data/app/views/layouts/decidim/initiative_signature_creation.html.erb +3 -11
- data/config/assets.rb +0 -1
- data/config/environment.rb +3 -0
- data/config/initializers/wicked_pdf.rb +1 -1
- data/config/locales/ar.yml +1 -92
- data/config/locales/ca.yml +65 -104
- data/config/locales/cs.yml +70 -109
- data/config/locales/de.yml +71 -110
- data/config/locales/el.yml +1 -97
- data/config/locales/en.yml +69 -108
- data/config/locales/es-MX.yml +65 -104
- data/config/locales/es-PY.yml +65 -104
- data/config/locales/es.yml +65 -104
- data/config/locales/eu.yml +171 -161
- data/config/locales/fi-plain.yml +67 -106
- data/config/locales/fi.yml +67 -106
- data/config/locales/fr-CA.yml +72 -106
- data/config/locales/fr.yml +70 -104
- data/config/locales/ga-IE.yml +0 -35
- data/config/locales/gl.yml +1 -87
- data/config/locales/hu.yml +25 -107
- data/config/locales/id-ID.yml +1 -88
- data/config/locales/is-IS.yml +1 -57
- data/config/locales/it.yml +6 -111
- data/config/locales/ja.yml +63 -109
- data/config/locales/lb.yml +6 -73
- data/config/locales/lt.yml +72 -101
- data/config/locales/lv.yml +1 -98
- data/config/locales/nl.yml +6 -103
- data/config/locales/no.yml +6 -114
- data/config/locales/pl.yml +11 -111
- data/config/locales/pt-BR.yml +21 -116
- data/config/locales/pt.yml +6 -111
- data/config/locales/ro-RO.yml +13 -108
- data/config/locales/ru.yml +1 -65
- data/config/locales/sk.yml +1 -84
- data/config/locales/sl.yml +3 -5
- data/config/locales/sq-AL.yml +1 -0
- data/config/locales/sv.yml +20 -107
- data/config/locales/th-TH.yml +1 -0
- data/config/locales/tr-TR.yml +9 -111
- data/config/locales/uk.yml +1 -65
- data/config/locales/zh-CN.yml +6 -102
- data/config/locales/zh-TW.yml +31 -97
- data/db/migrate/20171017091734_add_scopes_for_all_initiative_types.rb +1 -1
- data/db/migrate/20171017095143_update_initiative_scoped_type.rb +1 -1
- data/db/migrate/20191002082220_move_signature_type_to_initative_type.rb +1 -1
- data/lib/decidim/api/initiative_committee_member_type.rb +2 -2
- data/lib/decidim/initiatives/admin_engine.rb +13 -93
- data/lib/decidim/initiatives/content_blocks/registry_manager.rb +22 -0
- data/lib/decidim/initiatives/engine.rb +45 -23
- data/lib/decidim/initiatives/menu.rb +150 -0
- data/lib/decidim/initiatives/participatory_space.rb +6 -91
- data/lib/decidim/initiatives/query_extensions.rb +5 -5
- data/lib/decidim/initiatives/seeds.rb +95 -0
- data/lib/decidim/initiatives/test/factories.rb +25 -7
- data/lib/decidim/initiatives/version.rb +1 -1
- data/lib/decidim/initiatives.rb +1 -1
- data/lib/tasks/decidim_initiatives.rake +2 -2
- data/lib/tasks/initiatives/upgrade/decidim_initiatives_upgrade_tasks.rake +1 -1
- metadata +49 -75
- data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives/show.erb +0 -28
- data/app/cells/decidim/initiatives/initiative_m/author.erb +0 -10
- data/app/cells/decidim/initiatives/initiative_m/footer.erb +0 -28
- data/app/cells/decidim/initiatives/initiative_m/tags.erb +0 -9
- data/app/cells/decidim/initiatives/initiative_m_cell.rb +0 -77
- data/app/controllers/decidim/initiatives/widgets_controller.rb +0 -30
- data/app/packs/stylesheets/decidim/initiatives/admin.scss +0 -33
- data/app/packs/stylesheets/decidim/initiatives/initiatives.scss +0 -64
- data/app/packs/stylesheets/decidim/initiatives/popularity_item.scss +0 -76
- data/app/packs/stylesheets/decidim/initiatives/statistics.scss +0 -15
- data/app/views/decidim/initiatives/create_initiative/_finish_help.html.erb +0 -2
- data/app/views/decidim/initiatives/create_initiative/previous_form.html.erb +0 -40
- data/app/views/decidim/initiatives/create_initiative/show_similar_initiatives.html.erb +0 -23
- data/app/views/decidim/initiatives/initiatives/_author.html.erb +0 -35
- data/app/views/decidim/initiatives/initiatives/_count.html.erb +0 -1
- data/app/views/decidim/initiatives/initiatives/_filters.html.erb +0 -33
- data/app/views/decidim/initiatives/initiatives/_filters_small_view.html.erb +0 -18
- data/app/views/decidim/initiatives/initiatives/_index_header.html.erb +0 -44
- data/app/views/decidim/initiatives/initiatives/_tags.html.erb +0 -7
- data/app/views/decidim/initiatives/versions/index.html.erb +0 -8
- data/db/seeds/city.jpeg +0 -0
- data/db/seeds/city2.jpeg +0 -0
- data/lib/decidim/initiatives/initiatives_filter_form_builder.rb +0 -56
- data/lib/gem_overrides/origami/date.rb +0 -47
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Initiatives
|
@@ -9,35 +9,35 @@ module Decidim
|
|
9
9
|
def email_subject
|
10
10
|
I18n.t(
|
11
11
|
"decidim.initiatives.events.approve_membership_request.email_subject",
|
12
|
-
author_nickname:
|
12
|
+
author_nickname:
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
16
16
|
def email_intro
|
17
17
|
I18n.t(
|
18
18
|
"decidim.initiatives.events.approve_membership_request.email_intro",
|
19
|
-
resource_title
|
20
|
-
resource_url
|
21
|
-
author_profile_url
|
22
|
-
author_nickname:
|
19
|
+
resource_title:,
|
20
|
+
resource_url:,
|
21
|
+
author_profile_url:,
|
22
|
+
author_nickname:
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
26
26
|
def email_outro
|
27
27
|
I18n.t(
|
28
28
|
"decidim.initiatives.events.approve_membership_request.email_outro",
|
29
|
-
resource_title
|
30
|
-
resource_url:
|
29
|
+
resource_title:,
|
30
|
+
resource_url:
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
34
34
|
def notification_title
|
35
35
|
I18n.t(
|
36
36
|
"decidim.initiatives.events.approve_membership_request.notification_title",
|
37
|
-
resource_title
|
38
|
-
resource_url
|
39
|
-
author_profile_url
|
40
|
-
author_nickname:
|
37
|
+
resource_title:,
|
38
|
+
resource_url:,
|
39
|
+
author_profile_url:,
|
40
|
+
author_nickname:
|
41
41
|
).html_safe
|
42
42
|
end
|
43
43
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Initiatives
|
@@ -9,7 +9,7 @@ module Decidim
|
|
9
9
|
def email_subject
|
10
10
|
I18n.t(
|
11
11
|
"decidim.initiatives.events.create_initiative_event.email_subject",
|
12
|
-
resource_title
|
12
|
+
resource_title:,
|
13
13
|
author_nickname: author.nickname,
|
14
14
|
author_name: author.name
|
15
15
|
)
|
@@ -18,7 +18,7 @@ module Decidim
|
|
18
18
|
def email_intro
|
19
19
|
I18n.t(
|
20
20
|
"decidim.initiatives.events.create_initiative_event.email_intro",
|
21
|
-
resource_title
|
21
|
+
resource_title:,
|
22
22
|
author_nickname: author.nickname,
|
23
23
|
author_name: author.name
|
24
24
|
)
|
@@ -27,7 +27,7 @@ module Decidim
|
|
27
27
|
def email_outro
|
28
28
|
I18n.t(
|
29
29
|
"decidim.initiatives.events.create_initiative_event.email_outro",
|
30
|
-
resource_title
|
30
|
+
resource_title:,
|
31
31
|
author_nickname: author.nickname,
|
32
32
|
author_name: author.name
|
33
33
|
)
|
@@ -36,8 +36,8 @@ module Decidim
|
|
36
36
|
def notification_title
|
37
37
|
I18n.t(
|
38
38
|
"decidim.initiatives.events.create_initiative_event.notification_title",
|
39
|
-
resource_title
|
40
|
-
resource_path
|
39
|
+
resource_title:,
|
40
|
+
resource_path:,
|
41
41
|
author_nickname: author.nickname,
|
42
42
|
author_name: author.name,
|
43
43
|
author_path: author.profile_path
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Initiatives
|
@@ -9,35 +9,35 @@ module Decidim
|
|
9
9
|
def email_subject
|
10
10
|
I18n.t(
|
11
11
|
"decidim.initiatives.events.revoke_membership_request.email_subject",
|
12
|
-
author_nickname:
|
12
|
+
author_nickname:
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
16
16
|
def email_intro
|
17
17
|
I18n.t(
|
18
18
|
"decidim.initiatives.events.revoke_membership_request.email_intro",
|
19
|
-
resource_title
|
20
|
-
resource_url
|
21
|
-
author_profile_url
|
22
|
-
author_nickname:
|
19
|
+
resource_title:,
|
20
|
+
resource_url:,
|
21
|
+
author_profile_url:,
|
22
|
+
author_nickname:
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
26
26
|
def email_outro
|
27
27
|
I18n.t(
|
28
28
|
"decidim.initiatives.events.revoke_membership_request.email_outro",
|
29
|
-
resource_title
|
30
|
-
resource_url:
|
29
|
+
resource_title:,
|
30
|
+
resource_url:
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
34
34
|
def notification_title
|
35
35
|
I18n.t(
|
36
36
|
"decidim.initiatives.events.revoke_membership_request.notification_title",
|
37
|
-
resource_title
|
38
|
-
resource_url
|
39
|
-
author_profile_url
|
40
|
-
author_nickname:
|
37
|
+
resource_title:,
|
38
|
+
resource_url:,
|
39
|
+
author_profile_url:,
|
40
|
+
author_nickname:
|
41
41
|
).html_safe
|
42
42
|
end
|
43
43
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Initiatives
|
@@ -9,35 +9,35 @@ module Decidim
|
|
9
9
|
def email_subject
|
10
10
|
I18n.t(
|
11
11
|
"decidim.initiatives.events.spawn_committee_request_event.email_subject",
|
12
|
-
applicant_nickname:
|
12
|
+
applicant_nickname:
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
16
16
|
def email_intro
|
17
17
|
I18n.t(
|
18
18
|
"decidim.initiatives.events.spawn_committee_request_event.email_intro",
|
19
|
-
resource_title
|
20
|
-
resource_url
|
21
|
-
applicant_profile_url
|
22
|
-
applicant_nickname:
|
19
|
+
resource_title:,
|
20
|
+
resource_url:,
|
21
|
+
applicant_profile_url:,
|
22
|
+
applicant_nickname:
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
26
26
|
def email_outro
|
27
27
|
I18n.t(
|
28
28
|
"decidim.initiatives.events.spawn_committee_request_event.email_outro",
|
29
|
-
resource_title
|
30
|
-
resource_url:
|
29
|
+
resource_title:,
|
30
|
+
resource_url:
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
34
34
|
def notification_title
|
35
35
|
I18n.t(
|
36
36
|
"decidim.initiatives.events.spawn_committee_request_event.notification_title",
|
37
|
-
resource_title
|
38
|
-
resource_url
|
39
|
-
applicant_profile_url
|
40
|
-
applicant_nickname:
|
37
|
+
resource_title:,
|
38
|
+
resource_url:,
|
39
|
+
applicant_profile_url:,
|
40
|
+
applicant_nickname:
|
41
41
|
).html_safe
|
42
42
|
end
|
43
43
|
|
@@ -95,7 +95,7 @@ module Decidim
|
|
95
95
|
@type ||= type_id ? Decidim::InitiativesType.find(type_id) : context.initiative.type
|
96
96
|
end
|
97
97
|
|
98
|
-
# This method will add an error to the `attachment` field only if there
|
98
|
+
# This method will add an error to the `attachment` field only if there is
|
99
99
|
# any error in any other field. This is needed because when the form has
|
100
100
|
# an error, the attachment is lost, so we need a way to inform the user of
|
101
101
|
# this problem.
|
@@ -3,16 +3,12 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Initiatives
|
5
5
|
# A form object used to collect the data for a new initiative.
|
6
|
-
class InitiativeForm <
|
6
|
+
class InitiativeForm < PreviousForm
|
7
7
|
include TranslatableAttributes
|
8
8
|
include AttachmentAttributes
|
9
9
|
|
10
10
|
mimic :initiative
|
11
11
|
|
12
|
-
attribute :title, String
|
13
|
-
attribute :description, String
|
14
|
-
attribute :type_id, Integer
|
15
|
-
attribute :scope_id, Integer
|
16
12
|
attribute :area_id, Integer
|
17
13
|
attribute :decidim_user_group_id, Integer
|
18
14
|
attribute :signature_type, String
|
@@ -20,18 +16,16 @@ module Decidim
|
|
20
16
|
attribute :state, String
|
21
17
|
attribute :attachment, AttachmentForm
|
22
18
|
attribute :hashtag, String
|
19
|
+
attribute :scope_id, Integer
|
23
20
|
|
24
21
|
attachments_attribute :photos
|
25
22
|
attachments_attribute :documents
|
26
23
|
|
27
|
-
validates :title, :description, presence: true
|
28
|
-
validates :title, length: { maximum: 150 }
|
29
24
|
validates :signature_type, presence: true
|
30
|
-
validates :type_id, presence: true
|
31
25
|
validates :area, presence: true, if: ->(form) { form.area_id.present? }
|
32
|
-
validate :scope_exists
|
33
26
|
validate :notify_missing_attachment_if_errored
|
34
27
|
validate :trigger_attachment_errors
|
28
|
+
validate :scope_exists
|
35
29
|
validates :signature_end_date, date: { after: Date.current }, if: lambda { |form|
|
36
30
|
form.context.initiative_type.custom_signature_end_date_enabled? && form.signature_end_date.present?
|
37
31
|
}
|
@@ -39,7 +33,8 @@ module Decidim
|
|
39
33
|
def map_model(model)
|
40
34
|
self.type_id = model.type.id
|
41
35
|
self.scope_id = model.scope&.id
|
42
|
-
self.
|
36
|
+
self.decidim_user_group_id = model.decidim_user_group_id
|
37
|
+
self.signature_type = model.signature_type || initiative_type.signature_type
|
43
38
|
self.title = translated_attribute(model.title)
|
44
39
|
self.description = translated_attribute(model.description)
|
45
40
|
end
|
@@ -56,12 +51,6 @@ module Decidim
|
|
56
51
|
@area_updatable ||= current_user.admin? || context.initiative.created?
|
57
52
|
end
|
58
53
|
|
59
|
-
def scope_id
|
60
|
-
return nil if initiative_type.only_global_scope_enabled?
|
61
|
-
|
62
|
-
super.presence
|
63
|
-
end
|
64
|
-
|
65
54
|
def area
|
66
55
|
@area ||= current_organization.areas.find_by(id: area_id)
|
67
56
|
end
|
@@ -70,37 +59,39 @@ module Decidim
|
|
70
59
|
@initiative_type ||= type_id ? InitiativesType.find(type_id) : context.initiative.type
|
71
60
|
end
|
72
61
|
|
73
|
-
def
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
initiative_type.scopes
|
78
|
-
end
|
62
|
+
def scoped_type_id
|
63
|
+
return unless type && scope_id
|
64
|
+
|
65
|
+
type.scopes.find_by(decidim_scopes_id: scope_id.presence).id
|
79
66
|
end
|
80
67
|
|
81
68
|
def scope
|
82
69
|
@scope ||= Scope.find(scope_id) if scope_id.present?
|
83
70
|
end
|
84
71
|
|
85
|
-
def
|
86
|
-
return
|
72
|
+
def scope_id
|
73
|
+
return nil if type.only_global_scope_enabled?
|
87
74
|
|
88
|
-
|
75
|
+
super.presence
|
89
76
|
end
|
90
77
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
78
|
+
def available_scopes
|
79
|
+
@available_scopes ||= if type.only_global_scope_enabled?
|
80
|
+
type.scopes.where(scope: nil)
|
81
|
+
else
|
82
|
+
type.scopes
|
83
|
+
end
|
95
84
|
end
|
96
85
|
|
86
|
+
private
|
87
|
+
|
97
88
|
def scope_exists
|
98
89
|
return if scope_id.blank?
|
99
90
|
|
100
|
-
errors.add(:scope_id, :invalid) unless InitiativesTypeScope.exists?(type
|
91
|
+
errors.add(:scope_id, :invalid) unless InitiativesTypeScope.exists?(type:, scope:)
|
101
92
|
end
|
102
93
|
|
103
|
-
# This method will add an error to the `attachment` field only if there
|
94
|
+
# This method will add an error to the `attachment` field only if there is
|
104
95
|
# any error in any other field. This is needed because when the form has
|
105
96
|
# an error, the attachment is lost, so we need a way to inform the user of
|
106
97
|
# this problem.
|
@@ -15,6 +15,10 @@ module Decidim
|
|
15
15
|
validates :title, :description, presence: true
|
16
16
|
validates :title, length: { maximum: 150 }
|
17
17
|
validates :type_id, presence: true
|
18
|
+
|
19
|
+
def type
|
20
|
+
@type ||= type_id ? Decidim::InitiativesType.find(type_id) : context.initiative.type
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|
@@ -109,10 +109,10 @@ module Decidim
|
|
109
109
|
|
110
110
|
def metadata
|
111
111
|
{
|
112
|
-
name_and_surname
|
113
|
-
document_number
|
114
|
-
date_of_birth
|
115
|
-
postal_code:
|
112
|
+
name_and_surname:,
|
113
|
+
document_number:,
|
114
|
+
date_of_birth:,
|
115
|
+
postal_code:
|
116
116
|
}
|
117
117
|
end
|
118
118
|
|
@@ -137,9 +137,9 @@ module Decidim
|
|
137
137
|
errors.add(:document_number, :invalid) unless authorized? && authorization_handler && authorization.unique_id == authorization_handler.unique_id
|
138
138
|
end
|
139
139
|
|
140
|
-
# Private: Checks if there
|
140
|
+
# Private: Checks if there is any existing vote that matches the user's data.
|
141
141
|
def already_voted?
|
142
|
-
errors.add(:document_number, :taken) if initiative.votes.exists?(hash_id
|
142
|
+
errors.add(:document_number, :taken) if initiative.votes.exists?(hash_id:, scope:)
|
143
143
|
end
|
144
144
|
|
145
145
|
def author
|
@@ -158,7 +158,7 @@ module Decidim
|
|
158
158
|
).first
|
159
159
|
end
|
160
160
|
|
161
|
-
# Private: Checks if the authorization
|
161
|
+
# Private: Checks if the authorization has not expired or is invalid.
|
162
162
|
def authorized?
|
163
163
|
authorization_status&.first == :ok
|
164
164
|
end
|
@@ -180,10 +180,10 @@ module Decidim
|
|
180
180
|
return unless document_number && handler_name
|
181
181
|
|
182
182
|
@authorization_handler ||= Decidim::AuthorizationHandler.handler_for(handler_name,
|
183
|
-
document_number
|
184
|
-
name_and_surname
|
185
|
-
date_of_birth
|
186
|
-
postal_code:
|
183
|
+
document_number:,
|
184
|
+
name_and_surname:,
|
185
|
+
date_of_birth:,
|
186
|
+
postal_code:)
|
187
187
|
end
|
188
188
|
|
189
189
|
# Private: The AuthorizationHandler name used to verify the user's
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
module InitiativesHelper
|
7
7
|
def export_dropdown(collection_ids = nil)
|
8
|
-
render partial: "decidim/initiatives/admin/exports/dropdown", locals: { collection_ids:
|
8
|
+
render partial: "decidim/initiatives/admin/exports/dropdown", locals: { collection_ids: }
|
9
9
|
end
|
10
10
|
|
11
11
|
def export_dropdowns(query)
|
@@ -6,6 +6,8 @@ module Decidim
|
|
6
6
|
#
|
7
7
|
module ApplicationHelper
|
8
8
|
include Decidim::CheckBoxesTreeHelper
|
9
|
+
include Decidim::DateRangeHelper
|
10
|
+
include InitiativesHelper
|
9
11
|
|
10
12
|
def filter_states_values
|
11
13
|
TreeNode.new(
|
@@ -24,35 +26,6 @@ module Decidim
|
|
24
26
|
)
|
25
27
|
end
|
26
28
|
|
27
|
-
def filter_scopes_values
|
28
|
-
main_scopes = current_organization.scopes.top_level
|
29
|
-
|
30
|
-
scopes_values = main_scopes.includes(:scope_type, :children).flat_map do |scope|
|
31
|
-
TreeNode.new(
|
32
|
-
TreePoint.new(scope.id.to_s, translated_attribute(scope.name, current_organization)),
|
33
|
-
scope_children_to_tree(scope)
|
34
|
-
)
|
35
|
-
end
|
36
|
-
|
37
|
-
scopes_values.prepend(TreePoint.new("global", t("decidim.scopes.global")))
|
38
|
-
|
39
|
-
TreeNode.new(
|
40
|
-
TreePoint.new("", t("decidim.initiatives.application_helper.filter_scope_values.all")),
|
41
|
-
scopes_values
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
def scope_children_to_tree(scope)
|
46
|
-
return unless scope.children.any?
|
47
|
-
|
48
|
-
scope.children.includes(:scope_type, :children).flat_map do |child|
|
49
|
-
TreeNode.new(
|
50
|
-
TreePoint.new(child.id.to_s, translated_attribute(child.name, current_organization)),
|
51
|
-
scope_children_to_tree(child)
|
52
|
-
)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
29
|
def filter_types_values
|
57
30
|
types_values = Decidim::InitiativesType.where(organization: current_organization).map do |type|
|
58
31
|
TreeNode.new(
|
@@ -66,38 +39,8 @@ module Decidim
|
|
66
39
|
)
|
67
40
|
end
|
68
41
|
|
69
|
-
def
|
70
|
-
|
71
|
-
|
72
|
-
areas_values = if areas_or_types.first.is_a?(Decidim::Area)
|
73
|
-
filter_areas(areas_or_types)
|
74
|
-
else
|
75
|
-
filter_areas_and_types(areas_or_types)
|
76
|
-
end
|
77
|
-
|
78
|
-
TreeNode.new(
|
79
|
-
TreePoint.new("", t("decidim.initiatives.application_helper.filter_area_values.all")),
|
80
|
-
areas_values
|
81
|
-
)
|
82
|
-
end
|
83
|
-
|
84
|
-
def filter_areas(areas)
|
85
|
-
areas.map do |area|
|
86
|
-
TreeNode.new(
|
87
|
-
TreePoint.new(area.id.to_s, area.name[I18n.locale.to_s])
|
88
|
-
)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def filter_areas_and_types(area_types)
|
93
|
-
area_types.map do |area_type|
|
94
|
-
TreeNode.new(
|
95
|
-
TreePoint.new(area_type.area_ids.join("_"), area_type.name[I18n.locale.to_s]),
|
96
|
-
area_type.areas.map do |area|
|
97
|
-
TreePoint.new(area.id.to_s, area.name[I18n.locale.to_s])
|
98
|
-
end
|
99
|
-
)
|
100
|
-
end
|
42
|
+
def component_name
|
43
|
+
(defined?(current_component) && translated_attribute(current_component&.name).presence) || t("decidim.admin.models.initiatives.fields.title")
|
101
44
|
end
|
102
45
|
end
|
103
46
|
end
|
@@ -19,6 +19,19 @@ module Decidim
|
|
19
19
|
"warning"
|
20
20
|
end
|
21
21
|
|
22
|
+
def metadata_badge_css_class(initiative)
|
23
|
+
case initiative
|
24
|
+
when "accepted", "published"
|
25
|
+
"success"
|
26
|
+
when "rejected", "discarded"
|
27
|
+
"alert"
|
28
|
+
when "validating"
|
29
|
+
"warning"
|
30
|
+
else
|
31
|
+
"muted"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
22
35
|
# Public: The state of an initiative in a way a human can understand.
|
23
36
|
#
|
24
37
|
# initiative - Decidim::Initiative.
|
@@ -85,22 +98,42 @@ module Decidim
|
|
85
98
|
initiative.percentage >= 100
|
86
99
|
end
|
87
100
|
|
88
|
-
def
|
101
|
+
def authorized_create_modal_button(type, html_options, &)
|
102
|
+
tag = "button"
|
103
|
+
html_options ||= {}
|
104
|
+
|
105
|
+
if current_user
|
106
|
+
if action_authorized_to("create", permissions_holder: type).ok?
|
107
|
+
html_options["data-dialog-open"] = "not-authorized-modal"
|
108
|
+
else
|
109
|
+
html_options["data-dialog-open"] = "authorizationModal"
|
110
|
+
html_options["data-dialog-remote-url"] = authorization_create_modal_initiative_path(type)
|
111
|
+
end
|
112
|
+
else
|
113
|
+
html_options["data-dialog-open"] = "loginModal"
|
114
|
+
end
|
115
|
+
|
116
|
+
html_options["onclick"] = "event.preventDefault();"
|
117
|
+
|
118
|
+
send("#{tag}_to", "", html_options, &)
|
119
|
+
end
|
120
|
+
|
121
|
+
def authorized_vote_modal_button(initiative, html_options, &)
|
89
122
|
return if current_user && action_authorized_to("vote", resource: initiative, permissions_holder: initiative.type).ok?
|
90
123
|
|
91
124
|
tag = "button"
|
92
125
|
html_options ||= {}
|
93
126
|
|
94
127
|
if current_user
|
95
|
-
html_options["data-open"] = "authorizationModal"
|
96
|
-
html_options["data-
|
128
|
+
html_options["data-dialog-open"] = "authorizationModal"
|
129
|
+
html_options["data-dialog-remote-url"] = authorization_sign_modal_initiative_path(initiative)
|
97
130
|
else
|
98
|
-
html_options["data-open"] = "loginModal"
|
131
|
+
html_options["data-dialog-open"] = "loginModal"
|
99
132
|
end
|
100
133
|
|
101
134
|
html_options["onclick"] = "event.preventDefault();"
|
102
135
|
|
103
|
-
send("#{tag}_to", "", html_options, &
|
136
|
+
send("#{tag}_to", "", html_options, &)
|
104
137
|
end
|
105
138
|
|
106
139
|
def can_edit_custom_signature_end_date?(initiative)
|
@@ -114,6 +147,16 @@ module Decidim
|
|
114
147
|
|
115
148
|
initiative.created? || initiative.validating?
|
116
149
|
end
|
150
|
+
|
151
|
+
def render_committee_tooltip
|
152
|
+
with_tooltip t("decidim.initiatives.create_initiative.share_committee_link.invite_to_committee_help"), class: "left" do
|
153
|
+
icon "file-copy-line"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def hero_background_path(initiative)
|
158
|
+
initiative.attachments.find(&:image?)&.url
|
159
|
+
end
|
117
160
|
end
|
118
161
|
end
|
119
162
|
end
|
@@ -4,18 +4,16 @@ module Decidim
|
|
4
4
|
module Initiatives
|
5
5
|
# Helper functions for initiatives views
|
6
6
|
module InitiativesHelper
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
yield form
|
18
|
-
end
|
7
|
+
# Items to display in the navigation of an initiative
|
8
|
+
def initiative_nav_items(participatory_space)
|
9
|
+
components = participatory_space.components.published.or(Decidim::Component.where(id: try(:current_component)))
|
10
|
+
|
11
|
+
components.map do |component|
|
12
|
+
{
|
13
|
+
name: translated_attribute(component.name),
|
14
|
+
url: main_component_path(component),
|
15
|
+
active: is_active_link?(main_component_path(component), :inclusive)
|
16
|
+
}
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
@@ -27,6 +25,29 @@ module Decidim
|
|
27
25
|
def filter_form_namespace
|
28
26
|
"filters_#{SecureRandom.uuid}"
|
29
27
|
end
|
28
|
+
|
29
|
+
# i18n-tasks-use t('decidim.initiatives.initiatives.filters.state')
|
30
|
+
# i18n-tasks-use t('decidim.initiatives.initiatives.filters.scope')
|
31
|
+
# i18n-tasks-use t('decidim.initiatives.initiatives.filters.type')
|
32
|
+
# i18n-tasks-use t('decidim.initiatives.initiatives.filters.area')
|
33
|
+
# i18n-tasks-use t('decidim.initiatives.initiatives.filters.author')
|
34
|
+
def filter_sections
|
35
|
+
sections = [
|
36
|
+
{ method: :with_any_state, collection: filter_states_values, label_scope: "decidim.initiatives.initiatives.filters", id: "state" },
|
37
|
+
{ method: :with_any_scope, collection: filter_global_scopes_values, label_scope: "decidim.initiatives.initiatives.filters", id: "scope" }
|
38
|
+
]
|
39
|
+
sections.append(method: :with_any_type, collection: filter_types_values, label_scope: "decidim.initiatives.initiatives.filters", id: "type") unless single_initiative_type?
|
40
|
+
sections.append(method: :with_any_area, collection: filter_areas_values, label_scope: "decidim.initiatives.initiatives.filters", id: "area")
|
41
|
+
sections.append(method: :author, collection: filter_author_values, label_scope: "decidim.initiatives.initiatives.filters", id: "author") if current_user
|
42
|
+
sections.reject { |item| item[:collection].blank? }
|
43
|
+
end
|
44
|
+
|
45
|
+
def filter_author_values
|
46
|
+
[
|
47
|
+
["any", t("any", scope: "decidim.initiatives.initiatives.filters")],
|
48
|
+
["myself", t("myself", scope: "decidim.initiatives.initiatives.filters")]
|
49
|
+
]
|
50
|
+
end
|
30
51
|
end
|
31
52
|
end
|
32
53
|
end
|
@@ -17,7 +17,7 @@ module Decidim
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def collection_to_export(ids, organization)
|
20
|
-
collection = Decidim::Initiative.where(organization:
|
20
|
+
collection = Decidim::Initiative.where(organization:)
|
21
21
|
|
22
22
|
collection = collection.where(id: ids) if ids.present?
|
23
23
|
|