decidim-core 0.14.4 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +20 -0
- data/app/assets/images/decidim/cc-badge.png +0 -0
- data/app/assets/images/decidim/gamification/badges/continuity.svg +73 -0
- data/app/assets/images/decidim/gamification/badges/followers.svg +115 -0
- data/app/assets/images/decidim/icons.svg +1 -0
- data/app/assets/javascripts/decidim/vizzs/areachart.js.es6 +186 -208
- data/app/assets/javascripts/decidim/vizzs/linechart.js.es6 +263 -0
- data/app/assets/javascripts/decidim/vizzs/metrics.js.es6 +36 -26
- data/app/assets/javascripts/decidim/vizzs/orgchart.js.es6 +3 -2
- data/app/assets/javascripts/decidim/vizzs/rowchart.js.es6 +324 -0
- data/app/assets/stylesheets/decidim/_decidim.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_cards.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_conference-diploma.scss +75 -0
- data/app/assets/stylesheets/decidim/modules/_conference-media.scss +44 -0
- data/app/assets/stylesheets/decidim/modules/_conference-programme.scss +5 -1
- data/app/assets/stylesheets/decidim/modules/_conference-registration.scss +34 -0
- data/app/assets/stylesheets/decidim/modules/_list-request.scss +16 -0
- data/app/assets/stylesheets/decidim/modules/_modules.scss +4 -4
- data/app/assets/stylesheets/decidim/modules/_process-phase.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_reveal.scss +6 -1
- data/app/assets/stylesheets/decidim/utils/_helpers.scss +1 -1
- data/app/assets/stylesheets/decidim/{modules → vizzs}/_areachart.scss +8 -11
- data/app/assets/stylesheets/decidim/{modules → vizzs}/_chart-tooltip.scss +0 -0
- data/app/assets/stylesheets/decidim/vizzs/_linechart.scss +115 -0
- data/app/assets/stylesheets/decidim/vizzs/_rowchart.scss +77 -0
- data/app/cells/decidim/activities/show.erb +3 -0
- data/app/cells/decidim/activities_cell.rb +38 -0
- data/app/cells/decidim/activity/show.erb +21 -0
- data/app/cells/decidim/activity_cell.rb +85 -0
- data/app/cells/decidim/address/details.erb +7 -0
- data/app/cells/decidim/address/show.erb +14 -0
- data/app/cells/decidim/address_cell.rb +19 -0
- data/app/cells/decidim/author/contact.erb +1 -1
- data/app/cells/decidim/author_cell.rb +1 -0
- data/app/cells/decidim/badge/show.erb +2 -2
- data/app/cells/decidim/badge/small.erb +5 -0
- data/app/cells/decidim/badge_cell.rb +36 -14
- data/app/cells/decidim/badges/show.erb +6 -3
- data/app/cells/decidim/badges_cell.rb +4 -4
- data/app/cells/decidim/coauthorships_cell.rb +8 -2
- data/app/cells/decidim/collapsible_authors/show.erb +9 -7
- data/app/cells/decidim/content_blocks/html/show.erb +3 -0
- data/app/cells/decidim/content_blocks/html_cell.rb +11 -0
- data/app/cells/decidim/content_blocks/html_settings_form/show.erb +3 -0
- data/app/cells/decidim/content_blocks/html_settings_form_cell.rb +17 -0
- data/app/cells/decidim/content_blocks/last_activity/show.erb +17 -0
- data/app/cells/decidim/content_blocks/last_activity_cell.rb +60 -0
- data/app/cells/decidim/content_blocks/metrics/show.erb +13 -0
- data/app/cells/decidim/content_blocks/metrics_cell.rb +18 -0
- data/app/cells/decidim/content_blocks/stats/show.erb +2 -1
- data/app/cells/decidim/groups/show.erb +10 -0
- data/app/cells/decidim/groups_cell.rb +19 -0
- data/app/cells/decidim/members/show.erb +9 -0
- data/app/cells/decidim/members_cell.rb +32 -0
- data/app/cells/decidim/profile/show.erb +3 -11
- data/app/cells/decidim/profile/user_group_tabs.erb +5 -0
- data/app/cells/decidim/profile/user_tabs.erb +12 -0
- data/app/cells/decidim/profile_cell.rb +7 -2
- data/app/cells/decidim/profile_sidebar/show.erb +108 -23
- data/app/cells/decidim/profile_sidebar_cell.rb +36 -2
- data/app/cells/decidim/user_group_admin_membership_profile/footer.erb +29 -0
- data/app/cells/decidim/user_group_admin_membership_profile_cell.rb +14 -0
- data/app/cells/decidim/user_group_membership_profile/tags.erb +1 -0
- data/app/cells/decidim/user_group_membership_profile_cell.rb +8 -0
- data/app/cells/decidim/user_group_pending_invitations_list/show.erb +23 -0
- data/app/cells/decidim/user_group_pending_invitations_list_cell.rb +26 -0
- data/app/cells/decidim/user_group_pending_requests_list/show.erb +23 -0
- data/app/cells/decidim/user_group_pending_requests_list_cell.rb +26 -0
- data/app/cells/decidim/user_profile/header.erb +1 -1
- data/app/cells/decidim/user_profile_cell.rb +15 -9
- data/app/commands/decidim/accept_group_invitation.rb +43 -0
- data/app/commands/decidim/accept_user_group_join_request.rb +53 -0
- data/app/commands/decidim/create_follow.rb +6 -0
- data/app/commands/decidim/create_registration.rb +13 -23
- data/app/commands/decidim/create_user_group.rb +57 -0
- data/app/commands/decidim/delete_follow.rb +7 -0
- data/app/commands/decidim/demote_membership.rb +57 -0
- data/app/commands/decidim/destroy_account.rb +6 -0
- data/app/commands/decidim/invite_user.rb +1 -3
- data/app/commands/decidim/invite_user_to_group.rb +62 -0
- data/app/commands/decidim/join_user_group.rb +63 -0
- data/app/commands/decidim/leave_user_group.rb +41 -0
- data/app/commands/decidim/promote_membership.rb +55 -0
- data/app/commands/decidim/reject_group_invitation.rb +42 -0
- data/app/commands/decidim/reject_user_group_join_request.rb +53 -0
- data/app/commands/decidim/remove_user_from_group.rb +53 -0
- data/app/commands/decidim/update_user_group.rb +53 -0
- data/app/controllers/concerns/decidim/locale_switcher.rb +3 -3
- data/app/controllers/concerns/decidim/paginable.rb +1 -0
- data/app/controllers/decidim/application_controller.rb +7 -0
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +1 -1
- data/app/controllers/decidim/devise/sessions_controller.rb +1 -1
- data/app/controllers/decidim/gamification/badges_controller.rb +11 -0
- data/app/controllers/decidim/group_admins_controller.rb +41 -0
- data/app/controllers/decidim/group_invites_controller.rb +74 -0
- data/app/controllers/decidim/group_members_controller.rb +59 -0
- data/app/controllers/decidim/groups_controller.rb +85 -0
- data/app/controllers/decidim/last_activities_controller.rb +46 -0
- data/app/controllers/decidim/pages_controller.rb +9 -1
- data/app/controllers/decidim/profiles_controller.rb +35 -5
- data/app/controllers/decidim/user_group_join_requests_controller.rb +69 -0
- data/app/events/decidim/demoted_membership_event.rb +28 -0
- data/app/events/decidim/invited_to_group_event.rb +33 -0
- data/app/events/decidim/join_request_accepted_event.rb +28 -0
- data/app/events/decidim/join_request_created_event.rb +28 -0
- data/app/events/decidim/join_request_rejected_event.rb +28 -0
- data/app/events/decidim/promoted_to_admin_event.rb +28 -0
- data/app/events/decidim/removed_from_group_event.rb +28 -0
- data/app/forms/decidim/account_form.rb +1 -1
- data/app/forms/decidim/invite_user_to_group_form.rb +29 -0
- data/app/forms/decidim/notifications_settings_form.rb +4 -0
- data/app/forms/decidim/registration_form.rb +0 -27
- data/app/forms/decidim/user_group_form.rb +81 -0
- data/app/helpers/decidim/component_path_helper.rb +10 -0
- data/app/helpers/decidim/filters_helper.rb +3 -2
- data/app/helpers/decidim/icon_helper.rb +3 -1
- data/app/helpers/decidim/map_helper.rb +1 -1
- data/app/jobs/decidim/metric_job.rb +14 -0
- data/app/mailers/decidim/newsletter_mailer.rb +2 -0
- data/app/mailers/decidim/notification_mailer.rb +1 -1
- data/app/models/decidim/action_log.rb +66 -0
- data/app/models/decidim/coauthorship.rb +9 -0
- data/app/models/decidim/component.rb +5 -0
- data/app/models/decidim/continuity_badge_status.rb +9 -0
- data/app/models/decidim/gamification/badge_score.rb +1 -1
- data/app/models/decidim/messaging/message.rb +1 -0
- data/app/models/decidim/metric.rb +13 -0
- data/app/models/decidim/participatory_space_private_user.rb +4 -0
- data/app/models/decidim/user.rb +14 -38
- data/app/models/decidim/user_base_entity.rb +52 -0
- data/app/models/decidim/user_group.rb +48 -9
- data/app/models/decidim/user_group_membership.rb +8 -0
- data/app/permissions/decidim/permissions.rb +21 -0
- data/app/presenters/decidim/admin_log/organization_presenter.rb +0 -2
- data/app/presenters/decidim/admin_log/participatory_space_private_user_presenter.rb +38 -0
- data/app/presenters/decidim/metric_charts_presenter.rb +53 -0
- data/app/presenters/decidim/metric_object_presenter.rb +28 -0
- data/app/presenters/decidim/user_group_presenter.rb +16 -8
- data/app/presenters/decidim/user_presenter.rb +14 -0
- data/app/queries/decidim/metric_manage.rb +59 -0
- data/app/queries/decidim/metrics/users_metric_manage.rb +26 -0
- data/app/queries/decidim/user_groups/accepted_memberships.rb +36 -0
- data/app/queries/decidim/user_groups/accepted_user_groups.rb +38 -0
- data/app/queries/decidim/user_groups/accepted_users.rb +36 -0
- data/app/queries/decidim/user_groups/admin_memberships.rb +37 -0
- data/app/queries/decidim/user_groups/invited_memberships.rb +36 -0
- data/app/queries/decidim/user_groups/manageable_user_groups.rb +39 -0
- data/app/queries/decidim/user_groups/member_memberships.rb +37 -0
- data/app/resolvers/decidim/core/metric_resolver.rb +38 -0
- data/app/services/decidim/action_logger.rb +4 -2
- data/app/services/decidim/activity_search.rb +76 -0
- data/app/services/decidim/continuity_badge_tracker.rb +64 -0
- data/app/services/decidim/resource_search.rb +0 -1
- data/app/types/decidim/core/metric_history_type.rb +17 -0
- data/app/types/decidim/core/metric_type.rb +14 -0
- data/app/types/decidim/core/session_type.rb +1 -1
- data/app/types/decidim/core/user_group_type.rb +2 -2
- data/app/views/decidim/authorization_modals/show.html.erb +40 -27
- data/app/views/decidim/devise/registrations/new.html.erb +0 -19
- data/app/views/decidim/gamification/badges/index.html.erb +42 -0
- data/app/views/decidim/group_admins/index.html.erb +18 -0
- data/app/views/decidim/group_invites/index.html.erb +27 -0
- data/app/views/decidim/group_members/index.html.erb +19 -0
- data/app/views/decidim/groups/_form.html.erb +23 -0
- data/app/views/decidim/groups/edit.html.erb +26 -0
- data/app/views/decidim/groups/new.html.erb +26 -0
- data/app/views/decidim/last_activities/_activities.html.erb +13 -0
- data/app/views/decidim/last_activities/index.html.erb +18 -0
- data/app/views/decidim/last_activities/index.js.erb +6 -0
- data/app/views/decidim/profiles/show.html.erb +1 -1
- data/app/views/layouts/decidim/_user_menu.html.erb +0 -1
- data/app/views/layouts/decidim/_wrapper.html.erb +1 -1
- data/config/initializers/devise.rb +1 -1
- data/config/initializers/foundation_rails_helper.rb +1 -0
- data/config/locales/ca.yml +325 -32
- data/config/locales/de.yml +325 -32
- data/config/locales/en.yml +325 -32
- data/config/locales/es-PY.yml +325 -32
- data/config/locales/es.yml +325 -32
- data/config/locales/eu.yml +325 -32
- data/config/locales/fi.yml +330 -37
- data/config/locales/fr.yml +325 -32
- data/config/locales/gl.yml +325 -32
- data/config/locales/hu.yml +327 -34
- data/config/locales/it.yml +325 -32
- data/config/locales/nl.yml +325 -32
- data/config/locales/pl.yml +329 -32
- data/config/locales/pt-BR.yml +326 -33
- data/config/locales/pt.yml +325 -32
- data/config/locales/ru.yml +4 -33
- data/config/locales/sv.yml +346 -53
- data/config/locales/uk.yml +4 -33
- data/config/routes.rb +27 -1
- data/db/migrate/20170128112958_change_user_groups_verified_to_timestamp.rb +11 -0
- data/db/migrate/20180705134647_create_decidim_metrics.rb +16 -0
- data/db/migrate/20180730071851_add_core_content_blocks.rb +3 -3
- data/db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb +4 -2
- data/db/migrate/20180918072506_add_visibility_to_action_logs.rb +8 -0
- data/db/migrate/20181001124950_move_users_groups_to_users_table.rb +84 -0
- data/db/migrate/20181008102144_add_badge_switch_to_organizations.rb +8 -0
- data/db/migrate/20181010044613_create_decidim_continuity_badge_statuses.rb +11 -0
- data/db/migrate/20181011080252_add_roles_to_memberships.rb +24 -0
- data/db/migrate/20181016091601_make_authors_polymorphic.rb +31 -0
- data/db/migrate/20181029112820_fix_user_follows.rb +18 -0
- data/db/migrate/20181030090144_destroy_deleted_users_follows.rb +16 -0
- data/db/seeds.rb +18 -4
- data/lib/decidim/attributes.rb +1 -0
- data/lib/decidim/attributes/localized_date.rb +16 -0
- data/lib/decidim/attributes/time_with_zone.rb +3 -1
- data/lib/decidim/authorable.rb +5 -4
- data/lib/decidim/authorization_form_builder.rb +2 -2
- data/lib/decidim/coauthorable.rb +68 -18
- data/lib/decidim/content_block_manifest.rb +7 -0
- data/lib/decidim/content_processor.rb +17 -7
- data/lib/decidim/core.rb +12 -0
- data/lib/decidim/core/engine.rb +54 -6
- data/lib/decidim/core/test/factories.rb +63 -17
- data/lib/decidim/core/test/shared_examples/coauthorable.rb +27 -9
- data/lib/decidim/core/test/shared_examples/coauthorable_interface_examples.rb +2 -2
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/data_portability.rb +3 -1
- data/lib/decidim/data_portability_file_reader.rb +1 -1
- data/lib/decidim/events/author_event.rb +4 -1
- data/lib/decidim/events/coauthor_event.rb +4 -1
- data/lib/decidim/faker/localized.rb +5 -4
- data/lib/decidim/form_builder.rb +18 -17
- data/lib/decidim/gamification.rb +8 -2
- data/lib/decidim/gamification/badge.rb +34 -0
- data/lib/decidim/gamification/badge_scorer.rb +29 -14
- data/lib/decidim/gamification/badge_status.rb +2 -0
- data/lib/decidim/hashtaggable.rb +1 -1
- data/lib/decidim/manifest_registry.rb +5 -3
- data/lib/decidim/metric_manifest.rb +20 -0
- data/lib/decidim/metric_registry.rb +71 -0
- data/lib/decidim/participable.rb +1 -1
- data/lib/decidim/participatory_space_resourceable.rb +0 -1
- data/lib/decidim/query_extensions.rb +19 -0
- data/lib/decidim/resourceable.rb +1 -0
- data/lib/decidim/searchable.rb +2 -1
- data/lib/tasks/decidim_metrics_tasks.rake +41 -0
- data/lib/tasks/decidim_tasks.rake +1 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ca.js +1 -2
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.es.js +1 -2
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.fr.js +1 -2
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.gl.js +1 -2
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.pt.js +1 -2
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ru.js +1 -2
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.uk.js +1 -2
- data/vendor/assets/javascripts/form_datepicker.js.es6 +1 -11
- metadata +144 -23
- data/app/cells/decidim/invitations_toggle/content.erb +0 -1
- data/app/cells/decidim/invitations_toggle/label.erb +0 -1
- data/app/cells/decidim/invitations_toggle_cell.rb +0 -27
- data/app/cells/decidim/toggle/show.erb +0 -8
- data/app/cells/decidim/toggle_cell.rb +0 -42
- data/app/commands/decidim/invite_friends.rb +0 -48
- data/app/controllers/decidim/invitations_controller.rb +0 -32
- data/app/forms/decidim/invitations_form.rb +0 -37
- data/app/views/decidim/invitations/index.html.erb +0 -48
- data/app/views/devise/mailer/invite_friend.html.erb +0 -27
- data/app/views/devise/mailer/invite_friend.text.erb +0 -19
- data/lib/decidim/rectify_ext.rb +0 -32
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# The controller to show all the last activities in a Decidim Organization.
|
5
|
+
class LastActivitiesController < Decidim::ApplicationController
|
6
|
+
include FilterResource
|
7
|
+
include Paginable
|
8
|
+
|
9
|
+
helper Decidim::ResourceHelper
|
10
|
+
helper Decidim::FiltersHelper
|
11
|
+
|
12
|
+
helper_method :activities, :resource_types
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def resource_types
|
17
|
+
return @resource_types if defined?(@resource_types)
|
18
|
+
|
19
|
+
@resource_types = search.resource_types.sort_by do |klass|
|
20
|
+
klass.constantize.model_name.human
|
21
|
+
end
|
22
|
+
|
23
|
+
@resource_types = @resource_types.map do |klass|
|
24
|
+
[klass, klass.constantize.model_name.human]
|
25
|
+
end
|
26
|
+
|
27
|
+
@resource_types << ["all", I18n.t("decidim.last_activities.all")]
|
28
|
+
end
|
29
|
+
|
30
|
+
def activities
|
31
|
+
@activities ||= paginate(search.results)
|
32
|
+
end
|
33
|
+
|
34
|
+
def search_klass
|
35
|
+
ActivitySearch
|
36
|
+
end
|
37
|
+
|
38
|
+
def context_params
|
39
|
+
{ organization: current_organization }
|
40
|
+
end
|
41
|
+
|
42
|
+
def default_filter_params
|
43
|
+
{ resource_type: "all" }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -5,11 +5,13 @@ module Decidim
|
|
5
5
|
class PagesController < Decidim::ApplicationController
|
6
6
|
layout "layouts/decidim/application"
|
7
7
|
|
8
|
-
helper_method :page
|
8
|
+
helper_method :page
|
9
9
|
helper CtaButtonHelper
|
10
10
|
helper Decidim::SanitizeHelper
|
11
11
|
skip_before_action :store_current_location
|
12
12
|
|
13
|
+
before_action :set_default_request_format
|
14
|
+
|
13
15
|
def index
|
14
16
|
enforce_permission_to :read, :public_page
|
15
17
|
@pages = current_organization.static_pages.sorted_by_i18n_title
|
@@ -29,5 +31,11 @@ module Decidim
|
|
29
31
|
def page
|
30
32
|
@page ||= current_organization.static_pages.find_by(slug: params[:id])
|
31
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def set_default_request_format
|
38
|
+
request.format = :html
|
39
|
+
end
|
32
40
|
end
|
33
41
|
end
|
@@ -5,11 +5,16 @@ module Decidim
|
|
5
5
|
class ProfilesController < Decidim::ApplicationController
|
6
6
|
helper Decidim::Messaging::ConversationHelper
|
7
7
|
|
8
|
-
helper_method :
|
8
|
+
helper_method :profile_holder, :active_content
|
9
|
+
|
10
|
+
before_action :ensure_profile_holder
|
11
|
+
before_action :ensure_profile_holder_is_a_group, only: [:members]
|
12
|
+
before_action :ensure_profile_holder_is_a_user, only: [:groups, :following]
|
9
13
|
|
10
14
|
def show
|
11
|
-
return redirect_to notifications_path if current_user ==
|
12
|
-
|
15
|
+
return redirect_to notifications_path if current_user == profile_holder
|
16
|
+
return redirect_to profile_members_path if profile_holder.is_a?(Decidim::UserGroup)
|
17
|
+
redirect_to profile_following_path
|
13
18
|
end
|
14
19
|
|
15
20
|
def following
|
@@ -27,10 +32,35 @@ module Decidim
|
|
27
32
|
render :show
|
28
33
|
end
|
29
34
|
|
35
|
+
def groups
|
36
|
+
@content_cell = "decidim/groups"
|
37
|
+
render :show
|
38
|
+
end
|
39
|
+
|
40
|
+
def members
|
41
|
+
@content_cell = "decidim/members"
|
42
|
+
render :show
|
43
|
+
end
|
44
|
+
|
30
45
|
private
|
31
46
|
|
32
|
-
def
|
33
|
-
|
47
|
+
def ensure_profile_holder_is_a_group
|
48
|
+
raise ActionController::RoutingError, "No user group with the given nickname" unless profile_holder.is_a?(Decidim::UserGroup)
|
49
|
+
end
|
50
|
+
|
51
|
+
def ensure_profile_holder_is_a_user
|
52
|
+
raise ActionController::RoutingError, "No user with the given nickname" unless profile_holder.is_a?(Decidim::User)
|
53
|
+
end
|
54
|
+
|
55
|
+
def ensure_profile_holder
|
56
|
+
raise ActionController::RoutingError, "No user or user group with the given nickname" unless profile_holder
|
57
|
+
end
|
58
|
+
|
59
|
+
def profile_holder
|
60
|
+
@profile_holder ||= Decidim::User.find_by(
|
61
|
+
nickname: params[:nickname],
|
62
|
+
organization: current_organization
|
63
|
+
) || Decidim::UserGroup.find_by(
|
34
64
|
nickname: params[:nickname],
|
35
65
|
organization: current_organization
|
36
66
|
)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# The controller to handle user groups join requests.
|
5
|
+
class UserGroupJoinRequestsController < Decidim::ApplicationController
|
6
|
+
include FormFactory
|
7
|
+
|
8
|
+
def create
|
9
|
+
enforce_permission_to :join, :user_group
|
10
|
+
|
11
|
+
JoinUserGroup.call(current_user, user_group) do
|
12
|
+
on(:ok) do
|
13
|
+
flash[:notice] = t("groups.join.success", scope: "decidim")
|
14
|
+
|
15
|
+
redirect_back fallback_location: profile_members_path(user_group.nickname)
|
16
|
+
end
|
17
|
+
|
18
|
+
on(:invalid) do
|
19
|
+
flash[:alert] = t("groups.join.error", scope: "decidim")
|
20
|
+
redirect_back fallback_location: profile_members_path(user_group.nickname)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def update
|
26
|
+
enforce_permission_to :manage, :user_group, user_group: user_group
|
27
|
+
|
28
|
+
AcceptUserGroupJoinRequest.call(membership) do
|
29
|
+
on(:ok) do
|
30
|
+
flash[:notice] = t("group_members.accept.success", scope: "decidim")
|
31
|
+
|
32
|
+
redirect_back fallback_location: group_manage_users_path(user_group.nickname)
|
33
|
+
end
|
34
|
+
|
35
|
+
on(:invalid) do
|
36
|
+
flash[:alert] = t("group_members.accept.error", scope: "decidim")
|
37
|
+
redirect_back fallback_location: group_manage_users_path(user_group.nickname)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def destroy
|
43
|
+
enforce_permission_to :manage, :user_group, user_group: user_group
|
44
|
+
|
45
|
+
RejectUserGroupJoinRequest.call(membership) do
|
46
|
+
on(:ok) do
|
47
|
+
flash[:notice] = t("group_members.reject.success", scope: "decidim")
|
48
|
+
|
49
|
+
redirect_back fallback_location: group_manage_users_path(user_group.nickname)
|
50
|
+
end
|
51
|
+
|
52
|
+
on(:invalid) do
|
53
|
+
flash[:alert] = t("group_members.reject.error", scope: "decidim")
|
54
|
+
redirect_back fallback_location: group_manage_users_path(user_group.nickname)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def user_group
|
62
|
+
@user_group ||= Decidim::UserGroup.where(organization: current_user.organization).find_by(nickname: params[:group_id])
|
63
|
+
end
|
64
|
+
|
65
|
+
def membership
|
66
|
+
@membership ||= Decidim::UserGroupMembership.where(user_group: user_group).find(params[:id])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen-string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class DemotedMembershipEvent < Decidim::Events::SimpleEvent
|
5
|
+
delegate :url_helpers, to: "Decidim::Core::Engine.routes"
|
6
|
+
|
7
|
+
i18n_attributes :user_group_name
|
8
|
+
|
9
|
+
def resource_url
|
10
|
+
url_helpers.group_manage_users_url(
|
11
|
+
user_group_nickname,
|
12
|
+
host: user.organization.host
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def resource_path
|
17
|
+
url_helpers.group_manage_users_path(user_group_nickname)
|
18
|
+
end
|
19
|
+
|
20
|
+
def user_group_nickname
|
21
|
+
extra.dig("user_group_nickname")
|
22
|
+
end
|
23
|
+
|
24
|
+
def user_group_name
|
25
|
+
extra.dig("user_group_name")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen-string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class InvitedToGroupEvent < Decidim::Events::SimpleEvent
|
5
|
+
delegate :url_helpers, to: "Decidim::Core::Engine.routes"
|
6
|
+
|
7
|
+
i18n_attributes :user_group_name
|
8
|
+
i18n_attributes :groups_profile_tab_path
|
9
|
+
|
10
|
+
def resource_url
|
11
|
+
url_helpers.profile_url(
|
12
|
+
user_group_nickname,
|
13
|
+
host: user.organization.host
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def resource_path
|
18
|
+
url_helpers.profile_path(user_group_nickname)
|
19
|
+
end
|
20
|
+
|
21
|
+
def groups_profile_tab_path
|
22
|
+
url_helpers.profile_groups_path(user.nickname)
|
23
|
+
end
|
24
|
+
|
25
|
+
def user_group_nickname
|
26
|
+
extra.dig("user_group_nickname")
|
27
|
+
end
|
28
|
+
|
29
|
+
def user_group_name
|
30
|
+
extra.dig("user_group_name")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen-string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class JoinRequestAcceptedEvent < Decidim::Events::SimpleEvent
|
5
|
+
delegate :url_helpers, to: "Decidim::Core::Engine.routes"
|
6
|
+
|
7
|
+
i18n_attributes :user_group_name
|
8
|
+
|
9
|
+
def resource_url
|
10
|
+
url_helpers.profile_url(
|
11
|
+
user_group_nickname,
|
12
|
+
host: user.organization.host
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def resource_path
|
17
|
+
url_helpers.profile_path(user_group_nickname)
|
18
|
+
end
|
19
|
+
|
20
|
+
def user_group_nickname
|
21
|
+
extra.dig("user_group_nickname")
|
22
|
+
end
|
23
|
+
|
24
|
+
def user_group_name
|
25
|
+
extra.dig("user_group_name")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen-string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class JoinRequestCreatedEvent < Decidim::Events::SimpleEvent
|
5
|
+
delegate :url_helpers, to: "Decidim::Core::Engine.routes"
|
6
|
+
|
7
|
+
i18n_attributes :user_group_name
|
8
|
+
|
9
|
+
def resource_url
|
10
|
+
url_helpers.group_manage_users_url(
|
11
|
+
user_group_nickname,
|
12
|
+
host: user.organization.host
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def resource_path
|
17
|
+
url_helpers.group_manage_users_path(user_group_nickname)
|
18
|
+
end
|
19
|
+
|
20
|
+
def user_group_nickname
|
21
|
+
extra.dig("user_group_nickname")
|
22
|
+
end
|
23
|
+
|
24
|
+
def user_group_name
|
25
|
+
extra.dig("user_group_name")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen-string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class JoinRequestRejectedEvent < Decidim::Events::SimpleEvent
|
5
|
+
delegate :url_helpers, to: "Decidim::Core::Engine.routes"
|
6
|
+
|
7
|
+
i18n_attributes :user_group_name
|
8
|
+
|
9
|
+
def resource_url
|
10
|
+
url_helpers.profile_url(
|
11
|
+
user_group_nickname,
|
12
|
+
host: user.organization.host
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def resource_path
|
17
|
+
url_helpers.profile_path(user_group_nickname)
|
18
|
+
end
|
19
|
+
|
20
|
+
def user_group_nickname
|
21
|
+
extra.dig("user_group_nickname")
|
22
|
+
end
|
23
|
+
|
24
|
+
def user_group_name
|
25
|
+
extra.dig("user_group_name")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen-string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class PromotedToAdminEvent < Decidim::Events::SimpleEvent
|
5
|
+
delegate :url_helpers, to: "Decidim::Core::Engine.routes"
|
6
|
+
|
7
|
+
i18n_attributes :user_group_name
|
8
|
+
|
9
|
+
def resource_url
|
10
|
+
url_helpers.group_manage_users_url(
|
11
|
+
user_group_nickname,
|
12
|
+
host: user.organization.host
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def resource_path
|
17
|
+
url_helpers.group_manage_users_path(user_group_nickname)
|
18
|
+
end
|
19
|
+
|
20
|
+
def user_group_nickname
|
21
|
+
extra.dig("user_group_nickname")
|
22
|
+
end
|
23
|
+
|
24
|
+
def user_group_name
|
25
|
+
extra.dig("user_group_name")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen-string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class RemovedFromGroupEvent < Decidim::Events::SimpleEvent
|
5
|
+
delegate :url_helpers, to: "Decidim::Core::Engine.routes"
|
6
|
+
|
7
|
+
i18n_attributes :user_group_name
|
8
|
+
|
9
|
+
def resource_url
|
10
|
+
url_helpers.group_manage_users_url(
|
11
|
+
user_group_nickname,
|
12
|
+
host: user.organization.host
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def resource_path
|
17
|
+
url_helpers.group_manage_users_path(user_group_nickname)
|
18
|
+
end
|
19
|
+
|
20
|
+
def user_group_nickname
|
21
|
+
extra.dig("user_group_nickname")
|
22
|
+
end
|
23
|
+
|
24
|
+
def user_group_name
|
25
|
+
extra.dig("user_group_name")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -17,7 +17,7 @@ module Decidim
|
|
17
17
|
attribute :about
|
18
18
|
|
19
19
|
validates :name, presence: true
|
20
|
-
validates :email, presence: true
|
20
|
+
validates :email, presence: true, 'valid_email_2/email': { disposable: true }
|
21
21
|
validates :nickname, presence: true
|
22
22
|
|
23
23
|
validates :nickname, length: { maximum: Decidim::User.nickname_max_length, allow_blank: true }
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# The form object that handles the data behind creating a user group.
|
5
|
+
class InviteUserToGroupForm < Form
|
6
|
+
mimic :invite
|
7
|
+
|
8
|
+
attribute :nickname, String
|
9
|
+
|
10
|
+
validates :nickname, presence: true
|
11
|
+
validate :user_exists
|
12
|
+
|
13
|
+
def user
|
14
|
+
@user ||= Decidim::User.find_by(nickname: clean_nickname, organization: current_organization)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def clean_nickname
|
20
|
+
nickname.to_s.tr("@", "")
|
21
|
+
end
|
22
|
+
|
23
|
+
def user_exists
|
24
|
+
return true if user.present?
|
25
|
+
|
26
|
+
errors.add :nickname, :invalid
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|