decidim-centers 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE-AGPLv3.txt +661 -0
  3. data/README.md +144 -0
  4. data/Rakefile +40 -0
  5. data/app/commands/concerns/decidim/centers/create_omniauth_registration_override.rb +42 -0
  6. data/app/commands/concerns/decidim/centers/create_registration_override.rb +32 -0
  7. data/app/commands/concerns/decidim/centers/publish_center_update_event.rb +20 -0
  8. data/app/commands/concerns/decidim/centers/update_account_override.rb +35 -0
  9. data/app/commands/decidim/centers/admin/create_center.rb +50 -0
  10. data/app/commands/decidim/centers/admin/destroy_center.rb +47 -0
  11. data/app/commands/decidim/centers/admin/update_center.rb +47 -0
  12. data/app/commands/decidim/centers/create_or_update_center_user.rb +44 -0
  13. data/app/commands/decidim/centers/create_or_update_scope_user.rb +44 -0
  14. data/app/controllers/concerns/decidim/centers/admin/needs_select2_snippets.rb +35 -0
  15. data/app/controllers/concerns/decidim/centers/devise/omniauth_registrations_controller_override.rb +21 -0
  16. data/app/controllers/concerns/decidim/centers/devise/sessions_controller_override.rb +21 -0
  17. data/app/controllers/concerns/decidim/centers/with_scopes_helper.rb +15 -0
  18. data/app/controllers/decidim/centers/admin/application_controller.rb +24 -0
  19. data/app/controllers/decidim/centers/admin/centers_controller.rb +106 -0
  20. data/app/controllers/decidim/centers/admin/scopes_controller.rb +40 -0
  21. data/app/forms/concerns/decidim/centers/account_form_override.rb +36 -0
  22. data/app/forms/decidim/centers/admin/center_form.rb +18 -0
  23. data/app/forms/decidim/centers/verifications/center.rb +33 -0
  24. data/app/helpers/decidim/centers/application_helper.rb +17 -0
  25. data/app/jobs/decidim/centers/auto_verification_job.rb +46 -0
  26. data/app/jobs/decidim/centers/sync_center_user_job.rb +29 -0
  27. data/app/jobs/decidim/centers/sync_scope_user_job.rb +29 -0
  28. data/app/models/concerns/decidim/centers/unique_by_user.rb +19 -0
  29. data/app/models/concerns/decidim/centers/user_override.rb +33 -0
  30. data/app/models/decidim/centers/application_record.rb +10 -0
  31. data/app/models/decidim/centers/center.rb +25 -0
  32. data/app/models/decidim/centers/center_user.rb +28 -0
  33. data/app/models/decidim/centers/scope_user.rb +28 -0
  34. data/app/overrides/decidim/account/show/centers.html.erb.deface +3 -0
  35. data/app/overrides/decidim/devise/omniauth_registrations/new/centers.html.erb.deface +3 -0
  36. data/app/overrides/decidim/devise/registrations/new/centers.html.erb.deface +3 -0
  37. data/app/packs/entrypoints/decidim_centers_admin_select2.js +2 -0
  38. data/app/packs/src/decidim/centers/admin/resource_permissions_select2.js +68 -0
  39. data/app/packs/stylesheets/vendor/select2_foundation_theme.scss +345 -0
  40. data/app/permissions/decidim/centers/admin/permissions.rb +19 -0
  41. data/app/presenters/decidim/centers/admin_log/center_presenter.rb +29 -0
  42. data/app/views/decidim/centers/_profile_form.html.erb +5 -0
  43. data/app/views/decidim/centers/_registration_form.html.erb +11 -0
  44. data/app/views/decidim/centers/admin/centers/_form.html.erb +10 -0
  45. data/app/views/decidim/centers/admin/centers/edit.html.erb +8 -0
  46. data/app/views/decidim/centers/admin/centers/index.html.erb +45 -0
  47. data/app/views/decidim/centers/admin/centers/new.html.erb +8 -0
  48. data/config/assets.rb +8 -0
  49. data/config/i18n-tasks.yml +11 -0
  50. data/config/locales/en.yml +51 -0
  51. data/db/migrate/20231129114029_create_decidim_centers_centers.rb +13 -0
  52. data/db/migrate/20231130125631_create_decidim_centers_center_users.rb +12 -0
  53. data/db/migrate/20231205153627_create_decidim_centers_scope_users.rb +12 -0
  54. data/lib/decidim/centers/admin.rb +10 -0
  55. data/lib/decidim/centers/admin_engine.rb +40 -0
  56. data/lib/decidim/centers/engine.rb +79 -0
  57. data/lib/decidim/centers/test/factories.rb +25 -0
  58. data/lib/decidim/centers/test/shared_contexts.rb +22 -0
  59. data/lib/decidim/centers/verifications/center_action_authorizer.rb +49 -0
  60. data/lib/decidim/centers/verifications.rb +11 -0
  61. data/lib/decidim/centers/version.rb +10 -0
  62. data/lib/decidim/centers.rb +19 -0
  63. metadata +138 -0
@@ -0,0 +1,345 @@
1
+ span.select2-container--foundation {
2
+ vertical-align: top;
3
+ }
4
+
5
+ span.select2-container--foundation .selection {
6
+ margin: 0 0 1rem;
7
+ }
8
+
9
+ .select2-container--foundation {
10
+ /**
11
+ * Search field in the Select2 dropdown.
12
+ */
13
+
14
+ /**
15
+ * No outline for all search fields - in the dropdown
16
+ * and inline in multi Select2s.
17
+ */
18
+
19
+ /* Clear the selection. */
20
+
21
+ /**
22
+ * Address disabled Select2 styles.
23
+ *
24
+ * @see https://select2.github.io/examples.html#disabled
25
+ * @see http://getbootstrap.com/css/#forms-control-disabled
26
+ */
27
+
28
+ /* ------------------------------------*\
29
+ #DROPDOWN
30
+ \*------------------------------------ */
31
+ }
32
+
33
+ .select2-container--foundation .select2-selection {
34
+ background-color: #fefefe;
35
+ border: 1px solid #cacaca;
36
+ border-radius: 0;
37
+ color: #0a0a0a;
38
+ font-family: inherit;
39
+ font-size: 1rem;
40
+ outline: 0;
41
+ }
42
+
43
+ .select2-container--foundation .select2-search--dropdown .select2-search__field {
44
+ background-color: #fefefe;
45
+ border: 1px solid #cacaca;
46
+ border-radius: 0;
47
+ color: #0a0a0a;
48
+ font-family: inherit;
49
+ font-size: 1rem;
50
+ }
51
+
52
+ .select2-container--foundation .select2-search__field {
53
+ outline: 0;
54
+
55
+ /* Firefox 18- */
56
+
57
+ /**
58
+ * Firefox 19+
59
+ *
60
+ * @see http://stackoverflow.com/questions/24236240/color-for-styled-placeholder-text-is-muted-in-firefox
61
+ */
62
+ }
63
+
64
+ .select2-container--foundation .select2-search__field::-webkit-input-placeholder {
65
+ color: #8a8a8a;
66
+ }
67
+
68
+ .select2-container--foundation .select2-search__field:-moz-placeholder {
69
+ color: #8a8a8a;
70
+ }
71
+
72
+ .select2-container--foundation .select2-search__field::-moz-placeholder {
73
+ color: #8a8a8a;
74
+ opacity: 1;
75
+ }
76
+
77
+ .select2-container--foundation .select2-search__field:-ms-input-placeholder {
78
+ color: #8a8a8a;
79
+ }
80
+
81
+ .select2-container--foundation .select2-results__option {
82
+ /**
83
+ * Disabled results.
84
+ *
85
+ * @see https://select2.github.io/examples.html#disabled-results
86
+ */
87
+
88
+ /**
89
+ * Hover state.
90
+ */
91
+
92
+ /**
93
+ * Selected state.
94
+ */
95
+ }
96
+
97
+ .select2-container--foundation .select2-results__option[role=group] {
98
+ padding: 0;
99
+ }
100
+
101
+ .select2-container--foundation .select2-results__option[role=group] strong {
102
+ padding-left: .125rem;
103
+ }
104
+
105
+ .select2-container--foundation .select2-results__option[aria-disabled=true] {
106
+ color: #8a8a8a;
107
+ cursor: default;
108
+ }
109
+
110
+ .select2-container--foundation .select2-results__option--highlighted[aria-selected] {
111
+ background-color: #2199e8;
112
+ color: foreground(#2199e8);
113
+ }
114
+
115
+ .select2-container--foundation.select2-container--focus .select2-selection {
116
+ border: 1px solid #8a8a8a;
117
+ }
118
+
119
+ .select2-container--foundation.select2-container--open .select2-selection {
120
+ border: 1px solid #8a8a8a;
121
+ border-radius: 0;
122
+ }
123
+
124
+ .select2-container--foundation.select2-container--open {
125
+ /**
126
+ * Make the dropdown arrow point up while the dropdown is visible.
127
+ */
128
+ }
129
+
130
+ .select2-container--foundation.select2-container--open .select2-selection__arrow b {
131
+ transform: rotate(180deg);
132
+ }
133
+
134
+ .select2-container--foundation .select2-choice {
135
+ box-shadow: none;
136
+ background-image: none;
137
+ }
138
+
139
+ .select2-container--foundation .select2-choice div {
140
+ background-clip: padding-box;
141
+ }
142
+
143
+ .select2-container--foundation .select2-choice .select2-arrow {
144
+ border: 0;
145
+ border-radius: 0;
146
+ background: transparent;
147
+ background-image: none;
148
+ }
149
+
150
+ .select2-container--foundation *:focus {
151
+ outline: 0;
152
+ }
153
+
154
+ .select2-container--foundation .select2-selection__clear {
155
+ color: #8a8a8a;
156
+ cursor: pointer;
157
+ float: left;
158
+ font-weight: bold;
159
+ margin-right: 0;
160
+ }
161
+
162
+ .select2-container--foundation .select2-selection__clear:hover {
163
+ color: #333;
164
+ }
165
+
166
+ .select2-container--foundation.select2-container--disabled .select2-selection {
167
+ border: 1px solid #cacaca;
168
+ }
169
+
170
+ .select2-container--foundation.select2-container--disabled .select2-selection,
171
+ .select2-container--foundation.select2-container--disabled .select2-search__field {
172
+ cursor: default;
173
+ }
174
+
175
+ .select2-container--foundation.select2-container--disabled .select2-selection,
176
+ .select2-container--foundation.select2-container--disabled .select2-selection--multiple .select2-selection__choice {
177
+ background-color: #e6e6e6;
178
+ color: foreground(#e6e6e6);
179
+ }
180
+
181
+ .select2-container--foundation.select2-container--disabled .select2-selection__clear,
182
+ .select2-container--foundation.select2-container--disabled .select2-selection--multiple .select2-selection__choice__remove {
183
+ display: none;
184
+ }
185
+
186
+ .select2-container--foundation .select2-dropdown {
187
+ border: 1px solid #8a8a8a;
188
+ border-top: 1px solid #cacaca;
189
+ background: #fefefe;
190
+ border-radius: 0;
191
+ overflow-x: hidden;
192
+ margin-top: -.0625rem;
193
+ }
194
+
195
+ .select2-container--foundation .select2-dropdown--above {
196
+ margin-top: .0625rem;
197
+ border-radius: 0;
198
+ border-top: 1px solid #8a8a8a;
199
+ border-bottom: 1px solid #cacaca;
200
+ }
201
+
202
+ .select2-container--foundation .select2-results > .select2-results__options {
203
+ /* Limit the dropdown height. */
204
+ max-height: 200px;
205
+ overflow-y: auto;
206
+ }
207
+
208
+ /**
209
+ * Temporary fix for https://github.com/select2/select2-bootstrap-theme/issues/9
210
+ *
211
+ * Provides `!important` for certain properties of the class applied to the
212
+ * original `<select>` element to hide it.
213
+ *
214
+ * @see https://github.com/select2/select2/pull/3301
215
+ * @see https://github.com/fk/select2/commit/31830c7b32cb3d8e1b12d5b434dee40a6e753ada
216
+ */
217
+ .form-control.select2-hidden-accessible {
218
+ position: absolute !important;
219
+ width: 1px !important;
220
+ }
221
+
222
+ /**
223
+ * Display override for inline forms
224
+ */
225
+ .input-group span.select2-container--foundation {
226
+ margin: 0;
227
+ vertical-align: middle;
228
+ }
229
+
230
+ .input-group span.select2-container--foundation .selection .select2-selection {
231
+ vertical-align: middle;
232
+ border-radius: 0;
233
+ }
234
+
235
+ /****** Single SCSS *******/
236
+ .select2-container--foundation .select2-selection--single,
237
+ .select2-container--foundation .selection .select2-selection--single {
238
+ height: 2.4375rem;
239
+ line-height: 1.5;
240
+ padding: .5rem;
241
+ }
242
+
243
+ .select2-container--foundation .select2-selection--single .select2-selection__rendered,
244
+ .select2-container--foundation .selection .select2-selection--single .select2-selection__rendered {
245
+ color: #0a0a0a;
246
+ }
247
+
248
+ .select2-container--foundation .select2-selection--single .select2-selection__arrow,
249
+ .select2-container--foundation .selection .select2-selection--single .select2-selection__arrow {
250
+ height: 2.4375rem;
251
+ position: absolute;
252
+ top: 0;
253
+ right: 1px;
254
+ width: 20px;
255
+ }
256
+
257
+ .select2-container--foundation .select2-selection--single .select2-selection__arrow b,
258
+ .select2-container--foundation .selection .select2-selection--single .select2-selection__arrow b {
259
+ border-color: #333 transparent transparent;
260
+ top: 50%;
261
+ border-style: solid;
262
+ border-width: 6px 4px 0;
263
+ height: 0;
264
+ left: 50%;
265
+ margin-left: -4px;
266
+ margin-top: -2px;
267
+ position: absolute;
268
+ width: 0;
269
+ }
270
+
271
+ .select2-container--foundation .select2-selection--single .select2-selection__placeholder,
272
+ .select2-container--foundation .selection .select2-selection--single .select2-selection__placeholder {
273
+ color: #8a8a8a;
274
+ }
275
+
276
+ .select2-container--foundation .select2-selection--single .select2-selection__clear,
277
+ .select2-container--foundation .selection .select2-selection--single .select2-selection__clear {
278
+ cursor: pointer;
279
+ float: right;
280
+ font-weight: bold;
281
+ }
282
+
283
+ /****** Multiple SCSS *******/
284
+ .select2-container--foundation .select2-selection--multiple {
285
+ /* Clear the selection. */
286
+ }
287
+
288
+ .select2-container--foundation .select2-selection--multiple .select2-selection__choice__remove:hover {
289
+ cursor: pointer;
290
+ }
291
+
292
+ .select2-container--foundation .select2-selection--multiple ul.select2-selection__rendered,
293
+ .select2-container--foundation .select2-selection--multiple .select2-selection__rendered {
294
+ display: inherit;
295
+ box-sizing: border-box;
296
+ list-style: none;
297
+ margin: 0;
298
+ padding: 0 5px;
299
+ width: 100%;
300
+ }
301
+
302
+ .select2-container--foundation .select2-selection--multiple .select2-selection__choice {
303
+ border-radius: 0;
304
+ padding: .1875rem .3125rem;
305
+ cursor: default;
306
+ float: left;
307
+ margin-right: .3125rem;
308
+ margin-top: .125rem;
309
+ margin-bottom: .125rem;
310
+ border: 1px solid #8a8a8a;
311
+ }
312
+
313
+ .select2-container--foundation .select2-selection--multiple .select2-selection__choice__remove {
314
+ margin-right: 6px;
315
+ margin-left: 6px;
316
+ float: right;
317
+ }
318
+
319
+ .select2-container--foundation .select2-selection--multiple .select2-search--inline .select2-search__field {
320
+ background: transparent;
321
+ line-height: 1.5;
322
+ border: 0;
323
+ margin-top: 0;
324
+ min-width: 5rem;
325
+ height: 2.375rem;
326
+ box-shadow: none;
327
+ margin-right: -2rem;
328
+ }
329
+
330
+ .select2-container--foundation .select2-selection--multiple .select2-selection__choice__remove {
331
+ color: #8a8a8a;
332
+ cursor: pointer;
333
+ display: inline-block;
334
+ font-weight: bold;
335
+ margin-right: .25rem;
336
+ }
337
+
338
+ .select2-container--foundation .select2-selection--multiple .select2-selection__choice__remove:hover {
339
+ color: #333;
340
+ }
341
+
342
+ .select2-container--foundation .select2-selection--multiple .select2-selection__clear {
343
+ margin-right: .1875rem;
344
+ margin-top: .5rem;
345
+ }
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Centers
5
+ module Admin
6
+ class Permissions < Decidim::DefaultPermissions
7
+ def permissions
8
+ return permission_action unless user
9
+ return permission_action unless user.admin?
10
+ return permission_action unless permission_action.scope == :admin
11
+ return permission_action unless permission_action.subject == :center
12
+
13
+ allow!
14
+ permission_action
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Centers
5
+ module AdminLog
6
+ # This class holds the logic to present a `Decidim::Centers::Center`
7
+ # for the `AdminLog` log.
8
+ #
9
+ # Usage should be automatic and you shouldn't need to call this class
10
+ # directly, but here's an example:
11
+ #
12
+ # action_log = Decidim::ActionLog.last
13
+ # view_helpers # => this comes from the views
14
+ # CenterPresenter.new(action_log, view_helpers).present
15
+ class CenterPresenter < Decidim::Log::BasePresenter
16
+ private
17
+
18
+ def action_string
19
+ case action
20
+ when "create", "delete", "update"
21
+ "decidim.centers.admin_log.center.#{action}"
22
+ else
23
+ super
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,5 @@
1
+ <%= f.collection_select :center_id, f.object.center_options_for_select, :first, :last %>
2
+
3
+ <% if Decidim::Centers.scopes_enabled %>
4
+ <%= scopes_picker_field f, :scope_id, root: nil %>
5
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <div class="card">
2
+ <div class="card__content card__centers">
3
+ <div class="field">
4
+ <%= f.collection_select :center_id, f.object.center_options_for_select, :first, :last %>
5
+
6
+ <% if Decidim::Centers.scopes_enabled %>
7
+ <%= scopes_picker_field f, :scope_id, root: nil %>
8
+ <% end %>
9
+ </div>
10
+ </div>
11
+ </div>
@@ -0,0 +1,10 @@
1
+ <div class="card">
2
+ <div class="card-divider">
3
+ <h2 class="card-title"><%= title %></h2>
4
+ </div>
5
+ <div class="card-section">
6
+ <div class="row column">
7
+ <%= form.translated :text_field, :title, autofocus: true %>
8
+ </div>
9
+ </div>
10
+ </div>
@@ -0,0 +1,8 @@
1
+ <% add_decidim_page_title(t(".title")) %>
2
+ <%= decidim_form_for(@form, html: { class: "form edit_center" }) do |f| %>
3
+ <%= render partial: "form", object: f, locals: { title: t(".title") } %>
4
+
5
+ <div class="button--double form-general-submit">
6
+ <%= f.submit t(".save") %>
7
+ </div>
8
+ <% end %>
@@ -0,0 +1,45 @@
1
+ <% add_decidim_page_title(t(".title")) %>
2
+ <div class="card">
3
+ <div class="card-divider">
4
+ <h2 class="card-title">
5
+ <%= t(".title") %>
6
+ <%= link_to t("actions.new", scope: "decidim.centers", name: t("models.center.name", scope: "decidim.centers.admin")), new_center_path, class: "button tiny button--title" if allowed_to? :create, :center %>
7
+ </h2>
8
+ </div>
9
+
10
+ <div class="card-section">
11
+ <div class="table-scroll">
12
+ <table class="table-list centers">
13
+ <thead>
14
+ <tr>
15
+ <th><%= t("models.center.fields.title", scope: "decidim.centers") %></th>
16
+ <th><%= t("models.center.fields.created_at", scope: "decidim.centers") %></th>
17
+ <th class="actions"><%= t("actions.title", scope: "decidim.centers") %></th>
18
+ </tr>
19
+ </thead>
20
+ <tbody>
21
+ <% centers.each do |center| %>
22
+ <tr data-id="<%= center.id %>">
23
+ <td>
24
+ <%= translated_attribute(center.title) %><br>
25
+ </td>
26
+ <td>
27
+ <%= l center.created_at, format: "%d/%m/%Y - %H:%M" %>
28
+ </td>
29
+ <td class="table-list__actions">
30
+ <% if allowed_to? :update, :center, center: center %>
31
+ <%= icon_link_to "pencil", edit_center_path(center), t("actions.edit", scope: "decidim.centers"), class: "action-icon--edit" %>
32
+ <% end %>
33
+
34
+ <% if allowed_to? :destroy, :center, center: center %>
35
+ <%= icon_link_to "circle-x", center_path(center), t("actions.destroy", scope: "decidim.centers"), method: :delete, class: "action-icon--remove", data: { confirm: t("actions.confirm_destroy", scope: "decidim.centers") } %>
36
+ <% end %>
37
+ </td>
38
+ </tr>
39
+ <% end %>
40
+ </tbody>
41
+ </table>
42
+ <%= paginate centers, theme: "decidim" %>
43
+ </div>
44
+ </div>
45
+ </div>
@@ -0,0 +1,8 @@
1
+ <% add_decidim_page_title(t(".title")) %>
2
+ <%= decidim_form_for(@form, html: { class: "form new_center" }) do |f| %>
3
+ <%= render partial: "form", object: f, locals: { title: t(".title") } %>
4
+
5
+ <div class="button--double form-general-submit">
6
+ <%= f.submit t(".create") %>
7
+ </div>
8
+ <% end %>
data/config/assets.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ base_path = File.expand_path("..", __dir__)
4
+
5
+ Decidim::Webpacker.register_path("#{base_path}/app/packs")
6
+ Decidim::Webpacker.register_entrypoints(
7
+ decidim_centers_admin_select2: "#{base_path}/app/packs/entrypoints/decidim_centers_admin_select2.js"
8
+ )
@@ -0,0 +1,11 @@
1
+ ---
2
+
3
+ base_locale: en
4
+ locales: [en]
5
+
6
+ ignore_missing:
7
+ - decidim.participatory_processes.scopes.global
8
+
9
+ ignore_unused:
10
+ - decidim.centers.admin_log.*
11
+ - decidim.authorization_handlers.*
@@ -0,0 +1,51 @@
1
+ ---
2
+ en:
3
+ decidim:
4
+ authorization_handlers:
5
+ center:
6
+ explanation: Get verified with the center of the user
7
+ fields:
8
+ centers: Centers
9
+ scopes: Scopes
10
+ name: Center
11
+ centers:
12
+ actions:
13
+ confirm_destroy: Are you sure you want to delete this center?
14
+ destroy: Delete
15
+ edit: Edit
16
+ new: New center
17
+ title: Actions
18
+ admin:
19
+ centers:
20
+ create:
21
+ invalid: There was a problem creating this center
22
+ success: Center successfully created
23
+ destroy:
24
+ success: Center successfully deleted
25
+ edit:
26
+ save: Update
27
+ title: Edit center
28
+ index:
29
+ title: Centers
30
+ new:
31
+ create: Create
32
+ title: Create center
33
+ update:
34
+ invalid: There was a problem saving the center.
35
+ success: Center successfully saved
36
+ models:
37
+ center:
38
+ name: Center
39
+ admin_log:
40
+ center:
41
+ create: "%{user_name} created the %{resource_name} center"
42
+ delete: "%{user_name} deleted the %{resource_name} center"
43
+ update: "%{user_name} updated the %{resource_name} center"
44
+ authorizations:
45
+ new:
46
+ error: The user has no center or scope configured
47
+ models:
48
+ center:
49
+ fields:
50
+ created_at: Created at
51
+ title: Title
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimCentersCenters < ActiveRecord::Migration[6.1]
4
+ def change
5
+ create_table :decidim_centers_centers do |t|
6
+ t.references :decidim_organization, foreign_key: true, index: true
7
+ t.jsonb :title, null: false
8
+ t.datetime :deleted_at
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimCentersCenterUsers < ActiveRecord::Migration[6.1]
4
+ def change
5
+ create_table :decidim_centers_center_users do |t|
6
+ t.references :decidim_centers_center, foreign_key: true, index: { name: "index_decidim_center_users_on_decidim_center_id" }
7
+ t.references :decidim_user, foreign_key: true, index: { name: "index_decidim_center_users_on_decidim_user_id" }
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimCentersScopeUsers < ActiveRecord::Migration[6.1]
4
+ def change
5
+ create_table :decidim_centers_scope_users do |t|
6
+ t.references :decidim_scope, foreign_key: true, index: { name: "index_decidim_scope_users_on_decidim_scope_id" }
7
+ t.references :decidim_user, foreign_key: true, index: { name: "index_decidim_scope_users_on_decidim_user_id" }
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Centers
5
+ # This module contains all the domain logic associated to Decidim's Centers
6
+ # admin panel.
7
+ module Admin
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Centers
5
+ # This is the engine that runs on the public interface of `Centers`.
6
+ class AdminEngine < ::Rails::Engine
7
+ isolate_namespace Decidim::Centers::Admin
8
+
9
+ paths["db/migrate"] = nil
10
+ paths["lib/tasks"] = nil
11
+
12
+ routes do
13
+ resources :centers
14
+ resources :scopes, only: :index
15
+ root to: "centers#index"
16
+ end
17
+
18
+ initializer "decidim_centers.admin_mount_routes" do
19
+ Decidim::Core::Engine.routes do
20
+ mount Decidim::Centers::AdminEngine, at: "/admin/centers", as: "decidim_admin_centers"
21
+ end
22
+ end
23
+
24
+ initializer "decidim_centers.admin_menu" do
25
+ Decidim.menu :admin_menu do |menu|
26
+ menu.add_item :centers,
27
+ I18n.t("menu.centers", scope: "decidim.admin", default: "Centers"),
28
+ decidim_admin_centers.centers_path,
29
+ icon_name: "home",
30
+ position: 15,
31
+ active: :inclusive
32
+ end
33
+ end
34
+
35
+ def load_seed
36
+ nil
37
+ end
38
+ end
39
+ end
40
+ end