Les colonnes booléennes sont bien gérées par rails, mais il faut les utiliser avec ?
This commit is contained in:
parent
12c621df2b
commit
8afe5848da
@ -4,7 +4,7 @@ class EventsController < ApplicationController
|
||||
before_filter :set_mailer_host
|
||||
|
||||
def index
|
||||
@events = Event.all_moderated
|
||||
@events = Event.moderated
|
||||
if params[:region] && params[:region].present? && params[:region] != 'all'
|
||||
@events = @events.region params[:region]
|
||||
end
|
||||
@ -108,7 +108,7 @@ class EventsController < ApplicationController
|
||||
if params[:secret].present?
|
||||
@event = Event.where secret: params[:secret]
|
||||
else
|
||||
@event = Event.all_moderated
|
||||
@event = Event.moderated
|
||||
end
|
||||
@event = @event.find params[:id]
|
||||
end
|
||||
|
@ -1,6 +1,3 @@
|
||||
# TODO migrate moderated column to a SQL bool type
|
||||
# TODO migrate locality column to a SQL bool type
|
||||
|
||||
class Event < ActiveRecord::Base
|
||||
extend SimpleCalendar
|
||||
|
||||
@ -14,7 +11,7 @@ class Event < ActiveRecord::Base
|
||||
validates :submitter, email: true
|
||||
|
||||
|
||||
scope :all_moderated, -> { where moderated: 1 }
|
||||
scope :moderated, -> { where moderated: true }
|
||||
scope :past, -> { where('end_time < now()').order(start_time: :desc) }
|
||||
scope :future, -> { where('end_time >= now()').order(start_time: :asc) }
|
||||
scope :future_30, -> {
|
||||
@ -30,7 +27,7 @@ class Event < ActiveRecord::Base
|
||||
start_date.beginning_of_week,
|
||||
start_date.next_month.end_of_week
|
||||
}
|
||||
scope :region, -> region { where 'region = ? or locality = 1', region }
|
||||
scope :region, -> region { where 'region = ? or locality', region }
|
||||
scope :tag, -> tag { where 'tags like ?', "%#{tag}%" }
|
||||
|
||||
|
||||
@ -52,8 +49,4 @@ class Event < ActiveRecord::Base
|
||||
def same_day?
|
||||
start_time.to_date == end_time.to_date
|
||||
end
|
||||
|
||||
def is_moderated?
|
||||
moderated == 1
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,7 @@
|
||||
=t '.title'
|
||||
|
||||
.box
|
||||
- if @event.is_moderated?
|
||||
- if @event.moderated?
|
||||
%h3=t '.already_moderated'
|
||||
|
||||
= form_for @event, method: :delete do |f|
|
||||
|
@ -2,7 +2,7 @@
|
||||
>>>
|
||||
=t '.preview'
|
||||
|
||||
- if @event.is_moderated?
|
||||
- if @event.moderated?
|
||||
.box
|
||||
%h3=t '.warning'
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
>>>
|
||||
=t '.preview'
|
||||
|
||||
- if @moderation.is_moderated?
|
||||
- if @moderation.moderated?
|
||||
.box
|
||||
%h3=t '.warning'
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
=t '.title'
|
||||
|
||||
.box
|
||||
- if @event.locality == 1
|
||||
- if @event.locality?
|
||||
%h2.warning=t '.warning'
|
||||
%h2=t '.question'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user