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
|
||||
def index
|
||||
end
|
||||
|
||||
def set_conference
|
||||
conference = Conference.find(params[:id])
|
||||
set_current_conference(conference)
|
||||
|
||||
redirect_to [:management, conference]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,20 @@ module Management
|
|||
|
||||
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!
|
||||
head :forbidden unless current_user.admin?
|
||||
end
|
||||
|
|
|
@ -5,36 +5,27 @@ nav.navbar.navbar-static-top.navbar-inverse role="navigation"
|
|||
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
|
||||
|
||||
.navbar-collapse.collapse.navbar-inverse-collapse
|
||||
- if user_signed_in?
|
||||
- if current_conference?
|
||||
ul.nav.navbar-nav
|
||||
li.dropdown class="#{'active' if current_page?(management_path) || current_page?(management_conferences_path)}"
|
||||
a.dropdown-toggle href="#" data-toggle="dropdown"
|
||||
li
|
||||
= link_to [:management, current_conference], class: 'navbar-brand'
|
||||
=> 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_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'
|
||||
= current_conference.title
|
||||
|
||||
-# TODO Instead of this, provide a generic `yield :navigation`?
|
||||
- if @conference.present? and @conference.persisted?
|
||||
li class="#{'active' if controller_name == 'events'}"
|
||||
= link_to management_conference_events_path(@conference) do
|
||||
=> icon 'file-text', Event.model_name.human(count: 2).mb_chars.capitalize, class: 'fa-fw'
|
||||
li class="#{'active' if controller_name == 'sponsorship_offers'}"
|
||||
= link_to '#' do
|
||||
=> icon 'money', t('activerecord.models.sponsorship_offer', count: 2).mb_chars.capitalize, class: 'fa-fw'
|
||||
li class="#{'active' if controller_name == 'volunteerships'}"
|
||||
= link_to '#' do
|
||||
=> icon 'hand-o-up', t('activerecord.models.volunteership', count: 2).mb_chars.capitalize, class: 'fa-fw'
|
||||
li class="#{'active' if controller_name == 'events'}"
|
||||
= link_to management_events_path do
|
||||
=> icon 'file-text', Event.model_name.human(count: 2).mb_chars.capitalize, class: 'fa-fw'
|
||||
li class="#{'active' if controller_name == 'sponsorship_offers'}"
|
||||
= link_to '#' do
|
||||
=> icon 'money', t('activerecord.models.sponsorship_offer', count: 2).mb_chars.capitalize, class: 'fa-fw'
|
||||
li class="#{'active' if controller_name == 'volunteerships'}"
|
||||
= 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
|
||||
li.dropdown
|
||||
|
|
|
@ -16,11 +16,13 @@
|
|||
= @conference.events.count
|
||||
div
|
||||
= 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
|
||||
span.pull-left = t 'views.conference.see_details'
|
||||
span.pull-right = icon 'arrow-circle-right'
|
||||
span.clearfix
|
||||
|
||||
.col-lg-3.col-md-6
|
||||
.panel.panel-danger
|
||||
.panel-heading
|
||||
|
@ -32,11 +34,12 @@
|
|||
= @conference.events.rejected.count
|
||||
div
|
||||
= 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
|
||||
span.pull-left = t 'views.conference.see_details'
|
||||
span.pull-right = icon 'arrow-circle-right'
|
||||
span.clearfix
|
||||
|
||||
.col-lg-3.col-md-6
|
||||
.panel.panel-info
|
||||
.panel-heading
|
||||
|
@ -48,7 +51,7 @@
|
|||
= @conference.events.approved.count
|
||||
div
|
||||
= 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
|
||||
span.pull-left = t 'views.conference.see_details'
|
||||
span.pull-right = icon 'arrow-circle-right'
|
||||
|
@ -64,7 +67,7 @@
|
|||
= @conference.events.approved.confirmed.count
|
||||
div
|
||||
= 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
|
||||
span.pull-left = t 'views.conference.see_details'
|
||||
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
|
||||
|
||||
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
|
||||
member do
|
||||
put :toggle_admin
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
root 'management/conferences#index'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue