decidim-core 0.14.4 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +20 -0
- data/app/assets/images/decidim/cc-badge.png +0 -0
- data/app/assets/images/decidim/gamification/badges/continuity.svg +73 -0
- data/app/assets/images/decidim/gamification/badges/followers.svg +115 -0
- data/app/assets/images/decidim/icons.svg +1 -0
- data/app/assets/javascripts/decidim/vizzs/areachart.js.es6 +186 -208
- data/app/assets/javascripts/decidim/vizzs/linechart.js.es6 +263 -0
- data/app/assets/javascripts/decidim/vizzs/metrics.js.es6 +36 -26
- data/app/assets/javascripts/decidim/vizzs/orgchart.js.es6 +3 -2
- data/app/assets/javascripts/decidim/vizzs/rowchart.js.es6 +324 -0
- data/app/assets/stylesheets/decidim/_decidim.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_cards.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_conference-diploma.scss +75 -0
- data/app/assets/stylesheets/decidim/modules/_conference-media.scss +44 -0
- data/app/assets/stylesheets/decidim/modules/_conference-programme.scss +5 -1
- data/app/assets/stylesheets/decidim/modules/_conference-registration.scss +34 -0
- data/app/assets/stylesheets/decidim/modules/_list-request.scss +16 -0
- data/app/assets/stylesheets/decidim/modules/_modules.scss +4 -4
- data/app/assets/stylesheets/decidim/modules/_process-phase.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_reveal.scss +6 -1
- data/app/assets/stylesheets/decidim/utils/_helpers.scss +1 -1
- data/app/assets/stylesheets/decidim/{modules → vizzs}/_areachart.scss +8 -11
- data/app/assets/stylesheets/decidim/{modules → vizzs}/_chart-tooltip.scss +0 -0
- data/app/assets/stylesheets/decidim/vizzs/_linechart.scss +115 -0
- data/app/assets/stylesheets/decidim/vizzs/_rowchart.scss +77 -0
- data/app/cells/decidim/activities/show.erb +3 -0
- data/app/cells/decidim/activities_cell.rb +38 -0
- data/app/cells/decidim/activity/show.erb +21 -0
- data/app/cells/decidim/activity_cell.rb +85 -0
- data/app/cells/decidim/address/details.erb +7 -0
- data/app/cells/decidim/address/show.erb +14 -0
- data/app/cells/decidim/address_cell.rb +19 -0
- data/app/cells/decidim/author/contact.erb +1 -1
- data/app/cells/decidim/author_cell.rb +1 -0
- data/app/cells/decidim/badge/show.erb +2 -2
- data/app/cells/decidim/badge/small.erb +5 -0
- data/app/cells/decidim/badge_cell.rb +36 -14
- data/app/cells/decidim/badges/show.erb +6 -3
- data/app/cells/decidim/badges_cell.rb +4 -4
- data/app/cells/decidim/coauthorships_cell.rb +8 -2
- data/app/cells/decidim/collapsible_authors/show.erb +9 -7
- data/app/cells/decidim/content_blocks/html/show.erb +3 -0
- data/app/cells/decidim/content_blocks/html_cell.rb +11 -0
- data/app/cells/decidim/content_blocks/html_settings_form/show.erb +3 -0
- data/app/cells/decidim/content_blocks/html_settings_form_cell.rb +17 -0
- data/app/cells/decidim/content_blocks/last_activity/show.erb +17 -0
- data/app/cells/decidim/content_blocks/last_activity_cell.rb +60 -0
- data/app/cells/decidim/content_blocks/metrics/show.erb +13 -0
- data/app/cells/decidim/content_blocks/metrics_cell.rb +18 -0
- data/app/cells/decidim/content_blocks/stats/show.erb +2 -1
- data/app/cells/decidim/groups/show.erb +10 -0
- data/app/cells/decidim/groups_cell.rb +19 -0
- data/app/cells/decidim/members/show.erb +9 -0
- data/app/cells/decidim/members_cell.rb +32 -0
- data/app/cells/decidim/profile/show.erb +3 -11
- data/app/cells/decidim/profile/user_group_tabs.erb +5 -0
- data/app/cells/decidim/profile/user_tabs.erb +12 -0
- data/app/cells/decidim/profile_cell.rb +7 -2
- data/app/cells/decidim/profile_sidebar/show.erb +108 -23
- data/app/cells/decidim/profile_sidebar_cell.rb +36 -2
- data/app/cells/decidim/user_group_admin_membership_profile/footer.erb +29 -0
- data/app/cells/decidim/user_group_admin_membership_profile_cell.rb +14 -0
- data/app/cells/decidim/user_group_membership_profile/tags.erb +1 -0
- data/app/cells/decidim/user_group_membership_profile_cell.rb +8 -0
- data/app/cells/decidim/user_group_pending_invitations_list/show.erb +23 -0
- data/app/cells/decidim/user_group_pending_invitations_list_cell.rb +26 -0
- data/app/cells/decidim/user_group_pending_requests_list/show.erb +23 -0
- data/app/cells/decidim/user_group_pending_requests_list_cell.rb +26 -0
- data/app/cells/decidim/user_profile/header.erb +1 -1
- data/app/cells/decidim/user_profile_cell.rb +15 -9
- data/app/commands/decidim/accept_group_invitation.rb +43 -0
- data/app/commands/decidim/accept_user_group_join_request.rb +53 -0
- data/app/commands/decidim/create_follow.rb +6 -0
- data/app/commands/decidim/create_registration.rb +13 -23
- data/app/commands/decidim/create_user_group.rb +57 -0
- data/app/commands/decidim/delete_follow.rb +7 -0
- data/app/commands/decidim/demote_membership.rb +57 -0
- data/app/commands/decidim/destroy_account.rb +6 -0
- data/app/commands/decidim/invite_user.rb +1 -3
- data/app/commands/decidim/invite_user_to_group.rb +62 -0
- data/app/commands/decidim/join_user_group.rb +63 -0
- data/app/commands/decidim/leave_user_group.rb +41 -0
- data/app/commands/decidim/promote_membership.rb +55 -0
- data/app/commands/decidim/reject_group_invitation.rb +42 -0
- data/app/commands/decidim/reject_user_group_join_request.rb +53 -0
- data/app/commands/decidim/remove_user_from_group.rb +53 -0
- data/app/commands/decidim/update_user_group.rb +53 -0
- data/app/controllers/concerns/decidim/locale_switcher.rb +3 -3
- data/app/controllers/concerns/decidim/paginable.rb +1 -0
- data/app/controllers/decidim/application_controller.rb +7 -0
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +1 -1
- data/app/controllers/decidim/devise/sessions_controller.rb +1 -1
- data/app/controllers/decidim/gamification/badges_controller.rb +11 -0
- data/app/controllers/decidim/group_admins_controller.rb +41 -0
- data/app/controllers/decidim/group_invites_controller.rb +74 -0
- data/app/controllers/decidim/group_members_controller.rb +59 -0
- data/app/controllers/decidim/groups_controller.rb +85 -0
- data/app/controllers/decidim/last_activities_controller.rb +46 -0
- data/app/controllers/decidim/pages_controller.rb +9 -1
- data/app/controllers/decidim/profiles_controller.rb +35 -5
- data/app/controllers/decidim/user_group_join_requests_controller.rb +69 -0
- data/app/events/decidim/demoted_membership_event.rb +28 -0
- data/app/events/decidim/invited_to_group_event.rb +33 -0
- data/app/events/decidim/join_request_accepted_event.rb +28 -0
- data/app/events/decidim/join_request_created_event.rb +28 -0
- data/app/events/decidim/join_request_rejected_event.rb +28 -0
- data/app/events/decidim/promoted_to_admin_event.rb +28 -0
- data/app/events/decidim/removed_from_group_event.rb +28 -0
- data/app/forms/decidim/account_form.rb +1 -1
- data/app/forms/decidim/invite_user_to_group_form.rb +29 -0
- data/app/forms/decidim/notifications_settings_form.rb +4 -0
- data/app/forms/decidim/registration_form.rb +0 -27
- data/app/forms/decidim/user_group_form.rb +81 -0
- data/app/helpers/decidim/component_path_helper.rb +10 -0
- data/app/helpers/decidim/filters_helper.rb +3 -2
- data/app/helpers/decidim/icon_helper.rb +3 -1
- data/app/helpers/decidim/map_helper.rb +1 -1
- data/app/jobs/decidim/metric_job.rb +14 -0
- data/app/mailers/decidim/newsletter_mailer.rb +2 -0
- data/app/mailers/decidim/notification_mailer.rb +1 -1
- data/app/models/decidim/action_log.rb +66 -0
- data/app/models/decidim/coauthorship.rb +9 -0
- data/app/models/decidim/component.rb +5 -0
- data/app/models/decidim/continuity_badge_status.rb +9 -0
- data/app/models/decidim/gamification/badge_score.rb +1 -1
- data/app/models/decidim/messaging/message.rb +1 -0
- data/app/models/decidim/metric.rb +13 -0
- data/app/models/decidim/participatory_space_private_user.rb +4 -0
- data/app/models/decidim/user.rb +14 -38
- data/app/models/decidim/user_base_entity.rb +52 -0
- data/app/models/decidim/user_group.rb +48 -9
- data/app/models/decidim/user_group_membership.rb +8 -0
- data/app/permissions/decidim/permissions.rb +21 -0
- data/app/presenters/decidim/admin_log/organization_presenter.rb +0 -2
- data/app/presenters/decidim/admin_log/participatory_space_private_user_presenter.rb +38 -0
- data/app/presenters/decidim/metric_charts_presenter.rb +53 -0
- data/app/presenters/decidim/metric_object_presenter.rb +28 -0
- data/app/presenters/decidim/user_group_presenter.rb +16 -8
- data/app/presenters/decidim/user_presenter.rb +14 -0
- data/app/queries/decidim/metric_manage.rb +59 -0
- data/app/queries/decidim/metrics/users_metric_manage.rb +26 -0
- data/app/queries/decidim/user_groups/accepted_memberships.rb +36 -0
- data/app/queries/decidim/user_groups/accepted_user_groups.rb +38 -0
- data/app/queries/decidim/user_groups/accepted_users.rb +36 -0
- data/app/queries/decidim/user_groups/admin_memberships.rb +37 -0
- data/app/queries/decidim/user_groups/invited_memberships.rb +36 -0
- data/app/queries/decidim/user_groups/manageable_user_groups.rb +39 -0
- data/app/queries/decidim/user_groups/member_memberships.rb +37 -0
- data/app/resolvers/decidim/core/metric_resolver.rb +38 -0
- data/app/services/decidim/action_logger.rb +4 -2
- data/app/services/decidim/activity_search.rb +76 -0
- data/app/services/decidim/continuity_badge_tracker.rb +64 -0
- data/app/services/decidim/resource_search.rb +0 -1
- data/app/types/decidim/core/metric_history_type.rb +17 -0
- data/app/types/decidim/core/metric_type.rb +14 -0
- data/app/types/decidim/core/session_type.rb +1 -1
- data/app/types/decidim/core/user_group_type.rb +2 -2
- data/app/views/decidim/authorization_modals/show.html.erb +40 -27
- data/app/views/decidim/devise/registrations/new.html.erb +0 -19
- data/app/views/decidim/gamification/badges/index.html.erb +42 -0
- data/app/views/decidim/group_admins/index.html.erb +18 -0
- data/app/views/decidim/group_invites/index.html.erb +27 -0
- data/app/views/decidim/group_members/index.html.erb +19 -0
- data/app/views/decidim/groups/_form.html.erb +23 -0
- data/app/views/decidim/groups/edit.html.erb +26 -0
- data/app/views/decidim/groups/new.html.erb +26 -0
- data/app/views/decidim/last_activities/_activities.html.erb +13 -0
- data/app/views/decidim/last_activities/index.html.erb +18 -0
- data/app/views/decidim/last_activities/index.js.erb +6 -0
- data/app/views/decidim/profiles/show.html.erb +1 -1
- data/app/views/layouts/decidim/_user_menu.html.erb +0 -1
- data/app/views/layouts/decidim/_wrapper.html.erb +1 -1
- data/config/initializers/devise.rb +1 -1
- data/config/initializers/foundation_rails_helper.rb +1 -0
- data/config/locales/ca.yml +325 -32
- data/config/locales/de.yml +325 -32
- data/config/locales/en.yml +325 -32
- data/config/locales/es-PY.yml +325 -32
- data/config/locales/es.yml +325 -32
- data/config/locales/eu.yml +325 -32
- data/config/locales/fi.yml +330 -37
- data/config/locales/fr.yml +325 -32
- data/config/locales/gl.yml +325 -32
- data/config/locales/hu.yml +327 -34
- data/config/locales/it.yml +325 -32
- data/config/locales/nl.yml +325 -32
- data/config/locales/pl.yml +329 -32
- data/config/locales/pt-BR.yml +326 -33
- data/config/locales/pt.yml +325 -32
- data/config/locales/ru.yml +4 -33
- data/config/locales/sv.yml +346 -53
- data/config/locales/uk.yml +4 -33
- data/config/routes.rb +27 -1
- data/db/migrate/20170128112958_change_user_groups_verified_to_timestamp.rb +11 -0
- data/db/migrate/20180705134647_create_decidim_metrics.rb +16 -0
- data/db/migrate/20180730071851_add_core_content_blocks.rb +3 -3
- data/db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb +4 -2
- data/db/migrate/20180918072506_add_visibility_to_action_logs.rb +8 -0
- data/db/migrate/20181001124950_move_users_groups_to_users_table.rb +84 -0
- data/db/migrate/20181008102144_add_badge_switch_to_organizations.rb +8 -0
- data/db/migrate/20181010044613_create_decidim_continuity_badge_statuses.rb +11 -0
- data/db/migrate/20181011080252_add_roles_to_memberships.rb +24 -0
- data/db/migrate/20181016091601_make_authors_polymorphic.rb +31 -0
- data/db/migrate/20181029112820_fix_user_follows.rb +18 -0
- data/db/migrate/20181030090144_destroy_deleted_users_follows.rb +16 -0
- data/db/seeds.rb +18 -4
- data/lib/decidim/attributes.rb +1 -0
- data/lib/decidim/attributes/localized_date.rb +16 -0
- data/lib/decidim/attributes/time_with_zone.rb +3 -1
- data/lib/decidim/authorable.rb +5 -4
- data/lib/decidim/authorization_form_builder.rb +2 -2
- data/lib/decidim/coauthorable.rb +68 -18
- data/lib/decidim/content_block_manifest.rb +7 -0
- data/lib/decidim/content_processor.rb +17 -7
- data/lib/decidim/core.rb +12 -0
- data/lib/decidim/core/engine.rb +54 -6
- data/lib/decidim/core/test/factories.rb +63 -17
- data/lib/decidim/core/test/shared_examples/coauthorable.rb +27 -9
- data/lib/decidim/core/test/shared_examples/coauthorable_interface_examples.rb +2 -2
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/data_portability.rb +3 -1
- data/lib/decidim/data_portability_file_reader.rb +1 -1
- data/lib/decidim/events/author_event.rb +4 -1
- data/lib/decidim/events/coauthor_event.rb +4 -1
- data/lib/decidim/faker/localized.rb +5 -4
- data/lib/decidim/form_builder.rb +18 -17
- data/lib/decidim/gamification.rb +8 -2
- data/lib/decidim/gamification/badge.rb +34 -0
- data/lib/decidim/gamification/badge_scorer.rb +29 -14
- data/lib/decidim/gamification/badge_status.rb +2 -0
- data/lib/decidim/hashtaggable.rb +1 -1
- data/lib/decidim/manifest_registry.rb +5 -3
- data/lib/decidim/metric_manifest.rb +20 -0
- data/lib/decidim/metric_registry.rb +71 -0
- data/lib/decidim/participable.rb +1 -1
- data/lib/decidim/participatory_space_resourceable.rb +0 -1
- data/lib/decidim/query_extensions.rb +19 -0
- data/lib/decidim/resourceable.rb +1 -0
- data/lib/decidim/searchable.rb +2 -1
- data/lib/tasks/decidim_metrics_tasks.rake +41 -0
- data/lib/tasks/decidim_tasks.rake +1 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ca.js +1 -2
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.es.js +1 -2
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.fr.js +1 -2
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.gl.js +1 -2
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.pt.js +1 -2
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ru.js +1 -2
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.uk.js +1 -2
- data/vendor/assets/javascripts/form_datepicker.js.es6 +1 -11
- metadata +144 -23
- data/app/cells/decidim/invitations_toggle/content.erb +0 -1
- data/app/cells/decidim/invitations_toggle/label.erb +0 -1
- data/app/cells/decidim/invitations_toggle_cell.rb +0 -27
- data/app/cells/decidim/toggle/show.erb +0 -8
- data/app/cells/decidim/toggle_cell.rb +0 -42
- data/app/commands/decidim/invite_friends.rb +0 -48
- data/app/controllers/decidim/invitations_controller.rb +0 -32
- data/app/forms/decidim/invitations_form.rb +0 -37
- data/app/views/decidim/invitations/index.html.erb +0 -48
- data/app/views/devise/mailer/invite_friend.html.erb +0 -27
- data/app/views/devise/mailer/invite_friend.text.erb +0 -19
- data/lib/decidim/rectify_ext.rb +0 -32
@@ -7,7 +7,15 @@ require "decidim/participatory_processes/test/factories"
|
|
7
7
|
require "decidim/assemblies/test/factories"
|
8
8
|
require "decidim/comments/test/factories"
|
9
9
|
|
10
|
+
def generate_localized_title
|
11
|
+
Decidim::Faker::Localized.localized { generate(:title) }
|
12
|
+
end
|
13
|
+
|
10
14
|
FactoryBot.define do
|
15
|
+
sequence(:title) do |n|
|
16
|
+
"#{Faker::Lorem.sentence(3)} #{n}"
|
17
|
+
end
|
18
|
+
|
11
19
|
sequence(:name) do |n|
|
12
20
|
"#{Faker::Name.name} #{n}"
|
13
21
|
end
|
@@ -24,6 +32,10 @@ FactoryBot.define do
|
|
24
32
|
"user#{n}@example.org"
|
25
33
|
end
|
26
34
|
|
35
|
+
sequence(:user_group_email) do |n|
|
36
|
+
"usergroup#{n}@example.org"
|
37
|
+
end
|
38
|
+
|
27
39
|
sequence(:slug) do |n|
|
28
40
|
"#{Faker::Internet.slug(nil, "-")}-#{n}"
|
29
41
|
end
|
@@ -41,8 +53,8 @@ FactoryBot.define do
|
|
41
53
|
end
|
42
54
|
|
43
55
|
factory :category, class: "Decidim::Category" do
|
44
|
-
name {
|
45
|
-
description { Decidim::Faker::Localized.wrapped("<p>", "</p>") {
|
56
|
+
name { generate_localized_title }
|
57
|
+
description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
|
46
58
|
|
47
59
|
association :participatory_space, factory: :participatory_process
|
48
60
|
end
|
@@ -62,7 +74,7 @@ FactoryBot.define do
|
|
62
74
|
youtube_handler { Faker::Hipster.word }
|
63
75
|
github_handler { Faker::Hipster.word }
|
64
76
|
sequence(:host) { |n| "#{n}.lvh.me" }
|
65
|
-
description { Decidim::Faker::Localized.wrapped("<p>", "</p>") {
|
77
|
+
description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
|
66
78
|
favicon { Decidim::Dev.test_file("icon.png", "image/png") }
|
67
79
|
default_locale { Decidim.default_locale }
|
68
80
|
available_locales { Decidim.available_locales }
|
@@ -72,6 +84,7 @@ FactoryBot.define do
|
|
72
84
|
highlighted_content_banner_enabled { false }
|
73
85
|
enable_omnipresent_banner { false }
|
74
86
|
tos_version { Time.current }
|
87
|
+
badges_enabled { true }
|
75
88
|
|
76
89
|
trait :with_tos do
|
77
90
|
after(:create) do |organization|
|
@@ -93,6 +106,7 @@ FactoryBot.define do
|
|
93
106
|
avatar { Decidim::Dev.test_file("avatar.jpg", "image/jpeg") }
|
94
107
|
personal_url { Faker::Internet.url }
|
95
108
|
about { Faker::Lorem.paragraph(2) }
|
109
|
+
confirmation_sent_at { Time.current }
|
96
110
|
|
97
111
|
after(:create) do |user|
|
98
112
|
tos_page = Decidim::StaticPage.find_by(slug: "terms-and-conditions", organization: user.organization)
|
@@ -127,7 +141,7 @@ FactoryBot.define do
|
|
127
141
|
|
128
142
|
trait :officialized do
|
129
143
|
officialized_at { Time.current }
|
130
|
-
officialized_as {
|
144
|
+
officialized_as { generate_localized_title }
|
131
145
|
end
|
132
146
|
end
|
133
147
|
|
@@ -142,9 +156,16 @@ FactoryBot.define do
|
|
142
156
|
end
|
143
157
|
|
144
158
|
factory :user_group, class: "Decidim::UserGroup" do
|
159
|
+
transient do
|
160
|
+
document_number { Faker::Number.number(8) + "X" }
|
161
|
+
phone { Faker::PhoneNumber.phone_number }
|
162
|
+
rejected_at { nil }
|
163
|
+
verified_at { nil }
|
164
|
+
end
|
165
|
+
|
145
166
|
sequence(:name) { |n| "#{Faker::Company.name} #{n}" }
|
146
|
-
|
147
|
-
|
167
|
+
email { generate(:user_group_email) }
|
168
|
+
nickname { generate(:nickname) }
|
148
169
|
avatar { Decidim::Dev.test_file("avatar.jpg", "image/jpeg") }
|
149
170
|
organization
|
150
171
|
|
@@ -160,18 +181,31 @@ FactoryBot.define do
|
|
160
181
|
rejected_at { Time.current }
|
161
182
|
end
|
162
183
|
|
184
|
+
after(:build) do |user_group, evaluator|
|
185
|
+
user_group.extended_data = {
|
186
|
+
document_number: evaluator.document_number,
|
187
|
+
phone: evaluator.phone,
|
188
|
+
rejected_at: evaluator.rejected_at,
|
189
|
+
verified_at: evaluator.verified_at
|
190
|
+
}
|
191
|
+
end
|
192
|
+
|
163
193
|
after(:create) do |user_group, evaluator|
|
164
|
-
users = evaluator.users
|
194
|
+
users = evaluator.users.dup
|
165
195
|
next if users.empty?
|
166
196
|
|
197
|
+
creator = users.shift
|
198
|
+
create(:user_group_membership, user: creator, user_group: user_group, role: :creator)
|
199
|
+
|
167
200
|
users.each do |user|
|
168
|
-
create(:user_group_membership, user: user, user_group: user_group)
|
201
|
+
create(:user_group_membership, user: user, user_group: user_group, role: :admin)
|
169
202
|
end
|
170
203
|
end
|
171
204
|
end
|
172
205
|
|
173
206
|
factory :user_group_membership, class: "Decidim::UserGroupMembership" do
|
174
207
|
user
|
208
|
+
role { :creator }
|
175
209
|
user_group
|
176
210
|
end
|
177
211
|
|
@@ -199,8 +233,8 @@ FactoryBot.define do
|
|
199
233
|
|
200
234
|
factory :static_page, class: "Decidim::StaticPage" do
|
201
235
|
slug { generate(:slug) }
|
202
|
-
title {
|
203
|
-
content { Decidim::Faker::Localized.wrapped("<p>", "</p>") {
|
236
|
+
title { generate_localized_title }
|
237
|
+
content { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
|
204
238
|
organization
|
205
239
|
|
206
240
|
trait :default do
|
@@ -213,16 +247,16 @@ FactoryBot.define do
|
|
213
247
|
end
|
214
248
|
|
215
249
|
factory :attachment_collection, class: "Decidim::AttachmentCollection" do
|
216
|
-
name {
|
217
|
-
description {
|
250
|
+
name { generate_localized_title }
|
251
|
+
description { generate_localized_title }
|
218
252
|
weight { Faker::Number.number(1) }
|
219
253
|
|
220
254
|
association :collection_for, factory: :participatory_process
|
221
255
|
end
|
222
256
|
|
223
257
|
factory :attachment, class: "Decidim::Attachment" do
|
224
|
-
title {
|
225
|
-
description { Decidim::Faker::Localized.wrapped("<p>", "</p>") {
|
258
|
+
title { generate_localized_title }
|
259
|
+
description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
|
226
260
|
file { Decidim::Dev.test_file("city.jpeg", "image/jpeg") }
|
227
261
|
weight { Faker::Number.number(1) }
|
228
262
|
attached_to { build(:participatory_process) }
|
@@ -245,7 +279,7 @@ FactoryBot.define do
|
|
245
279
|
organization { create(:organization) }
|
246
280
|
end
|
247
281
|
|
248
|
-
name {
|
282
|
+
name { generate_localized_title }
|
249
283
|
participatory_space { create(:participatory_process, organization: organization) }
|
250
284
|
manifest_name { "dummy" }
|
251
285
|
published_at { Time.current }
|
@@ -316,9 +350,9 @@ FactoryBot.define do
|
|
316
350
|
author { build(:user, :confirmed, organization: organization) }
|
317
351
|
organization
|
318
352
|
|
319
|
-
subject {
|
353
|
+
subject { generate_localized_title }
|
320
354
|
|
321
|
-
body { Decidim::Faker::Localized.wrapped("<p>", "</p>") {
|
355
|
+
body { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
|
322
356
|
|
323
357
|
trait :sent do
|
324
358
|
sent_at { Time.current }
|
@@ -384,6 +418,7 @@ FactoryBot.define do
|
|
384
418
|
component { build :component, participatory_space: participatory_space }
|
385
419
|
resource { build(:dummy_resource, component: component) }
|
386
420
|
action { "create" }
|
421
|
+
visibility { "admin-only" }
|
387
422
|
extra do
|
388
423
|
{
|
389
424
|
component: {
|
@@ -449,4 +484,15 @@ FactoryBot.define do
|
|
449
484
|
name { generate(:hashtag_name) }
|
450
485
|
organization
|
451
486
|
end
|
487
|
+
|
488
|
+
factory :metric, class: "Decidim::Metric" do
|
489
|
+
organization
|
490
|
+
day { Time.zone.today }
|
491
|
+
metric_type { "random_metric" }
|
492
|
+
cumulative { 2 }
|
493
|
+
quantity { 1 }
|
494
|
+
category { create :category }
|
495
|
+
participatory_space { create :participatory_process, organization: organization }
|
496
|
+
related_object { create :component, participatory_space: participatory_space }
|
497
|
+
end
|
452
498
|
end
|
@@ -16,10 +16,17 @@ shared_examples_for "coauthorable" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
context "when there are many authors" do
|
19
|
-
before
|
19
|
+
before do
|
20
|
+
coauthorable.coauthorships.destroy_all
|
21
|
+
coauthorable.reload
|
22
|
+
|
23
|
+
other_authors.each do |author|
|
24
|
+
coauthorable.add_coauthor(author)
|
25
|
+
end
|
26
|
+
end
|
20
27
|
|
21
28
|
it "returns all coauthors" do
|
22
|
-
expect(coauthorable.authors).to
|
29
|
+
expect(coauthorable.reload.authors).to match_array(other_authors)
|
23
30
|
end
|
24
31
|
end
|
25
32
|
end
|
@@ -66,7 +73,10 @@ shared_examples_for "coauthorable" do
|
|
66
73
|
|
67
74
|
describe "authored by? user" do
|
68
75
|
context "when there are no coauthors" do
|
69
|
-
before
|
76
|
+
before do
|
77
|
+
coauthorable.coauthorships.clear
|
78
|
+
coauthorable.reload
|
79
|
+
end
|
70
80
|
|
71
81
|
it "returns false" do
|
72
82
|
expect(coauthorable.authored_by?(creator_author)).to be(false)
|
@@ -82,23 +92,31 @@ shared_examples_for "coauthorable" do
|
|
82
92
|
expect(coauthorable.authored_by?(creator_author)).to be(true)
|
83
93
|
end
|
84
94
|
end
|
85
|
-
|
86
|
-
context "when the checked user is one of the coauthors user_groups"
|
87
95
|
end
|
88
96
|
|
89
97
|
describe "identities" do
|
90
98
|
context "when there are no coauthors" do
|
91
|
-
before
|
99
|
+
before do
|
100
|
+
coauthorable.coauthorships.clear
|
101
|
+
coauthorable.reload
|
102
|
+
end
|
92
103
|
|
93
104
|
it "returns an empty list" do
|
105
|
+
expect(coauthorable.identities).to be_blank
|
94
106
|
end
|
95
107
|
end
|
96
108
|
|
97
109
|
context "when there are many coauthors of both types" do
|
98
110
|
before do
|
99
|
-
other_authors.each
|
111
|
+
other_authors.each do |author|
|
112
|
+
coauthorable.add_coauthor(author)
|
113
|
+
end
|
114
|
+
|
100
115
|
other_user_groups.each do |user_group|
|
101
|
-
|
116
|
+
coauthorable.add_coauthor(
|
117
|
+
user_group.memberships.first.user,
|
118
|
+
user_group: user_group
|
119
|
+
)
|
102
120
|
end
|
103
121
|
end
|
104
122
|
|
@@ -106,7 +124,7 @@ shared_examples_for "coauthorable" do
|
|
106
124
|
identities = [creator_author]
|
107
125
|
identities += other_authors
|
108
126
|
identities += other_user_groups
|
109
|
-
expect(coauthorable.identities.to_a).to
|
127
|
+
expect(coauthorable.identities.to_a).to match_array(identities)
|
110
128
|
end
|
111
129
|
end
|
112
130
|
end
|
@@ -9,7 +9,7 @@ shared_examples_for "coauthorable interface" do
|
|
9
9
|
describe "with a regular user" do
|
10
10
|
let(:query) { "{ author { name } }" }
|
11
11
|
|
12
|
-
it "
|
12
|
+
it "returns the user's name as the author name" do
|
13
13
|
expect(response["author"]["name"]).to eq(author.name)
|
14
14
|
end
|
15
15
|
end
|
@@ -23,7 +23,7 @@ shared_examples_for "coauthorable interface" do
|
|
23
23
|
coauthorship.update!(user_group: user_group)
|
24
24
|
end
|
25
25
|
|
26
|
-
it "includes the user's
|
26
|
+
it "includes returns the user group's name as the author name" do
|
27
27
|
expect(response["author"]["name"]).to eq(user_group.name)
|
28
28
|
end
|
29
29
|
end
|
data/lib/decidim/core/version.rb
CHANGED
@@ -11,7 +11,9 @@ module Decidim
|
|
11
11
|
# Returns a collection scoped by user.
|
12
12
|
# This is the default, if you want, you can overwrite in each Class to be export.
|
13
13
|
def self.user_collection(user)
|
14
|
-
|
14
|
+
return unless user.is_a?(Decidim::User)
|
15
|
+
|
16
|
+
where(decidim_author_id: user.id, decidim_author_type: "Decidim::UserBaseEntity")
|
15
17
|
end
|
16
18
|
|
17
19
|
# Returns a Default export serializer
|
@@ -29,7 +29,7 @@ module Decidim
|
|
29
29
|
# Returns a String with the absolute file_path to be read or generate.
|
30
30
|
def file_path
|
31
31
|
directory_name = Rails.root.join(Decidim::DataPortabilityUploader.new.store_dir)
|
32
|
-
|
32
|
+
FileUtils.mkdir_p(directory_name) unless File.exist?(directory_name)
|
33
33
|
directory_name + file_name
|
34
34
|
end
|
35
35
|
|
@@ -34,7 +34,10 @@ module Decidim
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def author
|
37
|
-
|
37
|
+
return unless resource.respond_to?(:creator_author)
|
38
|
+
return unless resource.creator_author.is_a?(Decidim::UserBaseEntity)
|
39
|
+
|
40
|
+
resource.creator_author
|
38
41
|
end
|
39
42
|
end
|
40
43
|
end
|
@@ -135,7 +135,7 @@ module Decidim
|
|
135
135
|
end.with_indifferent_access
|
136
136
|
end
|
137
137
|
|
138
|
-
# Wrapps a text build by the block with some other text.
|
138
|
+
# Wrapps a text build by the block with some other text.
|
139
139
|
#
|
140
140
|
# before - The String text to inject at the begining of each value.
|
141
141
|
# after - The String text to inject at the end of each value.
|
@@ -155,7 +155,10 @@ module Decidim
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
-
#
|
158
|
+
# Runs the given block for each of the available locales in Decidim,
|
159
|
+
# momentarilly setting the locale to the current one.
|
160
|
+
#
|
161
|
+
# Returns a Hash with a value for each locale.
|
159
162
|
def self.localized
|
160
163
|
Decidim.available_locales.inject({}) do |result, locale|
|
161
164
|
text = ::Faker::Base.with_locale(locale) do
|
@@ -165,8 +168,6 @@ module Decidim
|
|
165
168
|
result.update(locale => text)
|
166
169
|
end.with_indifferent_access
|
167
170
|
end
|
168
|
-
|
169
|
-
private_class_method :localized
|
170
171
|
end
|
171
172
|
end
|
172
173
|
end
|
data/lib/decidim/form_builder.rb
CHANGED
@@ -257,20 +257,19 @@ module Decidim
|
|
257
257
|
def date_field(attribute, options = {})
|
258
258
|
value = object.send(attribute)
|
259
259
|
data = { datepicker: "" }
|
260
|
-
data[:startdate] = I18n.localize(value, format: :
|
261
|
-
|
260
|
+
data[:startdate] = I18n.localize(value, format: :decidim_short) if value.present? && value.is_a?(Date)
|
261
|
+
datepicker_format = ruby_format_to_datepicker(I18n.t("date.formats.decidim_short"))
|
262
|
+
data[:"date-format"] = datepicker_format
|
262
263
|
|
263
264
|
template = ""
|
264
265
|
template += label(attribute, label_for(attribute) + required_for_attribute(attribute))
|
265
266
|
template += @template.text_field(
|
266
267
|
@object_name,
|
267
268
|
attribute,
|
268
|
-
options.merge(
|
269
|
-
id: "date_field_#{@object_name}_#{attribute}",
|
270
|
-
data: data)
|
269
|
+
options.merge(data: data)
|
271
270
|
)
|
272
|
-
|
273
|
-
template += error_and_help_text(attribute, options)
|
271
|
+
help_text = I18n.t("decidim.datepicker.help_text", datepicker_format: datepicker_format)
|
272
|
+
template += error_and_help_text(attribute, options.merge(help_text: help_text))
|
274
273
|
template.html_safe
|
275
274
|
end
|
276
275
|
|
@@ -278,22 +277,20 @@ module Decidim
|
|
278
277
|
# datepicker library
|
279
278
|
def datetime_field(attribute, options = {})
|
280
279
|
value = object.send(attribute)
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
280
|
+
data = { datepicker: "", timepicker: "" }
|
281
|
+
data[:startdate] = I18n.localize(value, format: :decidim_short) if value.present? && value.is_a?(ActiveSupport::TimeWithZone)
|
282
|
+
datepicker_format = ruby_format_to_datepicker(I18n.t("time.formats.decidim_short"))
|
283
|
+
data[:"date-format"] = datepicker_format
|
284
|
+
|
285
285
|
template = ""
|
286
286
|
template += label(attribute, label_for(attribute) + required_for_attribute(attribute))
|
287
287
|
template += @template.text_field(
|
288
288
|
@object_name,
|
289
289
|
attribute,
|
290
|
-
options.merge(
|
291
|
-
name: nil,
|
292
|
-
id: "datetime_field_#{@object_name}_#{attribute}",
|
293
|
-
data: { datepicker: "", timepicker: "" })
|
290
|
+
options.merge(data: data)
|
294
291
|
)
|
295
|
-
|
296
|
-
template += error_and_help_text(attribute, options)
|
292
|
+
help_text = I18n.t("decidim.datepicker.help_text", datepicker_format: datepicker_format)
|
293
|
+
template += error_and_help_text(attribute, options.merge(help_text: help_text))
|
297
294
|
template.html_safe
|
298
295
|
end
|
299
296
|
|
@@ -605,5 +602,9 @@ module Decidim
|
|
605
602
|
selected = Decidim::Scope.where(id: selected.map(&:to_i)) unless selected.first.is_a?(Decidim::Scope)
|
606
603
|
selected
|
607
604
|
end
|
605
|
+
|
606
|
+
def ruby_format_to_datepicker(ruby_date_format)
|
607
|
+
ruby_date_format.gsub("%d", "dd").gsub("%m", "mm").gsub("%Y", "yyyy").gsub("%H", "hh").gsub("%M", "ii")
|
608
|
+
end
|
608
609
|
end
|
609
610
|
end
|
data/lib/decidim/gamification.rb
CHANGED
@@ -14,6 +14,7 @@ module Decidim
|
|
14
14
|
#
|
15
15
|
# Returns a `BadgeStatus` instance.
|
16
16
|
def self.status_for(user, badge_name)
|
17
|
+
return unless user.is_a?(Decidim::UserBaseEntity)
|
17
18
|
BadgeStatus.new(user, find_badge(badge_name))
|
18
19
|
end
|
19
20
|
|
@@ -25,6 +26,8 @@ module Decidim
|
|
25
26
|
#
|
26
27
|
# Returns nothing.
|
27
28
|
def self.increment_score(user, badge_name, amount = 1)
|
29
|
+
return unless amount.positive?
|
30
|
+
return unless user.is_a?(Decidim::UserBaseEntity)
|
28
31
|
BadgeScorer.new(user, find_badge(badge_name)).increment(amount)
|
29
32
|
end
|
30
33
|
|
@@ -36,6 +39,8 @@ module Decidim
|
|
36
39
|
#
|
37
40
|
# Returns nothing.
|
38
41
|
def self.decrement_score(user, badge_name, amount = 1)
|
42
|
+
return unless amount.positive?
|
43
|
+
return unless user.is_a?(Decidim::UserBaseEntity)
|
39
44
|
BadgeScorer.new(user, find_badge(badge_name)).decrement(amount)
|
40
45
|
end
|
41
46
|
|
@@ -47,6 +52,7 @@ module Decidim
|
|
47
52
|
#
|
48
53
|
# Returns nothing.
|
49
54
|
def self.set_score(user, badge_name, score)
|
55
|
+
return unless user.is_a?(Decidim::UserBaseEntity)
|
50
56
|
BadgeScorer.new(user, find_badge(badge_name)).set(score)
|
51
57
|
end
|
52
58
|
|
@@ -91,14 +97,14 @@ module Decidim
|
|
91
97
|
#
|
92
98
|
# Returns nothing.
|
93
99
|
def self.reset_badges(users = nil)
|
94
|
-
|
100
|
+
return reset_badges(User.all) && reset_badges(UserGroup.all) unless users
|
95
101
|
|
96
102
|
badges.each do |badge|
|
97
103
|
Rails.logger.info "Resetting #{badge.name}..."
|
98
104
|
|
99
105
|
if badge.reset
|
100
106
|
users.find_each do |user|
|
101
|
-
set_score(user, badge.name, badge.reset.call(user))
|
107
|
+
set_score(user, badge.name, badge.reset.call(user)) if badge.valid_for?(user)
|
102
108
|
end
|
103
109
|
else
|
104
110
|
Rails.logger.info "Badge can't be reset since it doesn't have a reset method."
|