Nest everything under /conferences/:id/ again
Would be more straightforward to work with, even if it's a bit more verbose sometimes.
This commit is contained in:
parent
798ffd8a39
commit
c6750d3a1a
|
@ -10,7 +10,7 @@ module Management
|
||||||
@conference = Conference.new(conference_params)
|
@conference = Conference.new(conference_params)
|
||||||
|
|
||||||
if @conference.save
|
if @conference.save
|
||||||
redirect_to management_conference_path(@conference, current_conference: @conference.slug)
|
redirect_to [:management, @conference]
|
||||||
else
|
else
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,21 +1,23 @@
|
||||||
module Management
|
module Management
|
||||||
class EventsController < ManagementController
|
class EventsController < ManagementController
|
||||||
before_action :require_current_conference
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@conference = find_conference
|
||||||
# TODO (2015-07-14) Scoped by conference? Why no conference_id
|
# TODO (2015-07-14) Scoped by conference? Why no conference_id
|
||||||
@events = Event.all
|
@events = Event.all
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@conference = find_conference
|
||||||
@event = Event.find(params[:id])
|
@event = Event.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@conference = find_conference
|
||||||
@event = Event.find(params[:id])
|
@event = Event.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@conference = find_conference
|
||||||
@event = Event.find(params[:id])
|
@event = Event.find(params[:id])
|
||||||
|
|
||||||
if @event.update_attributes(event_params)
|
if @event.update_attributes(event_params)
|
||||||
|
@ -27,6 +29,7 @@ module Management
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@conference = find_conference
|
||||||
@event = Event.find(params[:id])
|
@event = Event.find(params[:id])
|
||||||
@event.destroy
|
@event.destroy
|
||||||
|
|
||||||
|
@ -35,6 +38,10 @@ module Management
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def find_conference
|
||||||
|
Conference.find(params[:conference_id])
|
||||||
|
end
|
||||||
|
|
||||||
def event_params
|
def event_params
|
||||||
params.require(:event).permit(
|
params.require(:event).permit(
|
||||||
:title,
|
:title,
|
||||||
|
|
|
@ -2,10 +2,5 @@ module Management
|
||||||
class HomeController < ManagementController
|
class HomeController < ManagementController
|
||||||
def index
|
def index
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_conference
|
|
||||||
conference = Conference.find(params[:id])
|
|
||||||
redirect_to management_conference_path(conference, current_conference: conference.slug)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,22 +6,17 @@ module Management
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def default_url_options(options = {})
|
|
||||||
{ current_conference: current_conference.try(:slug) }.merge(options)
|
|
||||||
end
|
|
||||||
|
|
||||||
def current_conference?
|
def current_conference?
|
||||||
current_conference.present?
|
current_conference.present?
|
||||||
end
|
end
|
||||||
helper_method :current_conference?
|
helper_method :current_conference?
|
||||||
|
|
||||||
def current_conference
|
def current_conference
|
||||||
@current_conference ||=
|
if not @current_conference and params[:conference_id].present?
|
||||||
begin
|
@current_conference = Conference.find(params[:conference_id])
|
||||||
if params[:current_conference]
|
|
||||||
Conference.find_by_slug(params[:current_conference])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@current_conference
|
||||||
end
|
end
|
||||||
helper_method :current_conference
|
helper_method :current_conference
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
def action_buttons(record, actions = [:index, :show, :edit, :destroy])
|
def action_buttons(conference, record, actions = [:index, :show, :edit, :destroy])
|
||||||
klass = record.class
|
klass = record.class
|
||||||
output = ''
|
output = ''
|
||||||
|
|
||||||
if actions.include? :index
|
if actions.include? :index
|
||||||
output += link_to(icon(:list), [:management, klass], {
|
output += link_to(icon(:list), [:management, conference, klass], {
|
||||||
title: t('actions.index.button', models: klass.model_name.human(count: 2)),
|
title: t('actions.index.button', models: klass.model_name.human(count: 2)),
|
||||||
class: 'btn btn-info'
|
class: 'btn btn-info'
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if actions.include? :show
|
if actions.include? :show
|
||||||
output += link_to(icon(:eye), [:management, record], {
|
output += link_to(icon(:eye), [:management, conference, record], {
|
||||||
title: t('actions.view.button', model: klass.model_name.human),
|
title: t('actions.view.button', model: klass.model_name.human),
|
||||||
class: 'btn btn-info'
|
class: 'btn btn-info'
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if actions.include? :edit
|
if actions.include? :edit
|
||||||
output += link_to(icon(:edit), [:edit, :management, record], {
|
output += link_to(icon(:edit), [:edit, :management, conference, record], {
|
||||||
title: t('actions.edit.button', model: klass.model_name.human),
|
title: t('actions.edit.button', model: klass.model_name.human),
|
||||||
class: 'btn btn-primary'
|
class: 'btn btn-primary'
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if actions.include? :destroy
|
if actions.include? :destroy
|
||||||
output += link_to(icon(:trash), [:management, record], {
|
output += link_to(icon(:trash), [:management, conference, record], {
|
||||||
method: :delete,
|
method: :delete,
|
||||||
data: {confirm: t('actions.are_you_sure')},
|
data: {confirm: t('actions.are_you_sure')},
|
||||||
title: t('actions.edit.button', model: klass.model_name.human),
|
title: t('actions.edit.button', model: klass.model_name.human),
|
||||||
|
|
|
@ -16,7 +16,6 @@ class Conference < ActiveRecord::Base
|
||||||
|
|
||||||
accepts_nested_attributes_for :tracks, :halls, reject_if: :all_blank, allow_destroy: true
|
accepts_nested_attributes_for :tracks, :halls, reject_if: :all_blank, allow_destroy: true
|
||||||
|
|
||||||
before_create :slugify_title
|
|
||||||
after_create :create_call_for_participation
|
after_create :create_call_for_participation
|
||||||
|
|
||||||
def submissions_grouped_by_day
|
def submissions_grouped_by_day
|
||||||
|
@ -29,14 +28,6 @@ class Conference < ActiveRecord::Base
|
||||||
submissions.group_by { |s| s.confirmed_at.to_date }
|
submissions.group_by { |s| s.confirmed_at.to_date }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.find_by_slug(slug)
|
|
||||||
find_by(slug: slug)
|
|
||||||
end
|
|
||||||
|
|
||||||
def slugify_title
|
|
||||||
self.slug = title.gsub(/\s+/, '-')
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def start_date_is_before_end_date
|
def start_date_is_before_end_date
|
||||||
|
|
|
@ -18,7 +18,7 @@ nav.navbar.navbar-static-top.navbar-inverse role="navigation"
|
||||||
= current_conference.title
|
= current_conference.title
|
||||||
|
|
||||||
li class="#{'active' if controller_name == 'events'}"
|
li class="#{'active' if controller_name == 'events'}"
|
||||||
= link_to management_events_path do
|
= link_to [:management, current_conference, :events] do
|
||||||
=> icon 'file-text', Event.model_name.human(count: 2).mb_chars.capitalize, class: 'fa-fw'
|
=> icon 'file-text', Event.model_name.human(count: 2).mb_chars.capitalize, class: 'fa-fw'
|
||||||
li class="#{'active' if controller_name == 'sponsorship_offers'}"
|
li class="#{'active' if controller_name == 'sponsorship_offers'}"
|
||||||
= link_to '#' do
|
= link_to '#' do
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
div
|
div
|
||||||
= t Event.model_name.human(count: @conference.events.count)
|
= t Event.model_name.human(count: @conference.events.count)
|
||||||
|
|
||||||
= link_to management_events_path
|
= link_to [:management, @conference, :events] do
|
||||||
.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'
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
= @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_events_path(status: :rejected)
|
= link_to [:management, @conference, :events, {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'
|
||||||
|
@ -51,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_events_path(status: :approved)
|
= link_to [:management, @conference, :events, {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'
|
||||||
|
@ -67,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_events_path(status: :approved, confirmed: true)
|
= link_to [:management, @conference, :events, {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'
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
.row
|
.row
|
||||||
.col-lg-12
|
.col-lg-12
|
||||||
= simple_nested_form_for [:management, @event], wrapper: :horizontal_form, html: { class: 'form-horizontal' } do |f|
|
= simple_nested_form_for [:management, @conference, @event], wrapper: :horizontal_form, html: { class: 'form-horizontal' } do |f|
|
||||||
.panel.panel-primary
|
.panel.panel-primary
|
||||||
.panel-heading
|
.panel-heading
|
||||||
h1.panel-title
|
h1.panel-title
|
||||||
= t 'views.user.info'
|
= t 'views.user.info'
|
||||||
= link_to icon(:eye), [:management, @event], class: 'btn btn-xs btn-info pull-right'
|
= link_to icon(:eye), [:management, @conference, @event], class: 'btn btn-xs btn-info pull-right'
|
||||||
|
|
||||||
.panel-body
|
.panel-body
|
||||||
.row
|
.row
|
||||||
|
|
|
@ -23,4 +23,4 @@
|
||||||
|
|
||||||
td.actions
|
td.actions
|
||||||
div.btn-group.btn-group-sm
|
div.btn-group.btn-group-sm
|
||||||
= action_buttons(event, [:show, :edit, :destroy])
|
= action_buttons(@conference, event, [:show, :edit, :destroy])
|
||||||
|
|
|
@ -22,4 +22,4 @@
|
||||||
|
|
||||||
.panel-footer
|
.panel-footer
|
||||||
div.btn-group.btn-group-sm
|
div.btn-group.btn-group-sm
|
||||||
= action_buttons(@event, [:index, :edit, :destroy])
|
= action_buttons(@conference, @event, [:index, :edit, :destroy])
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
span.caret<
|
span.caret<
|
||||||
ul.dropdown-menu role="menu"
|
ul.dropdown-menu role="menu"
|
||||||
- Conference.all.each do |conference|
|
- Conference.all.each do |conference|
|
||||||
li= link_to conference.title, management_set_conference_path(conference), method: :put
|
li= link_to conference.title, [:management, conference]
|
||||||
|
|
||||||
= link_to new_management_conference_path, class: 'btn btn-lg btn-primary'
|
= link_to new_management_conference_path, class: 'btn btn-lg btn-primary'
|
||||||
=> icon 'plus', t('actions.create.button', model: Conference.model_name.human), class: 'fa-fw'
|
=> icon 'plus', t('actions.create.button', model: Conference.model_name.human), class: 'fa-fw'
|
||||||
|
|
|
@ -4,11 +4,7 @@ Rails.application.routes.draw do
|
||||||
namespace :management do
|
namespace :management do
|
||||||
root to: 'home#index'
|
root to: 'home#index'
|
||||||
|
|
||||||
put '/set_conference/:id', to: 'home#set_conference', as: :set_conference
|
resources :conferences do
|
||||||
|
|
||||||
resources :conferences
|
|
||||||
|
|
||||||
scope ':current_conference' do
|
|
||||||
resources :events
|
resources :events
|
||||||
resources :volunteers
|
resources :volunteers
|
||||||
resources :sponsorship_offers
|
resources :sponsorship_offers
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class RemoveSlugFromConferences < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
remove_column :conferences, :slug
|
||||||
|
end
|
||||||
|
end
|
|
@ -8,7 +8,7 @@ RSpec.describe Management::CallForParticipationsController, type: :controller do
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
it 'opens the CFP of the specified conference' do
|
it 'opens the CFP of the specified conference' do
|
||||||
expect do
|
expect do
|
||||||
post 'create', current_conference: conference.slug, format: :js
|
post 'create', conference_id: conference.id, format: :js
|
||||||
end.to change { Conference.find(conference.id).call_for_participation.in_progress? }.from(false).to(true)
|
end.to change { Conference.find(conference.id).call_for_participation.in_progress? }.from(false).to(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -18,7 +18,7 @@ RSpec.describe Management::CallForParticipationsController, type: :controller do
|
||||||
conference.call_for_participation.open!
|
conference.call_for_participation.open!
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
delete 'destroy', current_conference: conference.slug, format: :js
|
delete 'destroy', conference_id: conference.id, format: :js
|
||||||
end.to change { Conference.find(conference.id).call_for_participation.in_progress? }.from(true).to(false)
|
end.to change { Conference.find(conference.id).call_for_participation.in_progress? }.from(true).to(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue