decidim 0.0.1.alpha2 → 0.0.1.alpha3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.codeclimate.yml +8 -2
- data/.dockerignore +5 -0
- data/.gitignore +2 -1
- data/.hound.yml +4 -0
- data/.rubocop.yml +16 -3
- data/.ruby-version +1 -0
- data/.travis.yml +28 -0
- data/Dockerfile +36 -0
- data/Gemfile +7 -2
- data/Gemfile.lock +188 -30
- data/README.md +40 -6
- data/Rakefile +4 -20
- data/codecov.yml +71 -0
- data/common_gemfile.rb +6 -18
- data/decidim-admin/Gemfile +17 -0
- data/decidim-admin/Gemfile.lock +383 -0
- data/decidim-admin/README.md +28 -0
- data/decidim-admin/Rakefile +32 -0
- data/decidim-admin/app/assets/config/decidim_admin_manifest.js +2 -0
- data/{template.rb → decidim-admin/app/assets/images/decidim/admin/.keep} +0 -0
- data/decidim-admin/app/assets/javascripts/decidim/admin.js +21 -0
- data/decidim-admin/app/assets/stylesheets/decidim/admin.scss +8 -0
- data/decidim-admin/app/assets/stylesheets/decidim/admin/_actions.scss +8 -0
- data/decidim-admin/app/assets/stylesheets/decidim/admin/_foundation_and_overrides.scss +52 -0
- data/decidim-admin/app/assets/stylesheets/decidim/admin/_layout.scss +16 -0
- data/decidim-admin/app/assets/stylesheets/decidim/admin/_login.scss +36 -0
- data/decidim-admin/app/assets/stylesheets/decidim/admin/_settings.scss +566 -0
- data/decidim-admin/app/assets/stylesheets/decidim/admin/_sidebar.scss +73 -0
- data/decidim-admin/app/assets/stylesheets/decidim/admin/_tables.scss +5 -0
- data/decidim-admin/app/constraints/decidim/admin/organization_dashboard_constraint.rb +36 -0
- data/decidim-admin/app/controllers/decidim/admin/application_controller.rb +10 -0
- data/decidim-admin/app/controllers/decidim/admin/dashboard_controller.rb +9 -0
- data/decidim-admin/app/helpers/decidim/admin/application_helper.rb +12 -0
- data/decidim-admin/app/jobs/decidim/admin/application_job.rb +9 -0
- data/decidim-admin/app/mailers/decidim/admin/application_mailer.rb +11 -0
- data/decidim-admin/app/models/decidim/admin/application_record.rb +10 -0
- data/decidim-admin/app/policies/decidim/admin/application_policy.rb +20 -0
- data/decidim-admin/app/policies/decidim/admin/organization_policy.rb +15 -0
- data/decidim-admin/app/views/decidim/admin/dashboard/show.html.erb +3 -0
- data/decidim-admin/app/views/decidim/admin/devise/mailers/password_change.html.erb +3 -0
- data/decidim-admin/app/views/decidim/admin/devise/mailers/reset_password_instructions.html.erb +8 -0
- data/decidim-admin/app/views/layouts/decidim/admin/_header.html.erb +4 -0
- data/decidim-admin/app/views/layouts/decidim/admin/_login_items.html.erb +8 -0
- data/decidim-admin/app/views/layouts/decidim/admin/_sidebar.html.erb +13 -0
- data/decidim-admin/app/views/layouts/decidim/admin/application.html.erb +40 -0
- data/decidim-admin/app/views/layouts/decidim/admin/login.html.erb +19 -0
- data/decidim-admin/bin/rails +14 -0
- data/decidim-admin/config/i18n-tasks.yml +120 -0
- data/decidim-admin/config/locales/en.yml +8 -0
- data/decidim-admin/config/routes.rb +4 -0
- data/decidim-admin/decidim-admin.gemspec +38 -0
- data/decidim-admin/lib/decidim/admin.rb +12 -0
- data/decidim-admin/lib/decidim/admin/engine.rb +31 -0
- data/decidim-admin/lib/tasks/decidim/admin_tasks.rake +5 -0
- data/decidim-admin/spec/factories.rb +1 -0
- data/decidim-admin/spec/features/admin_access_control.rb +52 -0
- data/decidim-admin/spec/features/admin_invite_spec.rb +38 -0
- data/decidim-admin/spec/policies/organization_policy_spec.rb +41 -0
- data/decidim-admin/spec/spec_helper.rb +3 -0
- data/decidim-dev/Gemfile +17 -0
- data/decidim-dev/Gemfile.lock +381 -0
- data/decidim-dev/README.md +28 -0
- data/decidim-dev/decidim-dev.gemspec +30 -0
- data/decidim-dev/lib/decidim/common_rake.rb +14 -0
- data/decidim-dev/lib/decidim/test/base_spec_helper.rb +44 -0
- data/decidim-dev/lib/decidim/test/i18n_spec.rb +18 -0
- data/decidim-dev/lib/decidim/test/rspec_support/action_mailer.rb +46 -0
- data/decidim-dev/lib/decidim/test/rspec_support/active_job.rb +11 -0
- data/decidim-dev/lib/decidim/test/rspec_support/capybara.rb +19 -0
- data/decidim-dev/lib/decidim/test/rspec_support/database_cleaner.rb +13 -0
- data/decidim-dev/lib/decidim/test/rspec_support/factory_girl.rb +4 -0
- data/decidim-dev/lib/decidim/test/rspec_support/i18n.rb +12 -0
- data/decidim-dev/lib/decidim/test/rspec_support/warden.rb +8 -0
- data/decidim-dev/lib/decidim/test/rspec_support/wisper.rb +6 -0
- data/decidim-dev/lib/generators/decidim/dummy_generator.rb +65 -0
- data/decidim-system/Gemfile +17 -0
- data/decidim-system/Gemfile.lock +377 -0
- data/decidim-system/README.md +28 -0
- data/decidim-system/Rakefile +32 -0
- data/decidim-system/app/assets/config/decidim_system_manifest.js +2 -0
- data/decidim-system/app/assets/images/decidim/system/.keep +0 -0
- data/decidim-system/app/assets/javascripts/decidim/system.js +21 -0
- data/decidim-system/app/assets/stylesheets/decidim/system.scss +8 -0
- data/decidim-system/app/assets/stylesheets/decidim/system/_actions.scss +8 -0
- data/decidim-system/app/assets/stylesheets/decidim/system/_foundation_and_overrides.scss +52 -0
- data/decidim-system/app/assets/stylesheets/decidim/system/_layout.scss +16 -0
- data/decidim-system/app/assets/stylesheets/decidim/system/_login.scss +36 -0
- data/decidim-system/app/assets/stylesheets/decidim/system/_settings.scss +566 -0
- data/decidim-system/app/assets/stylesheets/decidim/system/_sidebar.scss +73 -0
- data/decidim-system/app/assets/stylesheets/decidim/system/_tables.scss +5 -0
- data/decidim-system/app/commands/decidim/system/create_admin.rb +40 -0
- data/decidim-system/app/commands/decidim/system/register_organization.rb +59 -0
- data/decidim-system/app/commands/decidim/system/update_admin.rb +52 -0
- data/decidim-system/app/commands/decidim/system/update_organization.rb +51 -0
- data/decidim-system/app/controllers/decidim/system/admins_controller.rb +67 -0
- data/decidim-system/app/controllers/decidim/system/application_controller.rb +11 -0
- data/decidim-system/app/controllers/decidim/system/dashboard_controller.rb +9 -0
- data/decidim-system/app/controllers/decidim/system/devise/passwords_controller.rb +12 -0
- data/decidim-system/app/controllers/decidim/system/devise/sessions_controller.rb +12 -0
- data/decidim-system/app/controllers/decidim/system/organizations_controller.rb +59 -0
- data/decidim-system/app/forms/decidim/system/admin_form.rb +33 -0
- data/decidim-system/app/forms/decidim/system/register_organization_form.rb +20 -0
- data/decidim-system/app/forms/decidim/system/update_organization_form.rb +28 -0
- data/decidim-system/app/helpers/decidim/system/application_helper.rb +12 -0
- data/decidim-system/app/jobs/decidim/system/application_job.rb +9 -0
- data/decidim-system/app/mailers/decidim/system/application_mailer.rb +11 -0
- data/decidim-system/app/models/decidim/system/admin.rb +18 -0
- data/decidim-system/app/models/decidim/system/application_record.rb +10 -0
- data/decidim-system/app/views/decidim/system/admins/_form.html.erb +11 -0
- data/decidim-system/app/views/decidim/system/admins/edit.html.erb +11 -0
- data/decidim-system/app/views/decidim/system/admins/index.html.erb +33 -0
- data/decidim-system/app/views/decidim/system/admins/new.html.erb +11 -0
- data/decidim-system/app/views/decidim/system/admins/show.html.erb +9 -0
- data/decidim-system/app/views/decidim/system/dashboard/show.html.erb +3 -0
- data/decidim-system/app/views/decidim/system/devise/mailers/password_change.html.erb +3 -0
- data/decidim-system/app/views/decidim/system/devise/mailers/reset_password_instructions.html.erb +8 -0
- data/decidim-system/app/views/decidim/system/devise/passwords/edit.html.erb +23 -0
- data/decidim-system/app/views/decidim/system/devise/passwords/new.html.erb +15 -0
- data/decidim-system/app/views/decidim/system/devise/sessions/new.html.erb +23 -0
- data/decidim-system/app/views/decidim/system/devise/shared/_links.html.erb +25 -0
- data/decidim-system/app/views/decidim/system/organizations/edit.html.erb +17 -0
- data/decidim-system/app/views/decidim/system/organizations/index.html.erb +34 -0
- data/decidim-system/app/views/decidim/system/organizations/new.html.erb +25 -0
- data/decidim-system/app/views/decidim/system/organizations/show.html.erb +11 -0
- data/decidim-system/app/views/layouts/decidim/system/_header.html.erb +4 -0
- data/decidim-system/app/views/layouts/decidim/system/_login_items.html.erb +8 -0
- data/decidim-system/app/views/layouts/decidim/system/_sidebar.html.erb +15 -0
- data/decidim-system/app/views/layouts/decidim/system/application.html.erb +40 -0
- data/decidim-system/app/views/layouts/decidim/system/login.html.erb +19 -0
- data/decidim-system/bin/rails +14 -0
- data/decidim-system/config/i18n-tasks.yml +120 -0
- data/decidim-system/config/locales/en.yml +60 -0
- data/decidim-system/config/routes.rb +17 -0
- data/decidim-system/db/migrate/20160919105637_devise_create_decidim_admins.rb +26 -0
- data/decidim-system/db/seeds.rb +9 -0
- data/decidim-system/decidim-system.gemspec +36 -0
- data/decidim-system/lib/decidim/system.rb +12 -0
- data/decidim-system/lib/decidim/system/engine.rb +31 -0
- data/decidim-system/lib/tasks/decidim/system_tasks.rake +5 -0
- data/decidim-system/spec/commands/decidim/system/create_admin_spec.rb +48 -0
- data/decidim-system/spec/commands/decidim/system/register_organization_spec.rb +68 -0
- data/decidim-system/spec/factories.rb +9 -0
- data/decidim-system/spec/features/manage_admins_spec.rb +67 -0
- data/decidim-system/spec/features/organizations_spec.rb +62 -0
- data/decidim-system/spec/features/sessions_spec.rb +38 -0
- data/decidim-system/spec/models/admin_spec.rb +23 -0
- data/decidim-system/spec/spec_helper.rb +2 -0
- data/decidim.gemspec +3 -1
- data/docker-compose.yml +24 -0
- data/lib/decidim.rb +8 -0
- data/lib/generators/decidim/app_builder.rb +1 -1
- data/lib/generators/decidim/app_generator.rb +35 -4
- data/lib/generators/decidim/install_generator.rb +121 -0
- data/lib/generators/decidim/templates/Dockerfile.erb +26 -0
- data/lib/generators/decidim/templates/Gemfile.erb +8 -1
- data/lib/generators/decidim/templates/README.md.erb +26 -0
- data/lib/generators/decidim/templates/app.json.erb +13 -0
- data/lib/generators/decidim/templates/cable.yml.erb +9 -0
- data/lib/generators/decidim/templates/database.yml.erb +85 -0
- data/lib/generators/decidim/templates/docker-compose.yml.erb +28 -0
- data/lib/generators/decidim/templates/initializer.rb +4 -0
- data/lib/generators/decidim/templates/secrets.yml.erb +30 -0
- data/run_ci.sh +7 -0
- metadata +183 -8
- data/circle.yml +0 -19
@@ -0,0 +1,73 @@
|
|
1
|
+
@mixin menu-title{
|
2
|
+
text-transform: uppercase;
|
3
|
+
letter-spacing: 5px;
|
4
|
+
}
|
5
|
+
|
6
|
+
.title-bar-title{
|
7
|
+
@include menu-title;
|
8
|
+
}
|
9
|
+
|
10
|
+
.sidebar{
|
11
|
+
color: $light-gray;
|
12
|
+
|
13
|
+
.title{
|
14
|
+
background-color: black;
|
15
|
+
background-color: map-get($foundation-palette, primary);
|
16
|
+
|
17
|
+
h1{
|
18
|
+
margin: 0;
|
19
|
+
padding: 0;
|
20
|
+
font-size: rem-calc(18);
|
21
|
+
font-weight: bold;
|
22
|
+
}
|
23
|
+
|
24
|
+
a{
|
25
|
+
display: block;
|
26
|
+
color: inherit;
|
27
|
+
padding: rem-calc(20) $global-padding;
|
28
|
+
@include menu-title;
|
29
|
+
}
|
30
|
+
|
31
|
+
@include show-for(large);
|
32
|
+
}
|
33
|
+
|
34
|
+
.main-menu{
|
35
|
+
border-top: 1px solid black;
|
36
|
+
border-bottom: 1px solid black;
|
37
|
+
a{
|
38
|
+
padding: $global-padding;
|
39
|
+
display: block;
|
40
|
+
color: $light-gray;
|
41
|
+
text-transform: uppercase;
|
42
|
+
font-weight: bold;
|
43
|
+
font-size: 0.9em;
|
44
|
+
border-left: 2px solid transparent;
|
45
|
+
|
46
|
+
transition: all 0.3s;
|
47
|
+
|
48
|
+
&.active {
|
49
|
+
border-color: map-get($foundation-palette, primary);
|
50
|
+
&, &:hover{
|
51
|
+
background-color: #101010;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
&:hover {
|
56
|
+
background-color: #1a1a1a;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
.session-box {
|
62
|
+
padding: $global-padding 0;
|
63
|
+
|
64
|
+
@include grid-row;
|
65
|
+
|
66
|
+
.admin-email {
|
67
|
+
@include grid-column(8);
|
68
|
+
text-overflow: ellipsis;
|
69
|
+
overflow: hidden;
|
70
|
+
}
|
71
|
+
.sign-out{ @include grid-column(4); }
|
72
|
+
}
|
73
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module System
|
4
|
+
# A command with all the business logic when creating a new admin in
|
5
|
+
# the system.
|
6
|
+
class CreateAdmin < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# form - A form object with the params.
|
10
|
+
def initialize(form)
|
11
|
+
@form = form
|
12
|
+
end
|
13
|
+
|
14
|
+
# Executes the command. Braodcasts these events:
|
15
|
+
#
|
16
|
+
# - :ok when everything is valid.
|
17
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
18
|
+
#
|
19
|
+
# Returns nothing.
|
20
|
+
def call
|
21
|
+
return broadcast(:invalid) if form.invalid?
|
22
|
+
|
23
|
+
create_admin
|
24
|
+
broadcast(:ok)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :form
|
30
|
+
|
31
|
+
def create_admin
|
32
|
+
Admin.create!(
|
33
|
+
email: form.email,
|
34
|
+
password: form.password,
|
35
|
+
password_confirmation: form.password_confirmation
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module System
|
4
|
+
# A command with all the business logic when creating a new organization in
|
5
|
+
# the system. It creates the organization and invites the admin to the
|
6
|
+
# system.
|
7
|
+
class RegisterOrganization < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# form - A form object with the params.
|
11
|
+
def initialize(form)
|
12
|
+
@form = form
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Braodcasts these events:
|
16
|
+
#
|
17
|
+
# - :ok when everything is valid.
|
18
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def call
|
22
|
+
return broadcast(:invalid) if form.invalid?
|
23
|
+
|
24
|
+
transaction do
|
25
|
+
organization = create_organization
|
26
|
+
invite_admin(organization)
|
27
|
+
end
|
28
|
+
|
29
|
+
broadcast(:ok)
|
30
|
+
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique
|
31
|
+
broadcast(:invalid)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :form
|
37
|
+
|
38
|
+
def create_organization
|
39
|
+
Decidim::Organization.create!(
|
40
|
+
name: form.name,
|
41
|
+
host: form.host,
|
42
|
+
description: form.description
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def invite_admin(organization)
|
47
|
+
Decidim::User.invite!(
|
48
|
+
{
|
49
|
+
email: form.organization_admin_email,
|
50
|
+
organization: organization,
|
51
|
+
roles: ["admin"]
|
52
|
+
},
|
53
|
+
nil,
|
54
|
+
invitation_instructions: "organization_admin_invitation_instructions"
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module System
|
4
|
+
# A command with all the business logic when updating an admin in
|
5
|
+
# the system.
|
6
|
+
class UpdateAdmin < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# form - A form object with the params.
|
10
|
+
def initialize(admin, form)
|
11
|
+
@admin = admin
|
12
|
+
@form = form
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Braodcasts these events:
|
16
|
+
#
|
17
|
+
# - :ok when everything is valid.
|
18
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def call
|
22
|
+
return broadcast(:invalid) if form.invalid?
|
23
|
+
|
24
|
+
update_admin
|
25
|
+
broadcast(:ok)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :form
|
31
|
+
|
32
|
+
def update_admin
|
33
|
+
@admin.update_attributes!(attributes)
|
34
|
+
end
|
35
|
+
|
36
|
+
def attributes
|
37
|
+
{
|
38
|
+
email: form.email
|
39
|
+
}.merge(password_attributes)
|
40
|
+
end
|
41
|
+
|
42
|
+
def password_attributes
|
43
|
+
return {} if form.password == form.password_confirmation && form.password.blank?
|
44
|
+
|
45
|
+
{
|
46
|
+
password: form.password,
|
47
|
+
password_confirmation: form.password_confirmation
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module System
|
4
|
+
# A command with all the business logic when creating a new organization in
|
5
|
+
# the system. It creates the organization and invites the admin to the
|
6
|
+
# system.
|
7
|
+
class UpdateOrganization < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# form - A form object with the params.
|
11
|
+
def initialize(id, form)
|
12
|
+
@organization_id = id
|
13
|
+
@form = form
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Braodcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everything is valid.
|
19
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def call
|
23
|
+
return broadcast(:invalid) if form.invalid?
|
24
|
+
|
25
|
+
transaction do
|
26
|
+
save_organization
|
27
|
+
end
|
28
|
+
|
29
|
+
broadcast(:ok)
|
30
|
+
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique
|
31
|
+
broadcast(:invalid)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :form, :organization_id
|
37
|
+
|
38
|
+
def organization
|
39
|
+
@organization ||= Organization.find(organization_id)
|
40
|
+
end
|
41
|
+
|
42
|
+
def save_organization
|
43
|
+
organization.name = form.name
|
44
|
+
organization.host = form.host
|
45
|
+
organization.description = form.description
|
46
|
+
|
47
|
+
organization.save!
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency "decidim/system/application_controller"
|
3
|
+
|
4
|
+
module Decidim
|
5
|
+
module System
|
6
|
+
# Controller that allows managing all the Admins.
|
7
|
+
#
|
8
|
+
class AdminsController < ApplicationController
|
9
|
+
def index
|
10
|
+
@admins = Admin.all
|
11
|
+
end
|
12
|
+
|
13
|
+
def new
|
14
|
+
@form = AdminForm.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
@form = AdminForm.from_params(params)
|
19
|
+
|
20
|
+
CreateAdmin.call(@form) do
|
21
|
+
on(:ok) do
|
22
|
+
flash[:notice] = I18n.t("admins.create.success", scope: "decidim.system")
|
23
|
+
redirect_to admins_path
|
24
|
+
end
|
25
|
+
|
26
|
+
on(:invalid) do
|
27
|
+
flash.now[:alert] = I18n.t("admins.create.error", scope: "decidim.system")
|
28
|
+
render :new
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def edit
|
34
|
+
@admin = Admin.find(params[:id])
|
35
|
+
@form = AdminForm.from_model(@admin)
|
36
|
+
end
|
37
|
+
|
38
|
+
def update
|
39
|
+
@admin = Admin.find(params[:id])
|
40
|
+
@form = AdminForm.from_params(params)
|
41
|
+
|
42
|
+
UpdateAdmin.call(@admin, @form) do
|
43
|
+
on(:ok) do
|
44
|
+
flash[:notice] = I18n.t("admins.update.success", scope: "decidim.system")
|
45
|
+
redirect_to admins_path
|
46
|
+
end
|
47
|
+
|
48
|
+
on(:invalid) do
|
49
|
+
flash.now[:alert] = I18n.t("admins.update.error", scope: "decidim.system")
|
50
|
+
render :edit
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def show
|
56
|
+
@admin = Admin.find(params[:id])
|
57
|
+
end
|
58
|
+
|
59
|
+
def destroy
|
60
|
+
@admin = Admin.find(params[:id]).destroy!
|
61
|
+
flash[:notice] = I18n.t("admins.destroy.success", scope: "decidim.system")
|
62
|
+
|
63
|
+
redirect_to admins_path
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module System
|
4
|
+
# The main application controller that inherits from Rails.
|
5
|
+
class ApplicationController < ActionController::Base
|
6
|
+
protect_from_forgery with: :exception, prepend: true
|
7
|
+
|
8
|
+
helper Decidim::TranslationsHelper
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module System
|
4
|
+
module Devise
|
5
|
+
# Custom Passwords controller for Devise in order to use a custom layout
|
6
|
+
# and views.
|
7
|
+
class PasswordsController < ::Devise::PasswordsController
|
8
|
+
layout "decidim/system/login"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module System
|
4
|
+
module Devise
|
5
|
+
# Custom Sessions controller for Devise in order to use a custom layout
|
6
|
+
# and views.
|
7
|
+
class SessionsController < ::Devise::SessionsController
|
8
|
+
layout "decidim/system/login"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency "decidim/system/application_controller"
|
3
|
+
|
4
|
+
module Decidim
|
5
|
+
module System
|
6
|
+
# Controller to manage Organizations (tenants).
|
7
|
+
#
|
8
|
+
class OrganizationsController < ApplicationController
|
9
|
+
def new
|
10
|
+
@form = RegisterOrganizationForm.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def create
|
14
|
+
@form = RegisterOrganizationForm.from_params(params)
|
15
|
+
|
16
|
+
RegisterOrganization.call(@form) do
|
17
|
+
on(:ok) do
|
18
|
+
flash[:notice] = t("organizations.create.success", scope: "decidim.system")
|
19
|
+
redirect_to organizations_path
|
20
|
+
end
|
21
|
+
|
22
|
+
on(:invalid) do
|
23
|
+
flash.now[:alert] = t("organizations.create.error", scope: "decidim.system")
|
24
|
+
render :new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def index
|
30
|
+
@organizations = Organization.all
|
31
|
+
end
|
32
|
+
|
33
|
+
def show
|
34
|
+
@organization = Organization.find(params[:id])
|
35
|
+
end
|
36
|
+
|
37
|
+
def edit
|
38
|
+
organization = Organization.find(params[:id])
|
39
|
+
@form = UpdateOrganizationForm.from_model(organization)
|
40
|
+
end
|
41
|
+
|
42
|
+
def update
|
43
|
+
@form = UpdateOrganizationForm.from_params(params)
|
44
|
+
|
45
|
+
UpdateOrganization.call(params[:id], @form) do
|
46
|
+
on(:ok) do
|
47
|
+
flash[:notice] = t("organizations.update.success", scope: "decidim.system")
|
48
|
+
redirect_to organizations_path
|
49
|
+
end
|
50
|
+
|
51
|
+
on(:invalid) do
|
52
|
+
flash.now[:alert] = I18n.t("organizations.update.error", scope: "decidim.system")
|
53
|
+
render :edit
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|