decidim-core 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/app/assets/stylesheets/decidim/modules/_modules.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_navbar.scss +3 -3
- data/app/assets/stylesheets/decidim/modules/_pagination.scss +5 -0
- data/app/commands/decidim/authorize_user.rb +1 -0
- data/app/commands/decidim/create_omniauth_registration.rb +1 -0
- data/app/commands/decidim/create_registration.rb +1 -0
- data/app/commands/decidim/create_report.rb +1 -0
- data/app/commands/decidim/invite_user.rb +1 -0
- data/app/commands/decidim/invite_user_again.rb +1 -0
- data/app/commands/decidim/remove_user_role.rb +1 -0
- data/app/commands/decidim/update_account.rb +1 -0
- data/app/commands/decidim/update_notifications_settings.rb +1 -0
- data/app/constraints/decidim/current_feature.rb +1 -0
- data/app/controllers/concerns/decidim/action_authorization.rb +1 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +3 -0
- data/app/controllers/concerns/decidim/feature_settings.rb +1 -0
- data/app/controllers/concerns/decidim/filter_resource.rb +1 -0
- data/app/controllers/concerns/decidim/needs_organization.rb +1 -1
- data/app/controllers/concerns/decidim/user_profile.rb +1 -0
- data/app/controllers/decidim/account_controller.rb +1 -0
- data/app/controllers/decidim/application_controller.rb +2 -0
- data/app/controllers/decidim/authorizations_controller.rb +1 -0
- data/app/controllers/decidim/cookie_policy_controller.rb +1 -0
- data/app/controllers/decidim/devise/confirmations_controller.rb +1 -0
- data/app/controllers/decidim/devise/invitations_controller.rb +1 -0
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +1 -0
- data/app/controllers/decidim/devise/passwords_controller.rb +1 -0
- data/app/controllers/decidim/devise/registrations_controller.rb +1 -0
- data/app/controllers/decidim/devise/sessions_controller.rb +2 -1
- data/app/controllers/decidim/locales_controller.rb +1 -0
- data/app/controllers/decidim/notifications_settings_controller.rb +1 -0
- data/app/controllers/decidim/own_user_groups_controller.rb +1 -0
- data/app/controllers/decidim/pages_controller.rb +2 -1
- data/app/controllers/decidim/participatory_process_groups_controller.rb +1 -0
- data/app/controllers/decidim/participatory_process_steps_controller.rb +1 -0
- data/app/controllers/decidim/participatory_processes_controller.rb +6 -5
- data/app/controllers/decidim/static_map_controller.rb +1 -0
- data/app/forms/decidim/form.rb +1 -0
- data/app/forms/decidim/report_form.rb +1 -0
- data/app/helpers/decidim/action_authorization_helper.rb +1 -1
- data/app/helpers/decidim/application_helper.rb +1 -1
- data/app/helpers/decidim/aria_selected_link_to_helper.rb +1 -0
- data/app/helpers/decidim/attachments_helper.rb +1 -0
- data/app/helpers/decidim/authorization_form_helper.rb +1 -0
- data/app/helpers/decidim/cookies_helper.rb +1 -1
- data/app/helpers/decidim/decidim_form_helper.rb +1 -0
- data/app/helpers/decidim/feature_reference_helper.rb +1 -0
- data/app/helpers/decidim/filters_helper.rb +1 -0
- data/app/helpers/decidim/humanize_booleans_helper.rb +1 -0
- data/app/helpers/decidim/language_chooser_helper.rb +1 -0
- data/app/helpers/decidim/layout_helper.rb +1 -0
- data/app/helpers/decidim/localized_locales_helper.rb +1 -0
- data/app/helpers/decidim/map_helper.rb +1 -0
- data/app/helpers/decidim/menu_helper.rb +16 -0
- data/app/helpers/decidim/meta_tags_helper.rb +1 -0
- data/app/helpers/decidim/omniauth_helper.rb +1 -0
- data/app/helpers/decidim/orders_helper.rb +1 -0
- data/app/helpers/decidim/organization_scopes_helper.rb +1 -0
- data/app/helpers/decidim/paginate_helper.rb +1 -0
- data/app/helpers/decidim/participatory_process_helper.rb +1 -0
- data/app/helpers/decidim/participatory_process_steps_helper.rb +1 -0
- data/app/helpers/decidim/replace_buttons_helper.rb +1 -0
- data/app/helpers/decidim/resource_helper.rb +1 -0
- data/app/helpers/decidim/translations_helper.rb +1 -0
- data/app/helpers/decidim/user_profile_helper.rb +1 -0
- data/app/helpers/decidim/widget_urls_helper.rb +1 -0
- data/app/jobs/decidim/application_job.rb +1 -0
- data/app/jobs/decidim/export_job.rb +22 -0
- data/app/mailers/decidim/application_mailer.rb +1 -0
- data/app/mailers/decidim/decidim_devise_mailer.rb +2 -1
- data/app/mailers/decidim/export_mailer.rb +1 -0
- data/app/mailers/decidim/newsletter_mailer.rb +1 -0
- data/app/mailers/decidim/reported_mailer.rb +1 -0
- data/app/middleware/decidim/current_organization.rb +1 -0
- data/app/models/decidim/abilities/everyone.rb +1 -0
- data/app/models/decidim/ability.rb +1 -0
- data/app/models/decidim/application_record.rb +1 -0
- data/app/models/decidim/attachment.rb +1 -0
- data/app/models/decidim/authorization.rb +2 -1
- data/app/models/decidim/category.rb +4 -3
- data/app/models/decidim/component.rb +1 -0
- data/app/models/decidim/feature.rb +1 -0
- data/app/models/decidim/identity.rb +2 -2
- data/app/models/decidim/moderation.rb +2 -1
- data/app/models/decidim/newsletter.rb +2 -1
- data/app/models/decidim/organization.rb +7 -6
- data/app/models/decidim/participatory_process.rb +7 -20
- data/app/models/decidim/participatory_process_group.rb +3 -2
- data/app/models/decidim/participatory_process_step.rb +2 -1
- data/app/models/decidim/report.rb +3 -2
- data/app/models/decidim/resource_link.rb +1 -0
- data/app/models/decidim/scope.rb +2 -1
- data/app/models/decidim/static_page.rb +2 -1
- data/app/models/decidim/user.rb +6 -5
- data/app/models/decidim/user_group.rb +23 -7
- data/app/models/decidim/user_group_membership.rb +2 -2
- data/app/presenters/decidim/home_stats_presenter.rb +2 -1
- data/app/presenters/decidim/menu_item_presenter.rb +57 -0
- data/app/presenters/decidim/menu_presenter.rb +47 -0
- data/app/queries/decidim/highlighted_participatory_processes.rb +1 -0
- data/app/queries/decidim/organization_participatory_processes.rb +1 -0
- data/app/queries/decidim/organization_prioritized_participatory_processes.rb +18 -0
- data/app/queries/decidim/{public_participatory_processes.rb → prioritized_participatory_processes.rb} +4 -3
- data/app/queries/decidim/promoted_participatory_processes.rb +1 -0
- data/app/queries/decidim/stats_users_count.rb +1 -0
- data/app/services/decidim/action_authorizer.rb +1 -0
- data/app/services/decidim/authorization_handler.rb +1 -0
- data/app/services/decidim/resource_search.rb +1 -0
- data/app/services/decidim/static_map_generator.rb +1 -0
- data/app/uploaders/decidim/application_uploader.rb +1 -0
- data/app/uploaders/decidim/banner_image_uploader.rb +1 -0
- data/app/uploaders/decidim/hero_image_uploader.rb +1 -0
- data/app/uploaders/decidim/homepage_image_uploader.rb +1 -0
- data/app/uploaders/decidim/image_uploader.rb +1 -0
- data/app/uploaders/decidim/official_image_footer_uploader.rb +1 -0
- data/app/uploaders/decidim/official_image_header_uploader.rb +1 -0
- data/app/uploaders/decidim/organization_favicon_uploader.rb +1 -0
- data/app/uploaders/decidim/organization_logo_uploader.rb +1 -0
- data/app/validators/etiquette_validator.rb +3 -3
- data/app/validators/geocoding_validator.rb +1 -1
- data/app/views/decidim/own_user_groups/index.html.erb +8 -6
- data/app/views/decidim/participatory_processes/index.html.erb +1 -1
- data/app/views/decidim/shared/_orders.html.erb +4 -3
- data/app/views/layouts/decidim/_language_chooser.html.erb +1 -1
- data/app/views/layouts/decidim/_wrapper.html.erb +2 -2
- data/config/i18n-tasks.yml +5 -5
- data/config/initializers/devise.rb +1 -0
- data/config/initializers/foundation_rails_helper.rb +1 -0
- data/config/initializers/invisible_captcha.rb +1 -0
- data/config/initializers/mail_previews.rb +1 -0
- data/config/locales/ca.yml +3 -2
- data/config/locales/en.yml +3 -2
- data/config/locales/es.yml +4 -3
- data/config/locales/eu.yml +23 -1
- data/config/locales/fi.yml +0 -1
- data/config/locales/fr.yml +1 -2
- data/config/locales/nl.yml +0 -1
- data/config/routes.rb +1 -0
- data/db/migrate/20170529150743_add_rejected_at_to_user_groups.rb +5 -0
- data/db/seeds.rb +1 -0
- data/lib/decidim/attributes.rb +1 -0
- data/lib/decidim/attributes/time_with_zone.rb +1 -0
- data/lib/decidim/authorable.rb +1 -0
- data/lib/decidim/authorization_form_builder.rb +1 -0
- data/lib/decidim/core.rb +13 -0
- data/lib/decidim/core/api.rb +1 -0
- data/lib/decidim/core/api/author_interface.rb +1 -0
- data/lib/decidim/core/api/decidim_type.rb +1 -0
- data/lib/decidim/core/api/localized_string_type.rb +1 -0
- data/lib/decidim/core/api/process_step_type.rb +1 -0
- data/lib/decidim/core/api/process_type.rb +1 -0
- data/lib/decidim/core/api/session_type.rb +1 -0
- data/lib/decidim/core/api/translated_field_type.rb +1 -0
- data/lib/decidim/core/api/user_group_type.rb +1 -0
- data/lib/decidim/core/api/user_type.rb +1 -0
- data/lib/decidim/core/engine.rb +21 -1
- data/lib/decidim/core/test.rb +1 -0
- data/lib/decidim/core/test/factories.rb +9 -1
- data/lib/decidim/core/test/shared_examples/authorable.rb +1 -0
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +1 -0
- data/lib/decidim/core/test/shared_examples/has_attachments.rb +1 -0
- data/lib/decidim/core/test/shared_examples/has_category.rb +1 -0
- data/lib/decidim/core/test/shared_examples/has_feature.rb +1 -0
- data/lib/decidim/core/test/shared_examples/has_reference.rb +1 -0
- data/lib/decidim/core/test/shared_examples/has_scope.rb +1 -0
- data/lib/decidim/core/test/shared_examples/localised_email.rb +1 -0
- data/lib/decidim/core/test/shared_examples/manage_moderations_examples.rb +1 -0
- data/lib/decidim/core/test/shared_examples/reportable.rb +1 -0
- data/lib/decidim/core/test/shared_examples/reports_examples.rb +1 -0
- data/lib/decidim/core/version.rb +2 -1
- data/lib/decidim/devise_failure_app.rb +0 -1
- data/lib/decidim/exporters.rb +2 -0
- data/lib/decidim/exporters/csv.rb +1 -0
- data/lib/decidim/exporters/export_data.rb +1 -0
- data/lib/decidim/exporters/exporter.rb +1 -0
- data/lib/decidim/exporters/json.rb +1 -0
- data/lib/decidim/exporters/serializer.rb +30 -0
- data/lib/decidim/faker/localized.rb +1 -0
- data/lib/decidim/feature_manifest.rb +37 -0
- data/lib/decidim/feature_validator.rb +1 -0
- data/lib/decidim/features.rb +1 -0
- data/lib/decidim/features/export_manifest.rb +52 -0
- data/lib/decidim/features/settings_manifest.rb +1 -0
- data/lib/decidim/file_zipper.rb +1 -0
- data/lib/decidim/filter_form_builder.rb +1 -0
- data/lib/decidim/form_builder.rb +2 -1
- data/lib/decidim/has_attachments.rb +4 -3
- data/lib/decidim/has_category.rb +2 -1
- data/lib/decidim/has_feature.rb +1 -0
- data/lib/decidim/has_reference.rb +1 -0
- data/lib/decidim/has_scope.rb +2 -1
- data/lib/decidim/i18n_exceptions.rb +1 -0
- data/lib/decidim/menu.rb +61 -0
- data/lib/decidim/menu_item.rb +31 -0
- data/lib/decidim/menu_registry.rb +65 -0
- data/lib/decidim/page_finder.rb +1 -0
- data/lib/decidim/query_extensions.rb +1 -0
- data/lib/decidim/reportable.rb +1 -0
- data/lib/decidim/resource_manifest.rb +1 -0
- data/lib/decidim/resourceable.rb +1 -0
- data/lib/decidim/stats_registry.rb +1 -0
- data/lib/decidim/translatable_attributes.rb +1 -0
- data/lib/devise/models/decidim_validatable.rb +2 -1
- data/lib/tasks/decidim_tasks.rake +1 -0
- data/lib/tasks/factory_girl.rake +1 -0
- metadata +33 -29
- data/app/services/decidim/public_processes.rb +0 -44
- data/app/views/layouts/decidim/_main_nav.html.erb +0 -11
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Decidim
|
3
4
|
# A ParticipatoryProcess is composed of many steps that hold different
|
4
5
|
# features that will show up in the depending on what step is currently
|
5
6
|
# active.
|
6
7
|
class ParticipatoryProcessStep < ApplicationRecord
|
7
|
-
belongs_to :participatory_process, foreign_key: "decidim_participatory_process_id", class_name: Decidim::ParticipatoryProcess
|
8
|
+
belongs_to :participatory_process, foreign_key: "decidim_participatory_process_id", class_name: "Decidim::ParticipatoryProcess"
|
8
9
|
has_one :organization, through: :participatory_process
|
9
10
|
|
10
11
|
validates :start_date, date: { before: :end_date, allow_blank: true, if: proc { |obj| obj.end_date.present? } }
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Decidim
|
3
4
|
# A reportable can be reported one time for each user.
|
4
5
|
class Report < ApplicationRecord
|
5
6
|
REASONS = %w(spam offensive does_not_belong).freeze
|
6
7
|
|
7
|
-
belongs_to :moderation, foreign_key: "decidim_moderation_id", class_name: Decidim::Moderation
|
8
|
-
belongs_to :user, foreign_key: "decidim_user_id", class_name: Decidim::User
|
8
|
+
belongs_to :moderation, foreign_key: "decidim_moderation_id", class_name: "Decidim::Moderation"
|
9
|
+
belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User"
|
9
10
|
|
10
11
|
validates :moderation, :user, :reason, presence: true
|
11
12
|
validates :user, uniqueness: { scope: :decidim_moderation_id }
|
data/app/models/decidim/scope.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Decidim
|
3
4
|
# Scopes are used in some entities through Decidim to help users know which is
|
4
5
|
# the scope of a participatory process.
|
@@ -6,7 +7,7 @@ module Decidim
|
|
6
7
|
class Scope < ApplicationRecord
|
7
8
|
belongs_to :organization,
|
8
9
|
foreign_key: "decidim_organization_id",
|
9
|
-
class_name: Decidim::Organization,
|
10
|
+
class_name: "Decidim::Organization",
|
10
11
|
inverse_of: :scopes
|
11
12
|
|
12
13
|
validates :name, presence: true, uniqueness: { scope: :organization }
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Decidim
|
3
4
|
# A page is used to add static content to the website, it can be useful so
|
4
5
|
# organization can add their own terms and conditions, privacy policy or
|
@@ -7,7 +8,7 @@ module Decidim
|
|
7
8
|
# Pages with a default slug cannot be destroyed and its slug cannot be
|
8
9
|
# modified.
|
9
10
|
class StaticPage < ApplicationRecord
|
10
|
-
belongs_to :organization, foreign_key: "decidim_organization_id", class_name: Decidim::Organization, inverse_of: :static_pages
|
11
|
+
belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization", inverse_of: :static_pages
|
11
12
|
|
12
13
|
validates :slug, :organization, presence: true
|
13
14
|
validates :slug, uniqueness: { scope: :organization }
|
data/app/models/decidim/user.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require_dependency "devise/models/decidim_validatable"
|
3
4
|
|
4
5
|
module Decidim
|
@@ -11,11 +12,11 @@ module Decidim
|
|
11
12
|
:omniauthable, omniauth_providers: [:facebook, :twitter, :google_oauth2],
|
12
13
|
request_keys: [:env], reset_password_keys: [:decidim_organization_id, :email]
|
13
14
|
|
14
|
-
belongs_to :organization, foreign_key: "decidim_organization_id", class_name: Decidim::Organization
|
15
|
-
has_many :authorizations, foreign_key: "decidim_user_id", class_name: Decidim::Authorization, inverse_of: :user
|
16
|
-
has_many :identities, foreign_key: "decidim_user_id", class_name: Decidim::Identity
|
17
|
-
has_many :user_groups, through: :memberships, class_name: Decidim::UserGroup, foreign_key: :decidim_user_group_id
|
18
|
-
has_many :memberships, class_name: Decidim::UserGroupMembership, foreign_key: :decidim_user_id
|
15
|
+
belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization"
|
16
|
+
has_many :authorizations, foreign_key: "decidim_user_id", class_name: "Decidim::Authorization", inverse_of: :user
|
17
|
+
has_many :identities, foreign_key: "decidim_user_id", class_name: "Decidim::Identity"
|
18
|
+
has_many :user_groups, through: :memberships, class_name: "Decidim::UserGroup", foreign_key: :decidim_user_group_id
|
19
|
+
has_many :memberships, class_name: "Decidim::UserGroupMembership", foreign_key: :decidim_user_id
|
19
20
|
|
20
21
|
ROLES = %w(admin moderator collaborator official).freeze
|
21
22
|
|
@@ -3,25 +3,41 @@
|
|
3
3
|
module Decidim
|
4
4
|
# A UserGroup is an organization of citizens
|
5
5
|
class UserGroup < ApplicationRecord
|
6
|
-
has_many :users, through: :memberships, class_name: Decidim::User, foreign_key: :decidim_user_id
|
7
|
-
has_many :memberships, class_name: Decidim::UserGroupMembership, foreign_key: :decidim_user_group_id
|
6
|
+
has_many :users, through: :memberships, class_name: "Decidim::User", foreign_key: :decidim_user_id
|
7
|
+
has_many :memberships, class_name: "Decidim::UserGroupMembership", foreign_key: :decidim_user_group_id
|
8
8
|
|
9
9
|
validates :name, presence: true
|
10
10
|
validates :document_number, presence: true
|
11
11
|
validates :phone, presence: true
|
12
12
|
validates :avatar, file_size: { less_than_or_equal_to: 5.megabytes }
|
13
|
+
|
14
|
+
validate :correct_state
|
15
|
+
|
13
16
|
mount_uploader :avatar, Decidim::AvatarUploader
|
14
17
|
|
15
18
|
scope :verified, -> { where.not(verified_at: nil) }
|
16
|
-
|
17
|
-
# Public: Mark the user group as verified
|
18
|
-
def verify!
|
19
|
-
update_attribute(:verified_at, Time.current)
|
20
|
-
end
|
19
|
+
scope :rejected, -> { where.not(rejected_at: nil) }
|
21
20
|
|
22
21
|
# Public: Checks if the user group is verified.
|
23
22
|
def verified?
|
24
23
|
verified_at.present?
|
25
24
|
end
|
25
|
+
|
26
|
+
# Public: Checks if the user group is rejected.
|
27
|
+
def rejected?
|
28
|
+
rejected_at.present?
|
29
|
+
end
|
30
|
+
|
31
|
+
# Public: Checks if the user group is pending.
|
32
|
+
def pending?
|
33
|
+
verified_at.blank? && rejected_at.blank?
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# Private: Checks if the state user group is correct.
|
39
|
+
def correct_state
|
40
|
+
errors.add(:base, :invalid) if verified? && rejected?
|
41
|
+
end
|
26
42
|
end
|
27
43
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
# A UserGroupMembership associate user with user groups
|
5
5
|
class UserGroupMembership < ApplicationRecord
|
6
|
-
belongs_to :user, class_name: Decidim::User, foreign_key: :decidim_user_id
|
7
|
-
belongs_to :user_group, class_name: Decidim::UserGroup, foreign_key: :decidim_user_group_id
|
6
|
+
belongs_to :user, class_name: "Decidim::User", foreign_key: :decidim_user_id
|
7
|
+
belongs_to :user_group, class_name: "Decidim::UserGroup", foreign_key: :decidim_user_group_id
|
8
8
|
end
|
9
9
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Decidim
|
3
4
|
# A presenter to render statistics in the homepage.
|
4
5
|
class HomeStatsPresenter < Rectify::Presenter
|
@@ -62,7 +63,7 @@ module Decidim
|
|
62
63
|
content_tag :div, "", class: "home-pam__data" do
|
63
64
|
safe_join([
|
64
65
|
content_tag(:h4, I18n.t(name, scope: "pages.home.statistics"), class: "home-pam__title"),
|
65
|
-
content_tag(:span, " #{data}", class: "home-pam__number #{name}")
|
66
|
+
content_tag(:span, " #{number_with_delimiter(data)}", class: "home-pam__number #{name}")
|
66
67
|
])
|
67
68
|
end
|
68
69
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# A presenter to render menu items
|
5
|
+
class MenuItemPresenter
|
6
|
+
#
|
7
|
+
# Initializes a menu item for presentation
|
8
|
+
#
|
9
|
+
# @param menu_item [MenuItem] The menu item itself
|
10
|
+
# @param view [ActionView::Base] The view instance to help rendering the item
|
11
|
+
# @param options [Hash] The rendering options for the item
|
12
|
+
#
|
13
|
+
# @option options [String] :element_class
|
14
|
+
# The CSS class to be used for the item
|
15
|
+
#
|
16
|
+
# @option options [String] :active_class
|
17
|
+
# The CSS class to be used for the active item
|
18
|
+
#
|
19
|
+
def initialize(menu_item, view, options = {})
|
20
|
+
@menu_item = menu_item
|
21
|
+
@view = view
|
22
|
+
@element_class = options[:element_class]
|
23
|
+
@active_class = options[:active_class]
|
24
|
+
end
|
25
|
+
|
26
|
+
delegate :label, :url, :active, :icon_name, to: :@menu_item
|
27
|
+
delegate :content_tag, :link_to, :active_link_to_class, :is_active_link?, :icon, to: :@view
|
28
|
+
|
29
|
+
def render
|
30
|
+
content_tag :li, class: link_wrapper_classes do
|
31
|
+
if icon_name
|
32
|
+
link_to(url) { icon(icon_name) + label }
|
33
|
+
else
|
34
|
+
link_to label, url
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
attr_reader :element_class
|
42
|
+
|
43
|
+
def link_wrapper_classes
|
44
|
+
return element_class unless is_active_link?(url, active)
|
45
|
+
|
46
|
+
[element_class, active_class].compact.join(" ")
|
47
|
+
end
|
48
|
+
|
49
|
+
def active_class
|
50
|
+
active_link_to_class(
|
51
|
+
url,
|
52
|
+
active: active,
|
53
|
+
class_active: @active_class
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# A presenter to render menus
|
5
|
+
class MenuPresenter
|
6
|
+
#
|
7
|
+
# Initializes a menu for presentation
|
8
|
+
#
|
9
|
+
# @param name [Symbol] The name of the menu registry to be rendered
|
10
|
+
# @param view [ActionView::Base] The view scope to render the menu
|
11
|
+
# @param options [Hash] The rendering options for the menu entries
|
12
|
+
#
|
13
|
+
def initialize(name, view, options = {})
|
14
|
+
@name = name
|
15
|
+
@view = view
|
16
|
+
|
17
|
+
@options = options
|
18
|
+
end
|
19
|
+
|
20
|
+
delegate :items, to: :evaluated_menu
|
21
|
+
delegate :content_tag, :safe_join, to: :@view
|
22
|
+
|
23
|
+
def evaluated_menu
|
24
|
+
@evaluated_menu ||= begin
|
25
|
+
menu = Menu.new(@name)
|
26
|
+
menu.build_for(@view)
|
27
|
+
menu
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def render
|
32
|
+
content_tag :nav, class: "main-nav" do
|
33
|
+
content_tag :ul do
|
34
|
+
safe_join(menu_items)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def menu_items
|
42
|
+
items.map do |menu_item|
|
43
|
+
MenuItemPresenter.new(menu_item, @view, @options).render
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This query class returns the public Participatory Processes given an
|
5
|
+
# Organization in a meaningful order.
|
6
|
+
class OrganizationPrioritizedParticipatoryProcesses < Rectify::Query
|
7
|
+
def initialize(organization)
|
8
|
+
@organization = organization
|
9
|
+
end
|
10
|
+
|
11
|
+
def query
|
12
|
+
Rectify::Query.merge(
|
13
|
+
OrganizationParticipatoryProcesses.new(@organization),
|
14
|
+
PrioritizedParticipatoryProcesses.new
|
15
|
+
).query
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Decidim
|
3
|
-
# This query
|
4
|
-
#
|
5
|
-
class
|
4
|
+
# This query orders processes by importance, prioritizing promoted processes
|
5
|
+
# first, and closest to finalization date second.
|
6
|
+
class PrioritizedParticipatoryProcesses < Rectify::Query
|
6
7
|
def query
|
7
8
|
Decidim::ParticipatoryProcess.order("promoted DESC").includes(:active_step).order("decidim_participatory_process_steps.end_date ASC")
|
8
9
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# This validator takes care of ensuring the validated content is
|
4
4
|
# respectful, doesn't use caps, and overall is meaningful.
|
5
5
|
class EtiquetteValidator < ActiveModel::EachValidator
|
@@ -16,7 +16,7 @@ class EtiquetteValidator < ActiveModel::EachValidator
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def validate_caps(record, attribute, value)
|
19
|
-
return if value.scan(/[A-Z]/).length < value.length /
|
19
|
+
return if value.scan(/[A-Z]/).length < value.length / 4
|
20
20
|
record.errors.add(attribute, options[:message] || :too_much_caps)
|
21
21
|
end
|
22
22
|
|
@@ -26,7 +26,7 @@ class EtiquetteValidator < ActiveModel::EachValidator
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def validate_long_words(record, attribute, value)
|
29
|
-
return if value.scan(/[A-z]{
|
29
|
+
return if value.scan(/[A-z]{35,}/).empty?
|
30
30
|
record.errors.add(attribute, options[:message] || :long_words)
|
31
31
|
end
|
32
32
|
|