decidim-conferences 0.15.1 → 0.16.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.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/admin/decidim_conferences_manifest.js +1 -0
  3. data/app/assets/images/decidim/conferences/conference.svg +2 -5
  4. data/app/cells/decidim/conferences/linked_participatory_spaces_cell.rb +3 -0
  5. data/app/cells/decidim/conferences/{join_conference_button/show.erb → registration_type/join_conference.erb} +6 -7
  6. data/app/cells/decidim/conferences/{join_conference_button → registration_type}/registration_confirm.erb +2 -2
  7. data/app/cells/decidim/conferences/registration_type/show.erb +16 -0
  8. data/app/cells/decidim/conferences/registration_type_cell.rb +51 -0
  9. data/app/commands/decidim/conferences/admin/confirm_conference_registration.rb +75 -0
  10. data/app/commands/decidim/conferences/admin/create_conference.rb +1 -1
  11. data/app/commands/decidim/conferences/admin/create_registration_type.rb +77 -0
  12. data/app/commands/decidim/conferences/admin/destroy_registration_type.rb +56 -0
  13. data/app/commands/decidim/conferences/admin/invite_user_to_join_conference.rb +3 -2
  14. data/app/commands/decidim/conferences/admin/publish_registration_type.rb +36 -0
  15. data/app/commands/decidim/conferences/admin/send_conference_diplomas.rb +48 -0
  16. data/app/commands/decidim/conferences/admin/unpublish_registration_type.rb +36 -0
  17. data/app/commands/decidim/conferences/admin/update_conference.rb +2 -2
  18. data/app/commands/decidim/conferences/admin/update_diploma.rb +47 -0
  19. data/app/commands/decidim/conferences/admin/update_partner.rb +1 -1
  20. data/app/commands/decidim/conferences/admin/update_registration_type.rb +74 -0
  21. data/app/commands/decidim/conferences/join_conference.rb +21 -9
  22. data/app/commands/decidim/conferences/leave_conference.rb +5 -3
  23. data/app/controllers/decidim/conferences/admin/conference_registrations_controller.rb +21 -0
  24. data/app/controllers/decidim/conferences/admin/conferences_controller.rb +0 -9
  25. data/app/controllers/decidim/conferences/admin/diplomas_controller.rb +62 -0
  26. data/app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb +53 -0
  27. data/app/controllers/decidim/conferences/admin/registration_types_controller.rb +84 -0
  28. data/app/controllers/decidim/conferences/application_controller.rb +2 -0
  29. data/app/controllers/decidim/conferences/conference_registrations_controller.rb +6 -2
  30. data/app/controllers/decidim/conferences/conferences_controller.rb +4 -0
  31. data/app/controllers/decidim/conferences/registration_types_controller.rb +39 -0
  32. data/app/events/decidim/conferences/conference_registration_notification_event.rb +21 -0
  33. data/app/forms/decidim/conferences/admin/conference_form.rb +5 -2
  34. data/app/forms/decidim/conferences/admin/conference_registration_invite_form.rb +15 -0
  35. data/app/forms/decidim/conferences/admin/diploma_form.rb +24 -0
  36. data/app/forms/decidim/conferences/admin/registration_type_form.rb +44 -0
  37. data/app/helpers/decidim/conferences/conference_helper.rb +15 -0
  38. data/app/jobs/decidim/conferences/admin/send_conference_diploma_job.rb +20 -0
  39. data/app/jobs/decidim/conferences/upcoming_conference_notification_job.rb +1 -1
  40. data/app/mailers/decidim/conferences/admin/invite_join_conference_mailer.rb +2 -1
  41. data/app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb +48 -0
  42. data/app/mailers/decidim/conferences/conference_registration_mailer.rb +16 -1
  43. data/app/models/decidim/conference.rb +12 -0
  44. data/app/models/decidim/conference_meeting.rb +2 -0
  45. data/app/models/decidim/conferences/conference_invite.rb +1 -0
  46. data/app/models/decidim/conferences/conference_meeting_registration_type.rb +10 -0
  47. data/app/models/decidim/conferences/conference_registration.rb +11 -0
  48. data/app/models/decidim/conferences/registration_type.rb +25 -0
  49. data/app/permissions/decidim/conferences/permissions.rb +19 -12
  50. data/app/presenters/decidim/conference_speaker_presenter.rb +4 -0
  51. data/app/presenters/decidim/conferences/admin_log/conference_registration_presenter.rb +43 -0
  52. data/app/presenters/decidim/conferences/admin_log/conferences_presenter.rb +4 -2
  53. data/app/presenters/decidim/conferences/admin_log/partner_presenter.rb +1 -1
  54. data/app/presenters/decidim/conferences/admin_log/registration_type_presenter.rb +45 -0
  55. data/app/serializers/decidim/conferences/conference_registration_serializer.rb +4 -0
  56. data/app/serializers/decidim/conferences/data_portability_conference_invite_serializer.rb +4 -0
  57. data/app/serializers/decidim/conferences/data_portability_conference_registration_serializer.rb +4 -0
  58. data/app/uploaders/decidim/conferences/diploma_uploader.rb +12 -0
  59. data/app/views/decidim/conferences/admin/conference_invites/_form.html.erb +8 -0
  60. data/app/views/decidim/conferences/admin/conference_invites/index.html.erb +4 -0
  61. data/app/views/decidim/conferences/admin/conference_registrations/index.html.erb +16 -0
  62. data/app/views/decidim/conferences/admin/conferences/edit.html.erb +0 -4
  63. data/app/views/decidim/conferences/admin/diplomas/_form.html.erb +31 -0
  64. data/app/views/decidim/conferences/admin/diplomas/edit.html.erb +7 -0
  65. data/app/views/decidim/conferences/admin/invite_join_conference_mailer/invite.html.erb +2 -2
  66. data/app/views/decidim/conferences/admin/registration_types/_form.html.erb +30 -0
  67. data/app/views/decidim/conferences/admin/registration_types/edit.html.erb +7 -0
  68. data/app/views/decidim/conferences/admin/registration_types/index.html.erb +65 -0
  69. data/app/views/decidim/conferences/admin/registration_types/new.html.erb +7 -0
  70. data/app/views/decidim/conferences/admin/send_conference_diploma_mailer/diploma.html.erb +1 -0
  71. data/app/views/decidim/conferences/admin/send_conference_diploma_mailer/diploma_user.html.erb +24 -0
  72. data/app/views/decidim/conferences/conference_program/_program_meeting.html.erb +1 -2
  73. data/app/views/decidim/conferences/conference_registration_mailer/confirmation.html.erb +9 -1
  74. data/app/views/decidim/conferences/conference_registration_mailer/pending_validation.html.erb +11 -0
  75. data/app/views/decidim/conferences/conferences/index.html.erb +2 -2
  76. data/app/views/decidim/conferences/conferences/show.html.erb +10 -24
  77. data/app/views/decidim/conferences/registration_types/index.html.erb +30 -0
  78. data/app/views/decidim/conferences/shared/_conference_user_login.html.erb +14 -0
  79. data/app/views/layouts/decidim/_conference_hero.html.erb +5 -3
  80. data/app/views/layouts/decidim/_conferences_nav.html.erb +45 -89
  81. data/app/views/layouts/decidim/admin/conference.html.erb +26 -8
  82. data/app/views/layouts/decidim/diploma.html.erb +11 -0
  83. data/config/initializers/wicked_pdf.rb +23 -0
  84. data/config/locales/ca.yml +125 -19
  85. data/config/locales/de.yml +127 -21
  86. data/config/locales/en.yml +126 -23
  87. data/config/locales/es-PY.yml +125 -19
  88. data/config/locales/es.yml +125 -19
  89. data/config/locales/eu.yml +127 -21
  90. data/config/locales/fi-pl.yml +570 -0
  91. data/config/locales/fi.yml +145 -39
  92. data/config/locales/fr.yml +127 -21
  93. data/config/locales/gl.yml +126 -20
  94. data/config/locales/hu.yml +127 -21
  95. data/config/locales/id-ID.yml +563 -0
  96. data/config/locales/it.yml +127 -21
  97. data/config/locales/nl.yml +126 -20
  98. data/config/locales/pl.yml +127 -24
  99. data/config/locales/pt-BR.yml +125 -19
  100. data/config/locales/pt.yml +126 -20
  101. data/config/locales/sv.yml +164 -58
  102. data/config/locales/tr-TR.yml +567 -0
  103. data/db/migrate/20181023142325_add_conference_registration_types.rb +21 -0
  104. data/db/migrate/20181030090202_add_reference_registration_type_to_conference_registration.rb +9 -0
  105. data/db/migrate/20181030153614_add_registration_type_to_conference_invite.rb +8 -0
  106. data/db/migrate/20181106092826_add_diploma_fields_to_conference.rb +11 -0
  107. data/db/migrate/20181123124424_make_price_optional_conference_registration_type.rb +7 -0
  108. data/lib/decidim/conferences/admin_engine.rb +16 -2
  109. data/lib/decidim/conferences/engine.rb +8 -4
  110. data/lib/decidim/conferences/participatory_space.rb +11 -0
  111. data/lib/decidim/conferences/test/factories.rb +36 -0
  112. data/lib/decidim/conferences/version.rb +1 -1
  113. metadata +94 -22
  114. data/app/cells/decidim/conferences/join_conference_button_cell.rb +0 -42
  115. data/app/views/decidim/conferences/conferences/_conferences_sidebar.html.erb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce205f1fb75600c4d976b328d923dc03bb51751139ef47f3ba89055e8bd2a4d9
4
- data.tar.gz: 01fa65479b7451859b69f38f8d6f6a77f5fa0965dab90ce50bca00dee0735a02
3
+ metadata.gz: ddc7fa34e2b4e2c992da97804172fe9475eacda9bcbe53177305aa3a704f942c
4
+ data.tar.gz: ce3e59d39e71aef52043e06029ebaf2c647ee9884efae26bc2a74d0dbfea125f
5
5
  SHA512:
6
- metadata.gz: 4a14ccd3689e0b72f7519ac36f218999c5e06b34ba58a484f1833b9b7f9bacf579af884f85e783e00da9c5d22d4b33e4a1fff7c1a08791b5e216e4be35585cbc
7
- data.tar.gz: 224d0471a284fd188bc581009233a5cc24fc214c194aa694916da89c59abad0d1c7b2c05ea50257cb068f42731c590732641f2eeaf72bce551f06ab88a5171c9
6
+ metadata.gz: e8468192f591655efbbad30949b26d4f470f25b67687fc9de707eba4f53153a3d4ea5fd85b33cb0695cf439d0a3ae80209c83e895c9c3f1a9e81c7068e669706
7
+ data.tar.gz: e0fa55a79b3043b793c5184dd7dca4425626effd210f076f8056595eb1b33f4dd9c95be2ae19a44cf1d9c23de03d7bdfccc0588b6c37b2bc11f8e9a83baa9e11
@@ -1,2 +1,3 @@
1
1
  //= link decidim/conferences/admin/conferences.js
2
2
  //= link decidim/conferences/admin/conference_speakers.js
3
+ //= link decidim/conferences/admin/conference_invite_form.js
@@ -1,6 +1,3 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36.02 36.02">
2
- <path d="M883.8,543.84a18,18,0,1,1,18-18A18,18,0,0,1,883.8,543.84Zm0-34a16,16,0,1,0,16,16A16,16,0,0,0,883.8,509.83Z" transform="translate(-865.8 -507.83)" />
3
- <ellipse ry="5.504777" rx="5.5598245" cy="17.971844" cx="18" />
4
- <path d="M883.8,543.84a18,18,0,1,1,18-18A18,18,0,0,1,883.8,543.84Zm0-34a16,16,0,1,0,16,16A16,16,0,0,0,883.8,509.83Z" transform="translate(-865.8 -507.83)" />
5
- <path d="m 6.3078227,-25.154474 a 9.3338938,9.0435648 0 0 1 -8.7369752,9.025052 9.3338938,9.0435648 0 0 1 -9.8544645,-7.870717 9.3338938,9.0435648 0 0 1 7.4765554,-10.031744" transform="matrix(-0.78352169,0.62136443,-0.62136443,-0.78352169,0,0)" class="stroked-shape" />
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8">
2
+ <path d="M2.91-.03a1 1 0 0 0-.13.03 1 1 0 0 0-.78 1v2a1 1 0 1 0 2 0v-2a1 1 0 0 0-1.09-1.03zm-2.56 2.03a.5.5 0 0 0-.34.5v.5c0 1.48 1.09 2.69 2.5 2.94v1.06h-.5c-.55 0-1 .45-1 1h4.01c0-.55-.45-1-1-1h-.5v-1.06c1.41-.24 2.5-1.46 2.5-2.94v-.5a.5.5 0 1 0-1 0v.5c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2v-.5a.5.5 0 0 0-.59-.5.5.5 0 0 0-.06 0z" transform="translate(1)"/>
6
3
  </svg>
@@ -19,18 +19,21 @@ module Decidim
19
19
  end
20
20
 
21
21
  def conference_participatory_processes
22
+ return unless Decidim.participatory_space_manifests.map(&:name).include?(:participatory_processes)
22
23
  processes = model.linked_participatory_space_resources(:participatory_processes, "included_participatory_processes")
23
24
  return unless processes.any?
24
25
  processes
25
26
  end
26
27
 
27
28
  def conference_assemblies
29
+ return unless Decidim.participatory_space_manifests.map(&:name).include?(:assemblies)
28
30
  assemblies = model.linked_participatory_space_resources(:assemblies, "included_assemblies")
29
31
  return unless assemblies.any?
30
32
  assemblies
31
33
  end
32
34
 
33
35
  def conference_consultations
36
+ return unless Decidim.participatory_space_manifests.map(&:name).include?(:consultations)
34
37
  consultations = model.linked_participatory_space_resources(:consultations, "included_consultations")
35
38
  return unless consultations.any?
36
39
  consultations
@@ -1,9 +1,10 @@
1
- <% if model.registrations_enabled? %>
2
- <% if model.has_registration_for? current_user %>
1
+ <% if conference.registrations_enabled? %>
2
+ <% if conference.has_registration_for_user_and_registration_type?(current_user, model) %>
3
3
  <% if allowed? %>
4
- <%= button_to conference_conference_registration_path(model),
4
+ <%= button_to conference_registration_type_conference_registration_path(conference, model),
5
5
  method: :delete,
6
6
  class: "#{button_classes} secondary light",
7
+ style: "margin-bottom: 0;",
7
8
  data: { disable: true } do %>
8
9
  <%= icon("check", class: "icon--small") %>
9
10
  <%= t("going", scope: "decidim.conferences.conference.show") %>
@@ -14,12 +15,10 @@
14
15
  <% if allowed? %>
15
16
  <%= button_to i18n_join_text, "",
16
17
  class: button_classes,
17
- disabled: !model.has_available_slots?,
18
+ disabled: !conference.has_available_slots? || conference.has_registration_for?(current_user),
19
+ style: "margin-bottom: 0;",
18
20
  onclick: "event.preventDefault()",
19
21
  data: { open: current_user.present? ? "conference-registration-confirm-#{model.id}" : "loginModal" } %>
20
22
  <% end %>
21
23
  <% end %>
22
- <% if shows_remaining_slots? %>
23
- <span><%= t("remaining_slots", scope: "decidim.conferences.conference.show", count: model.remaining_slots) %></span>
24
- <% end %>
25
24
  <% end %>
@@ -1,12 +1,12 @@
1
1
  <div class="reveal" data-reveal id="conference-registration-confirm-<%= model.id %>">
2
2
  <div class="row">
3
3
  <div class="columns medium-10 medium-offset-1 help-text">
4
- <%= decidim_sanitize translated_attribute(model.registration_terms) %>
4
+ <%= decidim_sanitize translated_attribute(conference.registration_terms) %>
5
5
  </div>
6
6
  </div>
7
7
  <div class="row">
8
8
  <div class="columns medium-8 medium-offset-2">
9
- <%= button_to t("confirm", scope: "decidim.conferences.conference.registration_confirm"), conference_conference_registration_path(model), class: "button expanded", data: { disable: true } %>
9
+ <%= button_to t("confirm", scope: "decidim.conferences.conference.registration_confirm"), conference_registration_type_conference_registration_path(conference, model), class: "button expanded", data: { disable: true } %>
10
10
  </div>
11
11
  </div>
12
12
  <div class="text-center">
@@ -0,0 +1,16 @@
1
+ <div class="conference-registration card__block" id="registration-type-<%= model.id %>">
2
+ <div class="row flex--cc">
3
+ <div class="columns medium-8">
4
+ <div class="registration__text">
5
+ <strong><%= title %></strong>
6
+ <span> <%= description %></span>
7
+ </div>
8
+ </div>
9
+ <div class="columns medium-4">
10
+ <div class="registration__buttons">
11
+ <button type="button" class="small-5 small"><strong><%= price %></strong></button>
12
+ <%= render :join_conference %>
13
+ </div>
14
+ </div>
15
+ </div>
16
+ </div>
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Conferences
5
+ # This cell renders the media link card for an instance of a RegistrationType
6
+ class RegistrationTypeCell < Decidim::ViewModel
7
+ include ActionView::Helpers::NumberHelper
8
+ include Decidim::SanitizeHelper
9
+ include Decidim::Conferences::Engine.routes.url_helpers
10
+ include Decidim::LayoutHelper
11
+
12
+ def show
13
+ render
14
+ end
15
+
16
+ private
17
+
18
+ delegate :current_user, to: :controller, prefix: false
19
+
20
+ def title
21
+ translated_attribute model.title
22
+ end
23
+
24
+ def description
25
+ translated_attribute model.description
26
+ end
27
+
28
+ def price
29
+ return I18n.t("free", scope: "decidim.conferences.conference.show") if model.price.blank?
30
+ number_to_currency(model.price, locale: I18n.locale, unit: Decidim.currency_unit)
31
+ end
32
+
33
+ def allowed?
34
+ options[:allowed]
35
+ end
36
+
37
+ def button_classes
38
+ "button button--sc small"
39
+ end
40
+
41
+ def conference
42
+ model.conference
43
+ end
44
+
45
+ def i18n_join_text
46
+ return I18n.t("registration", scope: "decidim.conferences.conference.show") if conference.has_available_slots?
47
+ I18n.t("no_slots_available", scope: "decidim.conferences.conference.show")
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Conferences
5
+ module Admin
6
+ # This command is executed when the user joins a conference.
7
+ class ConfirmConferenceRegistration < Rectify::Command
8
+ # Initializes a JoinConference Command.
9
+ #
10
+ # conference_registration - The registration to be confirmed
11
+ def initialize(conference_registration, current_user)
12
+ @conference_registration = conference_registration
13
+ @current_user = current_user
14
+ end
15
+
16
+ # Creates a conference registration if the conference has registrations enabled
17
+ # and there are available slots.
18
+ #
19
+ # Broadcasts :ok if successful, :invalid otherwise.
20
+ def call
21
+ @conference_registration.with_lock do
22
+ return broadcast(:invalid) unless can_join_conference?
23
+ confirm_registration
24
+ send_email_confirmation
25
+ send_notification_confirmation
26
+ end
27
+ broadcast(:ok)
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :conference, :user
33
+
34
+ def confirm_registration
35
+ extra_info = {
36
+ resource: {
37
+ title: @conference_registration.conference.title
38
+ }
39
+ }
40
+
41
+ Decidim.traceability.perform_action!(
42
+ "confirm",
43
+ @conference_registration,
44
+ @current_user,
45
+ extra_info
46
+ ) do
47
+ @conference_registration.update!(confirmed_at: Time.current)
48
+ @conference_registration
49
+ end
50
+ end
51
+
52
+ def can_join_conference?
53
+ @conference_registration.conference.registrations_enabled? && @conference_registration.conference.has_available_slots?
54
+ end
55
+
56
+ def send_email_confirmation
57
+ Decidim::Conferences::ConferenceRegistrationMailer.confirmation(
58
+ @conference_registration.user,
59
+ @conference_registration.conference,
60
+ @conference_registration.registration_type
61
+ ).deliver_later
62
+ end
63
+
64
+ def send_notification_confirmation
65
+ Decidim::EventsManager.publish(
66
+ event: "decidim.events.conferences.conference_registration_confirmed",
67
+ event_class: Decidim::Conferences::ConferenceRegistrationNotificationEvent,
68
+ resource: @conference_registration.conference,
69
+ affected_users: [@conference_registration.user]
70
+ )
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -86,7 +86,7 @@ module Decidim
86
86
  event: "decidim.events.conferences.registrations_enabled",
87
87
  event_class: Decidim::Conferences::ConferenceRegistrationsEnabledEvent,
88
88
  resource: conference,
89
- recipient_ids: conference.followers.pluck(:id)
89
+ followers: conference.followers
90
90
  )
91
91
  end
92
92
 
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Conferences
5
+ module Admin
6
+ # A command with all the business logic when creating a new registration type
7
+ # in the system.
8
+ class CreateRegistrationType < Rectify::Command
9
+ # Public: Initializes the command.
10
+ #
11
+ # form - A form object with the params.
12
+ # current_user - The current user hwo do the action of create
13
+ # conference - The Conference that will hold the speaker
14
+ def initialize(form, current_user, conference)
15
+ @form = form
16
+ @current_user = current_user
17
+ @conference = conference
18
+ end
19
+
20
+ # Executes the command. Broadcasts these events:
21
+ #
22
+ # - :ok when everything is valid.
23
+ # - :invalid if the form wasn't valid and we couldn't proceed.
24
+ #
25
+ # Returns nothing.
26
+ def call
27
+ return broadcast(:invalid) if form.invalid?
28
+
29
+ transaction do
30
+ create_registration_type!
31
+ link_meetings(@registration_type)
32
+ end
33
+
34
+ broadcast(:ok)
35
+ end
36
+
37
+ private
38
+
39
+ attr_reader :form, :conference, :current_user
40
+
41
+ def create_registration_type!
42
+ log_info = {
43
+ resource: {
44
+ title: form.title
45
+ },
46
+ participatory_space: {
47
+ title: conference.title
48
+ }
49
+ }
50
+
51
+ @registration_type = Decidim.traceability.create!(
52
+ Decidim::Conferences::RegistrationType,
53
+ form.current_user,
54
+ form.attributes.slice(
55
+ :title,
56
+ :description,
57
+ :price,
58
+ :weight
59
+ ).merge(
60
+ conference: conference
61
+ ),
62
+ log_info
63
+ )
64
+ end
65
+
66
+ def conference_meetings(registration_type)
67
+ meeting_components = registration_type.conference.components.where(manifest_name: "meetings")
68
+ Decidim::ConferenceMeeting.where(component: meeting_components).where(id: @form.attributes[:conference_meeting_ids])
69
+ end
70
+
71
+ def link_meetings(registration_type)
72
+ registration_type.conference_meetings = conference_meetings(registration_type)
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Conferences
5
+ module Admin
6
+ # A command with all the business logic when destroying a conference
7
+ # registration type in the system.
8
+ class DestroyRegistrationType < Rectify::Command
9
+ # Public: Initializes the command.
10
+ #
11
+ # registration_type - the Partner to destroy
12
+ # current_user - the user performing this action
13
+ def initialize(registration_type, current_user)
14
+ @registration_type = registration_type
15
+ @current_user = current_user
16
+ end
17
+
18
+ # Executes the command. Broadcasts these events:
19
+ #
20
+ # - :ok when everything is valid.
21
+ # - :invalid if the form wasn't valid and we couldn't proceed.
22
+ #
23
+ # Returns nothing.
24
+ def call
25
+ destroy_registration_type!
26
+ broadcast(:ok)
27
+ end
28
+
29
+ private
30
+
31
+ attr_reader :registration_type, :current_user
32
+
33
+ def destroy_registration_type!
34
+ log_info = {
35
+ resource: {
36
+ title: registration_type.title
37
+ },
38
+ participatory_space: {
39
+ title: registration_type.conference.title
40
+ }
41
+ }
42
+
43
+ Decidim.traceability.perform_action!(
44
+ "delete",
45
+ registration_type,
46
+ current_user,
47
+ log_info
48
+ ) do
49
+ registration_type.destroy!
50
+ registration_type
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -59,6 +59,7 @@ module Decidim
59
59
  {
60
60
  user: user,
61
61
  conference: conference,
62
+ registration_type: form.registration_type,
62
63
  sent_at: Time.current
63
64
  },
64
65
  log_info
@@ -74,11 +75,11 @@ module Decidim
74
75
  if user.invited_to_sign_up?
75
76
  invite_user_to_sign_up
76
77
  else
77
- InviteJoinConferenceMailer.invite(user, conference, invited_by).deliver_later
78
+ InviteJoinConferenceMailer.invite(user, conference, form.registration_type, invited_by).deliver_later
78
79
  end
79
80
  else
80
81
  user.name = form.name
81
- user.nickname = User.nicknamize(user.name, organization: user.organization)
82
+ user.nickname = UserBaseEntity.nicknamize(user.name, organization: user.organization)
82
83
  invite_user_to_sign_up
83
84
  create_invitation!
84
85
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Conferences
5
+ module Admin
6
+ # This command gets called when a registration_type is published from the admin panel.
7
+ class PublishRegistrationType < Rectify::Command
8
+ # Public: Initializes the command.
9
+ #
10
+ # registration_type - The registration_type to publish.
11
+ # current_user - the user performing the action
12
+ def initialize(registration_type, current_user)
13
+ @registration_type = registration_type
14
+ @current_user = current_user
15
+ end
16
+
17
+ # Public: Publishes the Component.
18
+ #
19
+ # Broadcasts :ok if published, :invalid otherwise.
20
+ def call
21
+ return broadcast(:invalid) if registration_type.nil? || registration_type.published?
22
+
23
+ Decidim.traceability.perform_action!(:publish, registration_type, current_user) do
24
+ registration_type.publish!
25
+ end
26
+
27
+ broadcast(:ok)
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :registration_type, :current_user
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Conferences
5
+ module Admin
6
+ # A command with all the business logic to send diplomas to registered conference users.
7
+ #
8
+ class SendConferenceDiplomas < Rectify::Command
9
+ # Public: Initializes the command.
10
+ #
11
+ # conference - The conference which the user is invited to.
12
+ def initialize(conference, current_user)
13
+ @conference = conference
14
+ @current_user = current_user
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 conference.diploma_sent?
25
+
26
+ send_diplomas
27
+ broadcast(:ok)
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :current_user, :conference
33
+
34
+ def send_diplomas
35
+ Decidim.traceability.perform_action!(
36
+ :send_conference_diplomas,
37
+ conference,
38
+ current_user
39
+ ) do
40
+ SendConferenceDiplomaJob.perform_later(conference)
41
+ conference.diploma_sent_at = Time.current
42
+ conference.save!
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end