decidim-core 0.6.8 → 0.7.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/config/decidim_core_manifest.js +1 -0
- data/app/assets/images/decidim/decidim-logo.svg +62 -0
- data/app/assets/images/decidim/icons.svg +238 -1
- data/app/assets/javascripts/decidim/foundation.js.es6 +1 -0
- data/app/assets/javascripts/decidim/slug_form.js.es6 +9 -0
- data/app/assets/stylesheets/decidim/modules/_footer.scss +7 -0
- data/app/commands/decidim/invite_user.rb +2 -2
- data/app/commands/decidim/update_account.rb +1 -1
- data/app/controllers/concerns/decidim/action_authorization.rb +2 -3
- data/app/controllers/concerns/decidim/needs_authorization.rb +1 -1
- data/app/controllers/decidim/account_controller.rb +0 -5
- data/app/controllers/decidim/application_controller.rb +0 -10
- data/app/controllers/decidim/authorizations_controller.rb +5 -15
- data/app/controllers/decidim/devise/invitations_controller.rb +2 -2
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +1 -9
- data/app/controllers/decidim/devise/registrations_controller.rb +1 -1
- data/app/controllers/decidim/devise/sessions_controller.rb +0 -8
- data/app/controllers/decidim/locales_controller.rb +2 -2
- data/app/controllers/decidim/pages_controller.rb +1 -0
- data/app/controllers/decidim/scopes_controller.rb +1 -3
- data/app/forms/decidim/account_form.rb +2 -2
- data/app/forms/decidim/form.rb +1 -3
- data/app/forms/translatable_presence_validator.rb +1 -1
- data/app/helpers/decidim/cta_button_helper.rb +27 -0
- data/app/helpers/decidim/decidim_form_helper.rb +25 -0
- data/app/helpers/decidim/layout_helper.rb +1 -1
- data/app/helpers/decidim/map_helper.rb +1 -1
- data/app/helpers/decidim/meta_tags_helper.rb +1 -1
- data/app/helpers/decidim/omniauth_helper.rb +7 -0
- data/app/helpers/decidim/scopes_helper.rb +1 -1
- data/app/mailers/decidim/decidim_devise_mailer.rb +1 -0
- data/app/models/decidim/attachment.rb +1 -3
- data/app/models/decidim/authorization.rb +6 -6
- data/app/models/decidim/category.rb +1 -1
- data/app/models/decidim/feature.rb +1 -1
- data/app/models/decidim/scope.rb +2 -1
- data/app/models/decidim/user.rb +4 -4
- data/app/models/decidim/user_group.rb +1 -1
- data/app/services/decidim/action_authorizer.rb +8 -6
- data/app/services/decidim/authorization_handler.rb +7 -4
- data/app/services/decidim/static_map_generator.rb +1 -1
- data/app/views/decidim/account/_password_fields.html.erb +2 -2
- data/app/views/decidim/authorizations/first_login.html.erb +1 -1
- data/app/views/decidim/authorizations/new.html.erb +3 -1
- data/app/views/decidim/devise/shared/_omniauth_buttons.html.erb +1 -1
- data/app/views/decidim/devise/shared/_omniauth_buttons_mini.html.erb +1 -1
- data/app/views/decidim/newsletter_mailer/newsletter.html.erb +2 -2
- data/app/views/decidim/notifications/index.html.erb +13 -9
- data/app/views/decidim/shared/_address_details.html.erb +2 -2
- data/app/views/decidim/shared/_announcement.html.erb +1 -1
- data/app/views/decidim/shared/_follow_button.html.erb +19 -4
- data/app/views/devise/mailer/invite_admin.html.erb +1 -1
- data/app/views/devise/mailer/invite_admin.text.erb +1 -1
- data/app/views/devise/mailer/invite_collaborator.html.erb +1 -1
- data/app/views/devise/mailer/invite_collaborator.text.erb +1 -1
- data/app/views/layouts/decidim/_feature_authorization_modals.html.erb +5 -0
- data/app/views/layouts/decidim/_head.html.erb +1 -1
- data/app/views/layouts/decidim/_wrapper.html.erb +10 -1
- data/app/views/pages/decidim_page.html.erb +1 -1
- data/app/views/pages/home/_footer_sub_hero.html.erb +1 -1
- data/app/views/pages/home/_hero.html.erb +2 -2
- data/app/views/pages/home/_sub_hero.html.erb +1 -1
- data/config/initializers/devise.rb +3 -0
- data/config/locales/ca.yml +10 -7
- data/config/locales/en.yml +11 -8
- data/config/locales/es.yml +10 -7
- data/config/locales/eu.yml +26 -23
- data/config/locales/fi.yml +21 -18
- data/config/locales/fr.yml +20 -17
- data/config/locales/it.yml +11 -8
- data/config/locales/nl.yml +11 -8
- data/config/locales/pl.yml +11 -8
- data/config/locales/ru.yml +403 -0
- data/config/locales/uk.yml +50 -47
- data/db/migrate/20170215115407_add_organization_custom_reference.rb +6 -2
- data/db/migrate/20170313095436_add_available_authorizations_to_organization.rb +7 -3
- data/db/migrate/20171017084546_add_cta_button_url_and_text_to_organization.rb +8 -0
- data/db/seeds.rb +4 -3
- data/lib/decidim/authorization_form_builder.rb +1 -1
- data/lib/decidim/core.rb +11 -1
- data/lib/decidim/core/engine.rb +1 -2
- data/lib/decidim/core/test/factories.rb +2 -2
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +3 -7
- data/lib/decidim/core/version.rb +5 -20
- data/lib/decidim/events/base_event.rb +1 -1
- data/lib/decidim/exporters.rb +3 -2
- data/lib/decidim/exporters/excel.rb +49 -0
- data/lib/decidim/exporters/export_data.rb +1 -1
- data/lib/decidim/exporters/exporter.rb +1 -1
- data/lib/decidim/faker/localized.rb +10 -1
- data/lib/decidim/feature_validator.rb +1 -1
- data/lib/decidim/form_builder.rb +16 -6
- data/lib/decidim/page_finder.rb +1 -1
- data/lib/decidim/participable.rb +9 -4
- data/lib/decidim/publicable.rb +2 -2
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ru.js +14 -0
- metadata +36 -86
- data/app/assets/stylesheets/decidim/extras/_callout.scss +0 -5
- data/config/secrets.yml +0 -36
@@ -4,15 +4,15 @@ module Decidim
|
|
4
4
|
# This controller allows users to create and destroy their authorizations. It
|
5
5
|
# shouldn't be necessary to expand it to add new authorization schemes.
|
6
6
|
class AuthorizationsController < Decidim::ApplicationController
|
7
|
-
helper_method :handler, :handlers
|
7
|
+
helper_method :handler, :handlers
|
8
8
|
before_action :valid_handler, only: [:new, :create]
|
9
9
|
|
10
10
|
include Decidim::UserProfile
|
11
11
|
helper Decidim::DecidimFormHelper
|
12
|
+
helper Decidim::CtaButtonHelper
|
12
13
|
helper Decidim::AuthorizationFormHelper
|
13
14
|
|
14
15
|
layout "layouts/decidim/user_profile", only: [:index]
|
15
|
-
skip_before_action :store_current_location
|
16
16
|
|
17
17
|
def new; end
|
18
18
|
|
@@ -34,7 +34,7 @@ module Decidim
|
|
34
34
|
AuthorizeUser.call(handler) do
|
35
35
|
on(:ok) do
|
36
36
|
flash[:notice] = t("authorizations.create.success", scope: "decidim")
|
37
|
-
redirect_to params[:redirect_url] ||
|
37
|
+
redirect_to params[:redirect_url] || authorizations_path
|
38
38
|
end
|
39
39
|
|
40
40
|
on(:invalid) do
|
@@ -44,16 +44,10 @@ module Decidim
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def handler
|
48
|
-
@handler ||= AuthorizationHandler.handler_for(handler_name, handler_params)
|
49
|
-
end
|
50
|
-
|
51
47
|
protected
|
52
48
|
|
53
|
-
def
|
54
|
-
|
55
|
-
store_location_for(current_user, location)
|
56
|
-
location
|
49
|
+
def handler
|
50
|
+
@handler ||= AuthorizationHandler.handler_for(handler_name, handler_params)
|
57
51
|
end
|
58
52
|
|
59
53
|
def handler_params
|
@@ -73,10 +67,6 @@ module Decidim
|
|
73
67
|
redirect_to(authorizations_path) && (return false)
|
74
68
|
end
|
75
69
|
|
76
|
-
def only_one_handler?
|
77
|
-
redirect_to(action: :new, handler: available_handlers.first.handler_name) && return if available_handlers.length == 1
|
78
|
-
end
|
79
|
-
|
80
70
|
def handlers
|
81
71
|
@handlers ||= available_authorization_handlers.reject do |handler|
|
82
72
|
authorized_handlers.include?(handler.handler_name)
|
@@ -16,13 +16,13 @@ module Decidim
|
|
16
16
|
# invitation. Using the param `invite_redirect` we can redirect the user
|
17
17
|
# to a custom path after it has accepted the invitation.
|
18
18
|
def after_accept_path_for(resource)
|
19
|
-
params[:invite_redirect] ||
|
19
|
+
params[:invite_redirect] || super
|
20
20
|
end
|
21
21
|
|
22
22
|
# When a managed user accepts the invitation is promoted to non-managed user.
|
23
23
|
def accept_resource
|
24
24
|
resource = resource_class.accept_invitation!(update_resource_params)
|
25
|
-
resource.
|
25
|
+
resource.update_attributes!(managed: false) if resource.managed?
|
26
26
|
resource
|
27
27
|
end
|
28
28
|
end
|
@@ -44,21 +44,13 @@ module Decidim
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def after_sign_in_path_for(user)
|
47
|
-
if
|
47
|
+
if first_login_and_not_authorized?(user)
|
48
48
|
authorizations_path
|
49
49
|
else
|
50
50
|
super
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
# Calling the `stored_location_for` method removes the key, so in order
|
55
|
-
# to check if there's any pending redirect after login I need to call
|
56
|
-
# this method and use the value to set a pending redirect. This is the
|
57
|
-
# only way to do this without checking the session directly.
|
58
|
-
def pending_redirect?(user)
|
59
|
-
store_location_for(user, stored_location_for(user))
|
60
|
-
end
|
61
|
-
|
62
54
|
def first_login_and_not_authorized?(user)
|
63
55
|
user.is_a?(User) && user.sign_in_count == 1 && Decidim.authorization_handlers.any?
|
64
56
|
end
|
@@ -48,7 +48,7 @@ module Decidim
|
|
48
48
|
private
|
49
49
|
|
50
50
|
def terms_and_conditions_page
|
51
|
-
@terms_and_conditions_page ||= Decidim::StaticPage.
|
51
|
+
@terms_and_conditions_page ||= Decidim::StaticPage.find_by(slug: "terms-and-conditions")
|
52
52
|
end
|
53
53
|
|
54
54
|
protected
|
@@ -12,14 +12,6 @@ module Decidim
|
|
12
12
|
super
|
13
13
|
end
|
14
14
|
|
15
|
-
# Calling the `stored_location_for` method removes the key, so in order
|
16
|
-
# to check if there's any pending redirect after login I need to call
|
17
|
-
# this method and use the value to set a pending redirect. This is the
|
18
|
-
# only way to do this without checking the session directly.
|
19
|
-
def pending_redirect?(user)
|
20
|
-
store_location_for(user, stored_location_for(user))
|
21
|
-
end
|
22
|
-
|
23
15
|
def first_login_and_not_authorized?(user)
|
24
16
|
user.is_a?(User) && user.sign_in_count == 1 && current_organization.available_authorizations.any?
|
25
17
|
end
|
@@ -7,7 +7,7 @@ module Decidim
|
|
7
7
|
|
8
8
|
def create
|
9
9
|
if current_user && params["locale"] && available_locales.include?(params["locale"])
|
10
|
-
current_user.
|
10
|
+
current_user.update_attributes!(locale: params["locale"])
|
11
11
|
end
|
12
12
|
|
13
13
|
redirect_to referer_with_new_locale
|
@@ -16,7 +16,7 @@ module Decidim
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def referer_with_new_locale
|
19
|
-
uri = URI(request.
|
19
|
+
uri = URI(request.referer || "/")
|
20
20
|
query = uri.query.to_s.gsub(/locale\=[a-zA-Z\-]{2,5}/, "")
|
21
21
|
params = URI.decode_www_form(query) << ["locale", current_locale]
|
22
22
|
uri.query = URI.encode_www_form(params)
|
@@ -12,6 +12,7 @@ module Decidim
|
|
12
12
|
authorize_resource :public_pages, class: false
|
13
13
|
delegate :page, to: :page_finder
|
14
14
|
helper_method :page, :promoted_participatory_processes, :highlighted_participatory_processes, :stats
|
15
|
+
helper CtaButtonHelper
|
15
16
|
|
16
17
|
def index
|
17
18
|
@pages = current_organization.static_pages.all.to_a.sort do |a, b|
|
@@ -3,8 +3,6 @@
|
|
3
3
|
module Decidim
|
4
4
|
# Exposes the scopes text search so users can choose a scope writing its name.
|
5
5
|
class ScopesController < Decidim::ApplicationController
|
6
|
-
skip_before_action :store_current_location
|
7
|
-
|
8
6
|
def search
|
9
7
|
authorize! :search, Scope
|
10
8
|
root = Scope.where(id: params[:root], organization: current_organization).first
|
@@ -15,7 +13,7 @@ module Decidim
|
|
15
13
|
else
|
16
14
|
current_organization.top_scopes
|
17
15
|
end
|
18
|
-
root_option = if params[:include_root] == "true" &&
|
16
|
+
root_option = if params[:include_root] == "true" && params[:term].blank?
|
19
17
|
if root
|
20
18
|
[{ id: root.id.to_s, text: root.name[I18n.locale.to_s] }]
|
21
19
|
else
|
@@ -19,14 +19,14 @@ module Decidim
|
|
19
19
|
validates :password, confirmation: true
|
20
20
|
validates :password, length: { in: Decidim::User.password_length, allow_blank: true }
|
21
21
|
validates :password_confirmation, presence: true, if: :password_present
|
22
|
-
validates :avatar, file_size: { less_than_or_equal_to: ->(_record) { Decidim
|
22
|
+
validates :avatar, file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_avatar_size } }
|
23
23
|
|
24
24
|
validate :unique_email
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
28
|
def password_present
|
29
|
-
|
29
|
+
password.present?
|
30
30
|
end
|
31
31
|
|
32
32
|
def unique_email
|
data/app/forms/decidim/form.rb
CHANGED
@@ -12,7 +12,7 @@ class TranslatablePresenceValidator < ActiveModel::EachValidator
|
|
12
12
|
def validate_each(record, attribute, _value)
|
13
13
|
available_locales_for(record).each do |locale|
|
14
14
|
translated_attr = "#{attribute}_#{locale}"
|
15
|
-
record.errors.add(translated_attr, :blank)
|
15
|
+
record.errors.add(translated_attr, :blank) if record.send(translated_attr).blank?
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# A Helper to render the Call To Action button.
|
5
|
+
module CtaButtonHelper
|
6
|
+
# Renders the Call To Action button. Link and text can be configured
|
7
|
+
# per organizationn.
|
8
|
+
def cta_button
|
9
|
+
button_text = translated_attribute(current_organization.cta_button_text).presence || t("pages.home.hero.participate")
|
10
|
+
|
11
|
+
link_to button_text, cta_button_path, class: "hero-cta button expanded large button--sc"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Finds the CTA button path to reuse it in other places.
|
15
|
+
def cta_button_path
|
16
|
+
if current_organization.cta_button_path.present?
|
17
|
+
current_organization.cta_button_path
|
18
|
+
elsif Decidim::ParticipatoryProcess.where(organization: current_organization).published.any?
|
19
|
+
decidim_participatory_processes.participatory_processes_path
|
20
|
+
elsif current_user
|
21
|
+
decidim.account_path
|
22
|
+
else
|
23
|
+
decidim.new_user_registration_path
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -124,5 +124,30 @@ module Decidim
|
|
124
124
|
def form_field_has_error?(object, attribute)
|
125
125
|
object.respond_to?(:errors) && object.errors[attribute].present?
|
126
126
|
end
|
127
|
+
|
128
|
+
# Helper method to show how slugs will look like. Intended to be used in forms
|
129
|
+
# together with some JavaScript code. More precisely, this will most probably
|
130
|
+
# show in help texts in forms. The space slug is surrounded with a `span` so
|
131
|
+
# the slug can be updated via JavaScript with the input value.
|
132
|
+
#
|
133
|
+
# prepend_path - a path to prepend to the slug, without final slash
|
134
|
+
# value - the initial value of the slug field, so that edit forms have a value
|
135
|
+
#
|
136
|
+
# Returns an HTML-safe String.
|
137
|
+
def decidim_form_slug_url(prepend_path = "", value = "")
|
138
|
+
prepend_slug_path = if prepend_path.present?
|
139
|
+
"/#{prepend_path}/"
|
140
|
+
else
|
141
|
+
"/"
|
142
|
+
end
|
143
|
+
content_tag(:span, class: "slug-url") do
|
144
|
+
[
|
145
|
+
request.protocol,
|
146
|
+
request.host_with_port,
|
147
|
+
prepend_slug_path
|
148
|
+
].join("").html_safe +
|
149
|
+
content_tag(:span, value, class: "slug-url-value")
|
150
|
+
end
|
151
|
+
end
|
127
152
|
end
|
128
153
|
end
|
@@ -8,7 +8,7 @@ module Decidim
|
|
8
8
|
#
|
9
9
|
# Returns a safe String with the versions.
|
10
10
|
def favicon
|
11
|
-
return
|
11
|
+
return if current_organization.favicon.blank?
|
12
12
|
|
13
13
|
safe_join(Decidim::OrganizationFaviconUploader::SIZES.map do |version, size|
|
14
14
|
favicon_link_tag(current_organization.favicon.send(version).url, sizes: "#{size}x#{size}")
|
@@ -20,5 +20,12 @@ module Decidim
|
|
20
20
|
def normalize_provider_name(provider)
|
21
21
|
provider.to_s.split("_").first
|
22
22
|
end
|
23
|
+
|
24
|
+
# Public: icon for omniauth buttons
|
25
|
+
def oauth_icon(provider)
|
26
|
+
name = provider == :developer ? "phone" : normalize_provider_name(provider)
|
27
|
+
|
28
|
+
icon(name)
|
29
|
+
end
|
23
30
|
end
|
24
31
|
end
|
@@ -9,7 +9,7 @@ module Decidim
|
|
9
9
|
#
|
10
10
|
# Returns boolean.
|
11
11
|
def has_visible_scopes?(resource)
|
12
|
-
current_participatory_space.scopes_enabled? &&
|
12
|
+
current_participatory_space.scopes_enabled? && current_participatory_space.scope.blank? && resource.scope.present?
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -17,6 +17,7 @@ module Decidim
|
|
17
17
|
with_user(user) do
|
18
18
|
@token = token
|
19
19
|
@organization = user.organization
|
20
|
+
@opts = opts
|
20
21
|
|
21
22
|
if opts[:invitation_instructions]
|
22
23
|
opts[:subject] = I18n.t("devise.mailer.#{opts[:invitation_instructions]}.subject", organization: user.organization.name)
|
@@ -13,14 +13,14 @@ module Decidim
|
|
13
13
|
class Authorization < ApplicationRecord
|
14
14
|
belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User", inverse_of: :authorizations
|
15
15
|
|
16
|
-
validates :name, :handler, presence: true
|
17
16
|
validates :name, uniqueness: { scope: :decidim_user_id }
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
validate :active_handler?
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def active_handler?
|
23
|
+
AuthorizationHandler.active_handler?(name)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/app/models/decidim/scope.rb
CHANGED
@@ -56,7 +56,8 @@ module Decidim
|
|
56
56
|
private
|
57
57
|
|
58
58
|
def forbid_cycles
|
59
|
-
|
59
|
+
return unless parent
|
60
|
+
errors.add(:parent_id, :cycle_detected) if parent.part_of.include?(id)
|
60
61
|
end
|
61
62
|
|
62
63
|
def create_part_of
|
data/app/models/decidim/user.rb
CHANGED
@@ -5,12 +5,12 @@ require_dependency "devise/models/decidim_validatable"
|
|
5
5
|
module Decidim
|
6
6
|
# A User is a citizen that wants to join the platform to participate.
|
7
7
|
class User < ApplicationRecord
|
8
|
-
|
8
|
+
OMNIAUTH_PROVIDERS = [:facebook, :twitter, :google_oauth2, (:developer if Rails.env.development?)].compact
|
9
9
|
ROLES = %w(admin user_manager).freeze
|
10
10
|
|
11
11
|
devise :invitable, :database_authenticatable, :registerable, :confirmable,
|
12
12
|
:recoverable, :rememberable, :trackable, :decidim_validatable,
|
13
|
-
:omniauthable, omniauth_providers:
|
13
|
+
:omniauthable, omniauth_providers: OMNIAUTH_PROVIDERS,
|
14
14
|
request_keys: [:env], reset_password_keys: [:decidim_organization_id, :email]
|
15
15
|
|
16
16
|
belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization"
|
@@ -24,7 +24,7 @@ module Decidim
|
|
24
24
|
validates :name, presence: true, unless: -> { deleted? }
|
25
25
|
validates :locale, inclusion: { in: :available_locales }, allow_blank: true
|
26
26
|
validates :tos_agreement, acceptance: true, allow_nil: false, on: :create
|
27
|
-
validates :avatar, file_size: { less_than_or_equal_to:
|
27
|
+
validates :avatar, file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_avatar_size } }
|
28
28
|
validates :email, uniqueness: { scope: :organization }, unless: -> { deleted? || managed? }
|
29
29
|
validate :all_roles_are_valid
|
30
30
|
|
@@ -106,7 +106,7 @@ module Decidim
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def all_roles_are_valid
|
109
|
-
errors.add(:roles, :invalid) unless roles.all? { |role| ROLES.include?(role) }
|
109
|
+
errors.add(:roles, :invalid) unless roles.compact.all? { |role| ROLES.include?(role) }
|
110
110
|
end
|
111
111
|
|
112
112
|
def available_locales
|
@@ -11,7 +11,7 @@ module Decidim
|
|
11
11
|
validates :name, presence: true, uniqueness: { scope: :decidim_organization_id }
|
12
12
|
validates :document_number, presence: true, uniqueness: { scope: :decidim_organization_id }
|
13
13
|
validates :phone, presence: true
|
14
|
-
validates :avatar, file_size: { less_than_or_equal_to:
|
14
|
+
validates :avatar, file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_avatar_size } }
|
15
15
|
|
16
16
|
validate :correct_state
|
17
17
|
|
@@ -31,9 +31,9 @@ module Decidim
|
|
31
31
|
|
32
32
|
return status(:ok) unless authorization_handler_name
|
33
33
|
|
34
|
-
return status(:missing
|
35
|
-
return status(:invalid,
|
36
|
-
return status(:incomplete,
|
34
|
+
return status(:missing) unless authorization
|
35
|
+
return status(:invalid, fields: unmatched_fields) if unmatched_fields.any?
|
36
|
+
return status(:incomplete, fields: missing_fields) if missing_fields.any?
|
37
37
|
|
38
38
|
status(:ok)
|
39
39
|
end
|
@@ -48,10 +48,12 @@ module Decidim
|
|
48
48
|
|
49
49
|
def authorization
|
50
50
|
return nil unless user
|
51
|
-
return nil unless permission["authorization_handler_name"]
|
52
51
|
|
53
|
-
|
54
|
-
|
52
|
+
handler = permission["authorization_handler_name"]
|
53
|
+
return nil unless handler
|
54
|
+
|
55
|
+
@authorization ||= user.authorizations.find do |authorization|
|
56
|
+
authorization.name == handler
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|