decidim-core 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim.js.es6 +2 -4
- data/app/assets/javascripts/decidim/append_elements.js.es6 +1 -1
- data/app/assets/javascripts/decidim/editor.js.es6 +33 -35
- data/app/assets/javascripts/decidim/filters.js.es6 +9 -15
- data/app/assets/javascripts/decidim/form_filter.component.js.es6 +5 -5
- data/app/assets/javascripts/decidim/form_filter.component.test.js +1 -1
- data/app/assets/javascripts/decidim/foundation.js.es6 +17 -0
- data/app/assets/javascripts/decidim/user_registrations.js.es6 +2 -3
- data/app/assets/stylesheets/decidim/_decidim.scss +9 -0
- data/app/assets/stylesheets/decidim/_variables.scss +5 -11
- data/app/assets/stylesheets/decidim/application.scss.erb +6 -0
- data/app/assets/stylesheets/decidim/extras/_leaflet.scss +13 -0
- data/app/assets/stylesheets/decidim/modules/_buttons.scss +8 -2
- data/app/assets/stylesheets/decidim/modules/_cards.scss +0 -2
- data/app/assets/stylesheets/decidim/modules/_comments.scss +33 -8
- data/app/assets/stylesheets/decidim/modules/{_defintion-data.scss → _definition-data.scss} +0 -0
- data/app/assets/stylesheets/decidim/modules/_filter-tags.scss +24 -0
- data/app/assets/stylesheets/decidim/modules/_layout.scss +1 -9
- data/app/assets/stylesheets/decidim/modules/_list-docs.scss +1 -1
- data/app/assets/stylesheets/decidim/modules/_margins.scss +15 -0
- data/app/assets/stylesheets/decidim/modules/_modules.scss +56 -0
- data/app/assets/stylesheets/decidim/modules/_opinion-toggle.scss +25 -5
- data/app/assets/stylesheets/decidim/modules/_order-by.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_process-header.scss +2 -1
- data/app/assets/stylesheets/decidim/modules/_process-phase.scss +0 -4
- data/app/assets/stylesheets/decidim/modules/_status-labels.scss +7 -1
- data/app/assets/stylesheets/decidim/modules/_typography.scss +17 -0
- data/app/assets/stylesheets/decidim/utils/_fontface.scss +3 -3
- data/app/assets/stylesheets/decidim/utils/_settings.scss +10 -7
- data/app/commands/decidim/invite_user.rb +2 -2
- data/app/commands/decidim/update_account.rb +48 -0
- data/app/controllers/concerns/decidim/form_factory.rb +1 -1
- data/app/controllers/concerns/decidim/needs_authorization.rb +12 -1
- data/app/controllers/concerns/decidim/user_profile.rb +30 -0
- data/app/controllers/decidim/account_controller.rb +28 -10
- data/app/controllers/decidim/authorizations_controller.rb +21 -8
- data/app/controllers/decidim/devise/invitations_controller.rb +2 -0
- data/app/controllers/decidim/devise/sessions_controller.rb +1 -1
- data/app/controllers/decidim/own_user_groups_controller.rb +14 -0
- data/app/controllers/decidim/participatory_processes_controller.rb +1 -1
- data/app/forms/decidim/account_form.rb +41 -0
- data/app/helpers/decidim/aria_selected_link_to_helper.rb +26 -0
- data/app/helpers/decidim/attachments_helper.rb +15 -0
- data/app/helpers/decidim/filters_helper.rb +2 -3
- data/app/helpers/decidim/layout_helper.rb +29 -6
- data/app/helpers/decidim/resource_helper.rb +64 -0
- data/app/helpers/decidim/user_profile_helper.rb +23 -0
- data/app/mailers/decidim/decidim_devise_mailer.rb +1 -0
- data/app/models/decidim/abilities/everyone.rb +5 -1
- data/app/models/decidim/ability.rb +3 -4
- data/app/models/decidim/{participatory_process_attachment.rb → attachment.rb} +5 -5
- data/app/models/decidim/feature.rb +2 -0
- data/app/models/decidim/organization.rb +1 -0
- data/app/models/decidim/participatory_process.rb +2 -5
- data/app/models/decidim/resource_link.rb +28 -0
- data/app/models/decidim/user.rb +6 -0
- data/app/models/decidim/user_group.rb +10 -1
- data/app/services/decidim/resource_search.rb +1 -4
- data/app/types/decidim/session_type.rb +16 -0
- data/app/types/decidim/user_group_type.rb +20 -0
- data/app/types/decidim/user_type.rb +5 -1
- data/app/uploaders/decidim/attachment_uploader.rb +4 -1
- data/app/uploaders/decidim/avatar_uploader.rb +8 -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 +5 -1
- data/app/uploaders/decidim/image_uploader.rb +1 -1
- data/app/uploaders/decidim/organization_favicon_uploader.rb +17 -0
- data/app/uploaders/decidim/organization_logo_uploader.rb +2 -2
- data/app/validators/feature_validator.rb +23 -0
- data/app/views/decidim/account/_password_fields.html.erb +2 -0
- data/app/views/decidim/account/_user_groups.html.erb +0 -0
- data/app/views/decidim/account/show.html.erb +24 -29
- data/app/views/decidim/application/_attachments.html.erb +8 -0
- data/app/views/decidim/{participatory_processes → application}/_documents.html.erb +0 -0
- data/app/views/decidim/{participatory_processes → application}/_photos.html.erb +0 -0
- data/app/views/decidim/authorizations/first_login.html.erb +22 -0
- data/app/views/decidim/authorizations/index.html.erb +46 -19
- data/app/views/decidim/devise/omniauth_registrations/new.html.erb +1 -1
- data/app/views/decidim/devise/registrations/new.html.erb +1 -1
- data/app/views/decidim/own_user_groups/index.html.erb +24 -0
- data/app/views/decidim/participatory_process_steps/_participatory_process_step.html.erb +1 -1
- data/app/views/decidim/participatory_process_steps/index.html.erb +3 -1
- data/app/views/decidim/participatory_processes/_participatory_process.html.erb +2 -2
- data/app/views/decidim/participatory_processes/_promoted_process.html.erb +1 -1
- data/app/views/decidim/participatory_processes/index.html.erb +2 -0
- data/app/views/decidim/participatory_processes/show.html.erb +37 -8
- data/app/views/decidim/shared/_comments.html.erb +0 -0
- data/app/views/layouts/decidim/_application.html.erb +5 -3
- data/app/views/layouts/decidim/_header.html.erb +4 -4
- data/app/views/layouts/decidim/_logo.html.erb +29 -17
- data/app/views/layouts/decidim/_process_header.html.erb +15 -3
- data/app/views/layouts/decidim/_process_header_steps.html.erb +1 -1
- data/app/views/layouts/decidim/_user_menu.html.erb +3 -0
- data/app/views/layouts/decidim/mailer.html.erb +1 -1
- data/app/views/layouts/decidim/user_profile.html.erb +35 -0
- data/app/views/pages/home.html.erb +5 -139
- data/app/views/pages/home/_extended.html.erb +48 -0
- data/app/views/pages/home/_hero.html.erb +20 -0
- data/app/views/pages/home/_highlighted_processes.html.erb +37 -0
- data/app/views/pages/home/_statistics.html.erb +22 -0
- data/app/views/pages/home/_sub_hero.html.erb +11 -0
- data/config/i18n-tasks.yml +1 -0
- data/config/initializers/foundation_rails_helper.rb +2 -0
- data/config/locales/ca.yml +69 -33
- data/config/locales/en.yml +86 -29
- data/config/locales/es.yml +68 -32
- data/config/routes.rb +8 -3
- data/db/migrate/20161116115156_create_attachments.rb +0 -2
- data/db/migrate/20170113150627_create_resource_links.rb +10 -0
- data/db/migrate/20170123134023_make_attachments_polymorphic.rb +18 -0
- data/db/migrate/20170123140857_add_avatar_to_user_groups.rb +5 -0
- data/db/migrate/20170125135937_rename_attachable_to_attached_to.rb +11 -0
- data/db/migrate/20170125152026_add_weight_to_features.rb +5 -0
- data/db/migrate/20170126151123_add_extra_info_to_processes.rb +8 -0
- data/db/migrate/20170128140553_add_timestamps_to_identities.rb +5 -0
- data/db/migrate/20170130132833_add_favicon_to_decidim_organizations.rb +5 -0
- data/db/seeds.rb +38 -6
- data/lib/decidim/authorable.rb +32 -0
- data/lib/decidim/core.rb +37 -0
- data/lib/decidim/core/engine.rb +2 -3
- data/lib/decidim/core/test.rb +6 -0
- data/lib/decidim/core/test/factories.rb +24 -3
- data/lib/decidim/core/test/shared_examples/authorable.rb +31 -0
- data/lib/decidim/core/test/shared_examples/has_attachments.rb +29 -0
- data/lib/decidim/core/test/shared_examples/has_category.rb +10 -0
- data/lib/decidim/core/test/shared_examples/has_feature.rb +20 -0
- data/lib/decidim/core/test/shared_examples/has_scope.rb +10 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/feature_manifest.rb +31 -1
- data/lib/decidim/features/base_controller.rb +10 -0
- data/lib/decidim/features/settings_manifest.rb +1 -0
- data/lib/decidim/has_attachment.rb +32 -0
- data/lib/decidim/has_attachments.rb +32 -0
- data/lib/decidim/has_category.rb +21 -0
- data/lib/decidim/has_feature.rb +20 -0
- data/lib/decidim/has_scope.rb +21 -0
- data/lib/decidim/query_extensions.rb +2 -2
- data/lib/decidim/resource_manifest.rb +80 -0
- data/lib/decidim/resourceable.rb +85 -0
- metadata +67 -40
- data/app/assets/javascripts/decidim/inline_svg.js.es6 +0 -12
- data/app/assets/stylesheets/decidim/application.sass +0 -12
- data/app/assets/stylesheets/decidim/extras/_turbolinks.scss +0 -3
- data/app/assets/stylesheets/decidim/modules/_popularity.scss +0 -74
- data/app/assets/stylesheets/decidim/utils/_variables.scss +0 -22
- data/app/views/decidim/account/_authorizations.html.erb +0 -52
- data/vendor/assets/javascripts/owl.carousel.min.js +0 -47
- data/vendor/assets/javascripts/svg-injector.js +0 -464
@@ -0,0 +1,56 @@
|
|
1
|
+
//Basic modules
|
2
|
+
@import "margins";
|
3
|
+
@import "typography";
|
4
|
+
@import "title-action";
|
5
|
+
@import "buttons";
|
6
|
+
@import "forms";
|
7
|
+
@import "icons";
|
8
|
+
@import "video";
|
9
|
+
|
10
|
+
//Foundation overrides
|
11
|
+
@import "reveal";
|
12
|
+
|
13
|
+
//Layout
|
14
|
+
@import "layout";
|
15
|
+
@import "navbar";
|
16
|
+
@import "main-container";
|
17
|
+
@import "footer";
|
18
|
+
@import "static-pages";
|
19
|
+
|
20
|
+
//Cards and containers
|
21
|
+
@import "card-grid";
|
22
|
+
@import "cards";
|
23
|
+
@import "extra";
|
24
|
+
@import "definition-data";
|
25
|
+
@import "callout";
|
26
|
+
|
27
|
+
//Shared modules
|
28
|
+
@import "comments";
|
29
|
+
@import "opinion-toggle";
|
30
|
+
@import "flag";
|
31
|
+
@import "author-avatar";
|
32
|
+
@import "address";
|
33
|
+
@import "order-by";
|
34
|
+
@import "tags";
|
35
|
+
@import "list-docs";
|
36
|
+
|
37
|
+
//Process elements
|
38
|
+
@import "process-header";
|
39
|
+
@import "process-info";
|
40
|
+
@import "process-nav";
|
41
|
+
@import "process-phase";
|
42
|
+
@import "timeline";
|
43
|
+
@import "filter-tags";
|
44
|
+
@import "filters";
|
45
|
+
@import "reference";
|
46
|
+
@import "status-labels";
|
47
|
+
|
48
|
+
//User interface
|
49
|
+
@import "user-form";
|
50
|
+
@import "signup";
|
51
|
+
|
52
|
+
//Additional elements
|
53
|
+
@import "share";
|
54
|
+
@import "help";
|
55
|
+
@import "cookie-bar";
|
56
|
+
@import "map";
|
@@ -1,16 +1,22 @@
|
|
1
1
|
.opinion-toggle{
|
2
2
|
margin: 2rem 0;
|
3
|
+
display: flex;
|
4
|
+
text-align: center;
|
3
5
|
}
|
4
6
|
|
5
|
-
.
|
6
|
-
.
|
7
|
-
|
8
|
-
|
7
|
+
.opinion-toggle--ok,
|
8
|
+
.opinion-toggle--ko,
|
9
|
+
.opinion-toggle--meh{
|
10
|
+
&.is-inactive{
|
11
|
+
opacity: .3;
|
9
12
|
}
|
10
13
|
}
|
11
14
|
|
12
15
|
.opinion-toggle--ok{
|
16
|
+
border-top-right-radius: 0;
|
17
|
+
border-bottom-right-radius: 0;
|
13
18
|
&:hover,
|
19
|
+
&:focus,
|
14
20
|
&.is-active{
|
15
21
|
background-color: $success;
|
16
22
|
}
|
@@ -20,11 +26,25 @@
|
|
20
26
|
}
|
21
27
|
|
22
28
|
.opinion-toggle--ko{
|
29
|
+
border-top-left-radius: 0;
|
30
|
+
border-bottom-left-radius: 0;
|
23
31
|
&:hover,
|
32
|
+
&:focus,
|
24
33
|
&.is-active{
|
25
34
|
background-color: $alert;
|
26
35
|
}
|
27
36
|
.icon{
|
28
37
|
vertical-align: middle;
|
29
38
|
}
|
30
|
-
}
|
39
|
+
}
|
40
|
+
|
41
|
+
.opinion-toggle--meh{
|
42
|
+
border-radius: 0;
|
43
|
+
padding-left: .5em;
|
44
|
+
padding-right: .5em;
|
45
|
+
&:hover,
|
46
|
+
&:focus,
|
47
|
+
&.is-active{
|
48
|
+
background-color: $secondary;
|
49
|
+
}
|
50
|
+
}
|
@@ -1,6 +1,12 @@
|
|
1
1
|
.label--basic{
|
2
2
|
background-color: lighten($dark-gray, 60);
|
3
3
|
}
|
4
|
+
.label--highlight{
|
5
|
+
background-color: $secondary;
|
6
|
+
}
|
7
|
+
.label--admin{
|
8
|
+
background-color: $primary;
|
9
|
+
}
|
4
10
|
|
5
11
|
.proposal-status{
|
6
12
|
float: left;
|
@@ -11,4 +17,4 @@
|
|
11
17
|
.label--small{
|
12
18
|
margin: .2rem .2rem .2rem 0;
|
13
19
|
padding: .2rem .3rem;
|
14
|
-
}
|
20
|
+
}
|
@@ -72,6 +72,23 @@ hr{
|
|
72
72
|
}
|
73
73
|
}
|
74
74
|
|
75
|
+
.mini-title{
|
76
|
+
color: $muted;
|
77
|
+
text-transform: uppercase;
|
78
|
+
font-size: .9rem;
|
79
|
+
letter-spacing: .01em;
|
80
|
+
font-weight: 600;
|
81
|
+
margin-bottom: 0;
|
82
|
+
&__strong{
|
83
|
+
color: $body-font-color;
|
84
|
+
font-size: 1.2rem;
|
85
|
+
font-weight: 800;
|
86
|
+
}
|
87
|
+
&__strong--highlight{
|
88
|
+
font-size: 1.4rem;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
75
92
|
.page-title{
|
76
93
|
margin-bottom: 3rem;
|
77
94
|
}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
font-style: normal;
|
4
4
|
font-weight: 400;
|
5
5
|
src:
|
6
|
-
|
6
|
+
asset-data-url('decidim/Source_Sans_Pro_400.woff2') format('woff2'),
|
7
7
|
font-url('decidim/Source_Sans_Pro_400.woff') format('woff'),
|
8
8
|
font-url('decidim/Source_Sans_Pro_400.ttf') format('truetype');
|
9
9
|
}
|
@@ -12,7 +12,7 @@
|
|
12
12
|
font-style: normal;
|
13
13
|
font-weight: 600;
|
14
14
|
src:
|
15
|
-
|
15
|
+
asset-data-url('decidim/Source_Sans_Pro_600.woff2') format('woff2'),
|
16
16
|
font-url('decidim/Source_Sans_Pro_600.woff') format('woff'),
|
17
17
|
font-url('decidim/Source_Sans_Pro_600.ttf') format('truetype');
|
18
18
|
}
|
@@ -21,7 +21,7 @@
|
|
21
21
|
font-style: normal;
|
22
22
|
font-weight: 900;
|
23
23
|
src:
|
24
|
-
|
24
|
+
asset-data-url('decidim/Source_Sans_Pro_900.woff2') format('woff2'),
|
25
25
|
font-url('decidim/Source_Sans_Pro_900.woff') format('woff'),
|
26
26
|
font-url('decidim/Source_Sans_Pro_900.ttf') format('truetype');
|
27
27
|
}
|
@@ -42,7 +42,6 @@
|
|
42
42
|
|
43
43
|
@import 'util/util';
|
44
44
|
|
45
|
-
|
46
45
|
// 1. Global
|
47
46
|
// ---------
|
48
47
|
|
@@ -50,19 +49,21 @@ $global-font-size: 100%;
|
|
50
49
|
$global-width: rem-calc(1200);
|
51
50
|
$global-lineheight: 1.5;
|
52
51
|
$foundation-palette: (
|
53
|
-
primary:
|
54
|
-
secondary:
|
55
|
-
success:
|
56
|
-
warning:
|
57
|
-
alert:
|
52
|
+
primary: $primary,
|
53
|
+
secondary: $secondary,
|
54
|
+
success: $success,
|
55
|
+
warning: $warning,
|
56
|
+
alert: $alert,
|
58
57
|
);
|
59
58
|
$light-gray: #fafafa;
|
60
59
|
$medium-gray: #e8e8e8;
|
61
60
|
$dark-gray: #2c2930;
|
62
61
|
$black: #1a181d;
|
63
62
|
$white: #fff;
|
63
|
+
$light-gray-dark: darken($light-gray, 2.5) !default;
|
64
64
|
$body-background: $light-gray;
|
65
65
|
$body-font-color: #3D393C;
|
66
|
+
$muted: lighten($body-font-color, 30) !default;
|
66
67
|
$body-font-family: 'Source Sans Pro', Helvetica, Roboto, Arial, sans-serif;
|
67
68
|
$body-antialiased: true;
|
68
69
|
$global-margin: 1rem;
|
@@ -74,6 +75,8 @@ $global-text-direction: ltr;
|
|
74
75
|
$global-flexbox: false;
|
75
76
|
$print-transparent-backgrounds: true;
|
76
77
|
|
78
|
+
$border: 1px solid $medium-gray !default;
|
79
|
+
|
77
80
|
@include add-foundation-colors;
|
78
81
|
|
79
82
|
// 2. Breakpoints
|
@@ -436,7 +439,7 @@ $pagination-item-color: $body-font-color;
|
|
436
439
|
$pagination-item-padding: rem-calc(3 10);
|
437
440
|
$pagination-item-spacing: rem-calc(1);
|
438
441
|
$pagination-radius: $global-radius;
|
439
|
-
$pagination-item-background-hover: $
|
442
|
+
$pagination-item-background-hover: $medium-gray;
|
440
443
|
$pagination-item-background-current: $secondary-color;
|
441
444
|
$pagination-item-color-current: $white;
|
442
445
|
$pagination-item-color-disabled: lighten($body-font-color, 30);
|
@@ -18,7 +18,7 @@ module Decidim
|
|
18
18
|
invite_user
|
19
19
|
end
|
20
20
|
|
21
|
-
broadcast(:ok)
|
21
|
+
broadcast(:ok, user)
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -35,7 +35,7 @@ module Decidim
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def invite_user
|
38
|
-
Decidim::User.invite!(
|
38
|
+
@user = Decidim::User.invite!(
|
39
39
|
{
|
40
40
|
name: form.name,
|
41
41
|
email: form.email.downcase,
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
# This command updates the user's account.
|
4
|
+
class UpdateAccount < Rectify::Command
|
5
|
+
# Updates a user's account.
|
6
|
+
#
|
7
|
+
# user - The user to be updated.
|
8
|
+
# form - The form with the data.
|
9
|
+
def initialize(user, form)
|
10
|
+
@user = user
|
11
|
+
@form = form
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
return broadcast(:invalid) unless @form.valid?
|
16
|
+
|
17
|
+
update_personal_data
|
18
|
+
update_avatar
|
19
|
+
update_password
|
20
|
+
@user.save!
|
21
|
+
|
22
|
+
@form.remove_avatar = false
|
23
|
+
broadcast(:ok, @user.unconfirmed_email.present?)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def update_personal_data
|
29
|
+
@user.name = @form.name
|
30
|
+
@user.email = @form.email
|
31
|
+
end
|
32
|
+
|
33
|
+
def update_avatar
|
34
|
+
if @form.avatar
|
35
|
+
@user.avatar = @form.avatar
|
36
|
+
elsif @form.remove_avatar
|
37
|
+
@user.remove_avatar = true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def update_password
|
42
|
+
return unless @form.password.present?
|
43
|
+
|
44
|
+
@user.password = @form.password
|
45
|
+
@user.password_confirmation = @form.password_confirmation
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -43,7 +43,7 @@ module Decidim
|
|
43
43
|
#
|
44
44
|
# extra_context - A Hash with optional extra context data.
|
45
45
|
def instance(extra_context = {})
|
46
|
-
@klass.new(context.merge(extra_context))
|
46
|
+
@klass.new.with_context(context.merge(extra_context))
|
47
47
|
end
|
48
48
|
|
49
49
|
# Initializes a form object from a model. Delegates the functionality
|
@@ -17,7 +17,18 @@ module Decidim
|
|
17
17
|
# Overwrites `cancancan`'s method to point to the correct ability class,
|
18
18
|
# since the gem expects the ability class to be in the root namespace.
|
19
19
|
def current_ability
|
20
|
-
@current_ability ||=
|
20
|
+
@current_ability ||= current_ability_klass.new(current_user, ability_context)
|
21
|
+
end
|
22
|
+
|
23
|
+
def current_ability_klass
|
24
|
+
Decidim::Ability
|
25
|
+
end
|
26
|
+
|
27
|
+
def ability_context
|
28
|
+
{
|
29
|
+
current_organization: try(:current_organization),
|
30
|
+
current_feature: try(:current_feature)
|
31
|
+
}
|
21
32
|
end
|
22
33
|
|
23
34
|
# Handles the case when a user visits a path that is not allowed to them.
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "active_support/concern"
|
3
|
+
|
4
|
+
module Decidim
|
5
|
+
# The UserProfile concern must be included in all the controllers
|
6
|
+
# that are shown in the user's profile settings. It adds the
|
7
|
+
# proper layout, as well as helper methods that help render the
|
8
|
+
# side menu, amongst others.
|
9
|
+
module UserProfile
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
include FormFactory
|
12
|
+
|
13
|
+
delegate :user_groups, to: :current_user, prefix: false
|
14
|
+
|
15
|
+
included do
|
16
|
+
layout "layouts/decidim/user_profile"
|
17
|
+
|
18
|
+
helper_method :available_authorization_handlers,
|
19
|
+
:user_groups
|
20
|
+
|
21
|
+
authorize_resource :current_user
|
22
|
+
end
|
23
|
+
|
24
|
+
# Public: Available authorization handlers in order to conditionally
|
25
|
+
# show the menu element.
|
26
|
+
def available_authorization_handlers
|
27
|
+
Decidim.authorization_handlers
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -4,23 +4,41 @@ require_dependency "decidim/application_controller"
|
|
4
4
|
module Decidim
|
5
5
|
# The controller to handle the user's account page.
|
6
6
|
class AccountController < ApplicationController
|
7
|
-
helper_method :authorizations
|
8
|
-
|
7
|
+
helper_method :authorizations
|
8
|
+
include Decidim::UserProfile
|
9
9
|
|
10
|
-
|
10
|
+
def show
|
11
|
+
authorize! :show, current_user
|
12
|
+
@account = form(AccountForm).from_model(current_user)
|
13
|
+
end
|
14
|
+
|
15
|
+
def update
|
16
|
+
authorize! :update, current_user
|
17
|
+
@account = form(AccountForm).from_params(params)
|
18
|
+
|
19
|
+
UpdateAccount.call(current_user, @account) do
|
20
|
+
on(:ok) do |_account, unconfirmed_email|
|
21
|
+
flash.now[:notice] = if unconfirmed_email
|
22
|
+
t("account.update.success_with_email_confirmation", scope: "decidim")
|
23
|
+
else
|
24
|
+
t("account.update.success", scope: "decidim")
|
25
|
+
end
|
26
|
+
|
27
|
+
bypass_sign_in(current_user)
|
28
|
+
end
|
11
29
|
|
12
|
-
|
13
|
-
|
14
|
-
|
30
|
+
on(:invalid) do
|
31
|
+
flash.now[:alert] = t("account.update.error", scope: "decidim")
|
32
|
+
end
|
15
33
|
end
|
34
|
+
|
35
|
+
render action: :show
|
16
36
|
end
|
17
37
|
|
38
|
+
private
|
39
|
+
|
18
40
|
def authorizations
|
19
41
|
@authorizations ||= current_user.authorizations
|
20
42
|
end
|
21
|
-
|
22
|
-
def authorized_handlers
|
23
|
-
authorizations.map(&:name)
|
24
|
-
end
|
25
43
|
end
|
26
44
|
end
|