Get rid of the home controller

This commit is contained in:
Henne Vogelsang 2014-11-14 17:24:24 +01:00
parent a41f76cca1
commit e65ca7fb58
11 changed files with 64 additions and 56 deletions

View file

@ -1,6 +1,12 @@
class ConferenceController < ApplicationController
before_filter :respond_to_options
load_and_authorize_resource find_by: :short_title
def index
@current = Conference.where('end_date >= ?', Date.current).order('start_date ASC')
@antiquated = @conferences - @current
end
def show
@keynote_speakers = @conference.keynote_speakers
end
@ -9,4 +15,12 @@ class ConferenceController < ApplicationController
@photos = @conference.photos
render 'photos', formats: [:js]
end
private
def respond_to_options
respond_to do |format|
format.html { head :ok }
end if request.options?
end
end

View file

@ -1,15 +0,0 @@
class HomeController < ApplicationController
before_filter :respond_to_options
skip_authorization_check
def index
@today = Date.current
@current = Conference.where('end_date >= ?', @today).order('start_date ASC')
end
def respond_to_options
respond_to do |format|
format.html { head :ok }
end if request.options?
end
end

View file

@ -112,7 +112,7 @@ class Ability
def guest
## Abilities for everyone, even guests (not logged in users)
can [:show, :gallery_photos], Conference do |conference|
can [:index, :show, :gallery_photos], Conference do |conference|
conference.splashpage && conference.splashpage.public == true
end

View file

@ -6,6 +6,8 @@ class Conference < ActiveRecord::Base
serialize :events_per_week, Hash
resourcify # Needed to call 'Conference.with_role' in /models/ability.rb
default_scope { order('start_date DESC') }
attr_accessible :title, :short_title, :timezone, :html_export_path,
:start_date, :end_date, :rooms_attributes, :tracks_attributes,
:dietary_choices_attributes, :use_dietary_choices,

View file

@ -0,0 +1,29 @@
.container
.row
.col-md-12
.page-header
%h2 Upcoming Conferences
- @current.each do |conference|
= render :partial => "conference_details", :locals => {:conference => conference}
-if @antiquated and @antiquated.any?
.row
.col-md-12
%p.text-right
%button{:type=>"button", :class=>"btn btn-link btn-sm", "data-toggle"=>"collapse", "data-target"=>"#antiquated", "aria-expanded"=>"true", "aria-controls"=>"antiquated"}
Older conferences
= "(#{@antiquated.count})"
%i.fa.fa-chevron-right
%i.fa.fa-chevron-down{:style => 'display: none'}
#antiquated.collapse
- @antiquated.each do |conference|
= render :partial => "conference_details", :locals => {:conference => conference}
:javascript
$('#antiquated').on('hidden.bs.collapse', function () {
$( ".fa-chevron-down" ).hide();
$( ".fa-chevron-right" ).show();
})
$('#antiquated').on('shown.bs.collapse', function () {
$( ".fa-chevron-down" ).show();
$( ".fa-chevron-right" ).hide();
})

View file

@ -1,5 +0,0 @@
.row
.col-md-12.page-header
%h2.text-center Upcoming Conferences
- @current.each do |conference|
= render :partial => "conference_details", :locals => {:conference => conference}