Set current conference, scope everything under it
This commit is contained in:
parent
32402b62e0
commit
296b80494b
|
@ -2,5 +2,12 @@ module Management
|
||||||
class HomeController < ManagementController
|
class HomeController < ManagementController
|
||||||
def index
|
def index
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_conference
|
||||||
|
conference = Conference.find(params[:id])
|
||||||
|
set_current_conference(conference)
|
||||||
|
|
||||||
|
redirect_to [:management, conference]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,20 @@ module Management
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def current_conference?
|
||||||
|
session[:current_conference_id] and current_conference.present?
|
||||||
|
end
|
||||||
|
helper_method :current_conference?
|
||||||
|
|
||||||
|
def current_conference
|
||||||
|
@current_conference ||= Conference.find(session[:current_conference_id])
|
||||||
|
end
|
||||||
|
helper_method :current_conference
|
||||||
|
|
||||||
|
def set_current_conference(conference)
|
||||||
|
session[:current_conference_id] = conference.id
|
||||||
|
end
|
||||||
|
|
||||||
def authorize_user!
|
def authorize_user!
|
||||||
head :forbidden unless current_user.admin?
|
head :forbidden unless current_user.admin?
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,36 +5,27 @@ nav.navbar.navbar-static-top.navbar-inverse role="navigation"
|
||||||
span.icon-bar
|
span.icon-bar
|
||||||
span.icon-bar
|
span.icon-bar
|
||||||
span.icon-bar
|
span.icon-bar
|
||||||
= link_to management_path, class: 'navbar-brand'
|
|
||||||
|
= link_to management_root_path, class: 'navbar-brand'
|
||||||
| Clarion
|
| Clarion
|
||||||
|
|
||||||
.navbar-collapse.collapse.navbar-inverse-collapse
|
.navbar-collapse.collapse.navbar-inverse-collapse
|
||||||
- if user_signed_in?
|
- if current_conference?
|
||||||
ul.nav.navbar-nav
|
ul.nav.navbar-nav
|
||||||
li.dropdown class="#{'active' if current_page?(management_path) || current_page?(management_conferences_path)}"
|
li
|
||||||
a.dropdown-toggle href="#" data-toggle="dropdown"
|
= link_to [:management, current_conference], class: 'navbar-brand'
|
||||||
=> icon 'users', class: 'fa-fw'
|
=> icon 'users', class: 'fa-fw'
|
||||||
span = Conference.model_name.human(count: 2).mb_chars.capitalize
|
= current_conference.title
|
||||||
span.caret<
|
|
||||||
ul.dropdown-menu role="menu"
|
|
||||||
- Conference.all.each do |conference|
|
|
||||||
li
|
|
||||||
= link_to conference.title, management_conference_path(conference)
|
|
||||||
li class="#{'active' if controller_name == 'sessions'}"
|
|
||||||
= link_to management_users_path do
|
|
||||||
=> icon 'user', User.model_name.human(count: 2).mb_chars.capitalize, class: 'fa-fw'
|
|
||||||
|
|
||||||
-# TODO Instead of this, provide a generic `yield :navigation`?
|
li class="#{'active' if controller_name == 'events'}"
|
||||||
- if @conference.present? and @conference.persisted?
|
= link_to management_events_path do
|
||||||
li class="#{'active' if controller_name == 'events'}"
|
=> icon 'file-text', Event.model_name.human(count: 2).mb_chars.capitalize, class: 'fa-fw'
|
||||||
= link_to management_conference_events_path(@conference) do
|
li class="#{'active' if controller_name == 'sponsorship_offers'}"
|
||||||
=> icon 'file-text', Event.model_name.human(count: 2).mb_chars.capitalize, class: 'fa-fw'
|
= link_to '#' do
|
||||||
li class="#{'active' if controller_name == 'sponsorship_offers'}"
|
=> icon 'money', t('activerecord.models.sponsorship_offer', count: 2).mb_chars.capitalize, class: 'fa-fw'
|
||||||
= link_to '#' do
|
li class="#{'active' if controller_name == 'volunteerships'}"
|
||||||
=> icon 'money', t('activerecord.models.sponsorship_offer', count: 2).mb_chars.capitalize, class: 'fa-fw'
|
= link_to '#' do
|
||||||
li class="#{'active' if controller_name == 'volunteerships'}"
|
=> icon 'hand-o-up', t('activerecord.models.volunteership', count: 2).mb_chars.capitalize, class: 'fa-fw'
|
||||||
= link_to '#' do
|
|
||||||
=> icon 'hand-o-up', t('activerecord.models.volunteership', count: 2).mb_chars.capitalize, class: 'fa-fw'
|
|
||||||
|
|
||||||
ul.nav.navbar-nav.navbar-right
|
ul.nav.navbar-nav.navbar-right
|
||||||
li.dropdown
|
li.dropdown
|
||||||
|
|
|
@ -16,11 +16,13 @@
|
||||||
= @conference.events.count
|
= @conference.events.count
|
||||||
div
|
div
|
||||||
= t Event.model_name.human(count: @conference.events.count)
|
= t Event.model_name.human(count: @conference.events.count)
|
||||||
= link_to management_conference_events_path(@conference)
|
|
||||||
|
= link_to management_events_path
|
||||||
.panel-footer.text-primary
|
.panel-footer.text-primary
|
||||||
span.pull-left = t 'views.conference.see_details'
|
span.pull-left = t 'views.conference.see_details'
|
||||||
span.pull-right = icon 'arrow-circle-right'
|
span.pull-right = icon 'arrow-circle-right'
|
||||||
span.clearfix
|
span.clearfix
|
||||||
|
|
||||||
.col-lg-3.col-md-6
|
.col-lg-3.col-md-6
|
||||||
.panel.panel-danger
|
.panel.panel-danger
|
||||||
.panel-heading
|
.panel-heading
|
||||||
|
@ -32,11 +34,12 @@
|
||||||
= @conference.events.rejected.count
|
= @conference.events.rejected.count
|
||||||
div
|
div
|
||||||
= t 'event_states.rejected', count: @conference.events.rejected.count
|
= t 'event_states.rejected', count: @conference.events.rejected.count
|
||||||
= link_to management_conference_events_path(@conference, status: :rejected)
|
= link_to management_events_path(status: :rejected)
|
||||||
.panel-footer.text-danger
|
.panel-footer.text-danger
|
||||||
span.pull-left = t 'views.conference.see_details'
|
span.pull-left = t 'views.conference.see_details'
|
||||||
span.pull-right = icon 'arrow-circle-right'
|
span.pull-right = icon 'arrow-circle-right'
|
||||||
span.clearfix
|
span.clearfix
|
||||||
|
|
||||||
.col-lg-3.col-md-6
|
.col-lg-3.col-md-6
|
||||||
.panel.panel-info
|
.panel.panel-info
|
||||||
.panel-heading
|
.panel-heading
|
||||||
|
@ -48,7 +51,7 @@
|
||||||
= @conference.events.approved.count
|
= @conference.events.approved.count
|
||||||
div
|
div
|
||||||
= t 'event_states.approved', count: @conference.events.approved.count
|
= t 'event_states.approved', count: @conference.events.approved.count
|
||||||
= link_to management_conference_events_path(@conference, status: :approved)
|
= link_to management_events_path(status: :approved)
|
||||||
.panel-footer.text-info
|
.panel-footer.text-info
|
||||||
span.pull-left = t 'views.conference.see_details'
|
span.pull-left = t 'views.conference.see_details'
|
||||||
span.pull-right = icon 'arrow-circle-right'
|
span.pull-right = icon 'arrow-circle-right'
|
||||||
|
@ -64,7 +67,7 @@
|
||||||
= @conference.events.approved.confirmed.count
|
= @conference.events.approved.confirmed.count
|
||||||
div
|
div
|
||||||
= t 'event_states.confirmed', count: @conference.events.approved.confirmed.count
|
= t 'event_states.confirmed', count: @conference.events.approved.confirmed.count
|
||||||
= link_to management_conference_events_path(@conference, status: :approved, confirmed: true)
|
= link_to management_events_path(status: :approved, confirmed: true)
|
||||||
.panel-footer.text-success
|
.panel-footer.text-success
|
||||||
span.pull-left = t 'views.conference.see_details'
|
span.pull-left = t 'views.conference.see_details'
|
||||||
span.pull-right = icon 'arrow-circle-right'
|
span.pull-right = icon 'arrow-circle-right'
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
.row
|
||||||
|
.col-lg-12
|
||||||
|
.dropdown
|
||||||
|
a.dropdown-toggle href="#" data-toggle="dropdown"
|
||||||
|
=> icon 'users', class: 'fa-fw'
|
||||||
|
span = Conference.model_name.human(count: 2).mb_chars.capitalize
|
||||||
|
span.caret<
|
||||||
|
ul.dropdown-menu role="menu"
|
||||||
|
- Conference.all.each do |conference|
|
||||||
|
li= link_to conference.title, management_set_conference_path(conference), method: :put
|
|
@ -2,20 +2,20 @@ Rails.application.routes.draw do
|
||||||
devise_for :users
|
devise_for :users
|
||||||
|
|
||||||
namespace :management do
|
namespace :management do
|
||||||
get '/', to: 'conferences#index'
|
root to: 'home#index'
|
||||||
|
|
||||||
|
put '/set_conference/:id', to: 'home#set_conference', as: :set_conference
|
||||||
|
|
||||||
|
resources :conferences
|
||||||
|
resources :events
|
||||||
|
resources :volunteers
|
||||||
|
resources :sponsorship_offers
|
||||||
|
resource :call_for_participation, only: [:create, :destroy]
|
||||||
|
|
||||||
resources :conferences do
|
|
||||||
resources :events
|
|
||||||
resources :volunteers
|
|
||||||
resources :sponsorship_offers
|
|
||||||
resource :call_for_participation, only: [:create, :destroy]
|
|
||||||
end
|
|
||||||
resources :users do
|
resources :users do
|
||||||
member do
|
member do
|
||||||
put :toggle_admin
|
put :toggle_admin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
root 'management/conferences#index'
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue