Skip to content
Snippets Groups Projects
Unverified Commit 8ba9eaa2 authored by Arnaud Levy's avatar Arnaud Levy Committed by GitHub
Browse files

Liens vers les archives d'événements dans les blocs agenda (#1626)

* wip

* Fix
parent b975e586
No related branches found
No related tags found
No related merge requests found
......@@ -54,8 +54,26 @@ class Communication::Block::Template::Agenda < Communication::Block::Template::B
mode != 'categories'
end
def title_link
return link_to_events_archive if time == 'archive'
return link_to_category if mode == 'category' && category.present?
link_to_events
end
protected
def link_to_events
website.special_page(Communication::Website::Page::CommunicationAgenda, language: block.language).path
end
def link_to_events_archive
website.special_page(Communication::Website::Page::CommunicationAgendaArchive, language: block.language).path
end
def link_to_category
category.current_permalink_in_website(website)&.path
end
def base_events
events = website.events.for_language(block.language).published
events = events.send(time) if time.in? AUTHORIZED_SCOPES
......
......@@ -76,7 +76,15 @@ class Communication::Website::Agenda::Event < ApplicationRecord
scope :published, -> { where(published: true) }
scope :draft, -> { where(published: false) }
scope :for_category, -> (category_id) { joins(:categories).where(communication_website_agenda_categories: { id: category_id }).distinct }
scope :for_category, -> (category_id) {
joins(:categories)
.where(
communication_website_agenda_categories: {
id: category_id
}
)
.distinct
}
def git_path(website)
return unless website.id == communication_website_id && published
......
......@@ -5,6 +5,7 @@
<%= block_component_static block, :show_summary %>
<%= block_component_static block, :show_category %>
<%= block_component_static block, :show_status %>
title_link: "<%= block.template.title_link %>"
<% if block.template.mode == 'category' && block.template.category %>
category: "<%= block.template.category.path %>"
<% end %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment