decidim-conferences 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 (118) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/decidim/conferences/conference.svg +1 -3
  3. data/app/cells/decidim/conferences/conference_m/footer.erb +1 -1
  4. data/app/cells/decidim/conferences/conference_m_cell.rb +4 -0
  5. data/app/cells/decidim/conferences/conference_speaker/show.erb +2 -2
  6. data/app/cells/decidim/conferences/content_blocks/highlighted_conferences/show.erb +9 -10
  7. data/app/cells/decidim/conferences/media_link/show.erb +2 -2
  8. data/app/cells/decidim/conferences/partner_cell.rb +1 -1
  9. data/app/cells/decidim/conferences/photo/show.erb +3 -5
  10. data/app/cells/decidim/conferences/photo_cell.rb +2 -2
  11. data/app/cells/decidim/conferences/photos_list/show.erb +1 -1
  12. data/app/cells/decidim/conferences/registration_type/join_conference.erb +1 -1
  13. data/app/cells/decidim/conferences/registration_type_cell.rb +2 -2
  14. data/app/commands/decidim/conferences/admin/create_conference_admin.rb +2 -1
  15. data/app/commands/decidim/conferences/admin/create_partner.rb +9 -9
  16. data/app/commands/decidim/conferences/admin/notify_role_assigned_to_conference.rb +22 -0
  17. data/app/commands/decidim/conferences/admin/update_conference.rb +10 -3
  18. data/app/commands/decidim/conferences/admin/update_conference_admin.rb +2 -1
  19. data/app/events/decidim/conferences/conference_role_assigned_event.rb +30 -0
  20. data/app/forms/decidim/conferences/admin/conference_form.rb +5 -2
  21. data/app/forms/decidim/conferences/admin/conference_speaker_form.rb +12 -1
  22. data/app/forms/decidim/conferences/admin/diploma_form.rb +6 -2
  23. data/app/forms/decidim/conferences/admin/partner_form.rb +16 -1
  24. data/app/jobs/decidim/conferences/admin/send_conference_diploma_job.rb +1 -1
  25. data/app/models/decidim/conference.rb +16 -1
  26. data/app/models/decidim/conference_speaker.rb +5 -2
  27. data/app/models/decidim/conferences/media_link.rb +3 -0
  28. data/app/models/decidim/conferences/partner.rb +5 -1
  29. data/app/models/decidim/conferences/registration_type.rb +3 -0
  30. data/app/presenters/decidim/conferences/admin_log/{conferences_presenter.rb → conference_presenter.rb} +2 -2
  31. data/app/presenters/decidim/conferences/admin_log/conference_registration_presenter.rb +2 -2
  32. data/app/presenters/decidim/conferences/admin_log/conference_speaker_presenter.rb +2 -2
  33. data/app/presenters/decidim/conferences/admin_log/{conferences_user_role_presenter.rb → conference_user_role_presenter.rb} +2 -2
  34. data/app/presenters/decidim/conferences/admin_log/media_link_presenter.rb +2 -2
  35. data/app/presenters/decidim/conferences/admin_log/partner_presenter.rb +2 -2
  36. data/app/presenters/decidim/conferences/admin_log/registration_type_presenter.rb +2 -2
  37. data/app/presenters/decidim/conferences/conference_stats_presenter.rb +1 -1
  38. data/app/views/decidim/conferences/_order_by_conferences.html.erb +1 -1
  39. data/app/views/decidim/conferences/admin/conference_invites/index.html.erb +2 -2
  40. data/app/views/decidim/conferences/admin/conference_speakers/index.html.erb +2 -2
  41. data/app/views/decidim/conferences/admin/conferences/index.html.erb +1 -1
  42. data/app/views/decidim/conferences/conference_program/_program_item.html.erb +6 -4
  43. data/app/views/decidim/conferences/conference_program/show.html.erb +6 -6
  44. data/app/views/decidim/conferences/conference_speakers/index.html.erb +1 -1
  45. data/app/views/decidim/conferences/conferences/_partners.html.erb +1 -1
  46. data/app/views/decidim/conferences/conferences/_promoted_conference.html.erb +3 -3
  47. data/app/views/decidim/conferences/conferences/show.html.erb +7 -13
  48. data/app/views/decidim/conferences/media/index.html.erb +3 -3
  49. data/app/views/decidim/conferences/registration_types/index.html.erb +1 -1
  50. data/app/views/layouts/decidim/_conference_hero.html.erb +4 -8
  51. data/app/views/layouts/decidim/_conferences_nav.html.erb +2 -2
  52. data/app/views/layouts/decidim/conference.html.erb +4 -5
  53. data/config/locales/am-ET.yml +1 -0
  54. data/config/locales/bg-BG.yml +7 -0
  55. data/config/locales/bg.yml +7 -0
  56. data/config/locales/ca.yml +9 -0
  57. data/config/locales/cs.yml +35 -26
  58. data/config/locales/da-DK.yml +1 -0
  59. data/config/locales/da.yml +1 -0
  60. data/config/locales/de.yml +51 -41
  61. data/config/locales/el.yml +579 -0
  62. data/config/locales/en.yml +9 -0
  63. data/config/locales/eo.yml +1 -0
  64. data/config/locales/es-MX.yml +9 -0
  65. data/config/locales/es-PY.yml +9 -0
  66. data/config/locales/es.yml +9 -0
  67. data/config/locales/et-EE.yml +1 -0
  68. data/config/locales/et.yml +1 -0
  69. data/config/locales/fi-plain.yml +10 -1
  70. data/config/locales/fi.yml +16 -7
  71. data/config/locales/fr-CA.yml +581 -0
  72. data/config/locales/fr.yml +10 -0
  73. data/config/locales/ga-IE.yml +1 -0
  74. data/config/locales/hr-HR.yml +1 -0
  75. data/config/locales/hr.yml +1 -0
  76. data/config/locales/hu.yml +3 -0
  77. data/config/locales/is.yml +1 -0
  78. data/config/locales/it.yml +169 -159
  79. data/config/locales/ja-JP.yml +575 -0
  80. data/config/locales/ja.yml +576 -0
  81. data/config/locales/ko-KR.yml +1 -0
  82. data/config/locales/ko.yml +1 -0
  83. data/config/locales/lt-LT.yml +1 -0
  84. data/config/locales/lt.yml +1 -0
  85. data/config/locales/lv.yml +584 -0
  86. data/config/locales/mt-MT.yml +1 -0
  87. data/config/locales/mt.yml +1 -0
  88. data/config/locales/nl.yml +15 -5
  89. data/config/locales/no.yml +12 -3
  90. data/config/locales/om-ET.yml +1 -0
  91. data/config/locales/pl.yml +204 -193
  92. data/config/locales/pt-BR.yml +1 -1
  93. data/config/locales/pt.yml +238 -229
  94. data/config/locales/ro-RO.yml +536 -0
  95. data/config/locales/si-LK.yml +1 -0
  96. data/config/locales/sk-SK.yml +585 -0
  97. data/config/locales/sk.yml +585 -0
  98. data/config/locales/sl.yml +42 -0
  99. data/config/locales/so-SO.yml +1 -0
  100. data/config/locales/sr-CS.yml +19 -0
  101. data/config/locales/sv.yml +25 -15
  102. data/config/locales/sw-KE.yml +1 -0
  103. data/config/locales/ti-ER.yml +1 -0
  104. data/config/locales/tr-TR.yml +68 -58
  105. data/config/locales/vi-VN.yml +1 -0
  106. data/config/locales/vi.yml +1 -0
  107. data/config/locales/zh-CN.yml +576 -0
  108. data/config/locales/zh-TW.yml +1 -0
  109. data/db/migrate/20200320105913_index_foreign_keys_in_decidim_conferences.rb +7 -0
  110. data/db/migrate/20200320105914_index_foreign_keys_in_decidim_conferences_conference_invites.rb +7 -0
  111. data/db/migrate/20200320105915_index_foreign_keys_in_decidim_conferences_conference_registrations.rb +7 -0
  112. data/db/seeds/city.jpeg +0 -0
  113. data/db/seeds/city2.jpeg +0 -0
  114. data/lib/decidim/conferences/admin_engine.rb +1 -0
  115. data/lib/decidim/conferences/participatory_space.rb +17 -12
  116. data/lib/decidim/conferences/test/factories.rb +3 -3
  117. data/lib/decidim/conferences/version.rb +1 -1
  118. metadata +58 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99821cad74f86b23d2243a063e9c5f347aff5a1c8e284e8c8c0cc250c726da59
4
- data.tar.gz: 681fd61ed392ae35e2f580fac6e6ff49e6fad73f90e2e87585a5e343042ef73b
3
+ metadata.gz: f7d8502a8f92d995cec27935a0965ee2e6f9dd3f90ed8f5bc1c1a3d7a32610be
4
+ data.tar.gz: 59b3ae649ad811e7d6efeaadf0189b6559e9654dd0bfa968232a5b3a79da74e4
5
5
  SHA512:
6
- metadata.gz: dd9b00dae882f1a7e7aba6aced3e95ae4812abc5e7f81e2abf3f10cfa425a26cea3b6fef3c706ceae59cca30008e86c1fc505130b963668c888b13eecf8af285
7
- data.tar.gz: 4ad9c3cfa57db46f38e22da1310323249f955d6c2f95b467ba62cbc184a7db7ff6b74e4bd60eec1bc75346f05bbf744674d2e8dbc07b2c1559e9d93559d78c84
6
+ metadata.gz: 86fc8af9b3022cd775795ccb96360b34130664bbac432e30a95a42dafc0d570a0c60e14bc29a390e6e34deae161dbe64fe6a98e976c2ee2dbd0792ed6700cce4
7
+ data.tar.gz: 3b6ff89eb36bef14a8f100b45d2191a544b0a98ab949e521ed365e53b824223e49585c41bf40974e03ed6270cdb4d737ecbee63a550c74d6a3ee581293d93997
@@ -1,3 +1 @@
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)"/>
3
- </svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8"><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)"/></svg>
@@ -3,7 +3,7 @@
3
3
  <%= link_to(
4
4
  t(model.cta_button_text_key, scope: "layouts.decidim.conferences.conference"),
5
5
  resource_path,
6
- class: "card__button button button--sc secondary light small"
6
+ class: "card__button button button--sc small"
7
7
  ) %>
8
8
  </div>
9
9
  </div>
@@ -14,6 +14,10 @@ module Decidim
14
14
 
15
15
  private
16
16
 
17
+ def title
18
+ decidim_html_escape(super)
19
+ end
20
+
17
21
  def has_image?
18
22
  true
19
23
  end
@@ -1,7 +1,7 @@
1
1
  <div class="column conference-speaker js-conference">
2
2
  <div class="speaker-img-wrapper">
3
3
  <div class="speaker-img">
4
- <%= image_tag avatar.url %>
4
+ <%= image_tag avatar.url, alt: "speaker-image" %>
5
5
  </div>
6
6
  </div>
7
7
  <div class="speaker-data">
@@ -26,7 +26,7 @@
26
26
  <div class="column medium-6">
27
27
  <div class="speaker-img-wrapper">
28
28
  <div class="speaker-img">
29
- <%= image_tag avatar.url %>
29
+ <%= image_tag avatar.url, alt: "speaker-image" %>
30
30
  </div>
31
31
  </div>
32
32
  <div class="speaker-data">
@@ -6,17 +6,13 @@
6
6
  large-up-4 card-grid">
7
7
  <% highlighted_conferences.each do |conference| %>
8
8
  <div class="column">
9
- <article class="card card--conference card--mini">
10
- <%= link_to decidim_conferences.conference_path(conference), class: "card__link" do %>
11
- <div class="card__image-top"
12
- style="background-image:url(<%= conference.hero_image.url %>)"></div>
13
- <% end %>
9
+ <%= link_to decidim_conferences.conference_path(conference), class: "card card--conference card--mini" do %>
10
+ <div aria-hidden="true" class="card__image-top"
11
+ style="background-image:url(<%= conference.hero_image.url %>)"></div>
14
12
  <div class="card__content">
15
- <%= link_to decidim_conferences.conference_path(conference), class: "card__link" do %>
16
- <h4 class="card__title"><%= translated_attribute conference.title %></h4>
17
- <% end %>
13
+ <span class="card__title card__link"><%= translated_attribute conference.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-conferences">
26
22
  <div class="columns small-centered small-12
27
23
  smallmedium-8 medium-6 large-4">
28
- <%= link_to t("see_all_conferences", scope: i18n_scope), decidim_conferences.conferences_path, class: "button expanded hollow button--sc home-section__cta" %>
24
+ <%= link_to t("see_all_conferences", scope: i18n_scope),
25
+ decidim_conferences.conferences_path,
26
+ class: "button expanded hollow button--sc home-section__cta",
27
+ title: t("conferences_button_title", scope: i18n_scope) %>
29
28
  </div>
30
29
  </div>
31
30
  </section>
@@ -1,9 +1,9 @@
1
1
  <li>
2
- <%= icon "external-link" %>
2
+ <%= icon "external-link", role: "img", "aria-hidden": true %>
3
3
  <div>
4
4
  <%= link_to model.link, target: "_blank" do %>
5
5
  <strong><%= translated_attribute(model.title) %> </strong>
6
6
  <% end %>
7
- <div class="text-small"><%= l(model.date, format: :decidim_short_with_month_name_short) %> · <%= model.link %></small>
7
+ <div class="text-small"><%= l(model.date, format: :decidim_short_with_month_name_short) %> · <%= model.link %></div>
8
8
  </div>
9
9
  </li>
@@ -19,7 +19,7 @@ module Decidim
19
19
  def logo
20
20
  return unless model.logo.presence
21
21
 
22
- "<div class='card p-m flex--cc'> #{image_tag model.logo.medium.url} </div>"
22
+ "<div class='card p-m flex--cc'> #{image_tag model.logo.medium.url, alt: "logo"} </div>"
23
23
  end
24
24
  end
25
25
  end
@@ -1,15 +1,13 @@
1
1
  <div class="column">
2
- <article class="card" data-open="media-picture-<%= index %>">
2
+ <div class="card" data-open="media-picture-<%= index %>">
3
3
  <div class="picture__content">
4
4
  <%= image_thumb %>
5
- <h5 class="card__title">
6
- <strong><%= title %></strong>
7
- </h5>
5
+ <strong class="card__title"><%= title %></strong>
8
6
  <div class="text-small">
9
7
  <%= short_description %>
10
8
  </div>
11
9
  </div>
12
- </article>
10
+ </div>
13
11
  <div id="media-picture-<%= index %>" class="reveal picture__modal" data-reveal>
14
12
  <div class="reveal__header">
15
13
  <h3 class="reveal__title"><%= t("conferences.photo.show.photo", scope: "decidim") %></h3>
@@ -18,11 +18,11 @@ module Decidim
18
18
  end
19
19
 
20
20
  def image_thumb
21
- image_tag model.thumbnail_url
21
+ image_tag model.thumbnail_url, alt: t("alt", scope: "decidim.conferences.photo.image.attributes")
22
22
  end
23
23
 
24
24
  def image_big
25
- image_tag model.big_url
25
+ image_tag model.big_url, alt: t("alt", scope: "decidim.conferences.photo.image.attributes")
26
26
  end
27
27
 
28
28
  def title
@@ -1,5 +1,5 @@
1
1
  <div class="section images">
2
- <h4 class="section-heading"><%= t("conferences.photos_list.show.related_photos", scope: "decidim") %></h4>
2
+ <h3 class="section-heading"><%= t("conferences.photos_list.show.related_photos", scope: "decidim") %></h3>
3
3
  <div class="row small-up-1 smallmedium-up-2 card-grid">
4
4
  <% model.each_with_index do |photo, index| %>
5
5
  <%= cell "decidim/conferences/photo", photo, index: index %>
@@ -13,7 +13,7 @@
13
13
  <% else %>
14
14
  <%= render :registration_confirm %>
15
15
  <% if allowed? %>
16
- <%= button_to i18n_join_text, "",
16
+ <%= button_to i18n_join_text, "#",
17
17
  class: button_classes,
18
18
  disabled: !conference.has_available_slots? || conference.has_registration_for?(current_user),
19
19
  style: "margin-bottom: 0;",
@@ -18,11 +18,11 @@ module Decidim
18
18
  delegate :current_user, to: :controller, prefix: false
19
19
 
20
20
  def title
21
- translated_attribute model.title
21
+ decidim_sanitize translated_attribute model.title
22
22
  end
23
23
 
24
24
  def description
25
- translated_attribute model.description
25
+ decidim_sanitize translated_attribute model.description
26
26
  end
27
27
 
28
28
  def price
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new conference
7
7
  # admin in the system.
8
- class CreateConferenceAdmin < Rectify::Command
8
+ class CreateConferenceAdmin < NotifyRoleAssignedToConference
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
  conference: @conference
58
58
  )
59
59
  end
60
+ send_notification user
60
61
  end
61
62
 
62
63
  def existing_user
@@ -49,15 +49,15 @@ module Decidim
49
49
  @partner = Decidim.traceability.create!(
50
50
  Decidim::Conferences::Partner,
51
51
  form.current_user,
52
- form.attributes.slice(
53
- :name,
54
- :weight,
55
- :link,
56
- :partner_type,
57
- :logo,
58
- :remove_avatar
59
- ).merge(
60
- conference: conference
52
+ { conference: conference }.merge(
53
+ form.attributes.slice(
54
+ :name,
55
+ :weight,
56
+ :link,
57
+ :partner_type,
58
+ :logo,
59
+ :remove_avatar
60
+ )
61
61
  ),
62
62
  log_info
63
63
  )
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Conferences
5
+ module Admin
6
+ # A command to notify users when a role is assigned for a Conference
7
+ class NotifyRoleAssignedToConference < Rectify::Command
8
+ def send_notification(user)
9
+ Decidim::EventsManager.publish(
10
+ event: "decidim.events.conferences.role_assigned",
11
+ event_class: Decidim::Conferences::ConferenceRoleAssignedEvent,
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
@@ -81,13 +81,20 @@ module Decidim
81
81
  location: form.location,
82
82
  start_date: form.start_date,
83
83
  end_date: form.end_date,
84
- hero_image: form.hero_image,
85
- banner_image: form.banner_image,
86
84
  promoted: form.promoted,
87
85
  scopes_enabled: form.scopes_enabled,
88
86
  scope: form.scope,
89
87
  show_statistics: form.show_statistics
90
- }
88
+ }.merge(uploader_attributes)
89
+ end
90
+
91
+ def uploader_attributes
92
+ {
93
+ hero_image: form.hero_image,
94
+ remove_hero_image: form.remove_hero_image,
95
+ banner_image: form.banner_image,
96
+ remove_banner_image: form.remove_banner_image
97
+ }.delete_if { |_k, val| val.is_a?(Decidim::ApplicationUploader) }
91
98
  end
92
99
 
93
100
  def send_notification_registrations_enabled
@@ -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 UpdateConferenceAdmin < Rectify::Command
8
+ class UpdateConferenceAdmin < NotifyRoleAssignedToConference
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,30 @@
1
+ # frozen-string_literal: true
2
+
3
+ module Decidim
4
+ module Conferences
5
+ class ConferenceRoleAssignedEvent < Decidim::Events::SimpleEvent
6
+ include Decidim::Events::NotificationEvent
7
+ include Decidim::Events::AuthorEvent
8
+
9
+ def notification_title
10
+ I18n.t("notification_title", i18n_options).html_safe
11
+ end
12
+
13
+ def i18n_role
14
+ I18n.t(extra["role"], "decidim.admin.models.conference_user_role.roles", default: extra["role"])
15
+ end
16
+
17
+ def i18n_options
18
+ {
19
+ resource_path: resource_path,
20
+ resource_title: resource_title,
21
+ resource_url: resource_url,
22
+ scope: event_name,
23
+ participatory_space_title: participatory_space_title,
24
+ participatory_space_url: participatory_space_url,
25
+ role: i18n_role
26
+ }
27
+ end
28
+ end
29
+ end
30
+ end
@@ -8,6 +8,7 @@ module Decidim
8
8
  #
9
9
  class ConferenceForm < Form
10
10
  include TranslatableAttributes
11
+ include Decidim::HasUploadValidations
11
12
 
12
13
  translatable_attribute :title, String
13
14
  translatable_attribute :slogan, String
@@ -45,13 +46,15 @@ module Decidim
45
46
  validates :registration_terms, translatable_presence: true, if: ->(form) { form.registrations_enabled? }
46
47
  validates :available_slots, numericality: { greater_than_or_equal_to: 0 }, if: ->(form) { form.registrations_enabled? }
47
48
 
48
- validates :hero_image, file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } }, file_content_type: { allow: ["image/jpeg", "image/png"] }
49
- validates :banner_image, file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } }, file_content_type: { allow: ["image/jpeg", "image/png"] }
49
+ validates :hero_image, passthru: { to: Decidim::Conference }
50
+ validates :banner_image, passthru: { to: Decidim::Conference }
50
51
  validate :available_slots_greater_than_or_equal_to_registrations_count, if: ->(form) { form.registrations_enabled? && form.available_slots.positive? }
51
52
 
52
53
  validates :start_date, presence: true, date: { before_or_equal_to: :end_date }
53
54
  validates :end_date, presence: true, date: { after_or_equal_to: :start_date }
54
55
 
56
+ alias organization current_organization
57
+
55
58
  def map_model(model)
56
59
  self.scope_id = model.decidim_scope_id
57
60
  end
@@ -26,7 +26,18 @@ module Decidim
26
26
  validates :full_name, presence: true, unless: proc { |object| object.existing_user }
27
27
  validates :user, presence: true, if: proc { |object| object.existing_user }
28
28
  validates :position, :affiliation, presence: true
29
- validates :avatar, file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_avatar_size } }
29
+ validates :avatar, passthru: {
30
+ to: Decidim::ConferenceSpeaker,
31
+ with: {
32
+ # The speaker gets its organization context through the conference
33
+ # object which is why we need to create a dummy conference in order
34
+ # to pass the correct organization context to the file upload
35
+ # validators.
36
+ conference: lambda do |form|
37
+ Decidim::Conference.new(organization: form.current_organization)
38
+ end
39
+ }
40
+ }
30
41
  validate :personal_url_format
31
42
 
32
43
  def personal_url
@@ -7,6 +7,8 @@ module Decidim
7
7
  # from the admin dashboard
8
8
  #
9
9
  class DiplomaForm < Form
10
+ include Decidim::HasUploadValidations
11
+
10
12
  mimic :conference
11
13
 
12
14
  attribute :main_logo
@@ -16,8 +18,10 @@ module Decidim
16
18
 
17
19
  validates :signature_name, :sign_date, :main_logo, :signature, presence: true
18
20
 
19
- validates :main_logo, file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } }, file_content_type: { allow: ["image/jpeg", "image/png"] }
20
- validates :signature, file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } }, file_content_type: { allow: ["image/jpeg", "image/png"] }
21
+ validates :main_logo, passthru: { to: Decidim::Conference }
22
+ validates :signature, passthru: { to: Decidim::Conference }
23
+
24
+ alias organization current_organization
21
25
  end
22
26
  end
23
27
  end
@@ -5,6 +5,8 @@ module Decidim
5
5
  module Admin
6
6
  # A form object used to create conference members from the admin dashboard.
7
7
  class PartnerForm < Form
8
+ include Decidim::HasUploadValidations
9
+
8
10
  mimic :conference_partner
9
11
 
10
12
  attribute :name, String
@@ -15,11 +17,24 @@ module Decidim
15
17
  attribute :remove_logo
16
18
 
17
19
  validates :name, :partner_type, presence: true, if: ->(form) { form.logo.present? }
18
- validates :logo, file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_avatar_size } }
20
+ validates :logo, passthru: {
21
+ to: Decidim::Conferences::Partner,
22
+ with: {
23
+ # The partner gets its organization context through the conference
24
+ # object which is why we need to create a dummy conference in order
25
+ # to pass the correct organization context to the file upload
26
+ # validators.
27
+ conference: lambda do |form|
28
+ Decidim::Conference.new(organization: form.current_organization)
29
+ end
30
+ }
31
+ }
19
32
  validate :link_format
20
33
  validates :weight, numericality: { greater_than_or_equal_to: 0 }
21
34
  validates :partner_type, inclusion: { in: Decidim::Conferences::Partner::TYPES }
22
35
 
36
+ alias organization current_organization
37
+
23
38
  def link
24
39
  return if super.blank?
25
40
 
@@ -11,7 +11,7 @@ module Decidim
11
11
  return unless confirmed_registrations.any?
12
12
 
13
13
  confirmed_registrations.each do |registration_confirmed|
14
- SendConferenceDiplomaMailer.diploma(conference, registration_confirmed.user).deliver_now
14
+ SendConferenceDiplomaMailer.diploma(conference, registration_confirmed.user).deliver_later
15
15
  end
16
16
  end
17
17
  end