mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Get rid of the home controller
This commit is contained in:
parent
a41f76cca1
commit
e65ca7fb58
11 changed files with 64 additions and 56 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
29
app/views/conference/index.html.haml
Normal file
29
app/views/conference/index.html.haml
Normal 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();
|
||||
})
|
||||
|
|
@ -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}
|
||||
|
|
@ -96,7 +96,7 @@ Osem::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :conference, only: [:show] do
|
||||
resources :conference, only: [:index, :show] do
|
||||
resources :proposal do
|
||||
resources :commercials, except: [:show, :index]
|
||||
resources :event_attachment, controller: 'event_attachments'
|
||||
|
|
@ -138,5 +138,5 @@ Osem::Application.routes.draw do
|
|||
|
||||
get '/admin' => redirect('/admin/conference')
|
||||
|
||||
root to: 'home#index', via: [:get, :options]
|
||||
root to: 'conference#index', via: [:get, :options]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,6 +3,13 @@ require 'spec_helper'
|
|||
describe ConferenceController do
|
||||
let(:conference) { create(:conference, splashpage: create(:splashpage, public: true)) }
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'Response code is 200' do
|
||||
get :index
|
||||
expect(response.response_code).to eq(200)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
context 'conference made public' do
|
||||
it 'assigns the requested conference to conference' do
|
||||
|
|
@ -28,4 +35,12 @@ describe ConferenceController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'OPTIONS #index' do
|
||||
it 'Response code is 200' do
|
||||
process :index, 'OPTIONS'
|
||||
expect(response.response_code).to eq(200)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe HomeController do
|
||||
let(:conference) { create(:conference) }
|
||||
describe 'GET #index' do
|
||||
it 'Response code is 200' do
|
||||
get :index
|
||||
expect(response.response_code).to eq(200)
|
||||
end
|
||||
|
||||
it 'Assigns conference' do
|
||||
get :index
|
||||
expect(assigns(:current)).to eq [conference]
|
||||
end
|
||||
|
||||
it 'Assigns only pending conferences' do
|
||||
create(:conference,
|
||||
end_date: Date.today - 7,
|
||||
start_date: Date.today - 14)
|
||||
get :index
|
||||
expect(assigns(:current)).to eq [conference]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'OPTIONS #index' do
|
||||
it 'Response code is 200' do
|
||||
process :index, 'OPTIONS'
|
||||
expect(response.response_code).to eq(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'home/index' do
|
||||
describe 'conference/index' do
|
||||
it 'renders _conference partial for each conference' do
|
||||
allow(view).to receive(:date_string).and_return('January 17 - 21 2014')
|
||||
assign(:current, [create(:conference), create(:conference)])
|
||||
Loading…
Add table
Add a link
Reference in a new issue