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
@@ -3,12 +3,19 @@
|
|
3
3
|
module Decidim
|
4
4
|
# This model holds all the data needed to send a newsletter.
|
5
5
|
class Newsletter < ApplicationRecord
|
6
|
+
include Decidim::Traceable
|
7
|
+
include Decidim::Loggable
|
8
|
+
|
6
9
|
belongs_to :author, class_name: "User"
|
7
10
|
belongs_to :organization
|
8
11
|
|
9
12
|
validates :subject, :body, presence: true
|
10
13
|
validate :author_belongs_to_organization
|
11
14
|
|
15
|
+
def self.log_presenter_class_for(_log)
|
16
|
+
Decidim::AdminLog::NewsletterPresenter
|
17
|
+
end
|
18
|
+
|
12
19
|
# Returns true if this newsletter was already sent.
|
13
20
|
#
|
14
21
|
# Returns a Boolean.
|
@@ -5,11 +5,16 @@ module Decidim
|
|
5
5
|
# installation we can find many organizations and each of them can start
|
6
6
|
# their own participatory processes.
|
7
7
|
class Organization < ApplicationRecord
|
8
|
+
include Decidim::Traceable
|
9
|
+
include Decidim::Loggable
|
10
|
+
|
8
11
|
SOCIAL_HANDLERS = [:twitter, :facebook, :instagram, :youtube, :github].freeze
|
9
12
|
|
10
13
|
has_many :static_pages, foreign_key: "decidim_organization_id", class_name: "Decidim::StaticPage", inverse_of: :organization, dependent: :destroy
|
11
14
|
has_many :scopes, -> { order(name: :asc) }, foreign_key: "decidim_organization_id", class_name: "Decidim::Scope", inverse_of: :organization
|
12
15
|
has_many :scope_types, -> { order(name: :asc) }, foreign_key: "decidim_organization_id", class_name: "Decidim::ScopeType", inverse_of: :organization
|
16
|
+
has_many :areas, -> { order(name: :asc) }, foreign_key: "decidim_organization_id", class_name: "Decidim::Area", inverse_of: :organization
|
17
|
+
has_many :area_types, -> { order(name: :asc) }, foreign_key: "decidim_organization_id", class_name: "Decidim::AreaType", inverse_of: :organization
|
13
18
|
has_many :admins, -> { where(admin: true) }, foreign_key: "decidim_organization_id", class_name: "Decidim::User"
|
14
19
|
has_many :users_with_any_role, -> { where.not(roles: []) }, foreign_key: "decidim_organization_id", class_name: "Decidim::User"
|
15
20
|
has_many :users, foreign_key: "decidim_organization_id", class_name: "Decidim::User", dependent: :destroy
|
@@ -25,6 +30,10 @@ module Decidim
|
|
25
30
|
mount_uploader :favicon, Decidim::OrganizationFaviconUploader
|
26
31
|
mount_uploader :highlighted_content_banner_image, ImageUploader
|
27
32
|
|
33
|
+
def self.log_presenter_class_for(_log)
|
34
|
+
Decidim::AdminLog::OrganizationPresenter
|
35
|
+
end
|
36
|
+
|
28
37
|
# Returns top level scopes for this organization.
|
29
38
|
#
|
30
39
|
# Returns an ActiveRecord::Relation.
|
@@ -4,13 +4,22 @@ module Decidim
|
|
4
4
|
# Defines a relation between a user and a participatory process, and what
|
5
5
|
# kind of relation does the user has.
|
6
6
|
class ParticipatoryProcessUserRole < ApplicationRecord
|
7
|
+
include Traceable
|
8
|
+
include Loggable
|
9
|
+
|
7
10
|
belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User", optional: true
|
8
11
|
belongs_to :participatory_process, foreign_key: "decidim_participatory_process_id", class_name: "Decidim::ParticipatoryProcess", optional: true
|
9
12
|
|
13
|
+
alias participatory_space participatory_process
|
14
|
+
|
10
15
|
ROLES = %w(admin collaborator moderator).freeze
|
11
16
|
validates :role, inclusion: { in: ROLES }, uniqueness: { scope: [:user, :participatory_process] }
|
12
17
|
validate :user_and_participatory_process_same_organization
|
13
18
|
|
19
|
+
def self.log_presenter_class_for(_log)
|
20
|
+
Decidim::ParticipatoryProcesses::AdminLog::ParticipatoryProcessUserRolePresenter
|
21
|
+
end
|
22
|
+
|
14
23
|
private
|
15
24
|
|
16
25
|
# Private: check if the process and the user have the same organization
|
@@ -13,8 +13,8 @@ module Decidim
|
|
13
13
|
belongs_to :to, polymorphic: true
|
14
14
|
|
15
15
|
validates :name, presence: true, uniqueness: { scope: [:from, :to] }
|
16
|
-
|
17
16
|
validate :same_organization
|
17
|
+
validate :same_participatory_space
|
18
18
|
|
19
19
|
private
|
20
20
|
|
@@ -24,5 +24,12 @@ module Decidim
|
|
24
24
|
errors.add(:from, :invalid)
|
25
25
|
errors.add(:to, :invalid)
|
26
26
|
end
|
27
|
+
|
28
|
+
def same_participatory_space
|
29
|
+
return if from.try(:participatory_space) == to.try(:participatory_space)
|
30
|
+
|
31
|
+
errors.add(:from, :invalid)
|
32
|
+
errors.add(:to, :invalid)
|
33
|
+
end
|
27
34
|
end
|
28
35
|
end
|
data/app/models/decidim/scope.rb
CHANGED
@@ -5,6 +5,9 @@ module Decidim
|
|
5
5
|
# the scope of a participatory process.
|
6
6
|
# (i.e. does it affect the whole city or just a district?)
|
7
7
|
class Scope < ApplicationRecord
|
8
|
+
include Decidim::Traceable
|
9
|
+
include Decidim::Loggable
|
10
|
+
|
8
11
|
belongs_to :organization,
|
9
12
|
foreign_key: "decidim_organization_id",
|
10
13
|
class_name: "Decidim::Organization",
|
@@ -43,6 +46,10 @@ module Decidim
|
|
43
46
|
where parent_id: nil
|
44
47
|
end
|
45
48
|
|
49
|
+
def self.log_presenter_class_for(_log)
|
50
|
+
Decidim::AdminLog::ScopePresenter
|
51
|
+
end
|
52
|
+
|
46
53
|
def descendants
|
47
54
|
organization.scopes.where("? = ANY(decidim_scopes.part_of)", id)
|
48
55
|
end
|
@@ -8,6 +8,9 @@ module Decidim
|
|
8
8
|
# Pages with a default slug cannot be destroyed and its slug cannot be
|
9
9
|
# modified.
|
10
10
|
class StaticPage < ApplicationRecord
|
11
|
+
include Decidim::Traceable
|
12
|
+
include Decidim::Loggable
|
13
|
+
|
11
14
|
belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization", inverse_of: :static_pages
|
12
15
|
|
13
16
|
validates :slug, presence: true, uniqueness: { scope: :organization }
|
@@ -29,6 +32,10 @@ module Decidim
|
|
29
32
|
DEFAULT_PAGES.include?(slug)
|
30
33
|
end
|
31
34
|
|
35
|
+
def self.log_presenter_class_for(_log)
|
36
|
+
Decidim::AdminLog::StaticPagePresenter
|
37
|
+
end
|
38
|
+
|
32
39
|
# Whether this is page is a default one or not.
|
33
40
|
#
|
34
41
|
# Returns Boolean.
|
data/app/models/decidim/user.rb
CHANGED
@@ -8,6 +8,7 @@ module Decidim
|
|
8
8
|
class User < ApplicationRecord
|
9
9
|
include Nicknamizable
|
10
10
|
include Decidim::Followable
|
11
|
+
include Decidim::Loggable
|
11
12
|
|
12
13
|
OMNIAUTH_PROVIDERS = [:facebook, :twitter, :google_oauth2, (:developer if Rails.env.development?)].compact
|
13
14
|
ROLES = %w(admin user_manager).freeze
|
@@ -29,7 +30,6 @@ module Decidim
|
|
29
30
|
validates :tos_agreement, acceptance: true, allow_nil: false, on: :create
|
30
31
|
validates :avatar, file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_avatar_size } }
|
31
32
|
validates :email, :nickname, uniqueness: { scope: :organization }, unless: -> { deleted? || managed? || nickname.blank? }
|
32
|
-
validates :email, 'valid_email_2/email': { disposable: true }
|
33
33
|
|
34
34
|
validate :all_roles_are_valid
|
35
35
|
|
@@ -44,6 +44,10 @@ module Decidim
|
|
44
44
|
# Returns a String.
|
45
45
|
attr_accessor :invitation_instructions
|
46
46
|
|
47
|
+
def self.log_presenter_class_for(_log)
|
48
|
+
Decidim::AdminLog::UserPresenter
|
49
|
+
end
|
50
|
+
|
47
51
|
# Checks if the user has the given `role` or not.
|
48
52
|
#
|
49
53
|
# role - a String or a Symbol that represents the role that is being
|
@@ -3,6 +3,9 @@
|
|
3
3
|
module Decidim
|
4
4
|
# A UserGroup is an organization of citizens
|
5
5
|
class UserGroup < ApplicationRecord
|
6
|
+
include Decidim::Traceable
|
7
|
+
include Decidim::Loggable
|
8
|
+
|
6
9
|
belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization"
|
7
10
|
|
8
11
|
has_many :memberships, class_name: "Decidim::UserGroupMembership", foreign_key: :decidim_user_group_id, dependent: :destroy
|
@@ -20,6 +23,10 @@ module Decidim
|
|
20
23
|
scope :verified, -> { where.not(verified_at: nil) }
|
21
24
|
scope :rejected, -> { where.not(rejected_at: nil) }
|
22
25
|
|
26
|
+
def self.log_presenter_class_for(_log)
|
27
|
+
Decidim::AdminLog::UserGroupPresenter
|
28
|
+
end
|
29
|
+
|
23
30
|
# Public: Checks if the user group is verified.
|
24
31
|
def verified?
|
25
32
|
verified_at.present?
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module AdminLog
|
5
|
+
# This class holds the logic to present a `Decidim::Feature`
|
6
|
+
# for the `AdminLog` log.
|
7
|
+
#
|
8
|
+
# Usage should be automatic and you shouldn't need to call this class
|
9
|
+
# directly, but here's an example:
|
10
|
+
#
|
11
|
+
# action_log = Decidim::ActionLog.last
|
12
|
+
# view_helpers # => this comes from the views
|
13
|
+
# FeaturePresenter.new(action_log, view_helpers).present
|
14
|
+
class FeaturePresenter < Decidim::Log::BasePresenter
|
15
|
+
private
|
16
|
+
|
17
|
+
def diff_fields_mapping
|
18
|
+
{
|
19
|
+
name: :i18n,
|
20
|
+
published_at: :date,
|
21
|
+
weight: :integer
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def i18n_labels_scope
|
26
|
+
"activemodel.attributes.feature"
|
27
|
+
end
|
28
|
+
|
29
|
+
def action_string
|
30
|
+
case action
|
31
|
+
when "create", "delete", "publish", "unpublish"
|
32
|
+
"decidim.admin_log.feature.#{action}"
|
33
|
+
else
|
34
|
+
super
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def has_diff?
|
39
|
+
action == "unpublish" || super
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module AdminLog
|
5
|
+
# This class holds the logic to present a `Decidim::Moderation`
|
6
|
+
# for the `AdminLog` log.
|
7
|
+
#
|
8
|
+
# Usage should be automatic and you shouldn't need to call this class
|
9
|
+
# directly, but here's an example:
|
10
|
+
#
|
11
|
+
# action_log = Decidim::ActionLog.last
|
12
|
+
# view_helpers # => this comes from the views
|
13
|
+
# ModerationPresenter.new(action_log, view_helpers).present
|
14
|
+
class ModerationPresenter < Decidim::Log::BasePresenter
|
15
|
+
private
|
16
|
+
|
17
|
+
def diff_fields_mapping
|
18
|
+
{
|
19
|
+
hidden_at: :date,
|
20
|
+
report_count: :integer
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def action_string
|
25
|
+
case action
|
26
|
+
when "hide", "unreport"
|
27
|
+
"decidim.admin_log.moderation.#{action}"
|
28
|
+
else
|
29
|
+
super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def i18n_labels_scope
|
34
|
+
"decidim.moderations.models.moderation.fields"
|
35
|
+
end
|
36
|
+
|
37
|
+
def i18n_params
|
38
|
+
super.merge(
|
39
|
+
resource_type: action_log.extra.dig("extra", "reportable_type").try(:demodulize)
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def has_diff?
|
44
|
+
action == "unreport" || super
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module AdminLog
|
5
|
+
# This class holds the logic to present a `Decidim::Newsletter`
|
6
|
+
# for the `AdminLog` log.
|
7
|
+
#
|
8
|
+
# Usage should be automatic and you shouldn't need to call this class
|
9
|
+
# directly, but here's an example:
|
10
|
+
#
|
11
|
+
# action_log = Decidim::ActionLog.last
|
12
|
+
# view_helpers # => this comes from the views
|
13
|
+
# NewsletterPresenter.new(action_log, view_helpers).present
|
14
|
+
class NewsletterPresenter < Decidim::Log::BasePresenter
|
15
|
+
private
|
16
|
+
|
17
|
+
def diff_fields_mapping
|
18
|
+
{
|
19
|
+
body: :i18n,
|
20
|
+
subject: :i18n
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def action_string
|
25
|
+
case action
|
26
|
+
when "create", "delete", "deliver", "update"
|
27
|
+
"decidim.admin_log.newsletter.#{action}"
|
28
|
+
else
|
29
|
+
super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def i18n_labels_scope
|
34
|
+
"activemodel.attributes.newsletter"
|
35
|
+
end
|
36
|
+
|
37
|
+
# Private: Caches the object that will be responsible of presenting the newsletter.
|
38
|
+
# Overwrites the method so that we can use a custom presenter to show the correct
|
39
|
+
# path for the newsletter.
|
40
|
+
#
|
41
|
+
# Returns an object that responds to `present`.
|
42
|
+
def resource_presenter
|
43
|
+
@resource_presenter ||= Decidim::AdminLog::NewsletterResourcePresenter.new(action_log.resource, h, action_log.extra["resource"])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module AdminLog
|
5
|
+
# This class extends the default resource presenter for logs, so that
|
6
|
+
# it can properly link to the newsletter.
|
7
|
+
class NewsletterResourcePresenter < Decidim::Log::ResourcePresenter
|
8
|
+
private
|
9
|
+
|
10
|
+
# Private: Finds the public link for the given static page..
|
11
|
+
#
|
12
|
+
# Returns an HTML-safe String.
|
13
|
+
def resource_path
|
14
|
+
@resource_path ||= h.decidim_admin.newsletter_path(resource)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module AdminLog
|
5
|
+
# This class holds the logic to present a `Decidim::Organization`
|
6
|
+
# for the `AdminLog` log.
|
7
|
+
#
|
8
|
+
# Usage should be automatic and you shouldn't need to call this class
|
9
|
+
# directly, but here's an example:
|
10
|
+
#
|
11
|
+
# action_log = Decidim::ActionLog.last
|
12
|
+
# view_helpers # => this comes from the views
|
13
|
+
# OrganizationPresenter.new(action_log, view_helpers).present
|
14
|
+
class OrganizationPresenter < Decidim::Log::BasePresenter
|
15
|
+
private
|
16
|
+
|
17
|
+
def diff_fields_mapping
|
18
|
+
settings_attributes_mapping
|
19
|
+
.merge(omnipresent_banner_attributes_mapping)
|
20
|
+
.merge(highlighted_content_banner_attributes_mapping)
|
21
|
+
.merge(appearance_attributes_mapping)
|
22
|
+
end
|
23
|
+
|
24
|
+
def settings_attributes_mapping
|
25
|
+
{
|
26
|
+
name: :string,
|
27
|
+
default_locale: :locale,
|
28
|
+
reference_prefix: :string,
|
29
|
+
twitter_handler: :string,
|
30
|
+
facebook_handler: :string,
|
31
|
+
instagram_handler: :string,
|
32
|
+
youtube_handler: :string,
|
33
|
+
github_handler: :string
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def omnipresent_banner_attributes_mapping
|
38
|
+
{
|
39
|
+
enable_omnipresent_banner: :boolean,
|
40
|
+
omnipresent_banner_url: :string,
|
41
|
+
omnipresent_banner_short_description: :i18n,
|
42
|
+
omnipresent_banner_title: :i18n
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def highlighted_content_banner_attributes_mapping
|
47
|
+
{
|
48
|
+
highlighted_content_banner_enabled: :boolean,
|
49
|
+
highlighted_content_banner_action_url: :string,
|
50
|
+
highlighted_content_banner_image: :string,
|
51
|
+
highlighted_content_banner_title: :i18n,
|
52
|
+
highlighted_content_banner_short_description: :i18n,
|
53
|
+
highlighted_content_banner_action_title: :i18n,
|
54
|
+
highlighted_content_banner_action_subtitle: :i18n
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def appearance_attributes_mapping
|
59
|
+
{
|
60
|
+
cta_button_path: :string,
|
61
|
+
cta_button_text: :i18n,
|
62
|
+
description: :i18n,
|
63
|
+
welcome_text: :i18n,
|
64
|
+
homepage_image: :string,
|
65
|
+
logo: :string,
|
66
|
+
header_snippets: :string,
|
67
|
+
favicon: :string,
|
68
|
+
official_img_header: :string,
|
69
|
+
official_img_footer: :string,
|
70
|
+
official_url: :string,
|
71
|
+
show_statistics: :boolean
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
def action_string
|
76
|
+
"decidim.admin_log.organization.update"
|
77
|
+
end
|
78
|
+
|
79
|
+
def i18n_labels_scope
|
80
|
+
"activemodel.attributes.organization"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module AdminLog
|
5
|
+
# This class holds the logic to present a `Decidim::Scope`
|
6
|
+
# for the `AdminLog` log.
|
7
|
+
#
|
8
|
+
# Usage should be automatic and you shouldn't need to call this class
|
9
|
+
# directly, but here's an example:
|
10
|
+
#
|
11
|
+
# action_log = Decidim::ActionLog.last
|
12
|
+
# view_helpers # => this comes from the views
|
13
|
+
# ScopePresenter.new(action_log, view_helpers).present
|
14
|
+
class ScopePresenter < Decidim::Log::BasePresenter
|
15
|
+
private
|
16
|
+
|
17
|
+
def diff_fields_mapping
|
18
|
+
{
|
19
|
+
code: :string,
|
20
|
+
name: :i18n,
|
21
|
+
parent_id: :scope,
|
22
|
+
scope_type_id: :scope_type
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def action_string
|
27
|
+
case action
|
28
|
+
when "create", "delete", "update"
|
29
|
+
if parent_name.present?
|
30
|
+
"decidim.admin_log.scope.#{action}_with_parent"
|
31
|
+
else
|
32
|
+
"decidim.admin_log.scope.#{action}"
|
33
|
+
end
|
34
|
+
else
|
35
|
+
super
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def i18n_labels_scope
|
40
|
+
"activemodel.attributes.scope"
|
41
|
+
end
|
42
|
+
|
43
|
+
def i18n_params
|
44
|
+
super.merge(
|
45
|
+
parent_scope: h.translated_attribute(parent_name)
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def parent_name
|
50
|
+
action_log.extra.dig("extra", "parent_name")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|