Skip to content
Snippets Groups Projects
Commit ecc6e47d authored by Arnaud Levy's avatar Arnaud Levy
Browse files

agenda block layout large

parent 8aac7c39
No related branches found
No related tags found
No related merge requests found
app/assets/images/communication/blocks/templates/agenda/large.png

112 KiB

class Communication::Block::Template::Agenda < Communication::Block::Template::Base
has_layouts [:grid, :list]
AUTHORIZED_SCOPES = [
'future_or_present',
'future',
'present',
'archive'
]
has_layouts [:grid, :list, :large]
has_component :description, :rich_text
has_component :quantity, :number, options: 3
......@@ -17,25 +24,9 @@ class Communication::Block::Template::Agenda < Communication::Block::Template::B
protected
def events_with_time_scope
events = block.about&.website
.events
.for_language(block.language)
.published
.limit(quantity)
# Whitelist for security
# (not very elegant though)
case time
when 'future_or_present'
events.future_or_present
when 'future'
events.future
when 'present'
events.present
when 'archive'
events.archive
else
events
end
events = website.events.for_language(block.language).published
events = events.send(time) if time.in? AUTHORIZED_SCOPES
events = events.limit(quantity)
end
end
......@@ -64,9 +64,10 @@ class Communication::Website::Agenda::Event < ApplicationRecord
scope :recent, -> { order(:updated_at).limit(5) }
scope :published, -> { where(published: true) }
scope :draft, -> { where(published: false) }
scope :future, -> { where('from_day > :today', today: Date.today).ordered_asc }
scope :future_or_present, -> { where('from_day >= :today', today: Date.today).ordered_asc }
scope :present, -> { where('(from_day >= :today AND to_day IS NULL) OR (from_day >= :today AND to_day <= :today)', today: Date.today).ordered_asc }
scope :present, -> { where('(from_day <= :today AND to_day IS NULL) OR (from_day <= :today AND to_day >= :today)', today: Date.today).ordered_asc }
scope :archive, -> { where('to_day < :today', today: Date.today).ordered_desc }
scope :past, -> { archive }
......
......@@ -58,7 +58,10 @@ en:
description: Events are presented as a grid, from left to right and top to bottom, with constant size cropped images.
list:
label: List
description: A list of posts with small images the same width.
description: A list of events with dates, small images, all the same width.
large:
label: Grand
description: Each event is presented in majesty, across the full width available, with a large image.
edit:
description:
label: Description
......
......@@ -59,6 +59,9 @@ fr:
list:
label: Liste
description: Une liste d'événements avec de petites images à la même largeur.
large:
label: Grand
description: Chaque événement est présenté en majesté, sur toute la largeur disponible avec une grande image.
edit:
description:
label: Description
......
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