diff --git a/app/controllers/admin/communication/websites_controller.rb b/app/controllers/admin/communication/websites_controller.rb index ce72fc7d0a2379094796ecc1dc478af0609060d1..9f311420edce99712300778865889c6f0d7886b4 100644 --- a/app/controllers/admin/communication/websites_controller.rb +++ b/app/controllers/admin/communication/websites_controller.rb @@ -38,6 +38,8 @@ class Admin::Communication::WebsitesController < Admin::Communication::Websites: @pages = @all_pages.recent @all_posts = @website.posts.accessible_by(current_ability).for_language(current_website_language) @posts = @all_posts.recent + @all_events = @website.events.accessible_by(current_ability).for_language(current_website_language) + @events = @all_events.recent breadcrumb end diff --git a/app/models/communication/website/agenda/event.rb b/app/models/communication/website/agenda/event.rb index e6d02ea18cd5c52c6a6c5821ae34fac930ae85de..af934528cd7d077791ca8f46193e140943693ea1 100644 --- a/app/models/communication/website/agenda/event.rb +++ b/app/models/communication/website/agenda/event.rb @@ -57,6 +57,7 @@ class Communication::Website::Agenda::Event < ApplicationRecord optional: true scope :ordered, -> { order(from_day: :desc) } + scope :recent, -> { order(from_day: :desc).limit(5) } validates_presence_of :from_day diff --git a/app/views/admin/communication/websites/show.html.erb b/app/views/admin/communication/websites/show.html.erb index 992eeddbfc9e04d5c5b96b762530086f2df2a2e2..b64dacd6b6cd7d403ff1838a4083b0426f8f34b0 100644 --- a/app/views/admin/communication/websites/show.html.erb +++ b/app/views/admin/communication/websites/show.html.erb @@ -15,6 +15,7 @@ <%= render 'admin/communication/websites/sidebar' do %> <%= render 'admin/communication/websites/show/posts' if can?(:read, Communication::Website::Post) && @website.feature_posts %> + <%= render 'admin/communication/websites/show/events' if can?(:read, Communication::Website::Agenda::Event) && @website.feature_agenda %> <%= render 'admin/communication/websites/show/pages' if can?(:read, Communication::Website::Page) %> <%= image_tag @website.deployment_status_badge, alt: '' if @website.deployment_status_badge.present? %> <% end %> diff --git a/app/views/admin/communication/websites/show/_events.html.erb b/app/views/admin/communication/websites/show/_events.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..371000ee46db8048c2299fd7c38411d1734ce677 --- /dev/null +++ b/app/views/admin/communication/websites/show/_events.html.erb @@ -0,0 +1,17 @@ +<% +action = '' +action += link_to t('create'), + new_admin_communication_website_agenda_event_path(website_id: @website), + class: button_classes if can?(:create, Communication::Website::Agenda::Event) +subtitle = '' +if @all_events.any? + subtitle = link_to t('communication.website.see_all', number: @all_events.size), + admin_communication_website_agenda_events_path(website_id: @website) +end +%> +<%= osuny_panel t('communication.website.last_events'), + subtitle: subtitle, + action: action do %> + <%= render 'admin/communication/websites/agenda/events/list', + events: @events %> +<% end %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 476d99b35a129d23f6bea51a007a157ad34a1a81..3874c4df16b217572ff75977f9525a8c66656e39 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -776,6 +776,7 @@ en: refresh: Refresh import show: Show import pending: Import in progress + last_events: Last events last_pages: Last pages last_posts: Last posts menus: diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index b5e5734f1fe279c2899a6d2a67b20e7c77dd66fe..30d469c1a147b0937e29ca477933f3060e2bed5c 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -773,6 +773,7 @@ fr: refresh: Relancer l'import show: Voir l'import pending: Import en cours + last_events: Derniers événements last_pages: Dernières pages last_posts: Dernières actualités menus: