diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index da0d2cb3..99317be2 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -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 diff --git a/app/models/event.rb b/app/models/event.rb index b304b7a4..b255281a 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -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 diff --git a/app/views/events/cancel.html.haml b/app/views/events/cancel.html.haml index 9a583c1a..3c53e4d2 100644 --- a/app/views/events/cancel.html.haml +++ b/app/views/events/cancel.html.haml @@ -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| diff --git a/app/views/events/edit.html.haml b/app/views/events/edit.html.haml index be22110d..251222de 100644 --- a/app/views/events/edit.html.haml +++ b/app/views/events/edit.html.haml @@ -2,7 +2,7 @@ >>> =t '.preview' -- if @event.is_moderated? +- if @event.moderated? .box %h3=t '.warning' diff --git a/app/views/moderations/edit.html.haml b/app/views/moderations/edit.html.haml index 972ee331..d5ab150b 100644 --- a/app/views/moderations/edit.html.haml +++ b/app/views/moderations/edit.html.haml @@ -3,7 +3,7 @@ >>> =t '.preview' -- if @moderation.is_moderated? +- if @moderation.moderated? .box %h3=t '.warning' diff --git a/app/views/moderations/validate.html.haml b/app/views/moderations/validate.html.haml index dca91493..e971c80b 100644 --- a/app/views/moderations/validate.html.haml +++ b/app/views/moderations/validate.html.haml @@ -4,7 +4,7 @@ =t '.title' .box - - if @event.locality == 1 + - if @event.locality? %h2.warning=t '.warning' %h2=t '.question'