decidim-department_admin 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE-AGPLv3.txt +661 -0
- data/README.md +132 -0
- data/Rakefile +9 -0
- data/app/controllers/decidim/department_admin/admin/application_controller.rb +15 -0
- data/app/controllers/decidim/department_admin/application_controller.rb +13 -0
- data/app/decorators/decidim/admin/newsletters_controller_decorator.rb +30 -0
- data/app/decorators/decidim/admin/users_controller_decorator.rb +128 -0
- data/app/decorators/decidim/area_decorator.rb +44 -0
- data/app/decorators/decidim/assemblies/admin/assemblies_controller_decorator.rb +25 -0
- data/app/decorators/decidim/assemblies/admin/assemblies_helper_decorator.rb +24 -0
- data/app/decorators/decidim/assemblies/create_assembly_decorator.rb +19 -0
- data/app/decorators/decidim/assemblies/parent_assemblies_for_select_decorator.rb +38 -0
- data/app/decorators/decidim/assemblies/permissions_decorator.rb +22 -0
- data/app/decorators/decidim/assemblies/update_assembly_decorator.rb +19 -0
- data/app/decorators/decidim/assemblies_decorator.rb +21 -0
- data/app/decorators/decidim/assemblies_with_user_role_decorator.rb +27 -0
- data/app/decorators/decidim/conference_form_decorator.rb +23 -0
- data/app/decorators/decidim/conferences/admin/conferences_controller_decorator.rb +27 -0
- data/app/decorators/decidim/conferences/create_conference_decorator.rb +51 -0
- data/app/decorators/decidim/conferences/permissions_decorator.rb +24 -0
- data/app/decorators/decidim/conferences/update_conference_decorator.rb +21 -0
- data/app/decorators/decidim/conferences_decorator.rb +27 -0
- data/app/decorators/decidim/conferences_with_user_role_decorator.rb +29 -0
- data/app/decorators/decidim/decidim_form_helper_decorator.rb +23 -0
- data/app/decorators/decidim/invite_user_decorator.rb +56 -0
- data/app/decorators/decidim/invite_user_form_decorator.rb +45 -0
- data/app/decorators/decidim/newsletter_decorator.rb +20 -0
- data/app/decorators/decidim/newsletters_helper_decorator.rb +44 -0
- data/app/decorators/decidim/participatory_process_decorator.rb +21 -0
- data/app/decorators/decidim/participatory_process_group_decorator.rb +17 -0
- data/app/decorators/decidim/participatory_processes/admin/participatory_processes_controller_decorator.rb +25 -0
- data/app/decorators/decidim/participatory_processes/create_participatory_process_decorator.rb +19 -0
- data/app/decorators/decidim/participatory_processes/permissions_decorator.rb +22 -0
- data/app/decorators/decidim/participatory_processes/update_participatory_process_decorator.rb +19 -0
- data/app/decorators/decidim/participatory_processes_with_user_role_decorator.rb +27 -0
- data/app/decorators/decidim/user_decorator.rb +59 -0
- data/app/decorators/lib/decidim/participatory_space_resourceable_decorator.rb +36 -0
- data/app/helpers/decidim/admin/user_roles_helper.rb +25 -0
- data/app/helpers/decidim/department_admin/application_helper.rb +54 -0
- data/app/models/decidim/participatory_space_role_config/department_admin.rb +8 -0
- data/app/overrides/decidim/admin/shared/add_radio_buttons_to_filters.rb +6 -0
- data/app/packs/entrypoints/decidim_department_admin.js +4 -0
- data/app/packs/entrypoints/decidim_department_admin.scss +1 -0
- data/app/packs/images/decidim/department_admin/icon.svg +1 -0
- data/app/packs/stylesheets/decidim/admin/department_admin.scss +5 -0
- data/app/permissions/decidim/assemblies/participatory_space_permissions.rb +14 -0
- data/app/permissions/decidim/conferences/participatory_space_permissions.rb +17 -0
- data/app/permissions/decidim/department_admin/permissions.rb +240 -0
- data/app/permissions/decidim/participatory_processes/participatory_space_permissions.rb +14 -0
- data/app/queries/decidim/admin/user_admin_by_space_name_filter.rb +67 -0
- data/app/queries/decidim/admin/user_admin_filter.rb +50 -0
- data/app/views/decidim/admin/users/_filters.html.erb +28 -0
- data/app/views/decidim/admin/users/_form.html.erb +30 -0
- data/app/views/decidim/admin/users/index.html.erb +93 -0
- data/app/views/decidim/admin/users/show.html.erb +99 -0
- data/app/views/decidim/assemblies/admin/assemblies/index.html.erb +147 -0
- data/app/views/decidim/conferences/admin/conferences/_form.html.erb +127 -0
- data/app/views/decidim/conferences/admin/conferences/index.html.erb +85 -0
- data/app/views/decidim/participatory_processes/admin/participatory_processes/index.html.erb +160 -0
- data/config/assets.rb +27 -0
- data/config/i18n-tasks.yml +148 -0
- data/config/initializers/user_roles.rb +4 -0
- data/config/locales/ca.yml +61 -0
- data/config/locales/cs.yml +46 -0
- data/config/locales/en.yml +61 -0
- data/config/locales/es.yml +61 -0
- data/db/migrate/20190328130102_create_department_admin_areas.rb +10 -0
- data/db/migrate/20210420143021_add_area_to_conferences.rb +7 -0
- data/lib/decidim/department_admin/admin.rb +10 -0
- data/lib/decidim/department_admin/admin_engine.rb +27 -0
- data/lib/decidim/department_admin/engine.rb +137 -0
- data/lib/decidim/department_admin/test/factories.rb +17 -0
- data/lib/decidim/department_admin/version.rb +11 -0
- data/lib/decidim/department_admin.rb +15 -0
- data/spec/commands/decidim/admin/deliver_newsletter_spec.rb +175 -0
- data/spec/commands/decidim/invite_user_spec.rb +42 -0
- data/spec/controllers/decidim/admin/users_controller_spec.rb +119 -0
- data/spec/factories.rb +4 -0
- data/spec/features/check_overrides_spec.rb +11 -0
- data/spec/i18n_spec.rb +29 -0
- data/spec/models/decidim/area_spec.rb +23 -0
- data/spec/permissions/decidim/department_admin/department_admin_permissions_spec.rb +120 -0
- data/spec/queries/parent_assemblies_for_select_spec.rb +52 -0
- data/spec/spec_helper.rb +47 -0
- data/spec/system/admin_explores_processes_spec.rb +53 -0
- data/spec/system/admin_invite_department_admin_spec.rb +118 -0
- data/spec/system/department_admin_manages_newsletters_spec.rb +237 -0
- data/spec/system/department_admin_should_be_able_to_access_admin_dashboard_spec.rb +75 -0
- data/spec/system/department_admin_should_be_able_to_manage_assemblies_spec.rb +99 -0
- data/spec/system/department_admin_should_be_able_to_manage_conferences_spec.rb +74 -0
- data/spec/system/department_admin_should_be_able_to_manage_processes_spec.rb +117 -0
- data/spec/system/department_admin_should_be_able_to_see_only_assemblies_from_her_area_spec.rb +46 -0
- data/spec/system/department_admin_should_be_able_to_see_only_newsletters_from_her_area_spec.rb +53 -0
- data/spec/system/department_admin_should_be_able_to_see_only_processes_from_her_area_spec.rb +50 -0
- metadata +229 -0
@@ -0,0 +1,148 @@
|
|
1
|
+
# i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
|
2
|
+
|
3
|
+
# The "main" locale.
|
4
|
+
base_locale: en
|
5
|
+
## All available locales are inferred from the data by default. Alternatively, specify them explicitly:
|
6
|
+
# locales: [es, fr]
|
7
|
+
## Reporting locale, default: en. Available: en, ru.
|
8
|
+
# internal_locale: en
|
9
|
+
|
10
|
+
# Read and write translations.
|
11
|
+
data:
|
12
|
+
## Translations are read from the file system. Supported format: YAML, JSON.
|
13
|
+
## Provide a custom adapter:
|
14
|
+
# adapter: I18n::Tasks::Data::FileSystem
|
15
|
+
|
16
|
+
# Locale files or `File.find` patterns where translations are read from:
|
17
|
+
read:
|
18
|
+
## Default:
|
19
|
+
# - config/locales/%{locale}.yml
|
20
|
+
## More files:
|
21
|
+
# - config/locales/**/*.%{locale}.yml
|
22
|
+
|
23
|
+
# Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
|
24
|
+
# `i18n-tasks normalize -p` will force move the keys according to these rules
|
25
|
+
write:
|
26
|
+
## For example, write devise and simple form keys to their respective files:
|
27
|
+
# - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml']
|
28
|
+
## Catch-all default:
|
29
|
+
# - config/locales/%{locale}.yml
|
30
|
+
|
31
|
+
# External locale data (e.g. gems).
|
32
|
+
# This data is not considered unused and is never written to.
|
33
|
+
external:
|
34
|
+
## Example (replace %#= with %=):
|
35
|
+
# - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"
|
36
|
+
|
37
|
+
## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class.
|
38
|
+
# router: conservative_router
|
39
|
+
|
40
|
+
yaml:
|
41
|
+
write:
|
42
|
+
# do not wrap lines at 80 characters
|
43
|
+
line_width: -1
|
44
|
+
|
45
|
+
## Pretty-print JSON:
|
46
|
+
# json:
|
47
|
+
# write:
|
48
|
+
# indent: ' '
|
49
|
+
# space: ' '
|
50
|
+
# object_nl: "\n"
|
51
|
+
# array_nl: "\n"
|
52
|
+
|
53
|
+
# Find translate calls
|
54
|
+
search:
|
55
|
+
## Paths or `File.find` patterns to search in:
|
56
|
+
# paths:
|
57
|
+
# - app/
|
58
|
+
|
59
|
+
## Root directories for relative keys resolution.
|
60
|
+
# relative_roots:
|
61
|
+
# - app/controllers
|
62
|
+
# - app/helpers
|
63
|
+
# - app/mailers
|
64
|
+
# - app/presenters
|
65
|
+
# - app/views
|
66
|
+
|
67
|
+
## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
|
68
|
+
## %w(*.jpg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less *.yml *.json)
|
69
|
+
exclude:
|
70
|
+
- app/assets/images
|
71
|
+
- app/assets/fonts
|
72
|
+
- app/assets/videos
|
73
|
+
- app/views/decidim/admin/users/_form.html.erb
|
74
|
+
|
75
|
+
## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`:
|
76
|
+
## If specified, this settings takes priority over `exclude`, but `exclude` still applies.
|
77
|
+
# only: ["*.rb", "*.html.slim"]
|
78
|
+
|
79
|
+
## If `strict` is `false`, guess usages such as t("categories.#{category}.title"). The default is `true`.
|
80
|
+
# strict: true
|
81
|
+
|
82
|
+
## Multiple scanners can be used. Their results are merged.
|
83
|
+
## The options specified above are passed down to each scanner. Per-scanner options can be specified as well.
|
84
|
+
## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example
|
85
|
+
|
86
|
+
## Translation Services
|
87
|
+
# translation:
|
88
|
+
# # Google Translate
|
89
|
+
# # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
|
90
|
+
# google_translate_api_key: "AbC-dEf5"
|
91
|
+
# # DeepL Pro Translate
|
92
|
+
# # Get an API key and subscription at https://www.deepl.com/pro to use DeepL Pro
|
93
|
+
# deepl_api_key: "48E92789-57A3-466A-9959-1A1A1A1A1A1A"
|
94
|
+
|
95
|
+
## Do not consider these keys missing:
|
96
|
+
# ignore_missing:
|
97
|
+
# - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
|
98
|
+
# - '{devise,simple_form}.*'
|
99
|
+
|
100
|
+
## Consider these keys used:
|
101
|
+
ignore_unused:
|
102
|
+
# - 'activerecord.attributes.*'
|
103
|
+
# - '{devise,kaminari,will_paginate}.*'
|
104
|
+
# - 'simple_form.{yes,no}'
|
105
|
+
# - 'simple_form.{placeholders,hints,labels}.*'
|
106
|
+
# - 'simple_form.{error_notification,required}.:'
|
107
|
+
- 'decidim.admin.models.user.fields.roles.department_admin'
|
108
|
+
- 'decidim.admin.users.form.area'
|
109
|
+
- 'decidim.components.department_admin.name'
|
110
|
+
- 'decidim.admin.models.user.fields.roles.department_admin'
|
111
|
+
- 'decidim.admin.users.form.area'
|
112
|
+
- 'decidim.components.department_admin.name'
|
113
|
+
- 'decidim.admin.models.user.fields.roles.department_admin'
|
114
|
+
- 'decidim.admin.users.form.area'
|
115
|
+
- 'decidim.components.department_admin.name'
|
116
|
+
- 'decidim.admin.shared.filters.filter.all'
|
117
|
+
- 'decidim.admin.shared.filters.filter_by'
|
118
|
+
- 'decidim.admin.users.index.filter.all'
|
119
|
+
- 'decidim.admin.users.index.filter_by'
|
120
|
+
- 'decidim.admin.users.index.search'
|
121
|
+
|
122
|
+
## Exclude these keys from the `i18n-tasks eq-base' report:
|
123
|
+
# ignore_eq_base:
|
124
|
+
# all:
|
125
|
+
# - common.ok
|
126
|
+
# fr,es:
|
127
|
+
# - common.brand
|
128
|
+
|
129
|
+
## Exclude these keys from the `i18n-tasks check-consistent-interpolations` report:
|
130
|
+
# ignore_inconsistent_interpolations:
|
131
|
+
# - 'activerecord.attributes.*'
|
132
|
+
|
133
|
+
## Ignore these keys completely:
|
134
|
+
# ignore:
|
135
|
+
# - kaminari.*
|
136
|
+
|
137
|
+
## Sometimes, it isn't possible for i18n-tasks to match the key correctly,
|
138
|
+
## e.g. in case of a relative key defined in a helper method.
|
139
|
+
## In these cases you can use the built-in PatternMapper to map patterns to keys, e.g.:
|
140
|
+
#
|
141
|
+
# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
|
142
|
+
# only: %w(*.html.haml *.html.slim),
|
143
|
+
# patterns: [['= title\b', '.page_title']] %>
|
144
|
+
#
|
145
|
+
# The PatternMapper can also match key literals via a special %{key} interpolation, e.g.:
|
146
|
+
#
|
147
|
+
# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
|
148
|
+
# patterns: [['\bSpree\.t[( ]\s*%{key}', 'spree.%{key}']] %>
|
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
ca:
|
3
|
+
decidim:
|
4
|
+
admin:
|
5
|
+
models:
|
6
|
+
assembly:
|
7
|
+
fields:
|
8
|
+
assembly_role: Rol consell
|
9
|
+
department: Departament/Àrea
|
10
|
+
department_role: Rol departament
|
11
|
+
conference:
|
12
|
+
fields:
|
13
|
+
conference_role: Rol jornada
|
14
|
+
department: Departament/Àrea
|
15
|
+
department_role: Rol department
|
16
|
+
participatory_process:
|
17
|
+
fields:
|
18
|
+
department: Departament/Àrea
|
19
|
+
department_role: Rol departament
|
20
|
+
process_role: Rol procés
|
21
|
+
user:
|
22
|
+
fields:
|
23
|
+
administrated_spaces: Espais administrats
|
24
|
+
assembly_type: Consell
|
25
|
+
created_at: Data de creació
|
26
|
+
department: Departament/Àrea
|
27
|
+
private: Privat
|
28
|
+
process_type: Procés
|
29
|
+
published: Publicat
|
30
|
+
roles:
|
31
|
+
assembly_admin: Administradora de consell
|
32
|
+
department_admin: Administradora de departament
|
33
|
+
process_admin: Administradora de procés
|
34
|
+
space_admin: Administradora d'espai
|
35
|
+
search_field_admins: Administradores
|
36
|
+
search_field_processes: Processos
|
37
|
+
search_question: Què estàs cercant?
|
38
|
+
spaces: Procés / Normativa / Consell
|
39
|
+
title: Titol
|
40
|
+
type: Tipus
|
41
|
+
shared:
|
42
|
+
filters:
|
43
|
+
filter:
|
44
|
+
all: Totes
|
45
|
+
filter_by: Filtra per
|
46
|
+
users:
|
47
|
+
form:
|
48
|
+
area: Àrea
|
49
|
+
index:
|
50
|
+
filter:
|
51
|
+
all: Totes
|
52
|
+
filter_by: Filtra per
|
53
|
+
search: Cerca
|
54
|
+
components:
|
55
|
+
department_admin:
|
56
|
+
name: Admin de Departament
|
57
|
+
conferences:
|
58
|
+
admin:
|
59
|
+
conferences:
|
60
|
+
form:
|
61
|
+
select_an_area: Selecciona una Àrea
|
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
cs:
|
3
|
+
decidim:
|
4
|
+
admin:
|
5
|
+
models:
|
6
|
+
assembly:
|
7
|
+
fields:
|
8
|
+
assembly_role: Role ve shromáždění
|
9
|
+
department: Oddělení / oblast
|
10
|
+
department_role: Role oddělení
|
11
|
+
participatory_process:
|
12
|
+
fields:
|
13
|
+
department: Oddělení / oblast
|
14
|
+
department_role: Role oddělení
|
15
|
+
process_role: Role procesu
|
16
|
+
user:
|
17
|
+
fields:
|
18
|
+
administrated_spaces: Spravované prostory
|
19
|
+
assembly_type: Shromáždění
|
20
|
+
created_at: Vytvořeno v
|
21
|
+
department: Oddělení / oblast
|
22
|
+
private: Soukromí
|
23
|
+
process_type: Proces
|
24
|
+
published: Publikováno
|
25
|
+
roles:
|
26
|
+
assembly_admin: Správce shromáždění
|
27
|
+
department_admin: Správce oddělení
|
28
|
+
process_admin: Správce procesu
|
29
|
+
space_admin: Správce prostoru
|
30
|
+
search_field_admins: Správci
|
31
|
+
search_field_processes: Procesy
|
32
|
+
search_question: Co hledáte?
|
33
|
+
spaces: Proces / Pravidlo / Shromáždění
|
34
|
+
title: Název
|
35
|
+
type: Typ
|
36
|
+
users:
|
37
|
+
form:
|
38
|
+
area: Oblast
|
39
|
+
index:
|
40
|
+
filter:
|
41
|
+
all: Vše
|
42
|
+
filter_by: filtrovat podle
|
43
|
+
search: Hledat
|
44
|
+
components:
|
45
|
+
department_admin:
|
46
|
+
name: Správce oddělení
|
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
decidim:
|
4
|
+
admin:
|
5
|
+
models:
|
6
|
+
assembly:
|
7
|
+
fields:
|
8
|
+
assembly_role: Assembly role
|
9
|
+
department: Department/Area
|
10
|
+
department_role: Department role
|
11
|
+
conference:
|
12
|
+
fields:
|
13
|
+
conference_role: Conference role
|
14
|
+
department: Department/Area
|
15
|
+
department_role: Department role
|
16
|
+
participatory_process:
|
17
|
+
fields:
|
18
|
+
department: Department/Area
|
19
|
+
department_role: Department role
|
20
|
+
process_role: Process role
|
21
|
+
user:
|
22
|
+
fields:
|
23
|
+
administrated_spaces: Administrated spaces
|
24
|
+
assembly_type: Assemby
|
25
|
+
created_at: Created at
|
26
|
+
department: Department/Area
|
27
|
+
private: Private
|
28
|
+
process_type: Process
|
29
|
+
published: Published
|
30
|
+
roles:
|
31
|
+
assembly_admin: Assembly Administrator
|
32
|
+
department_admin: Department Administrator
|
33
|
+
process_admin: Process Administrator
|
34
|
+
space_admin: Space Administrator
|
35
|
+
search_field_admins: Administrators
|
36
|
+
search_field_processes: Processes
|
37
|
+
search_question: What are you looking for?
|
38
|
+
spaces: Process / Regulations / Assemblies
|
39
|
+
title: Title
|
40
|
+
type: Type
|
41
|
+
shared:
|
42
|
+
filters:
|
43
|
+
filter:
|
44
|
+
all: All
|
45
|
+
filter_by: Filter by
|
46
|
+
users:
|
47
|
+
form:
|
48
|
+
area: Area
|
49
|
+
index:
|
50
|
+
filter:
|
51
|
+
all: All
|
52
|
+
filter_by: Filter by
|
53
|
+
search: Search
|
54
|
+
components:
|
55
|
+
department_admin:
|
56
|
+
name: Department Admin
|
57
|
+
conferences:
|
58
|
+
admin:
|
59
|
+
conferences:
|
60
|
+
form:
|
61
|
+
select_an_area: Select an area
|
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
es:
|
3
|
+
decidim:
|
4
|
+
admin:
|
5
|
+
models:
|
6
|
+
assembly:
|
7
|
+
fields:
|
8
|
+
assembly_role: Rol consejo
|
9
|
+
department: Departamento/Area
|
10
|
+
department_role: Rol departamento
|
11
|
+
conference:
|
12
|
+
fields:
|
13
|
+
conference_role: Rol jornada
|
14
|
+
department: Departamento/Area
|
15
|
+
department_role: Rol departamento
|
16
|
+
participatory_process:
|
17
|
+
fields:
|
18
|
+
department: Departamento/Area
|
19
|
+
department_role: Rol departamento
|
20
|
+
process_role: Rol proceso
|
21
|
+
user:
|
22
|
+
fields:
|
23
|
+
administrated_spaces: Espacios administrados
|
24
|
+
assembly_type: Consejo
|
25
|
+
created_at: Data de creación
|
26
|
+
department: Departamento/Área
|
27
|
+
private: Privado
|
28
|
+
process_type: Proceso
|
29
|
+
published: Publicado
|
30
|
+
roles:
|
31
|
+
assembly_admin: Administradora de consejo
|
32
|
+
department_admin: Administradora de departamento
|
33
|
+
process_admin: Administradora de proceso
|
34
|
+
space_admin: Administradora de espacio
|
35
|
+
search_field_admins: Administradoras
|
36
|
+
search_field_processes: Procesos
|
37
|
+
search_question: Que estás buscando?
|
38
|
+
spaces: Procesos / Normativas / Consejo
|
39
|
+
title: Título
|
40
|
+
type: Tipo
|
41
|
+
shared:
|
42
|
+
filters:
|
43
|
+
filter:
|
44
|
+
all: Todas
|
45
|
+
filter_by: Filtrado por
|
46
|
+
users:
|
47
|
+
form:
|
48
|
+
area: Area
|
49
|
+
index:
|
50
|
+
filter:
|
51
|
+
all: Todas
|
52
|
+
filter_by: Filtrado por
|
53
|
+
search: Buscar
|
54
|
+
components:
|
55
|
+
department_admin:
|
56
|
+
name: Admin de Departamento
|
57
|
+
conferences:
|
58
|
+
admin:
|
59
|
+
conferences:
|
60
|
+
form:
|
61
|
+
select_an_area: Selecciona una Area
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateDepartmentAdminAreas < ActiveRecord::Migration[5.2]
|
4
|
+
def change
|
5
|
+
create_table :department_admin_areas do |t|
|
6
|
+
t.belongs_to :decidim_user, foreign_key: true
|
7
|
+
t.belongs_to :decidim_area, foreign_key: true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DepartmentAdmin
|
5
|
+
# This is the engine that runs on the public interface of `DepartmentAdmin`.
|
6
|
+
class AdminEngine < ::Rails::Engine
|
7
|
+
isolate_namespace Decidim::DepartmentAdmin::Admin
|
8
|
+
|
9
|
+
paths["db/migrate"] = nil
|
10
|
+
paths["lib/tasks"] = nil
|
11
|
+
|
12
|
+
routes do
|
13
|
+
# Add admin engine routes here
|
14
|
+
# resources :department_admin do
|
15
|
+
# collection do
|
16
|
+
# resources :exports, only: [:create]
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
# root to: "department_admin#index"
|
20
|
+
end
|
21
|
+
|
22
|
+
def load_seed
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails"
|
4
|
+
require "decidim/core"
|
5
|
+
|
6
|
+
module Decidim
|
7
|
+
module DepartmentAdmin
|
8
|
+
# This is the engine that runs on the public interface of department_admin.
|
9
|
+
class Engine < ::Rails::Engine
|
10
|
+
isolate_namespace Decidim::DepartmentAdmin
|
11
|
+
|
12
|
+
# make decorators autoload in development env
|
13
|
+
config.autoload_paths << File.join(
|
14
|
+
Decidim::DepartmentAdmin::Engine.root, "app", "decorators", "{**}"
|
15
|
+
)
|
16
|
+
|
17
|
+
routes do
|
18
|
+
# Add engine routes here
|
19
|
+
# resources :department_admin
|
20
|
+
# root to: "department_admin#index"
|
21
|
+
end
|
22
|
+
|
23
|
+
initializer "department_admin.webpacker.assets_path" do
|
24
|
+
Decidim.register_assets_path File.expand_path("app/packs", root)
|
25
|
+
end
|
26
|
+
|
27
|
+
# rubocop: disable Lint/ConstantDefinitionInBlock
|
28
|
+
initializer "department_admin.permissions_registry" do
|
29
|
+
# activate Decidim LayoutHelper for the overriden views
|
30
|
+
::Decidim::Admin::ApplicationController.helper ::Decidim::LayoutHelper
|
31
|
+
::Decidim::ApplicationController.helper ::Decidim::LayoutHelper
|
32
|
+
|
33
|
+
# avoid webpacker to crash when executing before Decidim is loaded
|
34
|
+
next unless Rails.env.test? || defined? DecidimController
|
35
|
+
|
36
|
+
# **
|
37
|
+
# Modify decidim-admin permissions registry
|
38
|
+
# **
|
39
|
+
artifact = ::Decidim::Admin::ApplicationController
|
40
|
+
AdminApplicationControllerPermissions = Class.new(::Decidim::DepartmentAdmin::Permissions)
|
41
|
+
register_new_permissions_for(artifact, AdminApplicationControllerPermissions)
|
42
|
+
|
43
|
+
# **
|
44
|
+
# Modify decidim-particypatory_processes permissions registry
|
45
|
+
# **
|
46
|
+
|
47
|
+
# force the concern to be included so that registry is initialized
|
48
|
+
# we choose some random class already including it
|
49
|
+
require "decidim/participatory_processes/admin/categories_controller"
|
50
|
+
require "decidim/participatory_processes/admin/components_controller"
|
51
|
+
artifact = ::Decidim::ParticipatoryProcesses::Admin::Concerns::ParticipatoryProcessAdmin
|
52
|
+
ParticipatoryProcessesAdminConcernPermissions = Class.new(::Decidim::DepartmentAdmin::Permissions)
|
53
|
+
register_new_permissions_for(artifact, ParticipatoryProcessesAdminConcernPermissions)
|
54
|
+
|
55
|
+
artifact = Decidim::ParticipatoryProcesses::Admin::ApplicationController
|
56
|
+
ParticipatoryProcessesAdminApplicationControllerPermissions = Class.new(::Decidim::DepartmentAdmin::Permissions)
|
57
|
+
register_new_permissions_for(artifact, ParticipatoryProcessesAdminApplicationControllerPermissions)
|
58
|
+
|
59
|
+
# public views produce problems with Devise's current_user
|
60
|
+
# require 'decidim/participatory_processes/application_controller'
|
61
|
+
# artifact= 'Decidim::ParticipatoryProcesses::ApplicationController'
|
62
|
+
# chain= ::Decidim.permissions_registry.chain_for(artifact)
|
63
|
+
# chain << ::Decidim::DepartmentAdmin::Permissions
|
64
|
+
|
65
|
+
# **
|
66
|
+
# Modify decidim-assemblies permissions registry
|
67
|
+
# **
|
68
|
+
require "decidim/assemblies/admin/assembly_copies_controller"
|
69
|
+
require "decidim/assemblies/admin/components_controller"
|
70
|
+
artifact = ::Decidim::Assemblies::Admin::Concerns::AssemblyAdmin
|
71
|
+
AssembliesAdminConcernPermissions = Class.new(::Decidim::DepartmentAdmin::Permissions)
|
72
|
+
register_new_permissions_for(artifact, AssembliesAdminConcernPermissions)
|
73
|
+
|
74
|
+
artifact = Decidim::Assemblies::Admin::ApplicationController
|
75
|
+
AssembliesAdminApplicationControllerPermissions = Class.new(::Decidim::DepartmentAdmin::Permissions)
|
76
|
+
register_new_permissions_for(artifact, AssembliesAdminApplicationControllerPermissions)
|
77
|
+
|
78
|
+
if Decidim::DepartmentAdmin.conferences_defined?
|
79
|
+
# **
|
80
|
+
# Modify decidim-conferences permissions registry
|
81
|
+
# **
|
82
|
+
require "decidim/conferences/admin/conference_copies_controller"
|
83
|
+
require "decidim/conferences/admin/components_controller"
|
84
|
+
artifact = ::Decidim::Conferences::Admin::Concerns::ConferenceAdmin
|
85
|
+
ConferencesAdminConcernPermissions = Class.new(::Decidim::DepartmentAdmin::Permissions)
|
86
|
+
register_new_permissions_for(artifact, ConferencesAdminConcernPermissions)
|
87
|
+
|
88
|
+
artifact = Decidim::Conferences::Admin::ApplicationController
|
89
|
+
ConferencesAdminApplicationControllerPermissions = Class.new(::Decidim::DepartmentAdmin::Permissions)
|
90
|
+
register_new_permissions_for(artifact, ConferencesAdminApplicationControllerPermissions)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
# rubocop: enable Lint/ConstantDefinitionInBlock
|
94
|
+
|
95
|
+
# make decorators available to applications that use this Engine
|
96
|
+
config.to_prepare do
|
97
|
+
decorators = "#{Decidim::DepartmentAdmin::Engine.root}/app/decorators"
|
98
|
+
Dir.glob("#{decorators}/**/*_decorator.rb").each do |decorator|
|
99
|
+
require_dependency(decorator)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
config.after_initialize do
|
104
|
+
require "decidim/participatory_processes/participatory_space"
|
105
|
+
# override participatory_processes space manifest permissions with DepartmentAdmin's one
|
106
|
+
manifest = Decidim.find_participatory_space_manifest(:participatory_processes)
|
107
|
+
manifest.permissions_class_name = "Decidim::ParticipatoryProcesses::ParticipatorySpacePermissions"
|
108
|
+
# override assemblies space manifest permissions with DepartmentAdmin's one
|
109
|
+
manifest = Decidim.find_participatory_space_manifest(:assemblies)
|
110
|
+
manifest.permissions_class_name = "Decidim::Assemblies::ParticipatorySpacePermissions"
|
111
|
+
if Decidim::DepartmentAdmin.conferences_defined?
|
112
|
+
# override conferences space manifest permissions with DepartmentAdmin's one
|
113
|
+
manifest = Decidim.find_participatory_space_manifest(:conferences)
|
114
|
+
manifest.permissions_class_name = "Decidim::Conferences::ParticipatorySpacePermissions"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
#------------------------------------------------------
|
119
|
+
|
120
|
+
private
|
121
|
+
|
122
|
+
#------------------------------------------------------
|
123
|
+
|
124
|
+
# Modifies the permissions registry for the given +artifact+ with +new_permissions_class+.
|
125
|
+
# NOTE: Previous permissions are cleared and setted to the +new_permissions_class+ for delegation.
|
126
|
+
def register_new_permissions_for(artifact, new_permissions_class)
|
127
|
+
chain = ::Decidim.permissions_registry.chain_for(artifact)
|
128
|
+
# configure old chain, in case new permissions has to delegate
|
129
|
+
new_permissions_class.delegate_chain = chain.dup
|
130
|
+
# re-set the permissions classes to DepartmentAdmin::Permissions' subclass
|
131
|
+
chain.clear
|
132
|
+
chain << new_permissions_class
|
133
|
+
Rails.logger.info("Registered new permissions for #{artifact} to: #{::Decidim.permissions_registry.chain_for(artifact)}")
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "decidim/core/test/factories"
|
4
|
+
|
5
|
+
FactoryBot.define do
|
6
|
+
factory :department_admin, parent: :user do
|
7
|
+
roles { ["department_admin"] }
|
8
|
+
admin_terms_accepted_at { Time.zone.now }
|
9
|
+
transient do
|
10
|
+
area { nil }
|
11
|
+
end
|
12
|
+
|
13
|
+
after(:build) do |user, evaluator|
|
14
|
+
user.areas << evaluator.area if evaluator.area.present?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "decidim/department_admin/admin"
|
4
|
+
require "decidim/department_admin/engine"
|
5
|
+
require "decidim/department_admin/admin_engine"
|
6
|
+
|
7
|
+
module Decidim
|
8
|
+
# This namespace holds the logic of the `DepartmentAdmin` module. This module
|
9
|
+
# allows users to create department_admin in a participatory space.
|
10
|
+
module DepartmentAdmin
|
11
|
+
def self.conferences_defined?
|
12
|
+
defined?(Decidim::Conferences::QueryExtensions)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|