decidim-admin 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of decidim-admin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/admin/application.js.es6 +2 -1
- data/app/commands/decidim/admin/create_category.rb +1 -0
- data/app/commands/decidim/admin/update_category.rb +1 -0
- data/app/controllers/concerns/decidim/admin/participatory_space_export.rb +43 -0
- data/app/controllers/decidim/admin/component_permissions_controller.rb +1 -0
- data/app/forms/decidim/admin/category_form.rb +1 -0
- data/app/forms/decidim/admin/permission_form.rb +2 -2
- data/app/forms/decidim/admin/permissions_form.rb +6 -1
- data/app/views/decidim/admin/categories/_form.html.erb +4 -0
- data/app/views/decidim/admin/resource_permissions/_options_form.html.erb +2 -0
- data/config/locales/en.yml +1 -0
- data/lib/decidim/admin/test.rb +1 -0
- data/lib/decidim/admin/test/manage_categories_examples.rb +135 -0
- data/lib/decidim/admin/test/manage_component_permissions_examples.rb +22 -0
- data/lib/decidim/admin/version.rb +1 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6169801bdd623d709157b8d278ccf08d493303fc5d01876a3920d86b724d7648
|
4
|
+
data.tar.gz: 507ccab28d2bfe28c66381572b38dccc7c04bc35360db85bbdd7ac1383c545d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2ebfe6737abc8c78cbf70ae9f6055a0f6a4f6ae755856d9e48fea09b3fbe10209f8ac133caee837f3bf0a4349e2c0ea05c86e2428f942c444faee2eb2447806
|
7
|
+
data.tar.gz: 3a3f72ed03709b39e91424887f1ef29606982ac15f27d7f5ef70336c607cc3f054b3b3608dd7741d00f87a14080d56727565a15b0205e27685b4a66884c0e107
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// = require
|
1
|
+
// = require jquery3
|
2
2
|
// = require foundation
|
3
3
|
// = require rails-ujs
|
4
4
|
// = require ./tab_focus
|
@@ -19,6 +19,7 @@
|
|
19
19
|
// = require ./sortable
|
20
20
|
// = require decidim/input_tags
|
21
21
|
// = require decidim/input_hashtags
|
22
|
+
// = require decidim/input_mentions
|
22
23
|
// = require_self
|
23
24
|
|
24
25
|
window.Decidim = window.Decidim || {};
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
module ParticipatorySpaceExport
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
helper_method :exportable_space
|
10
|
+
|
11
|
+
def create
|
12
|
+
enforce_permission_to :create, :export_space, participatory_space: exportable_space
|
13
|
+
|
14
|
+
ExportParticipatorySpaceJob.perform_later(current_user, exportable_space, "participatory_processes", default_format)
|
15
|
+
|
16
|
+
flash[:notice] = t("decidim.admin.exports.notice")
|
17
|
+
|
18
|
+
redirect_back(fallback_location: after_export_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Public: The only method to be implemented at the controller. You need to
|
22
|
+
# return the space that will be exported.
|
23
|
+
def exportable_space
|
24
|
+
raise NotImplementedError
|
25
|
+
end
|
26
|
+
|
27
|
+
# Public: Returns a String or Object that will be passed to `redirect_to` after
|
28
|
+
# exporing a space. By default it redirects to the root_path.
|
29
|
+
#
|
30
|
+
# It can be redefined at controller level if you need to redirect elsewhere.
|
31
|
+
def after_export_path
|
32
|
+
decidim.root_path
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def default_format
|
38
|
+
"JSON"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -12,7 +12,7 @@ module Decidim
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def authorization_handler_options(handler_name)
|
15
|
-
find_handler(handler_name)
|
15
|
+
find_handler(handler_name)&.dig("options") || {}
|
16
16
|
end
|
17
17
|
|
18
18
|
def manifest(handler_name)
|
@@ -20,7 +20,7 @@ module Decidim
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def options_schema(handler_name)
|
23
|
-
options_manifest(handler_name).schema.new(
|
23
|
+
options_manifest(handler_name).schema.new(authorization_handler_options(handler_name))
|
24
24
|
end
|
25
25
|
|
26
26
|
def options_attributes(handler_name)
|
@@ -9,7 +9,12 @@ module Decidim
|
|
9
9
|
|
10
10
|
attribute :permissions, Hash[String => PermissionForm]
|
11
11
|
|
12
|
-
|
12
|
+
private
|
13
|
+
|
14
|
+
# Overriding Rectify::Form#form_attributes_valid? to preserve errors from custom method validations.
|
15
|
+
def form_attributes_valid?
|
16
|
+
return false unless errors.empty? && permissions.each_value.map(&:errors).all?(&:empty?)
|
17
|
+
|
13
18
|
super && permissions.values.all?(&:valid?)
|
14
19
|
end
|
15
20
|
end
|
data/config/locales/en.yml
CHANGED
data/lib/decidim/admin/test.rb
CHANGED
@@ -2,5 +2,6 @@
|
|
2
2
|
|
3
3
|
require "decidim/admin/test/manage_attachments_examples"
|
4
4
|
require "decidim/admin/test/manage_attachment_collections_examples"
|
5
|
+
require "decidim/admin/test/manage_categories_examples"
|
5
6
|
require "decidim/admin/test/manage_component_permissions_examples"
|
6
7
|
require "decidim/admin/test/manage_moderations_examples"
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
shared_examples "manage categories examples" do
|
4
|
+
it "lists all the categories for the process" do
|
5
|
+
within "#categories table" do
|
6
|
+
expect(page).to have_content(translated(category.name, locale: :en))
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
it "can view a category detail" do
|
11
|
+
within "#categories table" do
|
12
|
+
click_link translated(category.name, locale: :en)
|
13
|
+
end
|
14
|
+
|
15
|
+
expect(page).to have_selector("input#category_name_en[value='#{translated(category.name, locale: :en)}']")
|
16
|
+
expect(page).to have_selector("input#category_weight[value='#{category.weight}']")
|
17
|
+
within ".editor .editor-container" do
|
18
|
+
expect(page).to have_content(strip_tags(translated(category.description, locale: :en)))
|
19
|
+
end
|
20
|
+
|
21
|
+
expect(page).to have_selector("select#category_parent_id")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "creates a new category" do
|
25
|
+
find(".card-title a.new").click
|
26
|
+
|
27
|
+
within ".new_category" do
|
28
|
+
fill_in_i18n(
|
29
|
+
:category_name,
|
30
|
+
"#category-name-tabs",
|
31
|
+
en: "My category",
|
32
|
+
es: "Mi categoría",
|
33
|
+
ca: "La meva categoria"
|
34
|
+
)
|
35
|
+
fill_in_i18n_editor(
|
36
|
+
:category_description,
|
37
|
+
"#category-description-tabs",
|
38
|
+
en: "Description",
|
39
|
+
es: "Descripción",
|
40
|
+
ca: "Descripció"
|
41
|
+
)
|
42
|
+
|
43
|
+
find("*[type=submit]").click
|
44
|
+
end
|
45
|
+
|
46
|
+
expect(page).to have_admin_callout("successfully")
|
47
|
+
|
48
|
+
within "#categories table" do
|
49
|
+
expect(page).to have_content("My category")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "updates a category" do
|
54
|
+
within "#categories" do
|
55
|
+
within find("tr", text: translated(category.name)) do
|
56
|
+
click_link "Edit"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
within ".edit_category" do
|
61
|
+
fill_in_i18n(
|
62
|
+
:category_name,
|
63
|
+
"#category-name-tabs",
|
64
|
+
en: "My new name",
|
65
|
+
es: "Mi nuevo nombre",
|
66
|
+
ca: "El meu nou nom"
|
67
|
+
)
|
68
|
+
|
69
|
+
find("*[type=submit]").click
|
70
|
+
end
|
71
|
+
|
72
|
+
expect(page).to have_admin_callout("successfully")
|
73
|
+
|
74
|
+
within "#categories table" do
|
75
|
+
expect(page).to have_content("My new name")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "when deleting a category" do
|
80
|
+
let!(:category2) { create(:category, participatory_space: participatory_space) }
|
81
|
+
|
82
|
+
context "when the category has no associated content" do
|
83
|
+
context "when the category has no subcategories" do
|
84
|
+
before do
|
85
|
+
visit current_path
|
86
|
+
end
|
87
|
+
|
88
|
+
it "deletes a category" do
|
89
|
+
within find("tr", text: translated(category2.name)) do
|
90
|
+
accept_confirm { click_link "Delete" }
|
91
|
+
end
|
92
|
+
|
93
|
+
expect(page).to have_admin_callout("successfully")
|
94
|
+
|
95
|
+
within "#categories table" do
|
96
|
+
expect(page).to have_no_content(translated(category2.name))
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context "when the category has some subcategories" do
|
102
|
+
let!(:subcategory) { create(:subcategory, parent: category2) }
|
103
|
+
|
104
|
+
before do
|
105
|
+
visit current_path
|
106
|
+
end
|
107
|
+
|
108
|
+
it "deletes a category" do
|
109
|
+
within find("tr", text: translated(category2.name)) do
|
110
|
+
accept_confirm { click_link "Delete" }
|
111
|
+
end
|
112
|
+
|
113
|
+
expect(page).to have_admin_callout("problem deleting")
|
114
|
+
|
115
|
+
within "#categories table" do
|
116
|
+
expect(page).to have_content(translated(category2.name))
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context "when the category has associated content" do
|
123
|
+
let!(:component) { create(:component, participatory_space: participatory_space) }
|
124
|
+
let!(:dummy_resource) { create(:dummy_resource, component: component, category: category) }
|
125
|
+
|
126
|
+
it "cannot delete it" do
|
127
|
+
visit current_path
|
128
|
+
|
129
|
+
within find("tr", text: translated(category.name)) do
|
130
|
+
expect(page).to have_no_selector("a.action-icon--remove")
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -50,6 +50,28 @@ shared_examples "Managing component permissions" do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
context "when failing to set permissions" do
|
54
|
+
before do
|
55
|
+
# rubocop:disable RSpec/AnyInstance
|
56
|
+
allow_any_instance_of(Decidim::Admin::PermissionsForm).to receive(:valid?).and_return(false)
|
57
|
+
# rubocop:enable RSpec/AnyInstance
|
58
|
+
within ".component-#{component.id}" do
|
59
|
+
click_link "Permissions"
|
60
|
+
end
|
61
|
+
within "form.new_component_permissions" do
|
62
|
+
within ".foo-permission" do
|
63
|
+
check "Example authorization (Direct)"
|
64
|
+
fill_in "Postal code", with: "08002"
|
65
|
+
end
|
66
|
+
find("*[type=submit]").click
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it "renders the form again" do
|
71
|
+
expect(page).to have_content("problem")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
53
75
|
context "when unsetting permissions" do
|
54
76
|
before do
|
55
77
|
component.update!(
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-01-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: active_link_to
|
@@ -32,14 +32,14 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.
|
35
|
+
version: 0.20.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.
|
42
|
+
version: 0.20.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: devise
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,28 +136,28 @@ dependencies:
|
|
136
136
|
requirements:
|
137
137
|
- - '='
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 0.
|
139
|
+
version: 0.20.0
|
140
140
|
type: :development
|
141
141
|
prerelease: false
|
142
142
|
version_requirements: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
144
|
- - '='
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: 0.
|
146
|
+
version: 0.20.0
|
147
147
|
- !ruby/object:Gem::Dependency
|
148
148
|
name: decidim-participatory_processes
|
149
149
|
requirement: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
151
|
- - '='
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
version: 0.
|
153
|
+
version: 0.20.0
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
156
|
version_requirements: !ruby/object:Gem::Requirement
|
157
157
|
requirements:
|
158
158
|
- - '='
|
159
159
|
- !ruby/object:Gem::Version
|
160
|
-
version: 0.
|
160
|
+
version: 0.20.0
|
161
161
|
description: Organization administration to manage a single organization.
|
162
162
|
email:
|
163
163
|
- josepjaume@gmail.com
|
@@ -328,6 +328,7 @@ files:
|
|
328
328
|
- app/commands/decidim/admin/verify_user_group.rb
|
329
329
|
- app/constraints/decidim/admin/organization_dashboard_constraint.rb
|
330
330
|
- app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
|
331
|
+
- app/controllers/concerns/decidim/admin/participatory_space_export.rb
|
331
332
|
- app/controllers/concerns/decidim/admin/user_groups.rb
|
332
333
|
- app/controllers/decidim/admin/application_controller.rb
|
333
334
|
- app/controllers/decidim/admin/area_types_controller.rb
|
@@ -579,6 +580,7 @@ files:
|
|
579
580
|
- lib/decidim/admin/test/forms/category_form_examples.rb
|
580
581
|
- lib/decidim/admin/test/manage_attachment_collections_examples.rb
|
581
582
|
- lib/decidim/admin/test/manage_attachments_examples.rb
|
583
|
+
- lib/decidim/admin/test/manage_categories_examples.rb
|
582
584
|
- lib/decidim/admin/test/manage_component_permissions_examples.rb
|
583
585
|
- lib/decidim/admin/test/manage_moderations_examples.rb
|
584
586
|
- lib/decidim/admin/version.rb
|