decidim-core 0.8.4 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +1 -1
- data/app/assets/images/decidim/decidim-logo.svg +23 -23
- data/app/assets/images/decidim/default-avatar.svg +7 -7
- data/app/assets/images/decidim/icons.svg +1 -0
- data/app/assets/javascripts/decidim.js.es6 +5 -2
- data/app/assets/javascripts/decidim/append_redirect_url_to_modals.js.es6 +84 -0
- data/app/assets/javascripts/decidim/data_picker.js.es6 +177 -0
- data/app/assets/javascripts/decidim/form_filter.component.js.es6 +25 -20
- data/app/assets/javascripts/decidim/form_filter.component.test.js +24 -13
- data/app/assets/javascripts/decidim/history.js.es6 +3 -3
- data/app/assets/stylesheets/decidim/_decidim.scss +1 -4
- data/app/assets/stylesheets/decidim/_variables.scss +4 -4
- data/app/assets/stylesheets/decidim/editor.scss +13 -0
- data/app/assets/stylesheets/decidim/email.css +9 -1
- data/app/assets/stylesheets/decidim/extras/_add_comments.scss +3 -3
- data/app/assets/stylesheets/decidim/extras/_announcement.scss +1 -1
- data/app/assets/stylesheets/decidim/extras/_collection-sort-controls.scss +2 -2
- data/app/assets/stylesheets/decidim/extras/_embed.scss +6 -5
- data/app/assets/stylesheets/decidim/extras/_impersonation-bar.scss +4 -0
- data/app/assets/stylesheets/decidim/extras/_label-required.scss +1 -1
- data/app/assets/stylesheets/decidim/extras/_leaflet.scss +6 -4
- data/app/assets/stylesheets/decidim/extras/_meeting-registrations.scss +4 -4
- data/app/assets/stylesheets/decidim/extras/_process_stats.scss +11 -4
- data/app/assets/stylesheets/decidim/extras/_proposal_form.scss +3 -3
- data/app/assets/stylesheets/decidim/extras/_quill.scss +1 -1
- data/app/assets/stylesheets/decidim/extras/_reference.scss +3 -3
- data/app/assets/stylesheets/decidim/extras/_register_form.scss +3 -3
- data/app/assets/stylesheets/decidim/extras/_results-per-page.scss +10 -10
- data/app/assets/stylesheets/decidim/extras/_social_icons_mini.scss +4 -3
- data/app/assets/stylesheets/decidim/layouts/_highlighted_banner.scss +38 -0
- data/app/assets/stylesheets/decidim/layouts/_home.scss +33 -3
- data/app/assets/stylesheets/decidim/layouts/_user.scss +33 -5
- data/app/assets/stylesheets/decidim/layouts/_view.scss +1 -2
- data/app/assets/stylesheets/decidim/map.css +5 -3
- data/app/assets/stylesheets/decidim/modules/_address.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_author-avatar.scss +24 -9
- data/app/assets/stylesheets/decidim/modules/_buttons.scss +24 -10
- data/app/assets/stylesheets/decidim/modules/_callout.scss +5 -1
- data/app/assets/stylesheets/decidim/modules/_card-grid.scss +1 -1
- data/app/assets/stylesheets/decidim/modules/_cards.scss +102 -31
- data/app/assets/stylesheets/decidim/modules/_comments.scss +21 -20
- data/app/assets/stylesheets/decidim/modules/_cookie-bar.scss +4 -0
- data/app/assets/stylesheets/decidim/modules/_data-picker.scss +159 -0
- data/app/assets/stylesheets/decidim/modules/_datepicker.scss +36 -36
- data/app/assets/stylesheets/decidim/modules/_definition-data.scss +12 -9
- data/app/assets/stylesheets/decidim/modules/_extra.scss +4 -1
- data/app/assets/stylesheets/decidim/modules/_filter-tags.scss +3 -0
- data/app/assets/stylesheets/decidim/modules/_filters.scss +9 -5
- data/app/assets/stylesheets/decidim/modules/_flag.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_footer.scss +10 -0
- data/app/assets/stylesheets/decidim/modules/_forms.scss +2 -1
- data/app/assets/stylesheets/decidim/modules/_help.scss +2 -0
- data/app/assets/stylesheets/decidim/modules/_icons.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_layout.scss +4 -0
- data/app/assets/stylesheets/decidim/modules/_list-docs.scss +3 -0
- data/app/assets/stylesheets/decidim/modules/_main-container.scss +13 -7
- data/app/assets/stylesheets/decidim/modules/_map.scss +13 -1
- data/app/assets/stylesheets/decidim/modules/_margins.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_messages.scss +2 -1
- data/app/assets/stylesheets/decidim/modules/_modules.scss +3 -0
- data/app/assets/stylesheets/decidim/modules/_navbar.scss +36 -16
- data/app/assets/stylesheets/decidim/modules/_omnipresent_banner.scss +26 -0
- data/app/assets/stylesheets/decidim/modules/_opinion-toggle.scss +5 -0
- data/app/assets/stylesheets/decidim/modules/_order-by.scss +10 -10
- data/app/assets/stylesheets/decidim/modules/_pagination.scss +3 -2
- data/app/assets/stylesheets/decidim/modules/_process-header.scss +11 -2
- data/app/assets/stylesheets/decidim/modules/_process-info.scss +9 -1
- data/app/assets/stylesheets/decidim/modules/_process-nav.scss +20 -3
- data/app/assets/stylesheets/decidim/modules/_process-phase.scss +12 -3
- data/app/assets/stylesheets/decidim/modules/_progress-bar.scss +69 -0
- data/app/assets/stylesheets/decidim/modules/_reference.scss +1 -2
- data/app/assets/stylesheets/decidim/modules/_reveal.scss +1 -1
- data/app/assets/stylesheets/decidim/modules/_share.scss +2 -0
- data/app/assets/stylesheets/decidim/modules/_signup.scss +5 -1
- data/app/assets/stylesheets/decidim/modules/_static-pages.scss +6 -0
- data/app/assets/stylesheets/decidim/modules/_status-labels.scss +2 -0
- data/app/assets/stylesheets/decidim/modules/_tags.scss +3 -1
- data/app/assets/stylesheets/decidim/modules/_timeline.scss +41 -30
- data/app/assets/stylesheets/decidim/modules/_title-action.scss +2 -1
- data/app/assets/stylesheets/decidim/modules/_typography.scss +13 -4
- data/app/assets/stylesheets/decidim/modules/_user-form.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_video.scss +2 -2
- data/app/assets/stylesheets/decidim/utils/_fontface.scss +22 -20
- data/app/assets/stylesheets/decidim/utils/_helpers.scss +6 -6
- data/app/assets/stylesheets/decidim/utils/_keyframes.scss +6 -6
- data/app/assets/stylesheets/decidim/utils/_mixins.scss +24 -7
- data/app/assets/stylesheets/decidim/utils/_settings.scss +50 -52
- data/app/assets/stylesheets/decidim/utils/_toggle-expand.scss +1 -0
- data/app/commands/decidim/create_omniauth_registration.rb +3 -0
- data/app/commands/decidim/create_registration.rb +3 -1
- data/app/commands/decidim/destroy_account.rb +1 -0
- data/app/commands/decidim/invite_user_again.rb +1 -1
- data/app/commands/decidim/messaging/reply_to_conversation.rb +1 -3
- data/app/commands/decidim/unsubscribe_settings.rb +29 -0
- data/app/commands/decidim/update_account.rb +16 -3
- data/app/controllers/concerns/decidim/action_authorization.rb +1 -1
- data/app/controllers/concerns/decidim/devise_controllers.rb +10 -0
- data/app/controllers/concerns/decidim/form_factory.rb +2 -1
- data/app/controllers/concerns/decidim/impersonate_users.rb +13 -8
- data/app/controllers/concerns/decidim/participatory_space_context.rb +1 -1
- data/app/controllers/decidim/application_controller.rb +16 -0
- data/app/controllers/decidim/cookie_policy_controller.rb +2 -0
- data/app/controllers/decidim/devise/invitations_controller.rb +9 -1
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +10 -1
- data/app/controllers/decidim/devise/sessions_controller.rb +9 -1
- data/app/controllers/decidim/locales_controller.rb +2 -3
- data/app/controllers/decidim/messaging/conversations_controller.rb +2 -2
- data/app/controllers/decidim/newsletters_controller.rb +60 -0
- data/app/controllers/decidim/pages_controller.rb +1 -0
- data/app/controllers/decidim/profiles_controller.rb +23 -0
- data/app/controllers/decidim/scopes_controller.rb +19 -20
- data/app/events/decidim/profile_updated_event.rb +27 -0
- data/app/forms/decidim/account_form.rb +34 -0
- data/app/forms/decidim/form.rb +1 -0
- data/app/forms/decidim/messaging/conversation_form.rb +5 -2
- data/app/forms/decidim/omniauth_registration_form.rb +5 -0
- data/app/forms/decidim/registration_form.rb +8 -1
- data/app/helpers/decidim/action_authorization_helper.rb +2 -2
- data/app/helpers/decidim/application_helper.rb +8 -0
- data/app/helpers/decidim/feature_path_helper.rb +12 -2
- data/app/helpers/decidim/feature_reference_helper.rb +1 -1
- data/app/helpers/decidim/messaging/conversation_helper.rb +27 -9
- data/app/helpers/decidim/newsletters_helper.rb +49 -0
- data/app/helpers/decidim/scopes_helper.rb +43 -2
- data/app/helpers/decidim/translations_helper.rb +6 -2
- data/app/mailers/decidim/decidim_devise_mailer.rb +1 -3
- data/app/mailers/decidim/messaging/conversation_mailer.rb +1 -1
- data/app/mailers/decidim/newsletter_mailer.rb +7 -8
- data/app/models/decidim/abilities/everyone_ability.rb +1 -0
- data/app/models/decidim/authorization.rb +19 -5
- data/app/models/decidim/impersonation_log.rb +2 -1
- data/app/models/decidim/messaging/conversation.rb +2 -0
- data/app/models/decidim/messaging/message.rb +4 -0
- data/app/models/decidim/organization.rb +1 -0
- data/app/models/decidim/scope.rb +10 -2
- data/app/models/decidim/user.rb +10 -2
- data/app/presenters/decidim/home_stats_presenter.rb +10 -4
- data/app/presenters/decidim/user_group_presenter.rb +28 -0
- data/app/presenters/decidim/user_presenter.rb +42 -0
- data/app/services/decidim/action_authorizer.rb +32 -68
- data/app/services/decidim/notification_generator_for_recipient.rb +8 -3
- data/app/uploaders/decidim/avatar_uploader.rb +2 -2
- data/app/views/decidim/account/delete.html.erb +1 -1
- data/app/views/decidim/account/show.html.erb +4 -1
- data/app/views/decidim/devise/invitations/edit.html.erb +2 -0
- data/app/views/decidim/devise/omniauth_registrations/new.html.erb +7 -1
- data/app/views/decidim/devise/registrations/new.html.erb +7 -1
- data/app/views/decidim/messaging/conversations/_message.html.erb +6 -12
- data/app/views/decidim/messaging/conversations/_reply.html.erb +1 -1
- data/app/views/decidim/messaging/conversations/index.html.erb +1 -1
- data/app/views/decidim/messaging/conversations/update.js.erb +1 -0
- data/app/views/decidim/newsletter_mailer/newsletter.html.erb +11 -0
- data/app/views/decidim/newsletters/show.html.erb +11 -0
- data/app/views/decidim/newsletters/unsubscribe.html.erb +4 -0
- data/app/views/decidim/notifications/_notification.html.erb +1 -1
- data/app/views/decidim/profiles/show.html.erb +64 -0
- data/app/views/decidim/scopes/_scopes_picker_input.html.erb +6 -0
- data/app/views/decidim/scopes/picker.html.erb +36 -0
- data/app/views/decidim/shared/_action_authorization_modal.html.erb +25 -51
- data/app/views/decidim/shared/_author.html.erb +21 -0
- data/app/views/decidim/shared/_author_reference.html.erb +12 -0
- data/app/views/layouts/decidim/_application.html.erb +1 -0
- data/app/views/layouts/decidim/_impersonation_warning.html.erb +1 -1
- data/app/views/layouts/decidim/_mailer_logo.html.erb +6 -1
- data/app/views/layouts/decidim/_omnipresent_banner.html.erb +14 -0
- data/app/views/layouts/decidim/_user_menu.html.erb +3 -0
- data/app/views/layouts/decidim/mailer.html.erb +16 -4
- data/app/views/layouts/decidim/widget.html.erb +14 -9
- data/app/views/pages/home.html.erb +2 -0
- data/app/views/pages/home/_highlighted_content_banner.html.erb +26 -0
- data/config/initializers/devise.rb +1 -3
- data/config/locales/ca.yml +67 -9
- data/config/locales/en.yml +65 -4
- data/config/locales/es.yml +74 -14
- data/config/locales/eu.yml +66 -4
- data/config/locales/fi.yml +87 -25
- data/config/locales/fr.yml +71 -9
- data/config/locales/gl.yml +493 -0
- data/config/locales/it.yml +79 -17
- data/config/locales/nl.yml +71 -9
- data/config/locales/pl.yml +66 -4
- data/config/locales/pt-BR.yml +493 -0
- data/config/locales/pt.yml +99 -37
- data/config/locales/ru.yml +85 -13
- data/config/locales/sv.yml +493 -0
- data/config/locales/uk.yml +78 -16
- data/config/routes.rb +11 -1
- data/db/migrate/20171212103803_create_unique_nicknames.rb +29 -0
- data/db/migrate/20180115090038_extend_user_profile.rb +8 -0
- data/db/migrate/20180123125308_add_enable_omnipresent_banner_to_decidim_organizations.rb +7 -0
- data/db/migrate/20180123125409_add_omnipresent_banner_title_to_decidim_organizations.rb +7 -0
- data/db/migrate/20180123125432_add_omnipresent_banner_short_description_to_decidim_organizations.rb +7 -0
- data/db/migrate/20180123125452_add_omnipresent_banner_url_to_decidim_organizations.rb +7 -0
- data/db/migrate/20180125063433_add_highlighted_content_banner_to_decidim_organizations.rb +13 -0
- data/db/seeds.rb +8 -2
- data/lib/decidim/abilities/participatory_process_role_ability.rb +1 -3
- data/lib/decidim/content_parsers.rb +8 -0
- data/lib/decidim/content_parsers/base_parser.rb +58 -0
- data/lib/decidim/content_parsers/user_parser.rb +46 -0
- data/lib/decidim/content_processor.rb +84 -0
- data/lib/decidim/content_renderers.rb +8 -0
- data/lib/decidim/content_renderers/base_renderer.rb +37 -0
- data/lib/decidim/content_renderers/user_renderer.rb +32 -0
- data/lib/decidim/core.rb +66 -1
- data/lib/decidim/core/api/author_interface.rb +3 -3
- data/lib/decidim/core/api/user_group_type.rb +10 -8
- data/lib/decidim/core/api/user_type.rb +13 -7
- data/lib/decidim/core/engine.rb +7 -5
- data/lib/decidim/core/test.rb +1 -1
- data/lib/decidim/core/test/factories.rb +21 -45
- data/lib/decidim/core/test/shared_examples/announcements_examples.rb +3 -2
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +5 -2
- data/lib/decidim/core/test/shared_examples/scope_helper_examples.rb +40 -3
- data/lib/decidim/core/test/shared_examples/simple_event.rb +73 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/events.rb +2 -0
- data/lib/decidim/events/author_event.rb +41 -0
- data/lib/decidim/events/base_event.rb +28 -3
- data/lib/decidim/events/email_event.rb +1 -1
- data/lib/decidim/events/notification_event.rb +1 -1
- data/lib/decidim/events/simple_event.rb +79 -0
- data/lib/decidim/filter_form_builder.rb +2 -3
- data/lib/decidim/form_builder.rb +39 -27
- data/lib/decidim/friendly_dates.rb +26 -0
- data/lib/decidim/has_feature.rb +1 -0
- data/lib/decidim/has_reference.rb +1 -1
- data/lib/decidim/i18n_exceptions.rb +1 -3
- data/lib/decidim/menu.rb +1 -1
- data/lib/decidim/newsletter_encryptor.rb +22 -0
- data/lib/decidim/nicknamizable.rb +56 -0
- data/lib/decidim/participable.rb +8 -0
- data/lib/decidim/participatory_space_manifest.rb +10 -1
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.gl.js +13 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.pt-br.js +14 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.pt.js +5 -1
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ru.js +4 -1
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.sv.js +14 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.uk.js +4 -1
- data/vendor/assets/javascripts/form_datepicker.js.es6 +4 -2
- data/vendor/assets/javascripts/foundation-datepicker.js +42 -26
- metadata +124 -84
- data/app/assets/javascripts/decidim/select2.field.js.es6 +0 -47
- data/app/assets/javascripts/decidim/select2.js.es6 +0 -11
- data/app/assets/stylesheets/decidim/editor.sass +0 -4
- data/app/assets/stylesheets/decidim/plugins/_select2.scss +0 -63
- data/app/helpers/decidim/datetime_helper.rb +0 -23
- data/app/queries/decidim/freetext_scopes.rb +0 -39
- data/lib/decidim/core/test/shared_examples/manage_moderations_examples.rb +0 -64
@@ -50,6 +50,9 @@ module Decidim
|
|
50
50
|
unless @user.persisted?
|
51
51
|
@user.email = (verified_email || form.email)
|
52
52
|
@user.name = form.name
|
53
|
+
@user.nickname = form.normalized_nickname
|
54
|
+
@user.newsletter_notifications = true
|
55
|
+
@user.email_on_notification = true
|
53
56
|
@user.password = generated_password
|
54
57
|
@user.password_confirmation = generated_password
|
55
58
|
@user.skip_confirmation! if verified_email
|
@@ -35,11 +35,13 @@ module Decidim
|
|
35
35
|
def create_user
|
36
36
|
@user = User.create!(email: form.email,
|
37
37
|
name: form.name,
|
38
|
+
nickname: form.nickname,
|
38
39
|
password: form.password,
|
39
40
|
password_confirmation: form.password_confirmation,
|
40
41
|
organization: form.current_organization,
|
41
42
|
tos_agreement: form.tos_agreement,
|
42
|
-
newsletter_notifications: form.
|
43
|
+
newsletter_notifications: form.newsletter,
|
44
|
+
email_on_notification: true)
|
43
45
|
end
|
44
46
|
|
45
47
|
def create_user_group
|
@@ -43,9 +43,7 @@ module Decidim
|
|
43
43
|
|
44
44
|
def notify_interlocutors
|
45
45
|
conversation.interlocutors(sender).each do |recipient|
|
46
|
-
if conversation.unread_count(recipient) == 1
|
47
|
-
ConversationMailer.new_message(sender, recipient, conversation).deliver_later
|
48
|
-
end
|
46
|
+
ConversationMailer.new_message(sender, recipient, conversation).deliver_later if conversation.unread_count(recipient) == 1
|
49
47
|
end
|
50
48
|
end
|
51
49
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This command unsubscribes user from newsletter.
|
5
|
+
class UnsubscribeSettings < Rectify::Command
|
6
|
+
# unsubscribe user from newsletter.
|
7
|
+
#
|
8
|
+
# user - The user to be updated.
|
9
|
+
# newsletter_notifications - to be false
|
10
|
+
def initialize(user)
|
11
|
+
@user = user
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
return broadcast(:invalid) unless @user.newsletter_notifications
|
16
|
+
|
17
|
+
update_settings
|
18
|
+
@user.save!
|
19
|
+
|
20
|
+
broadcast(:ok, @user)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def update_settings
|
26
|
+
@user.newsletter_notifications = false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -21,11 +21,10 @@ module Decidim
|
|
21
21
|
|
22
22
|
if @user.valid?
|
23
23
|
@user.save!
|
24
|
+
notify_followers
|
24
25
|
broadcast(:ok, @user.unconfirmed_email.present?)
|
25
26
|
else
|
26
|
-
if @user.errors.has_key? :avatar
|
27
|
-
@form.errors.add :avatar, @user.errors[:avatar]
|
28
|
-
end
|
27
|
+
@form.errors.add :avatar, @user.errors[:avatar] if @user.errors.has_key? :avatar
|
29
28
|
broadcast(:invalid)
|
30
29
|
end
|
31
30
|
end
|
@@ -34,7 +33,10 @@ module Decidim
|
|
34
33
|
|
35
34
|
def update_personal_data
|
36
35
|
@user.name = @form.name
|
36
|
+
@user.nickname = @form.nickname
|
37
37
|
@user.email = @form.email
|
38
|
+
@user.personal_url = @form.personal_url
|
39
|
+
@user.about = @form.about
|
38
40
|
end
|
39
41
|
|
40
42
|
def update_avatar
|
@@ -48,5 +50,16 @@ module Decidim
|
|
48
50
|
@user.password = @form.password
|
49
51
|
@user.password_confirmation = @form.password_confirmation
|
50
52
|
end
|
53
|
+
|
54
|
+
def notify_followers
|
55
|
+
return if (@user.previous_changes.keys & %w(about personal_url)).empty?
|
56
|
+
|
57
|
+
Decidim::EventsManager.publish(
|
58
|
+
event: "decidim.events.users.profile_updated",
|
59
|
+
event_class: Decidim::ProfileUpdatedEvent,
|
60
|
+
resource: @user,
|
61
|
+
recipient_ids: @user.followers.pluck(:id)
|
62
|
+
)
|
63
|
+
end
|
51
64
|
end
|
52
65
|
end
|
@@ -19,7 +19,7 @@ module Decidim
|
|
19
19
|
status = action_authorization(action_name)
|
20
20
|
|
21
21
|
return if status.ok?
|
22
|
-
raise Unauthorized if status.code == :
|
22
|
+
raise Unauthorized if status.code == :unauthorized
|
23
23
|
|
24
24
|
redirect_to authorize_action_path(action_name, redirect_url: redirect_url)
|
25
25
|
end
|
@@ -25,6 +25,10 @@ module Decidim
|
|
25
25
|
helper Decidim::OmniauthHelper
|
26
26
|
|
27
27
|
layout "layouts/decidim/application"
|
28
|
+
|
29
|
+
# Saves the location before loading each page so we can return to the
|
30
|
+
# right page.
|
31
|
+
before_action :store_current_location
|
28
32
|
end
|
29
33
|
|
30
34
|
# Overwrites `cancancan`'s method to point to the correct ability class,
|
@@ -32,5 +36,11 @@ module Decidim
|
|
32
36
|
def current_ability_klass
|
33
37
|
Decidim::Abilities::BaseAbility
|
34
38
|
end
|
39
|
+
|
40
|
+
def store_current_location
|
41
|
+
return if params[:redirect_url].blank? || !request.format.html?
|
42
|
+
|
43
|
+
store_location_for(:user, params[:redirect_url])
|
44
|
+
end
|
35
45
|
end
|
36
46
|
end
|
@@ -73,7 +73,8 @@ module Decidim
|
|
73
73
|
{
|
74
74
|
current_organization: @controller.try(:current_organization),
|
75
75
|
current_feature: @controller.try(:current_feature),
|
76
|
-
current_user: @controller.try(:current_user)
|
76
|
+
current_user: @controller.try(:current_user),
|
77
|
+
current_participatory_space: @controller.try(:current_participatory_space)
|
77
78
|
}
|
78
79
|
end
|
79
80
|
end.new(klass, self)
|
@@ -37,14 +37,12 @@ module Decidim
|
|
37
37
|
|
38
38
|
# Check if the active impersonation session has expired or not.
|
39
39
|
def check_impersonation_log_expired
|
40
|
-
return unless can_impersonate_users? &&
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
redirect_to decidim_admin.managed_users_path
|
47
|
-
end
|
40
|
+
return unless can_impersonate_users? && expired_log
|
41
|
+
|
42
|
+
expired_log.ended_at = Time.current
|
43
|
+
expired_log.save!
|
44
|
+
flash[:alert] = I18n.t("managed_users.expired_session", scope: "decidim")
|
45
|
+
redirect_to decidim_admin.managed_users_path
|
48
46
|
end
|
49
47
|
|
50
48
|
# Gets the ability instance for the real user logged in.
|
@@ -56,6 +54,13 @@ module Decidim
|
|
56
54
|
real_user && real_ability.can?(:impersonate, :managed_users)
|
57
55
|
end
|
58
56
|
|
57
|
+
def expired_log
|
58
|
+
@expired_log ||= Decidim::ImpersonationLog
|
59
|
+
.where(admin: real_user)
|
60
|
+
.expired
|
61
|
+
.first
|
62
|
+
end
|
63
|
+
|
59
64
|
def impersonation_log
|
60
65
|
@impersonation_log ||= Decidim::ImpersonationLog
|
61
66
|
.where(admin: real_user)
|
@@ -20,6 +20,10 @@ module Decidim
|
|
20
20
|
helper Decidim::FeaturePathHelper
|
21
21
|
helper Decidim::ViewHooksHelper
|
22
22
|
|
23
|
+
# Saves the location before loading each page so we can return to the
|
24
|
+
# right page.
|
25
|
+
before_action :store_current_location
|
26
|
+
|
23
27
|
protect_from_forgery with: :exception, prepend: true
|
24
28
|
after_action :add_vary_header
|
25
29
|
|
@@ -27,6 +31,18 @@ module Decidim
|
|
27
31
|
|
28
32
|
private
|
29
33
|
|
34
|
+
# Stores the url where the user will be redirected after login.
|
35
|
+
#
|
36
|
+
# Uses the `redirect_url` param or the current url if there's no param.
|
37
|
+
# In Devise controllers we only store the URL if it's from the params, we don't
|
38
|
+
# want to overwrite the stored URL for a Devise one.
|
39
|
+
def store_current_location
|
40
|
+
return if (devise_controller? && params[:redirect_url].blank?) || !request.format.html?
|
41
|
+
|
42
|
+
value = params[:redirect_url] || request.url
|
43
|
+
store_location_for(:user, value)
|
44
|
+
end
|
45
|
+
|
30
46
|
def user_not_authorized_path
|
31
47
|
decidim.root_path
|
32
48
|
end
|
@@ -6,6 +6,8 @@ module Decidim
|
|
6
6
|
class InvitationsController < ::Devise::InvitationsController
|
7
7
|
include Decidim::DeviseControllers
|
8
8
|
|
9
|
+
before_action :configure_permitted_parameters
|
10
|
+
|
9
11
|
# We don't users to create invitations, so we just redirect them to the
|
10
12
|
# homepage.
|
11
13
|
def authenticate_inviter!
|
@@ -16,7 +18,7 @@ module Decidim
|
|
16
18
|
# invitation. Using the param `invite_redirect` we can redirect the user
|
17
19
|
# to a custom path after it has accepted the invitation.
|
18
20
|
def after_accept_path_for(resource)
|
19
|
-
params[:invite_redirect] ||
|
21
|
+
params[:invite_redirect] || after_sign_in_path_for(resource)
|
20
22
|
end
|
21
23
|
|
22
24
|
# When a managed user accepts the invitation is promoted to non-managed user.
|
@@ -25,6 +27,12 @@ module Decidim
|
|
25
27
|
resource.update_attributes!(managed: false) if resource.managed?
|
26
28
|
resource
|
27
29
|
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def configure_permitted_parameters
|
34
|
+
devise_parameter_sanitizer.permit(:accept_invitation, keys: [:nickname])
|
35
|
+
end
|
28
36
|
end
|
29
37
|
end
|
30
38
|
end
|
@@ -44,13 +44,21 @@ module Decidim
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def after_sign_in_path_for(user)
|
47
|
-
if first_login_and_not_authorized?(user)
|
47
|
+
if !pending_redirect?(user) && first_login_and_not_authorized?(user)
|
48
48
|
decidim_verifications.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
|
+
|
54
62
|
def first_login_and_not_authorized?(user)
|
55
63
|
user.is_a?(User) && user.sign_in_count == 1 && Decidim::Verifications.workflows.any?
|
56
64
|
end
|
@@ -75,6 +83,7 @@ module Decidim
|
|
75
83
|
provider: oauth_data[:provider],
|
76
84
|
uid: oauth_data[:uid],
|
77
85
|
name: oauth_data[:info][:name],
|
86
|
+
nickname: oauth_data[:info][:nickname],
|
78
87
|
oauth_signature: OmniauthRegistrationForm.create_signature(oauth_data[:provider], oauth_data[:uid])
|
79
88
|
}
|
80
89
|
end
|
@@ -7,13 +7,21 @@ module Decidim
|
|
7
7
|
include Decidim::DeviseControllers
|
8
8
|
|
9
9
|
def after_sign_in_path_for(user)
|
10
|
-
if first_login_and_not_authorized?(user) && !user.admin?
|
10
|
+
if first_login_and_not_authorized?(user) && !user.admin? && !pending_redirect?(user)
|
11
11
|
decidim_verifications.first_login_authorizations_path
|
12
12
|
else
|
13
13
|
super
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
# Calling the `stored_location_for` method removes the key, so in order
|
18
|
+
# to check if there's any pending redirect after login I need to call
|
19
|
+
# this method and use the value to set a pending redirect. This is the
|
20
|
+
# only way to do this without checking the session directly.
|
21
|
+
def pending_redirect?(user)
|
22
|
+
store_location_for(user, stored_location_for(user))
|
23
|
+
end
|
24
|
+
|
17
25
|
def first_login_and_not_authorized?(user)
|
18
26
|
user.is_a?(User) && user.sign_in_count == 1 && current_organization.available_authorizations.any?
|
19
27
|
end
|
@@ -3,12 +3,11 @@
|
|
3
3
|
module Decidim
|
4
4
|
# A controller to allow users switching their locale.
|
5
5
|
class LocalesController < Decidim::ApplicationController
|
6
|
+
skip_before_action :store_current_location
|
6
7
|
authorize_resource :locales, class: false
|
7
8
|
|
8
9
|
def create
|
9
|
-
if current_user && params["locale"] && available_locales.include?(params["locale"])
|
10
|
-
current_user.update_attributes!(locale: params["locale"])
|
11
|
-
end
|
10
|
+
current_user.update_attributes!(locale: params["locale"]) if current_user && params["locale"] && available_locales.include?(params["locale"])
|
12
11
|
|
13
12
|
redirect_to referer_with_new_locale
|
14
13
|
end
|
@@ -8,7 +8,6 @@ module Decidim
|
|
8
8
|
include FormFactory
|
9
9
|
|
10
10
|
helper ConversationHelper
|
11
|
-
helper Decidim::DatetimeHelper
|
12
11
|
|
13
12
|
before_action :authenticate_user!
|
14
13
|
|
@@ -18,8 +17,9 @@ module Decidim
|
|
18
17
|
authorize! :create, Conversation
|
19
18
|
@form = form(ConversationForm).from_params(params)
|
20
19
|
|
21
|
-
|
20
|
+
redirect_back(fallback_location: profile_path(current_user.nickname)) && return unless @form.recipient
|
22
21
|
|
22
|
+
conversation = conversation_between(current_user, @form.recipient)
|
23
23
|
redirect_to conversation_path(conversation) if conversation
|
24
24
|
end
|
25
25
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# The controller to show the newsletter on the website.
|
5
|
+
class NewslettersController < Decidim::ApplicationController
|
6
|
+
skip_authorization_check
|
7
|
+
|
8
|
+
layout "decidim/mailer", only: [:show]
|
9
|
+
helper Decidim::SanitizeHelper
|
10
|
+
include Decidim::NewslettersHelper
|
11
|
+
|
12
|
+
helper_method :newsletter
|
13
|
+
|
14
|
+
def show
|
15
|
+
@user = current_user
|
16
|
+
@organization = current_organization
|
17
|
+
|
18
|
+
if newsletter.sent?
|
19
|
+
@encrypted_token = Decidim::NewsletterEncryptor.sent_at_encrypted(@user.id, newsletter.sent_at) if @user.present?
|
20
|
+
@body = parse_interpolations(newsletter.body[I18n.locale.to_s], @user, newsletter.id)
|
21
|
+
else
|
22
|
+
redirect_to "/404"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def unsubscribe
|
27
|
+
encryptor = Decidim::NewsletterEncryptor
|
28
|
+
|
29
|
+
decrypted_string = encryptor.sent_at_decrypted(params[:u])
|
30
|
+
user = User.find_by(decidim_organization_id: current_organization.id, id: decrypted_string.split("-").first)
|
31
|
+
sent_at_time = Time.zone.at(decrypted_string.split("-").second.to_i)
|
32
|
+
|
33
|
+
if sent_at_time > (Time.current - 15.days)
|
34
|
+
UnsubscribeSettings.call(user) do
|
35
|
+
on(:ok) do
|
36
|
+
flash.now[:notice] = t("newsletters.unsubscribe.success", scope: "decidim")
|
37
|
+
end
|
38
|
+
|
39
|
+
on(:invalid) do
|
40
|
+
flash.now[:alert] = t("newsletters.unsubscribe.error", scope: "decidim")
|
41
|
+
render action: :unsubscribe
|
42
|
+
end
|
43
|
+
end
|
44
|
+
else
|
45
|
+
flash.now[:alert] = t("newsletters.unsubscribe.token_error", scope: "decidim")
|
46
|
+
render action: :unsubscribe
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def newsletter
|
51
|
+
@newsletter ||= collection.find(params[:id])
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def collection
|
57
|
+
Newsletter.where(organization: current_organization)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|