Nettoyage
This commit is contained in:
parent
cc8369a0f8
commit
98ef208564
@ -11,7 +11,7 @@ class EventsController < ApplicationController
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.html { render layout: 'iframe' if params[:iframe] }
|
||||
format.rss { @events = @events.future_in params[:daylimit] }
|
||||
format.rss { @events = @events.future.in params[:daylimit] }
|
||||
format.ics { @events = @events.last_year.order :id }
|
||||
format.xml { @events = @events.includes(:related_region).order :id }
|
||||
end
|
||||
|
@ -22,21 +22,19 @@ class Event < ActiveRecord::Base
|
||||
|
||||
scope :moderated, -> { where moderated: true }
|
||||
scope :unmoderated, -> { where moderated: false }
|
||||
scope :last_year, -> { where '? <= end_time', 360.days.ago }
|
||||
scope :last_year, -> { where '? <= end_time', 1.year.ago }
|
||||
scope :past, -> { where 'start_time <= ?', DateTime.now }
|
||||
scope :future, -> { where '? <= end_time', DateTime.now }
|
||||
scope :future_in, (lambda do |days = 30|
|
||||
future.where('end_time <= ?', days.to_i.days.from_now).order :start_time
|
||||
end)
|
||||
scope :in, -> days { where 'end_time <= ?', (days || 30).to_i.days.from_now }
|
||||
scope :year, (lambda do |year|
|
||||
where '? <= end_time and start_time <= ?',
|
||||
Date.new(year, 1, 1).beginning_of_week,
|
||||
Date.new(year, 12, 31).end_of_week
|
||||
end)
|
||||
scope :month, (lambda do |start_date|
|
||||
start_date ||= Date.today.beginning_of_month
|
||||
start_date ||= Date.today
|
||||
where '? <= end_time and start_time <= ?',
|
||||
start_date.beginning_of_week,
|
||||
start_date.beginning_of_month.beginning_of_week,
|
||||
start_date.end_of_month.end_of_week
|
||||
end)
|
||||
scope :region, -> region { where 'region = ? or locality', region }
|
||||
|
@ -12,7 +12,7 @@
|
||||
- (1..12).each do |i|
|
||||
- params[:start_date] = "#{params[:year]}-#{i}-01"
|
||||
|
||||
= month_calendar events: @events,
|
||||
= month_calendar day_names: 'date.day_names', events: @events,
|
||||
previous_link: nil, next_link: nil,
|
||||
title: ->(start_date) { raw link_to l(start_date, format: :month),
|
||||
root_url(start_date: start_date), class: 'month_selector' } do |date, events|
|
||||
@ -28,7 +28,7 @@
|
||||
- else
|
||||
-# One month calendar
|
||||
- @events = @events.month params[:start_date].try :to_date
|
||||
= month_calendar events: @events,
|
||||
= month_calendar day_names: 'date.day_names', events: @events,
|
||||
title: ->(start_date) { raw "#{I18n.t('date.month_names')[start_date.month]} #{link_to start_date.year,
|
||||
root_url(year: start_date.year)}" },
|
||||
previous_link: ->(param, date_range) { link_to '<<',
|
||||
|
@ -1,13 +1,5 @@
|
||||
fr:
|
||||
date:
|
||||
abbr_day_names:
|
||||
- Dimanche
|
||||
- Lundi
|
||||
- Mardi
|
||||
- Mercredi
|
||||
- Jeudi
|
||||
- Vendredi
|
||||
- Samedi
|
||||
formats:
|
||||
long: "%A %d %B %Y"
|
||||
month: "%B %Y"
|
||||
|
@ -86,10 +86,11 @@ class EventTest < ActiveSupport::TestCase
|
||||
assert @event.moderated?, @event.errors.messages
|
||||
end
|
||||
|
||||
test 'named scope future_in' do
|
||||
assert Event.respond_to? :future_in
|
||||
assert_match(/<= end_time/, Event.future_in.where_values[0])
|
||||
assert_match(/end_time <=/, Event.future_in.where_values[1])
|
||||
test 'named scope future.in' do
|
||||
assert Event.respond_to? :future
|
||||
assert Event.respond_to? :in
|
||||
assert_match(/<= end_time/, Event.future.in(nil).where_values[0])
|
||||
assert_match(/end_time <=/, Event.future.in(nil).where_values[1])
|
||||
end
|
||||
|
||||
test 'named scope year' do
|
||||
|
Loading…
Reference in New Issue
Block a user