decidim-core 0.9.3 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/append_redirect_url_to_modals.js.es6 +1 -1
- data/app/assets/javascripts/decidim/data_picker.js.es6 +32 -28
- data/app/assets/javascripts/decidim/form_filter.component.js.es6 +2 -2
- data/app/assets/javascripts/decidim/foundation.js.es6 +1 -2
- data/app/assets/stylesheets/decidim/_decidim.scss +6 -1
- data/app/assets/stylesheets/decidim/modules/_address.scss +4 -0
- data/app/assets/stylesheets/decidim/modules/_block-banner.scss +39 -0
- data/app/assets/stylesheets/decidim/modules/_buttons.scss +76 -1
- data/app/assets/stylesheets/decidim/modules/_callout.scss +4 -0
- data/app/assets/stylesheets/decidim/modules/_cards.scss +117 -16
- data/app/assets/stylesheets/decidim/modules/_collapsible-list.scss +19 -0
- data/app/assets/stylesheets/decidim/modules/_data-picker.scss +0 -1
- data/app/assets/stylesheets/decidim/modules/_docs-manager.scss +16 -0
- data/app/assets/stylesheets/decidim/modules/_icons.scss +13 -4
- data/app/assets/stylesheets/decidim/modules/_margins.scss +39 -0
- data/app/assets/stylesheets/decidim/modules/_modules.scss +4 -0
- data/app/assets/stylesheets/decidim/modules/_navbar.scss +26 -0
- data/app/assets/stylesheets/decidim/modules/_process-phase.scss +49 -0
- data/app/assets/stylesheets/decidim/modules/_reveal.scss +39 -0
- data/app/assets/stylesheets/decidim/modules/_typography.scss +45 -0
- data/app/assets/stylesheets/decidim/modules/_wizard-steps.scss +45 -0
- data/app/assets/stylesheets/decidim/utils/_helpers.scss +14 -0
- data/app/assets/stylesheets/decidim/utils/_mixins.scss +34 -0
- data/app/assets/stylesheets/decidim/utils/_settings.scss +6 -3
- data/app/commands/decidim/create_report.rb +2 -2
- data/app/controllers/decidim/devise/invitations_controller.rb +1 -1
- data/app/controllers/decidim/features/base_controller.rb +1 -1
- data/app/controllers/decidim/locales_controller.rb +1 -1
- data/app/forms/decidim/registration_form.rb +1 -1
- data/app/helpers/decidim/decidim_form_helper.rb +26 -1
- data/app/helpers/decidim/meta_tags_helper.rb +2 -0
- data/app/helpers/decidim/resource_reference_helper.rb +24 -0
- data/app/helpers/decidim/scopes_helper.rb +22 -4
- data/app/helpers/decidim/view_hooks_helper.rb +6 -3
- data/app/mailers/decidim/messaging/conversation_mailer.rb +2 -0
- data/app/models/decidim/abilities/base_ability.rb +1 -1
- data/app/models/decidim/action_log.rb +57 -0
- data/app/models/decidim/area.rb +25 -0
- data/app/models/decidim/area_type.rb +20 -0
- data/app/models/decidim/attachment.rb +3 -0
- data/app/models/decidim/attachment_collection.rb +16 -0
- data/app/models/decidim/authorization.rb +1 -0
- data/app/models/decidim/categorization.rb +2 -0
- data/app/models/decidim/category.rb +8 -0
- data/app/models/decidim/feature.rb +6 -1
- data/app/models/decidim/moderation.rb +7 -0
- data/app/models/decidim/newsletter.rb +7 -0
- data/app/models/decidim/organization.rb +9 -0
- data/app/models/decidim/participatory_process_user_role.rb +9 -0
- data/app/models/decidim/resource_link.rb +8 -1
- data/app/models/decidim/scope.rb +7 -0
- data/app/models/decidim/static_page.rb +7 -0
- data/app/models/decidim/user.rb +5 -1
- data/app/models/decidim/user_group.rb +7 -0
- data/app/presenters/decidim/admin_log/feature_presenter.rb +43 -0
- data/app/presenters/decidim/admin_log/moderation_presenter.rb +48 -0
- data/app/presenters/decidim/admin_log/newsletter_presenter.rb +47 -0
- data/app/presenters/decidim/admin_log/newsletter_resource_presenter.rb +18 -0
- data/app/presenters/decidim/admin_log/organization_presenter.rb +84 -0
- data/app/presenters/decidim/admin_log/scope_presenter.rb +54 -0
- data/app/presenters/decidim/admin_log/static_page_presenter.rb +48 -0
- data/app/presenters/decidim/admin_log/static_page_resource_presenter.rb +18 -0
- data/app/presenters/decidim/admin_log/user_group_presenter.rb +31 -0
- data/app/presenters/decidim/admin_log/user_presenter.rb +59 -0
- data/app/presenters/decidim/area_presenter.rb +14 -0
- data/app/presenters/decidim/area_type_presenter.rb +14 -0
- data/app/presenters/decidim/category_presenter.rb +14 -0
- data/app/presenters/decidim/log/base_presenter.rb +253 -0
- data/app/presenters/decidim/log/diff_presenter.rb +120 -0
- data/app/presenters/decidim/log/resource_presenter.rb +71 -0
- data/app/presenters/decidim/log/space_presenter.rb +63 -0
- data/app/presenters/decidim/log/user_presenter.rb +85 -0
- data/app/presenters/decidim/log/value_types/area_presenter.rb +28 -0
- data/app/presenters/decidim/log/value_types/date_presenter.rb +20 -0
- data/app/presenters/decidim/log/value_types/default_presenter.rb +43 -0
- data/app/presenters/decidim/log/value_types/locale_presenter.rb +20 -0
- data/app/presenters/decidim/log/value_types/percentage_presenter.rb +21 -0
- data/app/presenters/decidim/log/value_types/scope_presenter.rb +28 -0
- data/app/presenters/decidim/log/value_types/scope_type_presenter.rb +28 -0
- data/app/presenters/decidim/user_presenter.rb +1 -1
- data/app/services/decidim/action_authorizer.rb +1 -1
- data/app/services/decidim/action_logger.rb +108 -0
- data/app/services/decidim/events_manager.rb +1 -1
- data/app/services/decidim/log/diff_changeset_calculator.rb +135 -0
- data/app/services/decidim/resource_search.rb +2 -8
- data/app/services/decidim/settings_change.rb +31 -0
- data/app/services/decidim/traceability.rb +57 -11
- data/app/types/decidim/core/component_type.rb +12 -0
- data/app/types/decidim/core/date_time_type.rb +12 -0
- data/app/types/decidim/core/date_type.rb +13 -0
- data/app/types/decidim/core/decidim_type.rb +23 -0
- data/app/types/decidim/core/localized_string_type.rb +14 -0
- data/app/types/decidim/core/organization_type.rb +20 -0
- data/app/types/decidim/core/participatory_space_type.rb +12 -0
- data/app/types/decidim/core/session_type.rb +19 -0
- data/app/types/decidim/core/statistic_type.rb +22 -0
- data/app/types/decidim/core/translated_field_type.rb +45 -0
- data/app/types/decidim/core/user_group_type.rb +39 -0
- data/app/types/decidim/core/user_type.rb +41 -0
- data/app/validators/etiquette_validator.rb +1 -1
- data/app/views/decidim/application/_attachments.html.erb +4 -0
- data/app/views/decidim/application/_collection.html.erb +14 -0
- data/app/views/decidim/application/_document.html.erb +19 -0
- data/app/views/decidim/application/_documents.html.erb +8 -23
- data/app/views/decidim/shared/_announcement.html.erb +3 -2
- data/app/views/decidim/shared/_tags.html.erb +1 -0
- data/app/views/decidim/widgets/_data_picker.html.erb +6 -0
- data/app/views/layouts/decidim/mailer.html.erb +2 -2
- data/config/initializers/devise.rb +3 -3
- data/config/locales/ca.yml +65 -11
- data/config/locales/en.yml +64 -10
- data/config/locales/es.yml +66 -12
- data/config/locales/eu.yml +61 -10
- data/config/locales/fi.yml +64 -10
- data/config/locales/fr.yml +64 -10
- data/config/locales/gl.yml +64 -10
- data/config/locales/it.yml +64 -10
- data/config/locales/nl.yml +64 -10
- data/config/locales/pl.yml +60 -10
- data/config/locales/pt-BR.yml +64 -10
- data/config/locales/pt.yml +64 -10
- data/config/locales/sv.yml +64 -10
- data/config/locales/uk.yml +72 -0
- data/db/migrate/20170215115407_add_organization_custom_reference.rb +1 -1
- data/db/migrate/20170313095436_add_available_authorizations_to_organization.rb +1 -1
- data/db/migrate/20171207182729_create_decidim_attachment_collections.rb +12 -0
- data/db/migrate/20180130093153_add_action_log.rb +18 -0
- data/db/migrate/20180206143340_fix_reference_for_all_resources.rb +13 -0
- data/db/migrate/20180215104821_create_decidim_area_types.rb +11 -0
- data/db/migrate/20180215104945_create_decidim_areas.rb +12 -0
- data/db/migrate/20180221101934_fix_nickname_index.rb +1 -1
- data/db/migrate/20180226140756_add_version_to_action_logs.rb +19 -0
- data/db/migrate/20180314085339_rename_maximum_votes_per_proposal_to_threshold_per_proposal.rb +27 -0
- data/db/migrate/20180326075746_change_event_name_and_class_to_rename_to_publish_proposal_event.rb +17 -0
- data/db/seeds.rb +28 -0
- data/lib/decidim/abilities/participatory_process_role_ability.rb +2 -2
- data/lib/decidim/api/author_interface.rb +25 -0
- data/lib/decidim/api/component_interface.rb +16 -0
- data/lib/decidim/api/participatory_space_interface.rb +38 -0
- data/lib/decidim/authorable.rb +8 -0
- data/lib/decidim/core.rb +27 -9
- data/lib/decidim/core/engine.rb +3 -4
- data/lib/decidim/core/test.rb +2 -0
- data/lib/decidim/core/test/factories.rb +62 -6
- data/lib/decidim/core/test/shared_examples/announcements_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +47 -5
- data/lib/decidim/core/test/shared_examples/component_type.rb +7 -0
- data/lib/decidim/core/test/shared_examples/has_attachment_collections.rb +63 -0
- data/lib/decidim/core/test/shared_examples/has_attachments.rb +21 -0
- data/lib/decidim/core/test/shared_examples/has_reference.rb +1 -1
- data/lib/decidim/core/test/shared_examples/simple_event.rb +27 -1
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/events/author_event.rb +1 -1
- data/lib/decidim/events/base_event.rb +1 -1
- data/lib/decidim/events/simple_event.rb +21 -0
- data/lib/decidim/exporters/excel.rb +1 -1
- data/lib/decidim/feature_manifest.rb +2 -0
- data/lib/decidim/form_builder.rb +37 -3
- data/lib/decidim/has_attachment_collections.rb +18 -0
- data/lib/decidim/has_attachments.rb +14 -0
- data/lib/decidim/has_category.rb +5 -0
- data/lib/decidim/has_reference.rb +4 -4
- data/lib/decidim/loggable.rb +32 -0
- data/lib/decidim/participable.rb +0 -2
- data/lib/decidim/participatory_space_manifest.rb +2 -0
- data/lib/decidim/publicable.rb +2 -2
- data/lib/decidim/query_extensions.rb +46 -14
- data/lib/decidim/resourceable.rb +15 -6
- data/lib/decidim/scopable.rb +35 -1
- data/lib/decidim/scopable_feature.rb +16 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ca.js +0 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.es.js +0 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.eu.js +0 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.fi.js +0 -0
- data/vendor/assets/javascripts/leaflet.markercluster.js +0 -0
- metadata +91 -38
- data/app/commands/decidim/remove_admin.rb +0 -25
- data/app/helpers/decidim/feature_reference_helper.rb +0 -25
- data/lib/decidim/core/api.rb +0 -13
- data/lib/decidim/core/api/author_interface.rb +0 -18
- data/lib/decidim/core/api/decidim_type.rb +0 -17
- data/lib/decidim/core/api/localized_string_type.rb +0 -12
- data/lib/decidim/core/api/process_step_type.rb +0 -19
- data/lib/decidim/core/api/process_type.rb +0 -17
- data/lib/decidim/core/api/session_type.rb +0 -17
- data/lib/decidim/core/api/translated_field_type.rb +0 -43
- data/lib/decidim/core/api/user_group_type.rb +0 -37
- data/lib/decidim/core/api/user_type.rb +0 -39
- data/lib/decidim/devise_failure_app.rb +0 -36
- data/lib/decidim/has_scope.rb +0 -25
- data/lib/decidim/i18n_exceptions.rb +0 -15
@@ -9,7 +9,7 @@ class AddOrganizationCustomReference < ActiveRecord::Migration[5.0]
|
|
9
9
|
add_column :decidim_organizations, :reference_prefix, :string
|
10
10
|
|
11
11
|
Organization.find_each do |organization|
|
12
|
-
organization.
|
12
|
+
organization.update!(reference_prefix: organization.name[0])
|
13
13
|
end
|
14
14
|
|
15
15
|
change_column_null :decidim_organizations, :reference_prefix, false
|
@@ -10,7 +10,7 @@ class AddAvailableAuthorizationsToOrganization < ActiveRecord::Migration[5.0]
|
|
10
10
|
|
11
11
|
workflows = Decidim::Verifications.workflows.map(&:name)
|
12
12
|
Organization.find_each do |org|
|
13
|
-
org.
|
13
|
+
org.update!(available_authorizations: workflows)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateDecidimAttachmentCollections < ActiveRecord::Migration[5.1]
|
4
|
+
def change
|
5
|
+
create_table :decidim_attachment_collections do |t|
|
6
|
+
t.jsonb :name, null: false
|
7
|
+
t.jsonb :description, null: false
|
8
|
+
t.integer :weight, null: false, default: 0
|
9
|
+
t.references :collection_for, polymorphic: true, null: false, index: { name: "decidim_attachment_collections_collection_for_id_and_type" }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddActionLog < ActiveRecord::Migration[5.1]
|
4
|
+
def change
|
5
|
+
create_table :decidim_action_logs do |t|
|
6
|
+
t.references :decidim_organization, null: false, index: { name: "index_action_logs_on_organization_id" }
|
7
|
+
t.references :decidim_user, null: false, index: { name: "index_action_logs_on_user_id" }
|
8
|
+
t.references :decidim_feature, index: { name: "index_action_logs_on_feature_id" }
|
9
|
+
t.references :resource, polymorphic: true, null: false, index: { name: "index_action_logs_on_resource_type_and_id" }
|
10
|
+
t.references :participatory_space, polymorphic: true, index: { name: "index_action_logs_on_space_type_and_id" }
|
11
|
+
t.string :action, null: false
|
12
|
+
t.jsonb :extra
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
add_index :decidim_action_logs, :created_at
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class FixReferenceForAllResources < ActiveRecord::Migration[5.1]
|
4
|
+
def up
|
5
|
+
models = ActiveRecord::Base.descendants.select { |c| c.included_modules.include?(Decidim::HasReference) }
|
6
|
+
|
7
|
+
models.each do |model|
|
8
|
+
model.find_each(&:touch)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def down; end
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateDecidimAreaTypes < ActiveRecord::Migration[5.1]
|
4
|
+
def change
|
5
|
+
create_table :decidim_area_types do |t|
|
6
|
+
t.references :decidim_organization, foreign_key: true, index: true
|
7
|
+
t.jsonb :name, null: false
|
8
|
+
t.jsonb :plural, null: false
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateDecidimAreas < ActiveRecord::Migration[5.1]
|
4
|
+
def change
|
5
|
+
create_table :decidim_areas do |t|
|
6
|
+
t.jsonb :name
|
7
|
+
t.references :area_type, foreign_key: { to_table: :decidim_area_types }, index: true
|
8
|
+
t.references :decidim_organization, foreign_key: true, index: true
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -9,7 +9,7 @@ class FixNicknameIndex < ActiveRecord::Migration[5.1]
|
|
9
9
|
Decidim::User.where(nickname: nil)
|
10
10
|
.where(deleted_at: nil)
|
11
11
|
.where(managed: false)
|
12
|
-
.find_each { |u| u.
|
12
|
+
.find_each { |u| u.update(nickname: Decidim::User.nicknamize(u.name)) }
|
13
13
|
|
14
14
|
# rubocop:disable Rails/SkipsModelValidations
|
15
15
|
Decidim::User.where(nickname: nil)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddVersionToActionLogs < ActiveRecord::Migration[5.1]
|
4
|
+
def up
|
5
|
+
add_column :decidim_action_logs, :version_id, :integer, index: true
|
6
|
+
|
7
|
+
Decidim::ActionLog.find_each do |action_log|
|
8
|
+
version_id = action_log.extra.dig("version", "id")
|
9
|
+
next unless version_id
|
10
|
+
# rubocop:disable Rails/SkipsModelValidations
|
11
|
+
action_log.update_column(:version_id, version_id)
|
12
|
+
# rubocop:enable Rails/SkipsModelValidations
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def down
|
17
|
+
remove_column :decidim_action_logs, :version_id
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class RenameMaximumVotesPerProposalToThresholdPerProposal < ActiveRecord::Migration[5.1]
|
4
|
+
def up
|
5
|
+
execute <<~SQL
|
6
|
+
UPDATE decidim_features
|
7
|
+
SET settings = jsonb_set(
|
8
|
+
settings::jsonb,
|
9
|
+
array['global'],
|
10
|
+
(settings->'global')::jsonb - 'maximum_votes_per_proposal' || jsonb_build_object('threshold_per_proposal', settings->'global'->'maximum_votes_per_proposal')
|
11
|
+
)
|
12
|
+
WHERE manifest_name = 'proposals'
|
13
|
+
SQL
|
14
|
+
end
|
15
|
+
|
16
|
+
def down
|
17
|
+
execute <<~SQL
|
18
|
+
UPDATE decidim_features
|
19
|
+
SET settings = jsonb_set(
|
20
|
+
settings::jsonb,
|
21
|
+
array['global'],
|
22
|
+
(settings->'global')::jsonb - 'threshold_per_proposal' || jsonb_build_object('maximum_votes_per_proposal', settings->'global'->'threshold_per_proposal')
|
23
|
+
)
|
24
|
+
WHERE manifest_name = 'proposals'
|
25
|
+
SQL
|
26
|
+
end
|
27
|
+
end
|
data/db/migrate/20180326075746_change_event_name_and_class_to_rename_to_publish_proposal_event.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ChangeEventNameAndClassToRenameToPublishProposalEvent < ActiveRecord::Migration[5.1]
|
4
|
+
def up
|
5
|
+
# rubocop:disable Rails/SkipsModelValidations
|
6
|
+
Decidim::Notification.where(event_name: "decidim.events.proposals.proposal_created")
|
7
|
+
.update_all(event_name: "decidim.events.proposals.proposal_published", event_class: "Decidim::Proposals::PublishProposalEvent")
|
8
|
+
# rubocop:enable Rails/SkipsModelValidations
|
9
|
+
end
|
10
|
+
|
11
|
+
def down
|
12
|
+
# rubocop:disable Rails/SkipsModelValidations
|
13
|
+
Decidim::Notification.where(event_name: "decidim.events.proposals.proposal_published")
|
14
|
+
.update_all(event_name: "decidim.events.proposals.proposal_created", event_class: "Decidim::Proposals::CreateProposalEvent")
|
15
|
+
# rubocop:enable Rails/SkipsModelValidations
|
16
|
+
end
|
17
|
+
end
|
data/db/seeds.rb
CHANGED
@@ -55,6 +55,34 @@ if !Rails.env.production? || ENV["SEED"]
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
territorial = Decidim::AreaType.create!(
|
59
|
+
name: Decidim::Faker::Localized.literal("territorial"),
|
60
|
+
plural: Decidim::Faker::Localized.literal("territorials"),
|
61
|
+
organization: organization
|
62
|
+
)
|
63
|
+
|
64
|
+
sectorial = Decidim::AreaType.create!(
|
65
|
+
name: Decidim::Faker::Localized.literal("sectorials"),
|
66
|
+
plural: Decidim::Faker::Localized.literal("sectorials"),
|
67
|
+
organization: organization
|
68
|
+
)
|
69
|
+
|
70
|
+
3.times do
|
71
|
+
Decidim::Area.create!(
|
72
|
+
name: Decidim::Faker::Localized.word,
|
73
|
+
area_type: territorial,
|
74
|
+
organization: organization
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
5.times do
|
79
|
+
Decidim::Area.create!(
|
80
|
+
name: Decidim::Faker::Localized.word,
|
81
|
+
area_type: sectorial,
|
82
|
+
organization: organization
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
58
86
|
admin = Decidim::User.find_or_initialize_by(email: "admin@example.org")
|
59
87
|
|
60
88
|
admin.update!(
|
@@ -26,7 +26,7 @@ module Decidim
|
|
26
26
|
def define_participatory_process_abilities; end
|
27
27
|
|
28
28
|
# Abstract: A subclass must define this method returning a valid role.
|
29
|
-
# See
|
29
|
+
# See ParticipatoryProcessUserRole::ROLES for more information.
|
30
30
|
def role
|
31
31
|
raise "Needs implementation"
|
32
32
|
end
|
@@ -39,7 +39,7 @@ module Decidim
|
|
39
39
|
# Returns a collection of Participatory processes where the given user has the
|
40
40
|
# specific role privilege.
|
41
41
|
def participatory_processes_with_role_privileges
|
42
|
-
@
|
42
|
+
@participatory_processes_with_role_privileges ||= Decidim::ParticipatoryProcessesWithUserRole.for(@user, role)
|
43
43
|
end
|
44
44
|
|
45
45
|
# Whether the user has at least one process to manage or not.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Core
|
5
|
+
# This interface represents an author who owns a resource.
|
6
|
+
AuthorInterface = GraphQL::InterfaceType.define do
|
7
|
+
name "Author"
|
8
|
+
description "An author"
|
9
|
+
|
10
|
+
field :name, !types.String, "The author's name"
|
11
|
+
field :nickname, !types.String, "The author's nickname"
|
12
|
+
|
13
|
+
field :avatarUrl, !types.String, "The author's avatar url"
|
14
|
+
field :profilePath, !types.String, "The author's profile path"
|
15
|
+
field :badge, !types.String, "The author's badge icon"
|
16
|
+
|
17
|
+
field :deleted, !types.Boolean, "Whether the author's account has been deleted or not"
|
18
|
+
|
19
|
+
resolve_type ->(obj, _ctx) {
|
20
|
+
return Decidim::Core::UserType if obj.is_a? Decidim::User
|
21
|
+
return Decidim::Core::UserGroupType if obj.is_a? Decidim::UserGroup
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Core
|
5
|
+
ComponentInterface = GraphQL::InterfaceType.define do
|
6
|
+
name "ComponentInterface"
|
7
|
+
description "This interface is implemented by all components that belong into a Participatory Space"
|
8
|
+
|
9
|
+
field :id, !types.ID, "The Component's unique ID"
|
10
|
+
|
11
|
+
field :name, !TranslatedFieldType, "The name of this component."
|
12
|
+
|
13
|
+
resolve_type ->(obj, _ctx) { obj.manifest.query_type.constantize }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Core
|
5
|
+
ParticipatorySpaceInterface = GraphQL::InterfaceType.define do
|
6
|
+
name "ParticipatorySpaceInterface"
|
7
|
+
description "The interface that all participatory spaces should implement."
|
8
|
+
|
9
|
+
field :id, !types.ID, "The participatory space's unique ID"
|
10
|
+
|
11
|
+
field :title, !TranslatedFieldType, "The name of this participatory space."
|
12
|
+
|
13
|
+
field :components, types[ComponentInterface] do
|
14
|
+
description "Lists the components this space contains."
|
15
|
+
|
16
|
+
resolve ->(participatory_space, _args, _ctx) {
|
17
|
+
Decidim::Feature.where(
|
18
|
+
participatory_space: participatory_space
|
19
|
+
).published
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
field :stats, types[Decidim::Core::StatisticType] do
|
24
|
+
resolve ->(participatory_space, _args, _ctx) {
|
25
|
+
published_features = Feature.where(participatory_space: participatory_space).published
|
26
|
+
|
27
|
+
stats = Decidim.feature_manifests.map do |feature_manifest|
|
28
|
+
feature_manifest.stats.with_context(published_features).map { |name, data| [name, data] }.flatten
|
29
|
+
end
|
30
|
+
|
31
|
+
stats.reject(&:empty?)
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
resolve_type ->(obj, _ctx) { obj.manifest.query_type.constantize }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/decidim/authorable.rb
CHANGED
@@ -12,6 +12,14 @@ module Decidim
|
|
12
12
|
validate :verified_user_group, :user_group_membership
|
13
13
|
validate :author_belongs_to_organization
|
14
14
|
|
15
|
+
# Checks whether the user is author of the given proposal, either directly
|
16
|
+
# authoring it or via a user group.
|
17
|
+
#
|
18
|
+
# user - the user to check for authorship
|
19
|
+
def authored_by?(user)
|
20
|
+
author == user || user.user_groups.include?(user_group)
|
21
|
+
end
|
22
|
+
|
15
23
|
private
|
16
24
|
|
17
25
|
def verified_user_group
|
data/lib/decidim/core.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require "decidim/core/engine"
|
4
4
|
require "decidim/core/version"
|
5
|
-
require "decidim/core/api"
|
6
5
|
|
7
6
|
# Decidim configuration.
|
8
7
|
module Decidim
|
@@ -10,26 +9,27 @@ module Decidim
|
|
10
9
|
autoload :FormBuilder, "decidim/form_builder"
|
11
10
|
autoload :AuthorizationFormBuilder, "decidim/authorization_form_builder"
|
12
11
|
autoload :FilterFormBuilder, "decidim/filter_form_builder"
|
13
|
-
autoload :DeviseFailureApp, "decidim/devise_failure_app"
|
14
12
|
autoload :FeatureManifest, "decidim/feature_manifest"
|
15
13
|
autoload :ParticipatorySpaceManifest, "decidim/participatory_space_manifest"
|
16
14
|
autoload :ResourceManifest, "decidim/resource_manifest"
|
17
15
|
autoload :Resourceable, "decidim/resourceable"
|
18
16
|
autoload :Traceable, "decidim/traceable"
|
17
|
+
autoload :Loggable, "decidim/loggable"
|
19
18
|
autoload :Reportable, "decidim/reportable"
|
20
19
|
autoload :Authorable, "decidim/authorable"
|
21
20
|
autoload :Participable, "decidim/participable"
|
22
21
|
autoload :Publicable, "decidim/publicable"
|
23
22
|
autoload :Scopable, "decidim/scopable"
|
23
|
+
autoload :ScopableFeature, "decidim/scopable_feature"
|
24
24
|
autoload :ContentParsers, "decidim/content_parsers"
|
25
25
|
autoload :ContentRenderers, "decidim/content_renderers"
|
26
26
|
autoload :ContentProcessor, "decidim/content_processor"
|
27
27
|
autoload :Features, "decidim/features"
|
28
|
+
autoload :HasAttachmentCollections, "decidim/has_attachment_collections"
|
28
29
|
autoload :HasAttachments, "decidim/has_attachments"
|
29
30
|
autoload :FeatureValidator, "decidim/feature_validator"
|
30
31
|
autoload :HasSettings, "decidim/has_settings"
|
31
32
|
autoload :HasFeature, "decidim/has_feature"
|
32
|
-
autoload :HasScope, "decidim/has_scope"
|
33
33
|
autoload :HasCategory, "decidim/has_category"
|
34
34
|
autoload :Followable, "decidim/followable"
|
35
35
|
autoload :FriendlyDates, "decidim/friendly_dates"
|
@@ -49,6 +49,7 @@ module Decidim
|
|
49
49
|
autoload :Events, "decidim/events"
|
50
50
|
autoload :ViewHooks, "decidim/view_hooks"
|
51
51
|
autoload :NewsletterEncryptor, "decidim/newsletter_encryptor"
|
52
|
+
autoload :QueryExtensions, "decidim/query_extensions"
|
52
53
|
|
53
54
|
include ActiveSupport::Configurable
|
54
55
|
|
@@ -93,7 +94,7 @@ module Decidim
|
|
93
94
|
|
94
95
|
# Exposes a configuration option: The application available locales.
|
95
96
|
config_accessor :available_locales do
|
96
|
-
%w(en ca es eu fi fr gl it nl pt
|
97
|
+
%w(en ca es eu fi fr gl it nl pt pt-BR ru sv uk)
|
97
98
|
end
|
98
99
|
|
99
100
|
# Exposes a configuration option: an array of symbols representing processors
|
@@ -121,19 +122,30 @@ module Decidim
|
|
121
122
|
# Exposes a configuration option: an object to configure geocoder
|
122
123
|
config_accessor :geocoder
|
123
124
|
|
124
|
-
# Exposes a configuration option: a custom method to generate references
|
125
|
+
# Exposes a configuration option: a custom method to generate references.
|
126
|
+
# If overwritten, it should handle both feature resources and participatory spaces.
|
125
127
|
# Default: Calculates a unique reference for the model in
|
126
128
|
# the following format:
|
127
129
|
#
|
128
|
-
# "BCN-
|
130
|
+
# "BCN-PROP-2017-02-6589" which in this example translates to:
|
129
131
|
#
|
130
132
|
# BCN: A setting configured at the organization to be prepended to each reference.
|
131
|
-
# PROP: Unique name identifier for a resource: Decidim::Proposals::Proposal
|
133
|
+
# PROP: Unique name identifier for a resource: Decidim::Proposals::Proposal
|
134
|
+
# (MEET for meetings or PROJ for projects).
|
132
135
|
# 2017-02: Year-Month of the resource creation date
|
133
136
|
# 6589: ID of the resource
|
134
|
-
config_accessor :
|
137
|
+
config_accessor :reference_generator do
|
135
138
|
lambda do |resource, feature|
|
136
|
-
ref =
|
139
|
+
ref = ""
|
140
|
+
|
141
|
+
if resource.is_a?(Decidim::HasFeature) && feature.present?
|
142
|
+
# It's a feature resource
|
143
|
+
ref = feature.participatory_space.organization.reference_prefix
|
144
|
+
elsif resource.is_a?(Decidim::Participable)
|
145
|
+
# It's a participatory space
|
146
|
+
ref = resource.organization.reference_prefix
|
147
|
+
end
|
148
|
+
|
137
149
|
class_identifier = resource.class.name.demodulize[0..3].upcase
|
138
150
|
year_month = (resource.created_at || Time.current).strftime("%Y-%m")
|
139
151
|
|
@@ -321,4 +333,10 @@ module Decidim
|
|
321
333
|
def self.traceability
|
322
334
|
@traceability ||= Traceability.new
|
323
335
|
end
|
336
|
+
|
337
|
+
module Core
|
338
|
+
autoload :ParticipatorySpaceInterface, "decidim/api/participatory_space_interface"
|
339
|
+
autoload :ComponentInterface, "decidim/api/component_interface"
|
340
|
+
autoload :AuthorInterface, "decidim/api/author_interface"
|
341
|
+
end
|
324
342
|
end
|
data/lib/decidim/core/engine.rb
CHANGED
@@ -35,9 +35,6 @@ require "paper_trail"
|
|
35
35
|
|
36
36
|
require "decidim/api"
|
37
37
|
|
38
|
-
require "decidim/query_extensions"
|
39
|
-
require "decidim/i18n_exceptions"
|
40
|
-
|
41
38
|
module Decidim
|
42
39
|
module Core
|
43
40
|
# Decidim's core Rails Engine.
|
@@ -96,7 +93,9 @@ module Decidim
|
|
96
93
|
end
|
97
94
|
|
98
95
|
initializer "decidim.query_extensions" do
|
99
|
-
|
96
|
+
Decidim::Api::QueryType.define do
|
97
|
+
Decidim::QueryExtensions.define(self)
|
98
|
+
end
|
100
99
|
end
|
101
100
|
|
102
101
|
initializer "decidim.i18n_exceptions" do
|