decidim-assemblies 0.21.0 → 0.23.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/decidim/assemblies/assembly.svg +1 -3
  3. data/app/assets/javascripts/decidim/assemblies/orgchart.js.es6 +698 -0
  4. data/app/cells/decidim/assemblies/assembly_m/footer.erb +2 -2
  5. data/app/cells/decidim/assemblies/assembly_m_cell.rb +4 -0
  6. data/app/cells/decidim/assemblies/assembly_member/show.erb +4 -4
  7. data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies/show.erb +10 -11
  8. data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb +1 -0
  9. data/app/commands/decidim/assemblies/admin/create_assembly_admin.rb +2 -1
  10. data/app/commands/decidim/assemblies/admin/create_assembly_member.rb +12 -3
  11. data/app/commands/decidim/assemblies/admin/import_assembly.rb +72 -0
  12. data/app/commands/decidim/assemblies/admin/notify_role_assigned_to_assembly.rb +22 -0
  13. data/app/commands/decidim/assemblies/admin/update_assemblies_setting.rb +46 -0
  14. data/app/commands/decidim/assemblies/admin/update_assembly.rb +10 -5
  15. data/app/commands/decidim/assemblies/admin/update_assembly_admin.rb +2 -1
  16. data/app/controllers/decidim/assemblies/admin/assemblies_settings_controller.rb +49 -0
  17. data/app/controllers/decidim/assemblies/admin/assembly_exports_controller.rb +24 -0
  18. data/app/controllers/decidim/assemblies/admin/assembly_imports_controller.rb +31 -0
  19. data/app/controllers/decidim/assemblies/admin/assembly_user_roles_controller.rb +2 -1
  20. data/app/controllers/decidim/assemblies/assemblies_controller.rb +5 -1
  21. data/app/controllers/decidim/assemblies/{assembly_widgets_controller.rb → widgets_controller.rb} +2 -2
  22. data/app/events/decidim/assemblies/create_assembly_member_event.rb +17 -0
  23. data/app/events/decidim/role_assigned_to_assembly_event.rb +28 -0
  24. data/app/forms/decidim/assemblies/admin/assemblies_setting_form.rb +14 -0
  25. data/app/forms/decidim/assemblies/admin/assembly_form.rb +19 -10
  26. data/app/forms/decidim/assemblies/admin/assembly_import_form.rb +83 -0
  27. data/app/forms/decidim/assemblies/admin/assembly_user_role_form.rb +3 -2
  28. data/app/helpers/decidim/assemblies/assemblies_helper.rb +6 -3
  29. data/app/models/decidim/assemblies_setting.rb +17 -0
  30. data/app/models/decidim/assemblies_type.rb +3 -0
  31. data/app/models/decidim/assembly.rb +14 -1
  32. data/app/permissions/decidim/assemblies/permissions.rb +35 -2
  33. data/app/presenters/decidim/assemblies/admin_log/assemblies_setting_presenter.rb +27 -0
  34. data/app/presenters/decidim/assemblies/admin_log/assemblies_type_presenter.rb +2 -2
  35. data/app/presenters/decidim/assemblies/admin_log/assembly_member_presenter.rb +2 -2
  36. data/app/presenters/decidim/assemblies/admin_log/assembly_presenter.rb +2 -2
  37. data/app/presenters/decidim/assemblies/admin_log/assembly_user_role_presenter.rb +2 -2
  38. data/app/presenters/decidim/assemblies/assembly_presenter.rb +29 -0
  39. data/app/presenters/decidim/assemblies/assembly_stats_presenter.rb +1 -1
  40. data/app/queries/decidim/assemblies/parent_assemblies_for_select.rb +20 -1
  41. data/app/serializers/decidim/assemblies/assembly_importer.rb +172 -0
  42. data/app/serializers/decidim/assemblies/assembly_serializer.rb +147 -0
  43. data/app/views/decidim/assemblies/_filter_by_type.html.erb +11 -9
  44. data/app/views/decidim/assemblies/admin/assemblies/index.html.erb +13 -2
  45. data/app/views/decidim/assemblies/admin/assemblies_settings/_form.html.erb +10 -0
  46. data/app/views/decidim/assemblies/admin/assemblies_settings/edit.html.erb +6 -0
  47. data/app/views/decidim/assemblies/admin/assembly_imports/_form.html.erb +46 -0
  48. data/app/views/decidim/assemblies/admin/assembly_imports/new.html.erb +7 -0
  49. data/app/views/decidim/assemblies/admin/assembly_members/index.html.erb +2 -2
  50. data/app/views/decidim/assemblies/assemblies/_parent_assemblies.html.erb +2 -2
  51. data/app/views/decidim/assemblies/assemblies/_promoted_assembly.html.erb +3 -3
  52. data/app/views/decidim/assemblies/assemblies/index.html.erb +11 -8
  53. data/app/views/decidim/assemblies/assemblies/show.html.erb +10 -9
  54. data/app/views/decidim/assemblies/assembly_members/index.html.erb +1 -1
  55. data/app/views/layouts/decidim/admin/assemblies.html.erb +5 -0
  56. data/app/views/layouts/decidim/assembly.html.erb +1 -0
  57. data/config/locales/am-ET.yml +1 -0
  58. data/config/locales/bg-BG.yml +7 -0
  59. data/config/locales/bg.yml +7 -0
  60. data/config/locales/ca.yml +72 -1
  61. data/config/locales/cs.yml +118 -47
  62. data/config/locales/da-DK.yml +1 -0
  63. data/config/locales/da.yml +1 -0
  64. data/config/locales/de.yml +133 -39
  65. data/config/locales/el.yml +474 -0
  66. data/config/locales/en.yml +71 -0
  67. data/config/locales/eo.yml +1 -0
  68. data/config/locales/es-MX.yml +71 -0
  69. data/config/locales/es-PY.yml +71 -0
  70. data/config/locales/es.yml +71 -0
  71. data/config/locales/et-EE.yml +1 -0
  72. data/config/locales/et.yml +1 -0
  73. data/config/locales/fi-plain.yml +72 -1
  74. data/config/locales/fi.yml +79 -8
  75. data/config/locales/fr-CA.yml +481 -0
  76. data/config/locales/fr.yml +93 -1
  77. data/config/locales/ga-IE.yml +1 -0
  78. data/config/locales/gl.yml +37 -16
  79. data/config/locales/hr-HR.yml +1 -0
  80. data/config/locales/hr.yml +1 -0
  81. data/config/locales/hu.yml +53 -2
  82. data/config/locales/is.yml +263 -0
  83. data/config/locales/it.yml +159 -76
  84. data/config/locales/ja-JP.yml +471 -0
  85. data/config/locales/ja.yml +477 -0
  86. data/config/locales/ko-KR.yml +1 -0
  87. data/config/locales/ko.yml +1 -0
  88. data/config/locales/lt-LT.yml +1 -0
  89. data/config/locales/lt.yml +1 -0
  90. data/config/locales/lv.yml +454 -0
  91. data/config/locales/mt-MT.yml +1 -0
  92. data/config/locales/mt.yml +1 -0
  93. data/config/locales/nl.yml +77 -0
  94. data/config/locales/no.yml +79 -10
  95. data/config/locales/om-ET.yml +1 -0
  96. data/config/locales/pl.yml +240 -152
  97. data/config/locales/pt-BR.yml +1 -1
  98. data/config/locales/pt.yml +207 -119
  99. data/config/locales/ro-RO.yml +441 -0
  100. data/config/locales/si-LK.yml +1 -0
  101. data/config/locales/sk-SK.yml +168 -0
  102. data/config/locales/sk.yml +172 -0
  103. data/config/locales/sl.yml +283 -0
  104. data/config/locales/so-SO.yml +1 -0
  105. data/config/locales/sr-CS.yml +73 -0
  106. data/config/locales/sv.yml +178 -89
  107. data/config/locales/sw-KE.yml +1 -0
  108. data/config/locales/ti-ER.yml +1 -0
  109. data/config/locales/tr-TR.yml +237 -144
  110. data/config/locales/vi-VN.yml +1 -0
  111. data/config/locales/vi.yml +1 -0
  112. data/config/locales/zh-CN.yml +471 -0
  113. data/config/locales/zh-TW.yml +1 -0
  114. data/db/migrate/20200320105906_index_foreign_keys_in_decidim_assemblies.rb +7 -0
  115. data/db/migrate/20200320105907_index_foreign_keys_in_decidim_assembly_user_roles.rb +7 -0
  116. data/db/migrate/20200416132109_remove_legacy_decidim_assembly_type.rb +8 -0
  117. data/db/migrate/20200430202456_create_decidim_assemblies_settings.rb +10 -0
  118. data/db/seeds/city.jpeg +0 -0
  119. data/db/seeds/city2.jpeg +0 -0
  120. data/lib/decidim/assemblies/admin_engine.rb +8 -0
  121. data/lib/decidim/assemblies/engine.rb +1 -1
  122. data/lib/decidim/assemblies/participatory_space.rb +26 -13
  123. data/lib/decidim/assemblies/test/factories.rb +8 -3
  124. data/lib/decidim/assemblies/version.rb +1 -1
  125. metadata +74 -14
@@ -2,14 +2,14 @@
2
2
  <div class="card__support">
3
3
  <% if has_assembly_type? %>
4
4
  <div class="card__support__data--left">
5
- <div class="text-uppercase"><%= t("assemblies.show.assembly_type", scope: "decidim") %></div>
5
+ <div><%= t("assemblies.show.assembly_type", scope: "decidim") %></div>
6
6
  <div class="text-ellipsis"><strong><%= assembly_type %></strong></div>
7
7
  </div>
8
8
  <% end %>
9
9
  <%= link_to(
10
10
  t(model.cta_button_text_key, scope: "layouts.decidim.assemblies.assembly"),
11
11
  resource_path,
12
- class: "card__button button button--sc secondary light small"
12
+ class: "card__button button button--sc small"
13
13
  ) %>
14
14
  </div>
15
15
  </div>
@@ -36,6 +36,10 @@ module Decidim
36
36
  [:creation_date, :follow, :children_count]
37
37
  end
38
38
 
39
+ def creation_date_status
40
+ l(model.creation_date, format: :decidim_short) if model.creation_date
41
+ end
42
+
39
43
  def children_count_status
40
44
  content_tag(
41
45
  :strong,
@@ -1,5 +1,5 @@
1
1
  <div class="column">
2
- <article class="card card--member">
2
+ <div class="card card--member">
3
3
  <div class="card__content">
4
4
  <div class="card__header collapse">
5
5
  <div class="author-data author-data--big">
@@ -7,7 +7,7 @@
7
7
  <div class="author author--flex">
8
8
  <% if has_profile? %>
9
9
  <%= link_to profile_url, class: "author__avatar" do %>
10
- <%= image_tag model.avatar_url(:big) %>
10
+ <%= image_tag model.avatar_url(:big), alt: "member-avatar" %>
11
11
  <% end %>
12
12
  <div>
13
13
  <div class="author__name--container">
@@ -24,7 +24,7 @@
24
24
  <% end %>
25
25
  </div>
26
26
  <% else %>
27
- <div class="author__avatar"><%= image_tag asset_path("decidim/default-avatar.svg") %></div>
27
+ <div class="author__avatar"><%= image_tag asset_path("decidim/default-avatar.svg"), alt: "member-avatar" %></div>
28
28
  <div>
29
29
  <div class="author__name--container">
30
30
  <div class="author__name">
@@ -49,5 +49,5 @@
49
49
  <div class="text-small mt-s"><%= personal_information %></div>
50
50
  </div>
51
51
  </div>
52
- </article>
52
+ </div>
53
53
  </div>
@@ -1,4 +1,4 @@
1
- <section class="wrapper-home home-section">
1
+ <section class="wrapper-home home-section" xmlns="http://www.w3.org/1999/xhtml">
2
2
  <div class="row" id="highlighted-assemblies">
3
3
  <h3 class="section-heading"><%= t("active_assemblies", scope: i18n_scope) %></h3>
4
4
  <div class="row collapse">
@@ -6,17 +6,13 @@
6
6
  large-up-4 card-grid">
7
7
  <% highlighted_assemblies.each do |assembly| %>
8
8
  <div class="column">
9
- <article class="card card--assembly card--mini">
10
- <%= link_to decidim_assemblies.assembly_path(assembly), class: "card__link" do %>
11
- <div class="card__image-top"
12
- style="background-image:url(<%= assembly.hero_image.url %>)"></div>
13
- <% end %>
9
+ <%= link_to decidim_assemblies.assembly_path(assembly), class: "card card--assembly card--mini" do %>
10
+ <div aria-hidden="true" class="card__image-top"
11
+ style="background-image:url(<%= assembly.hero_image.url %>)"></div>
14
12
  <div class="card__content">
15
- <%= link_to decidim_assemblies.assembly_path(assembly), class: "card__link" do %>
16
- <h4 class="card__title"><%= translated_attribute assembly.title %></h4>
17
- <% end %>
13
+ <span class="card__title card__link"><%= translated_attribute assembly.title %></span>
18
14
  </div>
19
- </article>
15
+ <% end %>
20
16
  </div>
21
17
  <% end %>
22
18
  </div>
@@ -25,7 +21,10 @@
25
21
  <div class="row" id="see-all-assemblies">
26
22
  <div class="columns small-centered small-12
27
23
  smallmedium-8 medium-6 large-4">
28
- <%= link_to t("see_all_assemblies", scope: i18n_scope), decidim_assemblies.assemblies_path, class: "button expanded hollow button--sc home-section__cta" %>
24
+ <%= link_to t("see_all_assemblies", scope: i18n_scope),
25
+ decidim_assemblies.assemblies_path,
26
+ class: "button expanded hollow button--sc home-section__cta",
27
+ title: t("assemblies_button_title", scope: i18n_scope) %>
29
28
  </div>
30
29
  </div>
31
30
  </section>
@@ -18,6 +18,7 @@ module Decidim
18
18
  @highlighted_assemblies ||= OrganizationPrioritizedAssemblies
19
19
  .new(current_organization, current_user)
20
20
  .query
21
+ .includes([:organization])
21
22
  .limit(max_results)
22
23
  end
23
24
 
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new participatory
7
7
  # process admin in the system.
8
- class CreateAssemblyAdmin < Rectify::Command
8
+ class CreateAssemblyAdmin < NotifyRoleAssignedToAssembly
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -57,6 +57,7 @@ module Decidim
57
57
  assembly: @assembly
58
58
  )
59
59
  end
60
+ send_notification user
60
61
  end
61
62
 
62
63
  def existing_user
@@ -25,9 +25,8 @@ module Decidim
25
25
  def call
26
26
  return broadcast(:invalid) if form.invalid?
27
27
 
28
- transaction do
29
- create_assembly_member!
30
- end
28
+ create_assembly_member!
29
+ notify_assembly_member_about_new_membership
31
30
 
32
31
  broadcast(:ok)
33
32
  end
@@ -67,6 +66,16 @@ module Decidim
67
66
  log_info
68
67
  )
69
68
  end
69
+
70
+ def notify_assembly_member_about_new_membership
71
+ data = {
72
+ event: "decidim.events.assemblies.create_assembly_member",
73
+ event_class: Decidim::Assemblies::CreateAssemblyMemberEvent,
74
+ resource: assembly,
75
+ followers: [form.user]
76
+ }
77
+ Decidim::EventsManager.publish(data)
78
+ end
70
79
  end
71
80
  end
72
81
  end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module Admin
6
+ # A command with all the business logic to import a new assembly
7
+ # in the system.
8
+ class ImportAssembly < Rectify::Command
9
+ # Public: Initializes the command.
10
+ #
11
+ # form - A form object with the params.
12
+ # assembly - An assembly we want to duplicate
13
+ def initialize(form)
14
+ @form = form
15
+ end
16
+
17
+ # Executes the command. Broadcasts these events:
18
+ #
19
+ # - :ok when everything is valid.
20
+ # - :invalid if the form wasn't valid and we couldn't proceed.
21
+ #
22
+ # Returns nothing.
23
+ def call
24
+ return broadcast(:invalid) if form.invalid?
25
+
26
+ transaction do
27
+ import_assembly
28
+ add_admins_as_followers(@imported_assembly)
29
+ end
30
+
31
+ broadcast(:ok, @imported_assembly)
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :form
37
+
38
+ def import_assembly
39
+ importer = Decidim::Assemblies::AssemblyImporter.new(form.current_organization, form.current_user)
40
+ assemblies.each do |original_assembly|
41
+ @imported_assembly = importer.import(original_assembly, form.current_user, title: form.title, slug: form.slug)
42
+ importer.import_assemblies_type(original_assembly["decidim_assemblies_type_id"])
43
+ importer.import_categories(original_assembly["assembly_categories"]) if form.import_categories?
44
+ importer.import_folders_and_attachments(original_assembly["attachments"]) if form.import_attachments?
45
+ importer.import_components(original_assembly["components"]) if form.import_components?
46
+ end
47
+ end
48
+
49
+ def assemblies
50
+ document_parsed(form.document_text)
51
+ end
52
+
53
+ def document_parsed(document_text)
54
+ JSON.parse(document_text)
55
+ end
56
+
57
+ def add_admins_as_followers(assembly)
58
+ assembly.organization.admins.each do |admin|
59
+ form = Decidim::FollowForm
60
+ .from_params(followable_gid: assembly.to_signed_global_id.to_s)
61
+ .with_context(
62
+ current_organization: assembly.organization,
63
+ current_user: admin
64
+ )
65
+
66
+ Decidim::CreateFollow.new(form, admin).call
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module Admin
6
+ # A command to notify users when a role is assigned for an assembly
7
+ class NotifyRoleAssignedToAssembly < Rectify::Command
8
+ def send_notification(user)
9
+ Decidim::EventsManager.publish(
10
+ event: "decidim.events.assembly.role_assigned",
11
+ event_class: Decidim::RoleAssignedToAssemblyEvent,
12
+ resource: form.current_participatory_space,
13
+ affected_users: [user],
14
+ extra: {
15
+ role: form.role
16
+ }
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module Admin
6
+ # A command with all the business logic when updating assemblies
7
+ # settings in admin area.
8
+ class UpdateAssembliesSetting < Rectify::Command
9
+ # Public: Initializes the command.
10
+ #
11
+ # assemblies_setting - A assemblies_setting object to update.
12
+ # form - A form object with the params.
13
+ def initialize(assemblies_settings, form)
14
+ @assemblies_settings = assemblies_settings
15
+ @form = form
16
+ end
17
+
18
+ # Executes the command. Broadcasts these events:
19
+ #
20
+ # - :ok when everything is valid.
21
+ # - :invalid if the form or assemblies_settings isn't valid and we couldn't proceed.
22
+ #
23
+ # Returns nothing.
24
+ def call
25
+ return broadcast(:invalid) if form.invalid? || assemblies_settings.invalid?
26
+
27
+ update_assemblies_setting!
28
+
29
+ broadcast(:ok)
30
+ end
31
+
32
+ private
33
+
34
+ attr_reader :form, :assemblies_settings
35
+
36
+ def update_assemblies_setting!
37
+ Decidim.traceability.update!(
38
+ @assemblies_settings,
39
+ form.current_user,
40
+ enable_organization_chart: form.enable_organization_chart
41
+ )
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -62,10 +62,6 @@ module Decidim
62
62
  subtitle: form.subtitle,
63
63
  slug: form.slug,
64
64
  hashtag: form.hashtag,
65
- hero_image: form.hero_image,
66
- remove_hero_image: form.remove_hero_image,
67
- banner_image: form.banner_image,
68
- remove_banner_image: form.remove_banner_image,
69
65
  promoted: form.promoted,
70
66
  description: form.description,
71
67
  short_description: form.short_description,
@@ -99,7 +95,16 @@ module Decidim
99
95
  instagram_handler: form.instagram_handler,
100
96
  youtube_handler: form.youtube_handler,
101
97
  github_handler: form.github_handler
102
- }
98
+ }.merge(uploader_attributes)
99
+ end
100
+
101
+ def uploader_attributes
102
+ {
103
+ hero_image: form.hero_image,
104
+ remove_hero_image: form.remove_hero_image,
105
+ banner_image: form.banner_image,
106
+ remove_banner_image: form.remove_banner_image
107
+ }.delete_if { |_k, val| val.is_a?(Decidim::ApplicationUploader) }
103
108
  end
104
109
 
105
110
  def participatory_processes(assembly)
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when updated a participatory
7
7
  # process admin in the system.
8
- class UpdateAssemblyAdmin < Rectify::Command
8
+ class UpdateAssemblyAdmin < NotifyRoleAssignedToAssembly
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -45,6 +45,7 @@ module Decidim
45
45
  { role: form.role },
46
46
  log_info
47
47
  )
48
+ send_notification user_role.user
48
49
  end
49
50
  end
50
51
  end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module Admin
6
+ # Controller used to manage the assemblies settings for the current
7
+ # organization.
8
+ class AssembliesSettingsController < Decidim::Assemblies::Admin::ApplicationController
9
+ layout "decidim/admin/assemblies"
10
+
11
+ # GET /admin/assemblies_settings/edit
12
+ def edit
13
+ enforce_permission_to :edit, :assemblies_setting, assemblies_settings: current_assemblies_settings
14
+ @form = assemblies_settings_form.from_model(current_assemblies_settings)
15
+ end
16
+
17
+ # PUT /admin/assemblies_settings/:id
18
+ def update
19
+ enforce_permission_to :update, :assemblies_setting, assemblies_settings: current_assemblies_settings
20
+
21
+ @form = assemblies_settings_form
22
+ .from_params(params, assemblies_settings: current_assemblies_settings)
23
+
24
+ UpdateAssembliesSetting.call(current_assemblies_settings, @form) do
25
+ on(:ok) do
26
+ flash[:notice] = I18n.t("assemblies_settings.update.success", scope: "decidim.admin")
27
+ redirect_to edit_assemblies_settings_path
28
+ end
29
+
30
+ on(:invalid) do
31
+ flash.now[:alert] = I18n.t("assemblies_settings.update.error", scope: "decidim.admin")
32
+ render :edit
33
+ end
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def current_assemblies_settings
40
+ @current_assemblies_settings ||= Decidim::AssembliesSetting.find_or_create_by!(decidim_organization_id: current_organization.id)
41
+ end
42
+
43
+ def assemblies_settings_form
44
+ form(Decidim::Assemblies::Admin::AssembliesSettingForm)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module Admin
6
+ class AssemblyExportsController < Decidim::Admin::ApplicationController
7
+ include Concerns::AssemblyAdmin
8
+ include Decidim::Admin::ParticipatorySpaceExport
9
+
10
+ def exportable_space
11
+ current_assembly
12
+ end
13
+
14
+ def manifest_name
15
+ current_assembly.manifest.name.to_s
16
+ end
17
+
18
+ def after_export_path
19
+ assembly_path(current_assembly.slug)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module Admin
6
+ class AssemblyImportsController < Decidim::Assemblies::Admin::ApplicationController
7
+ def new
8
+ enforce_permission_to :import, :assembly
9
+ @form = form(AssemblyImportForm).instance
10
+ end
11
+
12
+ def create
13
+ enforce_permission_to :import, :assembly
14
+ @form = form(AssemblyImportForm).from_params(params)
15
+
16
+ ImportAssembly.call(@form) do
17
+ on(:ok) do
18
+ flash[:notice] = I18n.t("assembly_imports.create.success", scope: "decidim.admin")
19
+ redirect_to assemblies_path
20
+ end
21
+
22
+ on(:invalid) do
23
+ flash.now[:alert] = I18n.t("assembly_imports.create.error", scope: "decidim.admin")
24
+ render :new
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end