From f2f6bcf0cc9d204d20cd332568b51230fe875fd3 Mon Sep 17 00:00:00 2001 From: echarp <emmanuel.charpentier@free.fr> Date: Mon, 13 Oct 2014 23:55:18 +0200 Subject: [PATCH] =?UTF-8?q?Le=20filtrage=20par=20r=C3=A9gion=20n'inclue=20?= =?UTF-8?q?plus=20du=20tout=20les=20evts=20nationaux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/events_controller.rb | 6 +++--- app/models/event.rb | 6 +++--- app/views/events/show.json.jbuilder | 1 - config/locales/views/en.yml | 19 +++++++++---------- config/locales/views/fr.yml | 23 +++++++++++------------ 5 files changed, 26 insertions(+), 29 deletions(-) diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 0384ff455..914264581 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -89,10 +89,10 @@ class EventsController < ApplicationController @events = Event.moderated @events = @events.region params[:region] \ if params[:region] && params[:region] != 'all' - @events = @events.tag(params[:tag]) if params[:tag] + @events = @events.tag params[:tag] if params[:tag] end - # Use callbacks to share common setup or constraints between actions. + # Use callbacks to share common setup or constraints between actions def set_event if params[:secret].present? @event = Event.where secret: params[:secret] @@ -103,7 +103,7 @@ class EventsController < ApplicationController end # Never trust parameters from the scary internet, only allow the white list - # through. + # through def event_params params.require(:event) .permit :lock_version, :title, :start_time, :end_time, :description, diff --git a/app/models/event.rb b/app/models/event.rb index bc4fe60d9..f8a012a76 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -33,15 +33,15 @@ class Event < ActiveRecord::Base 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 + Date.new(year, 12, 31).end_of_week.end_of_day end) scope :month, (lambda do |start_date| start_date ||= Date.today where '? <= end_time and start_time <= ?', start_date.beginning_of_month.beginning_of_week, - start_date.end_of_month.end_of_week + start_date.end_of_month.end_of_week.end_of_day end) - scope :region, -> region { where 'region = ? or locality', region } + scope :region, -> region { where region: region } scope :tag, -> tag { where 'tags like ?', "%#{tag}%" } scope :geo, -> { where 'latitude is not null and longitude is not null' } diff --git a/app/views/events/show.json.jbuilder b/app/views/events/show.json.jbuilder index 43fe2bc61..d07eac2a9 100644 --- a/app/views/events/show.json.jbuilder +++ b/app/views/events/show.json.jbuilder @@ -2,4 +2,3 @@ json.extract! @event, :id, :title, :description, :start_time, :end_time, :address, :city, :region, :locality, :url, :contact, :contact, :submitter, :moderated, :tags, :secret, :decision_time, :submission_time, :moderator_mail_id, :submitter_mail_id - diff --git a/config/locales/views/en.yml b/config/locales/views/en.yml index b75f7d9f3..37402a298 100644 --- a/config/locales/views/en.yml +++ b/config/locales/views/en.yml @@ -119,17 +119,16 @@ it more readable or agreable. all_regions: All regions index: title: Feeds - quick: Each feed lists events for the coming 30 days in a given region. - If you subscribe to a regional feed, you will receive data on this - region's events, but also for all national events, like RMLL. + quick: Each feed lists events for the coming 30 days in a given region help: "Some interesting features: -\n -\n* You can limit events to a specific tag, through the `tag` parameter. This -will for example let you get a feed of all events organised by you association, -if you do remember to tag all your events with a specific tag. \n -Example: `%{tag}` -\n* You can modify the 30 days limit with the parameter `daylimit`. \n -Example: `%{daylimit}`" + \n + \n* You can limit events to a specific tag, through the `tag` + parameter. This will for example let you get a feed of all events + organised by you association, if you do remember to tag all your events + with a specific tag. \n + Example: `%{tag}` + \n* You can modify the 30 days limit with the parameter `daylimit`. \n + Example: `%{daylimit}`" stats: title: Statistics all: Validated events diff --git a/config/locales/views/fr.yml b/config/locales/views/fr.yml index 490635b6a..d5e2ce7d0 100644 --- a/config/locales/views/fr.yml +++ b/config/locales/views/fr.yml @@ -115,19 +115,18 @@ fr: index: title: Liste des flux quick: Chaque flux liste les évènements pour les 30 prochains jours en - cours dans une région donnée. En vous abonnant à un flux régional, vous - recevrez des informations sur les évènements de votre région, mais - également les évènements à portée nationale comme les RMLL. + cours dans une région donnée help: "Quelques fonctionnalités intéressantes:\n -\n -* Vous pouvez limiter les évènements à un certain tag, en passant le paramètre -`tag`. Cela permet par exemple de récupérer un flux des évènements organisés -uniquement par votre association, à partir du moment où vous pensez à marquer -tous vos évènements avec un tag précis. \n -Exemple: `%{tag}`\n -* Vous pouvez modifier la limite des 30 prochains jours des flux en utilisant -le paramètre `daylimit`. \n -Exemple: `%{daylimit}`" + \n + * Vous pouvez limiter les évènements à un certain tag, en passant le + paramètre `tag`. Cela permet par exemple de récupérer un flux des + évènements organisés uniquement par votre association, à partir du + moment où vous pensez à marquer tous vos évènements avec un tag + précis. \n + Exemple: `%{tag}`\n + * Vous pouvez modifier la limite des 30 prochains jours des flux en + utilisant le paramètre `daylimit`. \n + Exemple: `%{daylimit}`" stats: title: Statistiques all: Événements validés -- GitLab