commit
566382eca8
128 changed files with 1710 additions and 908 deletions
2
Gemfile
2
Gemfile
|
|
@ -23,6 +23,8 @@ gem 'omniauth-github'
|
||||||
|
|
||||||
# Use cancancan as authorization framework
|
# Use cancancan as authorization framework
|
||||||
gem 'cancancan'
|
gem 'cancancan'
|
||||||
|
# Use rolify to set roles
|
||||||
|
gem 'rolify'
|
||||||
|
|
||||||
# Use transitions as state machine
|
# Use transitions as state machine
|
||||||
gem 'transitions', :require => %w( transitions active_record/transitions )
|
gem 'transitions', :require => %w( transitions active_record/transitions )
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,7 @@ GEM
|
||||||
request_store (1.0.6)
|
request_store (1.0.6)
|
||||||
rest-client (1.6.7)
|
rest-client (1.6.7)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
|
rolify (3.4.0)
|
||||||
rspec (3.0.0)
|
rspec (3.0.0)
|
||||||
rspec-core (~> 3.0.0)
|
rspec-core (~> 3.0.0)
|
||||||
rspec-expectations (~> 3.0.0)
|
rspec-expectations (~> 3.0.0)
|
||||||
|
|
@ -445,6 +446,7 @@ DEPENDENCIES
|
||||||
rails-observers
|
rails-observers
|
||||||
rdoc-generator-fivefish
|
rdoc-generator-fivefish
|
||||||
redcarpet
|
redcarpet
|
||||||
|
rolify
|
||||||
rspec-activemodel-mocks
|
rspec-activemodel-mocks
|
||||||
rspec-rails
|
rspec-rails
|
||||||
rubocop
|
rubocop
|
||||||
|
|
|
||||||
|
|
@ -168,3 +168,7 @@ body {
|
||||||
-webkit-flex: 2;
|
-webkit-flex: 2;
|
||||||
flex: 2;
|
flex: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.table20 {
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
|
|
|
||||||
17
app/controllers/admin/base_controller.rb
Normal file
17
app/controllers/admin/base_controller.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
module Admin
|
||||||
|
class BaseController < ApplicationController
|
||||||
|
before_filter :verify_user_admin
|
||||||
|
|
||||||
|
def verify_user_admin
|
||||||
|
if (current_user.nil?)
|
||||||
|
redirect_to new_user_session_path
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
unless (current_user.has_role? :organizer, :any) || (current_user.has_role? :cfp, :any) ||
|
||||||
|
(current_user.has_role? :info_desk, :any) ||
|
||||||
|
(current_user.has_role? :volunteers_coordinator, :any) || current_user.is_admin
|
||||||
|
raise CanCan::AccessDenied.new('You are not authorized to access this area!')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
module Admin
|
module Admin
|
||||||
class CallforpapersController < ApplicationController
|
class CallforpapersController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
# load_and_authorize_resource :cfp, class: 'CallForPapers', through: :conference
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
authorize! :show, CallForPapers.new(conference_id: @conference.id)
|
||||||
@cfp = @conference.call_for_papers
|
@cfp = @conference.call_for_papers
|
||||||
if @cfp.nil?
|
if @cfp.nil?
|
||||||
@cfp = CallForPapers.new
|
@cfp = CallForPapers.new
|
||||||
|
|
@ -10,6 +12,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
authorize! :update, @conference.call_for_papers
|
||||||
@cfp = @conference.call_for_papers
|
@cfp = @conference.call_for_papers
|
||||||
@cfp.assign_attributes(params[:call_for_papers])
|
@cfp.assign_attributes(params[:call_for_papers])
|
||||||
send_mail_on_schedule_public = @cfp.notify_on_schedule_public?
|
send_mail_on_schedule_public = @cfp.notify_on_schedule_public?
|
||||||
|
|
@ -30,6 +33,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
authorize! :update, CallForPapers.new(conference_id: @conference.id)
|
||||||
@cfp = CallForPapers.new(params[:call_for_papers])
|
@cfp = CallForPapers.new(params[:call_for_papers])
|
||||||
if @cfp.valid?
|
if @cfp.valid?
|
||||||
@cfp.save
|
@cfp.save
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
module Admin
|
module Admin
|
||||||
class CampaignsController < ApplicationController
|
class CampaignsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource :campaign, through: :conference
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
authorize! :index, Campaign.new(conference_id: @conference.id)
|
||||||
@campaigns = @conference.campaigns
|
@campaigns = @conference.campaigns
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
@campaign.attributes = params[:campaign]
|
||||||
@campaign = @conference.campaigns.new(params[:campaign])
|
|
||||||
@campaign.conference_id = @conference.id
|
|
||||||
|
|
||||||
if @conference.save
|
if @conference.save
|
||||||
redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title),
|
redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title),
|
||||||
|
|
@ -22,20 +21,11 @@ module Admin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new; end
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
|
||||||
@campaign = @conference.campaigns.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def edit
|
def edit; end
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
|
||||||
@campaign = Campaign.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
|
||||||
@campaign = Campaign.find(params[:id])
|
|
||||||
|
|
||||||
if @campaign.update_attributes(params[:campaign])
|
if @campaign.update_attributes(params[:campaign])
|
||||||
redirect_to(admin_conference_campaigns_path(
|
redirect_to(admin_conference_campaigns_path(
|
||||||
conference_id: @conference.short_title),
|
conference_id: @conference.short_title),
|
||||||
|
|
@ -50,8 +40,6 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
|
||||||
@campaign = Campaign.find(params[:id])
|
|
||||||
if @campaign.destroy
|
if @campaign.destroy
|
||||||
redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title),
|
redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title),
|
||||||
notice: "Campaign '#{@campaign.name}' successfully deleted.")
|
notice: "Campaign '#{@campaign.name}' successfully deleted.")
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module Admin
|
module Admin
|
||||||
class CommercialsController < ApplicationController
|
class CommercialsController < Admin::BaseController
|
||||||
before_action :set_conference
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
before_action :set_commercial, only: [:edit, :update, :destroy]
|
load_and_authorize_resource through: :conference, except: [:new, :create]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@commercials = @conference.commercials
|
@commercials = @conference.commercials
|
||||||
|
|
@ -9,13 +9,14 @@ module Admin
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@commercial = @conference.commercials.build
|
@commercial = @conference.commercials.build
|
||||||
|
authorize! :create, @conference.commercials.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@commercial = @conference.commercials.build(commercial_params)
|
@commercial = @conference.commercials.build(commercial_params)
|
||||||
|
authorize! :create, @commercial
|
||||||
|
|
||||||
if @commercial.save
|
if @commercial.save
|
||||||
redirect_to admin_conference_commercials_path,
|
redirect_to admin_conference_commercials_path,
|
||||||
|
|
@ -43,14 +44,6 @@ module Admin
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_commercial
|
|
||||||
@commercial = @conference.commercials.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_conference
|
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def commercial_params
|
def commercial_params
|
||||||
#params.require(:commercial).permit(:commercial_id, :commercial_type)
|
#params.require(:commercial).permit(:commercial_id, :commercial_type)
|
||||||
params[:commercial]
|
params[:commercial]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
module Admin
|
module Admin
|
||||||
class ConferenceController < ApplicationController
|
class ConferenceController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_resource :user, only: [:remove_user]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
# Redirect to new form if there is no conference
|
# Redirect to new form if there is no conference
|
||||||
|
|
@ -63,8 +64,11 @@ module Admin
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@conference = Conference.new(params[:conference])
|
@conference = Conference.new(params[:conference])
|
||||||
|
|
||||||
if @conference.valid?
|
if @conference.valid?
|
||||||
@conference.save
|
@conference.save
|
||||||
|
# user that creates the conference becomes organizer of that conference
|
||||||
|
current_user.add_role :organizer, @conference
|
||||||
redirect_to(admin_conference_path(id: @conference.short_title),
|
redirect_to(admin_conference_path(id: @conference.short_title),
|
||||||
notice: 'Conference was successfully created.')
|
notice: 'Conference was successfully created.')
|
||||||
else
|
else
|
||||||
|
|
@ -108,6 +112,7 @@ module Admin
|
||||||
if @conference.update_attributes(params[:conference])
|
if @conference.update_attributes(params[:conference])
|
||||||
Mailbot.delay.conference_date_update_mail(@conference) if notify_on_conf_dates_updates
|
Mailbot.delay.conference_date_update_mail(@conference) if notify_on_conf_dates_updates
|
||||||
Mailbot.delay.conference_registration_date_update_mail(@conference) if notify_on_conf_reg_dates_updates
|
Mailbot.delay.conference_registration_date_update_mail(@conference) if notify_on_conf_reg_dates_updates
|
||||||
|
|
||||||
redirect_to(edit_admin_conference_path(id: @conference.short_title),
|
redirect_to(edit_admin_conference_path(id: @conference.short_title),
|
||||||
notice: 'Conference was successfully updated.')
|
notice: 'Conference was successfully updated.')
|
||||||
else
|
else
|
||||||
|
|
@ -186,12 +191,47 @@ module Admin
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@conferences = Conference.all
|
@conferences = Conference.all
|
||||||
@conference = Conference.find_by(short_title: params[:id])
|
|
||||||
@date_string = date_string(@conference.start_date, @conference.end_date)
|
@date_string = date_string(@conference.start_date, @conference.end_date)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.json { render json: @conference.to_json }
|
format.json { render json: @conference.to_json }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def roles
|
||||||
|
@user = User.new
|
||||||
|
@roles = Role::ACTIONABLES + Role::LABELS
|
||||||
|
|
||||||
|
params[:user] ? (@selection = params[:user][:roles].parameterize.underscore) : (@selection = 'organizer')
|
||||||
|
@role_users = get_users(@selection)
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_user
|
||||||
|
@user = User.find_by(email: params[:user][:email])
|
||||||
|
@selection = params[:role].parameterize.underscore
|
||||||
|
@user.add_role @selection.to_sym, @conference
|
||||||
|
|
||||||
|
@role_users = get_users(@selection)
|
||||||
|
render 'roles', formats: [:js]
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_user
|
||||||
|
@selection = params[:role]
|
||||||
|
@user.revoke @selection.to_sym, @conference
|
||||||
|
|
||||||
|
@role_users = get_users(@selection)
|
||||||
|
render 'roles', formats: [:js]
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def get_users(role_name)
|
||||||
|
@role_users = {}
|
||||||
|
# Initialize @role variable, so that view can show the role description
|
||||||
|
@role = Role.where(name: role_name, resource: @conference)
|
||||||
|
@role.blank? ? @role_users[role_name] = @role : @role_users[role_name] = @role.first.users
|
||||||
|
|
||||||
|
@role_users
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
module Admin
|
module Admin
|
||||||
class ContactsController < ApplicationController
|
class ContactsController < Admin::BaseController
|
||||||
before_action :set_conference
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
before_action :set_conference
|
load_and_authorize_resource through: :conference, singleton: true
|
||||||
before_action :set_contact, only: [:edit, :update]
|
|
||||||
|
# GET /:conference/contact
|
||||||
|
def show; end
|
||||||
|
|
||||||
# GET /:conference/contact/edit
|
# GET /:conference/contact/edit
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
# PATCH/PUT /:conference/contact
|
# PATCH/PUT /:conference/contact
|
||||||
def update
|
def update
|
||||||
|
|
@ -19,15 +20,6 @@ module Admin
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
|
||||||
def set_contact
|
|
||||||
@contact = @conference.contact
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_conference
|
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
# Only allow a trusted parameter "white list" through.
|
# Only allow a trusted parameter "white list" through.
|
||||||
def contact_params
|
def contact_params
|
||||||
# params.require(:contact).permit(:social_tag, :email, :facebook, :googleplus, :twitter, :instagram, :public)
|
# params.require(:contact).permit(:social_tag, :email, :facebook, :googleplus, :twitter, :instagram, :public)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
module Admin
|
module Admin
|
||||||
class DietchoicesController < ApplicationController
|
class DietchoicesController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource :dietary_choice, through: :conference
|
||||||
|
|
||||||
def show
|
def show
|
||||||
render :diets_list
|
render :diets_list
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
module Admin
|
module Admin
|
||||||
class DifficultyLevelsController < ApplicationController
|
class DifficultyLevelsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
authorize_resource through: :conference
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
authorize! :index, DifficultyLevel.new(conference_id: @conference.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
module Admin
|
module Admin
|
||||||
class EmailsController < ApplicationController
|
class EmailsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource class: EmailSettings
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@conference.email_settings.update_attributes(params[:email_settings])
|
@conference.email_settings.update_attributes(params[:email_settings])
|
||||||
|
|
@ -10,6 +11,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
authorize! :index, @conference.email_settings
|
||||||
@settings = @conference.email_settings
|
@settings = @conference.email_settings
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
module Admin
|
module Admin
|
||||||
class EventtypesController < ApplicationController
|
class EventTypesController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
authorize_resource :event_type, through: :conference
|
||||||
|
|
||||||
|
def index
|
||||||
|
authorize! :index, EventType.new(conference_id: @conference.id)
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
render :eventtypes
|
render :eventtypes
|
||||||
|
|
@ -8,11 +13,11 @@ module Admin
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@conference.update_attributes!(params[:conference])
|
@conference.update_attributes!(params[:conference])
|
||||||
redirect_to(admin_conference_eventtypes_path(
|
redirect_to(admin_conference_event_types_path(
|
||||||
conference_id: @conference.short_title),
|
conference_id: @conference.short_title),
|
||||||
notice: 'Event types were successfully updated.')
|
notice: 'Event types were successfully updated.')
|
||||||
rescue => e
|
rescue => e
|
||||||
redirect_to(admin_conference_eventtypes_path(
|
redirect_to(admin_conference_event_types_path(
|
||||||
conference_id: @conference.short_title),
|
conference_id: @conference.short_title),
|
||||||
alert: "Event types update failed: #{e.message}")
|
alert: "Event types update failed: #{e.message}")
|
||||||
end
|
end
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
module Admin
|
module Admin
|
||||||
class EventsController < ApplicationController
|
class EventsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource :event, through: :conference
|
||||||
|
|
||||||
before_action :get_event, except: [:index, :create]
|
before_action :get_event, except: [:index, :create]
|
||||||
|
|
||||||
|
|
@ -13,6 +14,8 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
authorize! :index, @conference.events.build
|
||||||
|
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||||
@events = @conference.events
|
@events = @conference.events
|
||||||
@tracks = @conference.tracks
|
@tracks = @conference.tracks
|
||||||
@machine_states = @events.state_machine.states.map
|
@machine_states = @events.state_machine.states.map
|
||||||
|
|
@ -121,8 +124,7 @@ module Admin
|
||||||
redirect_back_or_to(admin_conference_event_path(@conference.short_title, @event))
|
redirect_back_or_to(admin_conference_event_path(@conference.short_title, @event))
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create; end
|
||||||
end
|
|
||||||
|
|
||||||
def accept
|
def accept
|
||||||
send_mail = @event.conference.email_settings.send_on_accepted
|
send_mail = @event.conference.email_settings.send_on_accepted
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
module Admin
|
module Admin
|
||||||
class LodgingsController < ApplicationController
|
class LodgingsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource :venue, through: :conference, singleton: true
|
||||||
|
authorize_resource :lodging, through: :venue
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@venue = @conference.venue
|
authorize! :update, Lodging.new(venue_id: @venue.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show; end
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@venue = @conference.venue
|
|
||||||
if @venue.update_attributes(params[:venue])
|
if @venue.update_attributes(params[:venue])
|
||||||
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
|
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
|
||||||
notice: 'Lodgings were successfully updated.')
|
notice: 'Lodgings were successfully updated.')
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module Admin
|
module Admin
|
||||||
class PhotosController < ApplicationController
|
class PhotosController < Admin::BaseController
|
||||||
before_action :set_conference
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
before_action :set_photo, only: [:edit, :update, :destroy]
|
load_and_authorize_resource through: :conference
|
||||||
|
|
||||||
# GET /admin/photos
|
# GET /admin/photos
|
||||||
def index
|
def index
|
||||||
|
|
@ -14,8 +14,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /admin/photos/1/edit
|
# GET /admin/photos/1/edit
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
# POST /admin/photos
|
# POST /admin/photos
|
||||||
def create
|
def create
|
||||||
|
|
@ -46,16 +45,6 @@ module Admin
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
|
||||||
def set_conference
|
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
|
||||||
def set_photo
|
|
||||||
@photo = Photo.find_by(id: params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
# Only allow a trusted parameter "white list" through.
|
# Only allow a trusted parameter "white list" through.
|
||||||
def photo_params
|
def photo_params
|
||||||
params[:photo]
|
params[:photo]
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,24 @@
|
||||||
module Admin
|
module Admin
|
||||||
class QuestionsController < ApplicationController
|
class QuestionsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource through: :conference, except: [:new, :create]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
authorize! :index, Question.new(conference_id: @conference.id)
|
||||||
@questions = Question.where(global: true).all | Question.where(conference_id: @conference.id)
|
@questions = Question.where(global: true).all | Question.where(conference_id: @conference.id)
|
||||||
@questions_conference = @conference.questions
|
@questions_conference = @conference.questions
|
||||||
@new_question = @conference.questions.new
|
@new_question = @conference.questions.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
@question = Question.new(conference_id: @conference.id)
|
||||||
@new_question = @conference.questions.new
|
authorize! :create, @question
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
|
||||||
@question = @conference.questions.new(params[:question])
|
@question = @conference.questions.new(params[:question])
|
||||||
@question.conference_id = @conference.id
|
@question.conference_id = @conference.id
|
||||||
|
authorize! :create, @question
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @conference.save
|
if @conference.save
|
||||||
|
|
@ -31,19 +32,13 @@ module Admin
|
||||||
|
|
||||||
# GET questions/1/edit
|
# GET questions/1/edit
|
||||||
def edit
|
def edit
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
if @question.global
|
||||||
@question = Question.find(params[:id])
|
|
||||||
|
|
||||||
if @question.global == true && !has_role?(current_user, "Admin")
|
|
||||||
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), alert: "Sorry, you cannot edit global questions. Create a new one.")
|
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), alert: "Sorry, you cannot edit global questions. Create a new one.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT questions/1
|
# PUT questions/1
|
||||||
def update
|
def update
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
|
||||||
@question = Question.find(params[:id])
|
|
||||||
|
|
||||||
if @question.update_attributes(params[:question])
|
if @question.update_attributes(params[:question])
|
||||||
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Question '#{@question.title}' for #{@conference.short_title} successfully updated.")
|
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Question '#{@question.title}' for #{@conference.short_title} successfully updated.")
|
||||||
else
|
else
|
||||||
|
|
@ -53,8 +48,7 @@ module Admin
|
||||||
|
|
||||||
# Update questions used for the conference
|
# Update questions used for the conference
|
||||||
def update_conference
|
def update_conference
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
authorize! :update, Question.new(conference_id: @conference.id)
|
||||||
|
|
||||||
if @conference.update_attributes(params[:conference])
|
if @conference.update_attributes(params[:conference])
|
||||||
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Questions for #{@conference.short_title} successfully updated.")
|
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Questions for #{@conference.short_title} successfully updated.")
|
||||||
else
|
else
|
||||||
|
|
@ -64,19 +58,17 @@ module Admin
|
||||||
|
|
||||||
# DELETE questions/1
|
# DELETE questions/1
|
||||||
def destroy
|
def destroy
|
||||||
if has_role?(current_user, "Admin")
|
if can? :destroy, @question
|
||||||
@question = Question.find(params[:id])
|
|
||||||
|
|
||||||
# Do not delete global questions
|
# Do not delete global questions
|
||||||
if @question.global == false
|
if !@question.global
|
||||||
|
|
||||||
# Delete question and its answers
|
# Delete question and its answers
|
||||||
begin
|
begin
|
||||||
Question.transaction do
|
Question.transaction do
|
||||||
|
|
||||||
@question.delete
|
@question.destroy
|
||||||
@question.answers.each do |a|
|
@question.answers.each do |a|
|
||||||
a.delete
|
a.destroy
|
||||||
end
|
end
|
||||||
flash[:notice] = "Deleted question: #{@question.title} and its answers: #{@question.answers.map {|a| a.title}.join ','}"
|
flash[:notice] = "Deleted question: #{@question.title} and its answers: #{@question.answers.map {|a| a.title}.join ','}"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
module Admin
|
module Admin
|
||||||
class RegistrationsController < ApplicationController
|
class RegistrationsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource through: :conference
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
authorize! :show, Registration.new(conference_id: @conference.id)
|
||||||
session[:return_to] ||= request.referer
|
session[:return_to] ||= request.referer
|
||||||
@pdf_filename = "#{@conference.title}.pdf"
|
@pdf_filename = "#{@conference.title}.pdf"
|
||||||
@registrations = @conference.registrations.includes(:user)
|
@registrations = @conference.registrations.includes(:user)
|
||||||
|
|
@ -12,7 +14,6 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def change_field
|
def change_field
|
||||||
@registration = Registration.find(params[:id])
|
|
||||||
field = params[:view_field]
|
field = params[:view_field]
|
||||||
if @registration.send(field.to_sym)
|
if @registration.send(field.to_sym)
|
||||||
@registration.update_attribute(:"#{field}", 0)
|
@registration.update_attribute(:"#{field}", 0)
|
||||||
|
|
@ -26,12 +27,10 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@registration = @conference.registrations.where('id = ?', params[:id]).first
|
|
||||||
@user = User.where('id = ?', @registration.user_id).first
|
@user = User.where('id = ?', @registration.user_id).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@registration = @conference.registrations.where('id = ?', params[:id]).first
|
|
||||||
@user = User.where('id = ?', @registration.user_id).first
|
@user = User.where('id = ?', @registration.user_id).first
|
||||||
begin
|
begin
|
||||||
@user.update_attributes!(params[:registration][:user_attributes])
|
@user.update_attributes!(params[:registration][:user_attributes])
|
||||||
|
|
@ -55,6 +54,7 @@ module Admin
|
||||||
def new
|
def new
|
||||||
@user = User.new
|
@user = User.new
|
||||||
@registration = @user.registrations.new
|
@registration = @user.registrations.new
|
||||||
|
@registration.conference_id = @conference.id
|
||||||
@supporter_registration = @conference.supporter_registrations.new
|
@supporter_registration = @conference.supporter_registrations.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -97,7 +97,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if has_role?(current_user, 'Admin')
|
if can? :destroy, @registration
|
||||||
registration = @conference.registrations.where(id: params[:id]).first
|
registration = @conference.registrations.where(id: params[:id]).first
|
||||||
user = User.where('id = ?', registration.user_id).first
|
user = User.where('id = ?', registration.user_id).first
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
module Admin
|
module Admin
|
||||||
class RoomsController < ApplicationController
|
class RoomsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
authorize_resource through: :conference
|
||||||
|
|
||||||
|
def index
|
||||||
|
authorize! :index, Room.new(conference_id: @conference.id)
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
render :rooms_list
|
render :rooms_list
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
module Admin
|
module Admin
|
||||||
class SchedulesController < ApplicationController
|
class SchedulesController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
# By authorizing 'conference' resource, we can ensure there will be no unauthorized access to
|
||||||
|
# the schedule of a conference, which should not be accessed in the first place
|
||||||
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
|
||||||
skip_before_filter :verify_authenticity_token, only: [:update]
|
skip_before_filter :verify_authenticity_token, only: [:update]
|
||||||
layout 'schedule'
|
layout 'schedule'
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
authorize! :update, @conference.events.new
|
||||||
if @conference.nil?
|
if @conference.nil?
|
||||||
redirect_to admin_conference_index_path
|
redirect_to admin_conference_index_path
|
||||||
return
|
return
|
||||||
|
|
@ -14,6 +18,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
authorize! :update, @conference.events.new
|
||||||
event = Event.where(guid: params[:event]).first
|
event = Event.where(guid: params[:event]).first
|
||||||
error_message = nil
|
error_message = nil
|
||||||
if event.nil?
|
if event.nil?
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
module Admin
|
module Admin
|
||||||
class SocialEventsController < ApplicationController
|
class SocialEventsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
authorize_resource :social_event, through: :conference
|
||||||
|
|
||||||
def show
|
def show
|
||||||
render :social_events_list
|
render :social_events_list
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
module Admin
|
module Admin
|
||||||
class SpeakersController < ApplicationController
|
class SpeakersController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource :event
|
||||||
|
|
||||||
respond_to :js, :html
|
respond_to :js, :html
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@event = @conference.events.find(params[:event_id])
|
authorize! :update, @conference.events.new
|
||||||
@speaker = @event.event_users.where(event_role: 'speaker').first
|
@speaker = @event.event_users.where(event_role: 'speaker').first
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@event = @conference.events.find(params[:event_id])
|
authorize! :update, @conference.events.new
|
||||||
@speaker = @event.event_users.where(event_role: 'speaker').first
|
@speaker = @event.event_users.where(event_role: 'speaker').first
|
||||||
@speaker.user_id = params[:speaker][:user_id]
|
@speaker.user_id = params[:speaker][:user_id]
|
||||||
@speaker.save
|
@speaker.save
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
module Admin
|
module Admin
|
||||||
class SponsorsController < ApplicationController
|
class SponsorsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
authorize_resource :sponsor, through: :conference
|
||||||
|
|
||||||
|
def index
|
||||||
|
authorize! :index, Sponsor.new(conference_id: @conference.id)
|
||||||
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if @conference.update_attributes(params[:conference])
|
if @conference.update_attributes(params[:conference])
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
module Admin
|
module Admin
|
||||||
class SponsorshipLevelsController < ApplicationController
|
class SponsorshipLevelsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
authorize_resource through: :conference
|
||||||
|
|
||||||
|
def index
|
||||||
|
authorize! :index, SponsorshipLevel.new(conference_id: @conference.id)
|
||||||
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if @conference.update_attributes(params[:conference])
|
if @conference.update_attributes(params[:conference])
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
module Admin
|
module Admin
|
||||||
class StatsController < ApplicationController
|
class StatsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource
|
||||||
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@registrations = @conference.registrations.includes(:user)
|
@registrations = @conference.registrations.includes(:user)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
module Admin
|
module Admin
|
||||||
class SupporterLevelsController < ApplicationController
|
class SupporterLevelsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
authorize_resource through: :conference
|
||||||
|
|
||||||
|
def index
|
||||||
|
authorize! :update, SupporterLevel.new(conference_id: @conference.id)
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
render :supporter_levels
|
render :supporter_levels
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
module Admin
|
module Admin
|
||||||
class SupportersController < ApplicationController
|
class SupportersController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource through: :conference
|
||||||
|
|
||||||
def index
|
def index
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
module Admin
|
module Admin
|
||||||
class TargetsController < ApplicationController
|
class TargetsController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
authorize_resource through: :conference
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
authorize! :index, Target.new(conference_id: @conference.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
authorize! :update, @conference => Target
|
||||||
|
|
||||||
if @conference.update_attributes(params[:conference])
|
if @conference.update_attributes(params[:conference])
|
||||||
redirect_to(admin_conference_targets_path(
|
redirect_to(admin_conference_targets_path(
|
||||||
conference_id: @conference.short_title),
|
conference_id: @conference.short_title),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
module Admin
|
module Admin
|
||||||
class TracksController < ApplicationController
|
class TracksController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
authorize_resource through: :conference
|
||||||
|
|
||||||
|
def index
|
||||||
|
authorize! :index, Track.new(conference_id: @conference.id)
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
module Admin
|
module Admin
|
||||||
class UsersController < ApplicationController
|
class UsersController < Admin::BaseController
|
||||||
before_filter :verify_admin
|
load_and_authorize_resource
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@user = User.new
|
@user = User.new
|
||||||
end
|
end
|
||||||
|
|
@ -10,32 +11,25 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@user = User.find(params[:id])
|
|
||||||
|
|
||||||
# Variable @show_attributes holds the attributes that are visible for the 'show' action
|
# Variable @show_attributes holds the attributes that are visible for the 'show' action
|
||||||
# If you want to change the attributes that are shown in the 'show' action of users
|
# If you want to change the attributes that are shown in the 'show' action of users
|
||||||
# add/remove the attributes in the following string array
|
# add/remove the attributes in the following string array
|
||||||
@show_attributes = %w(name email affiliation biography registered attended created_at
|
@show_attributes = %w(name email affiliation biography registered attended roles created_at
|
||||||
updated_at sign_in_count current_sign_in_at last_sign_in_at
|
updated_at sign_in_count current_sign_in_at last_sign_in_at
|
||||||
current_sign_in_ip last_sign_in_ip)
|
current_sign_in_ip last_sign_in_ip)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
user = User.find(params[:id])
|
if @user.update_attributes(params[:user])
|
||||||
user.update_attributes!(params[:user])
|
redirect_to admin_users_path, notice: "Updated #{@user.name} (#{@user.email})!"
|
||||||
redirect_to admin_users_path, notice: "Updated #{user.email}"
|
else
|
||||||
|
redirect_to admin_users_path, alert: "Could not update #{@user.name} (#{@user.email}). #{@user.errors.full_messages.join('. ')}."
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit; end
|
||||||
@user = User.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def delete
|
|
||||||
@user = User.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@user = User.find(params[:id])
|
|
||||||
@user.destroy
|
@user.destroy
|
||||||
redirect_to admin_users_path, notice: 'User got deleted'
|
redirect_to admin_users_path, notice: 'User got deleted'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
module Admin
|
module Admin
|
||||||
class VenueController < ApplicationController
|
class VenueController < Admin::BaseController
|
||||||
before_filter :verify_organizer
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource :venue, through: :conference, singleton: true
|
||||||
|
|
||||||
def index
|
def index; end
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@venue = @conference.venue
|
@venue = @conference.venue
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,36 @@
|
||||||
module Admin
|
module Admin
|
||||||
class VolunteersController < ApplicationController
|
class VolunteersController < Admin::BaseController
|
||||||
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
if can_manage_volunteers(@conference)
|
||||||
render :index
|
render :index
|
||||||
|
else
|
||||||
|
authorize! :index, :volunteer
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
if can_manage_volunteers(@conference)
|
||||||
if @conference.use_vpositions
|
if @conference.use_vpositions
|
||||||
@volunteers = @conference.registrations.joins(:vchoices).uniq
|
@volunteers = @conference.registrations.joins(:vchoices).uniq
|
||||||
else
|
else
|
||||||
@volunteers = @conference.registrations.where(volunteer: true)
|
@volunteers = @conference.registrations.where(volunteer: true)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
authorize! :index, :volunteer
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
if can_manage_volunteers(@conference)
|
||||||
begin
|
if @conference.update_attributes(params[:conference])
|
||||||
@conference.update_attributes!(params[:conference])
|
|
||||||
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: "Volunteering options were successfully updated.")
|
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: "Volunteering options were successfully updated.")
|
||||||
rescue => e
|
else
|
||||||
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{e.message}")
|
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
authorize! :index, :volunteer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,15 @@ class ApplicationController < ActionController::Base
|
||||||
before_filter :get_conferences
|
before_filter :get_conferences
|
||||||
before_filter :store_location
|
before_filter :store_location
|
||||||
helper_method :date_string
|
helper_method :date_string
|
||||||
|
# Ensure every controller authorizes resource or skips authorization (skip_authorization_check)
|
||||||
|
check_authorization unless: :devise_controller?
|
||||||
|
|
||||||
def store_location
|
def store_location
|
||||||
session[:return_to] = request.fullpath if request.get? && controller_name != "user_sessions" && controller_name != "sessions"
|
session[:return_to] = request.fullpath if request.get? && controller_name != "user_sessions" && controller_name != "sessions"
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_sign_in_path_for(resource)
|
def after_sign_in_path_for(resource)
|
||||||
if organizer_or_admin? &&
|
if (can? :view, Conference) &&
|
||||||
(!session[:return_to] ||
|
(!session[:return_to] ||
|
||||||
session[:return_to] &&
|
session[:return_to] &&
|
||||||
session[:return_to] == root_path)
|
session[:return_to] == root_path)
|
||||||
|
|
@ -39,36 +41,17 @@ class ApplicationController < ActionController::Base
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def organizer_or_admin?
|
def current_ability
|
||||||
has_role?(current_user, 'admin') || has_role?(current_user, 'organizer')
|
@current_ability ||= Ability.new(current_user)
|
||||||
end
|
|
||||||
|
|
||||||
def verify_organizer
|
|
||||||
if !verify_user
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
## Todo simplify this
|
|
||||||
redirect_to root_path unless has_role?(current_user, 'admin') || has_role?(current_user, 'organizer')
|
|
||||||
end
|
|
||||||
|
|
||||||
def verify_admin
|
|
||||||
if !verify_user
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to root_path unless has_role?(current_user, 'admin')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
rescue_from CanCan::AccessDenied do |exception|
|
rescue_from CanCan::AccessDenied do |exception|
|
||||||
Rails.logger.debug("Access denied!")
|
Rails.logger.debug("Access denied!")
|
||||||
redirect_to root_path, alert: exception.message
|
redirect_to root_path, alert: exception.message
|
||||||
end
|
end
|
||||||
helper_method :organizer_or_admin?
|
|
||||||
|
|
||||||
def not_found
|
def not_found
|
||||||
raise ActionController::RoutingError.new('Not Found')
|
raise ActionController::RoutingError.new('Not Found')
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,18 @@
|
||||||
class CommercialsController < ApplicationController
|
class CommercialsController < ApplicationController
|
||||||
before_action :set_conference
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
before_action :set_event
|
before_action :set_event
|
||||||
before_action :set_commercial, only: [:edit, :update, :destroy]
|
load_and_authorize_resource through: @event, except: [:new, :create]
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@commercial = @event.commercials.build
|
@commercial = @event.commercials.build
|
||||||
|
authorize! :new, @commercial
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@commercial = @event.commercials.build(commercial_params)
|
@commercial = @event.commercials.build(commercial_params)
|
||||||
|
authorize! :create, @commercial
|
||||||
|
|
||||||
if @commercial.save
|
if @commercial.save
|
||||||
redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id),
|
redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id),
|
||||||
|
|
@ -40,14 +41,6 @@ class CommercialsController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_commercial
|
|
||||||
@commercial = @event.commercials.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_conference
|
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_event
|
def set_event
|
||||||
@event = @conference.events.find(params[:proposal_id])
|
@event = @conference.events.find(params[:proposal_id])
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
class ConferenceController < ApplicationController
|
class ConferenceController < ApplicationController
|
||||||
def show
|
load_and_authorize_resource find_by: :short_title
|
||||||
@conference = Conference.find_by_short_title(params[:id])
|
|
||||||
redirect_to root_path, notice: "Conference not ready yet!!" unless @conference.make_conference_public?
|
def show; end
|
||||||
end
|
|
||||||
|
|
||||||
def subscribe
|
def subscribe
|
||||||
conference = Conference.find_by_short_title(params[:id])
|
conference = Conference.find_by_short_title(params[:id])
|
||||||
|
|
@ -41,7 +40,7 @@ class ConferenceController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def gallery_photos
|
def gallery_photos
|
||||||
@photos = Conference.find_by_short_title(params[:id]).photos
|
@photos = @conference.photos
|
||||||
render "photos", formats: [:js]
|
render "photos", formats: [:js]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
class ConferenceRegistrationController < ApplicationController
|
class ConferenceRegistrationController < ApplicationController
|
||||||
before_filter :verify_user
|
before_filter :verify_user
|
||||||
|
load_resource :conference, find_by: :short_title
|
||||||
|
authorize_resource :conference_registration, class: Registration
|
||||||
|
|
||||||
def register
|
def register
|
||||||
# TODO Figure out how to change the route's id from :id to :conference_id
|
|
||||||
@conference = Conference.find_by(short_title: params[:id])
|
|
||||||
@workshops = @conference.events.where('require_registration = ? AND state LIKE ?',
|
@workshops = @conference.events.where('require_registration = ? AND state LIKE ?',
|
||||||
true, 'confirmed')
|
true, 'confirmed')
|
||||||
@user = current_user
|
@user = current_user
|
||||||
|
|
@ -23,9 +23,8 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
|
|
||||||
# TODO this is ugly
|
# TODO this is ugly
|
||||||
def update
|
def update
|
||||||
conference = Conference.find_by(short_title: params[:id])
|
|
||||||
user = current_user
|
user = current_user
|
||||||
registration = user.registrations.where(conference_id: conference.id).first
|
registration = user.registrations.where(conference_id: @conference.id).first
|
||||||
update_registration = true
|
update_registration = true
|
||||||
# First verify that the supporter code is legit
|
# First verify that the supporter code is legit
|
||||||
if !params[:registration][:supporter_registration_attributes].nil? &&
|
if !params[:registration][:supporter_registration_attributes].nil? &&
|
||||||
|
|
@ -35,7 +34,7 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
|
|
||||||
if regs.count != 0
|
if regs.count != 0
|
||||||
if regs.where(email: user.email).count == 0
|
if regs.where(email: user.email).count == 0
|
||||||
redirect_to(register_conference_path(id: conference.short_title),
|
redirect_to(conference_register_path(conference_id: @conference.short_title),
|
||||||
alert: "This code is already in use.
|
alert: "This code is already in use.
|
||||||
Please contact #{conference.contact.email} for assistance.")
|
Please contact #{conference.contact.email} for assistance.")
|
||||||
return
|
return
|
||||||
|
|
@ -50,7 +49,7 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
supporter_reg = params[:registration][:supporter_registration_attributes]
|
supporter_reg = params[:registration][:supporter_registration_attributes]
|
||||||
params[:registration].delete :supporter_registration_attributes
|
params[:registration].delete :supporter_registration_attributes
|
||||||
registration = user.registrations.new(registration_params)
|
registration = user.registrations.new(registration_params)
|
||||||
if conference.use_supporter_levels? && !supporter_reg.nil?
|
if @conference.use_supporter_levels? && !supporter_reg.nil?
|
||||||
if !supporter_reg[:id].blank?
|
if !supporter_reg[:id].blank?
|
||||||
# Means that their supporter registration was entered ahead of time, by an admin
|
# Means that their supporter registration was entered ahead of time, by an admin
|
||||||
registration.supporter_registration = SupporterRegistration.find(supporter_reg[:id])
|
registration.supporter_registration = SupporterRegistration.find(supporter_reg[:id])
|
||||||
|
|
@ -58,15 +57,15 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
raise 'Invalid code'
|
raise 'Invalid code'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
registration.supporter_registration = conference.
|
registration.supporter_registration = @conference.
|
||||||
supporter_registrations.new(registration_params[:supporter_registration_attributes])
|
supporter_registrations.new(registration_params[:supporter_registration_attributes])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
registration.conference_id = conference.id
|
registration.conference_id = @conference.id
|
||||||
registration.save!
|
registration.save!
|
||||||
if user.subscriptions.where(conference: conference).blank?
|
if user.subscriptions.where(conference: @conference).blank?
|
||||||
subscription = Subscription.new(conference_id: conference.id, user_id: user.id)
|
subscription = Subscription.new(conference_id: @conference.id, user_id: user.id)
|
||||||
redirect_message = subscription.save ? 'You are now Registered and will be receiving Email Notifications.' : 'You are now Registered.'
|
redirect_message = subscription.save ? 'You are now Registered and will be receiving Email Notifications.' : 'You are now Registered.'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
@ -74,7 +73,7 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
Rails.logger.debug e.backtrace.join('\n')
|
Rails.logger.debug e.backtrace.join('\n')
|
||||||
redirect_to(register_conference_path(id: conference.short_title),
|
redirect_to(conference_register_path(conference_id: @conference.short_title),
|
||||||
alert: 'Registration failed:' + e.message)
|
alert: 'Registration failed:' + e.message)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -84,19 +83,18 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
else
|
else
|
||||||
# Track ahoy event
|
# Track ahoy event
|
||||||
ahoy.track 'Registered', title: 'New registration'
|
ahoy.track 'Registered', title: 'New registration'
|
||||||
if conference.email_settings.send_on_registration?
|
if @conference.email_settings.send_on_registration?
|
||||||
Mailbot.delay.registration_mail(conference, current_user)
|
Mailbot.delay.registration_mail(@conference, current_user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect_to(register_conference_path(id: conference.short_title),
|
redirect_to(conference_register_path(conference_id: @conference.short_title),
|
||||||
notice: redirect_message)
|
notice: redirect_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def unregister
|
def unregister
|
||||||
conference = Conference.find_by(short_title: params[:id])
|
|
||||||
user = current_user
|
user = current_user
|
||||||
registration = user.registrations.where(conference_id: conference.id).first
|
registration = user.registrations.where(conference_id: @conference.id).first
|
||||||
subscription = user.subscriptions.where(conference: conference)
|
subscription = user.subscriptions.where(conference: @conference)
|
||||||
unless subscription.blank?
|
unless subscription.blank?
|
||||||
subscription.first.destroy
|
subscription.first.destroy
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
class EventAttachmentsController < ApplicationController
|
class EventAttachmentsController < ApplicationController
|
||||||
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource :proposal, class: Event
|
||||||
|
load_and_authorize_resource :upload, class: EventAttachment, through: :proposal
|
||||||
before_filter :verify_user
|
before_filter :verify_user
|
||||||
skip_before_filter :verify_user, only: [:show]
|
skip_before_filter :verify_user, only: [:show]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@proposal = Event.find(params[:proposal_id])
|
|
||||||
@uploads = @proposal.event_attachments
|
@uploads = @proposal.event_attachments
|
||||||
@uploads = @uploads.map{|upload| upload.to_jq_upload }
|
@uploads = @uploads.map{|upload| upload.to_jq_upload }
|
||||||
|
|
||||||
|
|
@ -14,9 +16,8 @@ class EventAttachmentsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
upload = EventAttachment.find(params[:id])
|
if @upload.public?
|
||||||
if upload.public?
|
send_file @upload.attachment.path
|
||||||
send_file upload.attachment.path
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -26,7 +27,7 @@ class EventAttachmentsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if organizer_or_admin? || current_user == upload.event.submitter
|
if organizer_or_admin? || current_user == upload.event.submitter
|
||||||
send_file upload.attachment.path
|
send_file @upload.attachment.path
|
||||||
else
|
else
|
||||||
raise ActionController::RoutingError.new('Not Found')
|
raise ActionController::RoutingError.new('Not Found')
|
||||||
end
|
end
|
||||||
|
|
@ -41,16 +42,14 @@ class EventAttachmentsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit; end
|
||||||
@upload = EventAttachment.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
params[:event_attachment][:title] = params[:title][0]
|
params[:event_attachment][:title] = params[:title][0]
|
||||||
params[:event_attachment][:public] = false
|
params[:event_attachment][:public] = false
|
||||||
params[:event_attachment][:event_id] = params[:proposal_id]
|
params[:event_attachment][:event_id] = params[:proposal_id]
|
||||||
|
|
||||||
if !organizer_or_admin?
|
if cannot? :create, EventAttachment
|
||||||
begin
|
begin
|
||||||
current_user.events.find(params[:proposal_id])
|
current_user.events.find(params[:proposal_id])
|
||||||
rescue
|
rescue
|
||||||
|
|
@ -83,9 +82,6 @@ class EventAttachmentsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@proposal = current_user.events.find(params[:proposal_id])
|
|
||||||
@upload = @proposal.event_attachments.find(params[:proposal_id])
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @upload.update_attributes(params[:upload])
|
if @upload.update_attributes(params[:upload])
|
||||||
format.html { redirect_to @upload, notice: 'Upload was successfully updated.' }
|
format.html { redirect_to @upload, notice: 'Upload was successfully updated.' }
|
||||||
|
|
@ -98,9 +94,7 @@ class EventAttachmentsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@proposal = Event.find(params[:proposal_id])
|
if can? :destroy, @proposal
|
||||||
|
|
||||||
if organizer_or_admin? || current_user == @proposal.submitter
|
|
||||||
@upload = @proposal.event_attachments.find(params[:id])
|
@upload = @proposal.event_attachments.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
class HomeController < ApplicationController
|
class HomeController < ApplicationController
|
||||||
before_filter :respond_to_options
|
before_filter :respond_to_options
|
||||||
|
skip_authorization_check
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@today = Date.current
|
@today = Date.current
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,19 @@
|
||||||
class ProposalController < ApplicationController
|
class ProposalController < ApplicationController
|
||||||
before_filter :verify_user, except: [:show]
|
before_filter :verify_user, except: [:show]
|
||||||
before_action :set_conference, only: [:show]
|
load_resource :conference, find_by: :short_title
|
||||||
before_action :set_event, only: [:show, :edit, :update, :destroy, :confirm, :restart]
|
load_and_authorize_resource :event, parent: false, through: :conference
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@events = current_user.proposals(@conference)
|
@events = current_user.proposals(@conference)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
authorize! :show, @event
|
|
||||||
# FIXME: We should show more than the first speaker
|
# FIXME: We should show more than the first speaker
|
||||||
@speaker = @event.speakers.first || @event.submitter
|
@speaker = @event.speakers.first || @event.submitter
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
authorize! :new, Event
|
|
||||||
@url = conference_proposal_index_path(@conference.short_title)
|
@url = conference_proposal_index_path(@conference.short_title)
|
||||||
@event = Event.new
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
|
@ -26,7 +23,6 @@ class ProposalController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
authorize! :create, Event
|
|
||||||
@url = conference_proposal_index_path(@conference.short_title)
|
@url = conference_proposal_index_path(@conference.short_title)
|
||||||
|
|
||||||
params[:event].delete :user
|
params[:event].delete :user
|
||||||
|
|
@ -53,7 +49,7 @@ class ProposalController < ApplicationController
|
||||||
registration = current_user.registrations.where(conference_id: @conference.id).first
|
registration = current_user.registrations.where(conference_id: @conference.id).first
|
||||||
ahoy.track 'Event submission', title: 'New submission'
|
ahoy.track 'Event submission', title: 'New submission'
|
||||||
if registration.nil?
|
if registration.nil?
|
||||||
redirect_to(register_conference_path(@conference.short_title),
|
redirect_to(conference_register_path(@conference.short_title),
|
||||||
alert: 'Event was successfully submitted.
|
alert: 'Event was successfully submitted.
|
||||||
You should register for the conference now.')
|
You should register for the conference now.')
|
||||||
else
|
else
|
||||||
|
|
@ -120,7 +116,7 @@ class ProposalController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if !@conference.user_registered?(current_user)
|
if !@conference.user_registered?(current_user)
|
||||||
redirect_to(register_conference_path(@conference.short_title),
|
redirect_to(conference_register_path(@conference.short_title),
|
||||||
alert: 'The proposal was confirmed. Please register to attend the conference.')
|
alert: 'The proposal was confirmed. Please register to attend the conference.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -149,14 +145,4 @@ class ProposalController < ApplicationController
|
||||||
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
|
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
|
||||||
notice: "The proposal was re-submitted. The #{@conference.short_title} organizers will review it again.")
|
notice: "The proposal was re-submitted. The #{@conference.short_title} organizers will review it again.")
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_conference
|
|
||||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_event
|
|
||||||
@event = Event.find(params[:id])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
class ScheduleController < ApplicationController
|
class ScheduleController < ApplicationController
|
||||||
|
authorize_resource class: false
|
||||||
layout "application"
|
layout "application"
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
module Users
|
module Users
|
||||||
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||||
skip_before_filter :verify_authenticity_token
|
skip_before_filter :verify_authenticity_token
|
||||||
|
skip_authorization_check
|
||||||
|
|
||||||
User.omniauth_providers.each do |provider|
|
User.omniauth_providers.each do |provider|
|
||||||
define_method(provider) { handle(provider) }
|
define_method(provider) { handle(provider) }
|
||||||
|
|
|
||||||
|
|
@ -137,14 +137,6 @@ module ApplicationHelper
|
||||||
render "shared/dynamic_association", association_name: association_name, title: title, f: form_builder, hint: options[:hint]
|
render "shared/dynamic_association", association_name: association_name, title: title, f: form_builder, hint: options[:hint]
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_role?(current_user, role)
|
|
||||||
if current_user.nil?
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
return !!current_user.role?(role.to_s.camelize)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Same as redirect_to(:back) if there is a valid HTTP referer, otherwise redirect_to()
|
# Same as redirect_to(:back) if there is a valid HTTP referer, otherwise redirect_to()
|
||||||
def redirect_back_or_to(options = {}, response_status = {})
|
def redirect_back_or_to(options = {}, response_status = {})
|
||||||
if request.env["HTTP_REFERER"]
|
if request.env["HTTP_REFERER"]
|
||||||
|
|
@ -204,4 +196,19 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
return providers
|
return providers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Receives a hash, generated from User model, function get_roles
|
||||||
|
# Outputs the roles of a user, including the conferences for which the user has the roles
|
||||||
|
# Eg. organizer(oSC13, oSC14), cfp(oSC12, oSC13)
|
||||||
|
def show_roles(roles)
|
||||||
|
roles.map { |x| x[0].titleize + ' ' + x[1] }.join ', '
|
||||||
|
end
|
||||||
|
|
||||||
|
def can_manage_volunteers(conference)
|
||||||
|
if (current_user.has_role? :organizer, conference) || (current_user.has_role? :volunteer_coordinator, conference)
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,147 @@ class Ability
|
||||||
include CanCan::Ability
|
include CanCan::Ability
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
# guest user (not logged in)
|
# The first argument to `can` is the action you are giving the user permission to do.
|
||||||
user ||= User.new
|
# If you pass :manage it will apply to every action. Other common actions here are
|
||||||
if user.admin? || user.organizer?
|
# :read, :create, :update and :destroy.
|
||||||
# An admin can manage everything
|
#
|
||||||
can :manage, :all
|
# The second argument is the resource the user can perform the action on. If you pass
|
||||||
|
# :all it will apply to every resource. Otherwise pass a Ruby class of the resource.
|
||||||
|
#
|
||||||
|
# The third argument is an optional hash of conditions to further filter the objects.
|
||||||
|
# For example, here the user can only update published articles.
|
||||||
|
#
|
||||||
|
# can :update, Article, :published => true
|
||||||
|
#
|
||||||
|
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
|
||||||
|
|
||||||
|
# Order Abilities
|
||||||
|
# (Check https://github.com/CanCanCommunity/cancancan/wiki/Ability-Precedence)
|
||||||
|
# Check roles of user, using rolify. Role name is *case sensitive*
|
||||||
|
# user.is_organizer? or user.has_role? :organizer
|
||||||
|
# user.is_cfp_of? Conference or user.has_role? :cfp, Conference
|
||||||
|
# user.is_info_desk_of? Conference
|
||||||
|
# user.is_volunteer_coordinator_of? Conference
|
||||||
|
# user.is_attendee_of? Conference
|
||||||
|
# The following is wrong because a user will only have 'cfp' role for a specific conference
|
||||||
|
# user.is_cfp? # This is always false
|
||||||
|
|
||||||
|
user ||= User.new # guest user (not logged in)
|
||||||
|
|
||||||
|
if user.new_record?
|
||||||
|
guest
|
||||||
else
|
else
|
||||||
can [:update, :destroy], Event do |event|
|
roles = Role::ACTIONABLES.map {|i| i.parameterize.underscore}
|
||||||
event.users.include?(user)
|
if (user.roles.pluck(:name) & roles).empty? && !user.is_admin # User has no roles
|
||||||
end
|
signed_in(user)
|
||||||
can [:create, :read], Event
|
else
|
||||||
|
user_with_roles(user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_with_roles(user)
|
||||||
|
conf_ids_for_organizer = []
|
||||||
|
venue_ids_for_organizer = []
|
||||||
|
conf_ids_for_cfp = []
|
||||||
|
venue_ids_for_cfp = []
|
||||||
|
conf_ids_for_info_desk = []
|
||||||
|
conf_ids_for_volunteer_coordinator = []
|
||||||
|
|
||||||
|
# Ids of all the conferences for which the user has an 'organizer' role
|
||||||
|
conf_ids_for_organizer =
|
||||||
|
Conference.with_role(:organizer, user).pluck(:id) if user.has_role? :organizer, :any
|
||||||
|
venue_ids_for_organizer =
|
||||||
|
Conference.with_role(:organizer, user).pluck(:venue_id) if user.has_role? :organizer, :any
|
||||||
|
conf_ids_for_cfp =
|
||||||
|
Conference.with_role(:cfp, user).pluck(:id) if user.has_role? :cfp, :any
|
||||||
|
venue_ids_for_cfp =
|
||||||
|
Conference.with_role(:cfp, user).pluck(:venue_id) if user.has_role? :cfp, :any
|
||||||
|
# Ids of all the conferences for which the user has an 'info_desk' role
|
||||||
|
conf_ids_for_info_desk =
|
||||||
|
Conference.with_role(:info_desk, user).pluck(:id) if user.has_role? :info_desk, :any
|
||||||
|
# Ids of all the conferences for which the user has a 'volunteer_coordinator' role
|
||||||
|
conf_ids_for_volunteer_coordinator =
|
||||||
|
Conference.with_role(:volunteer_coordinator, user).pluck(:id) if user.has_role? :volunteer_coordinator, :any
|
||||||
|
|
||||||
|
signed_in(user) # Inherit abilities from signed user
|
||||||
|
# User with role
|
||||||
|
can :manage, User if user.is_admin # ??? || (user.has_role? :organizer, :any)
|
||||||
|
can [:new, :create], Conference if user.is_admin || (user.has_role? :organizer, :any)
|
||||||
|
can [:index, :show, :gallery_photos], Conference
|
||||||
|
can :manage, Conference, id: conf_ids_for_organizer
|
||||||
|
# can :manage, Conference do |conference|
|
||||||
|
# conference.id = conf_ids_for_organizer
|
||||||
|
# end
|
||||||
|
can :manage, Venue, id: venue_ids_for_organizer
|
||||||
|
can :index, Venue, id: venue_ids_for_cfp
|
||||||
|
can :manage, Registration, conference_id: conf_ids_for_organizer + conf_ids_for_info_desk
|
||||||
|
can :manage, Question, conference_id: conf_ids_for_organizer + conf_ids_for_info_desk
|
||||||
|
cannot [:edit, :update, :destroy], Question, global: true
|
||||||
|
can :manage, Vposition, conference_id: conf_ids_for_organizer + conf_ids_for_volunteer_coordinator
|
||||||
|
can :manage, Vday, conference_id: conf_ids_for_organizer + conf_ids_for_volunteer_coordinator
|
||||||
|
# The ability to manage an Event means that:
|
||||||
|
# the user can also edit the schedule and that
|
||||||
|
# the user can also vote
|
||||||
|
can :manage, Event, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
||||||
|
can :create, Event
|
||||||
|
can :manage, CallForPapers, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
||||||
|
can :manage, EventType, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
||||||
|
can :manage, Track, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
||||||
|
can :manage, DifficultyLevel, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
||||||
|
can :manage, EmailSettings, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
||||||
|
can :manage, Campaign, conference_id: conf_ids_for_organizer
|
||||||
|
can :manage, Lodging, venue_id: venue_ids_for_organizer
|
||||||
|
can :manage, Photo, conference_id: conf_ids_for_organizer
|
||||||
|
can :manage, Room, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
||||||
|
can :manage, Sponsor, conference_id: conf_ids_for_organizer
|
||||||
|
can :manage, SponsorshipLevel, conference_id: conf_ids_for_organizer
|
||||||
|
can :manage, SupporterLevel, conference_id: conf_ids_for_organizer
|
||||||
|
can :manage, Target, conference_id: conf_ids_for_organizer
|
||||||
|
can :index, Commercial, commercialable_type: 'Conference'
|
||||||
|
can :manage, Commercial, commercialable_type: 'Conference', commercialable_id: conf_ids_for_organizer
|
||||||
|
# Manage commercials for events that belong to a conference of which user is organizer
|
||||||
|
can :manage, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(conference_id: conf_ids_for_organizer + conf_ids_for_cfp).pluck(:id)
|
||||||
|
can :manage, Contact, conference_id: conf_ids_for_organizer
|
||||||
|
can :manage, Campaign, conference_id: conf_ids_for_organizer
|
||||||
|
can :manage, Photo, conference_id: conf_ids_for_organizer
|
||||||
|
end
|
||||||
|
|
||||||
|
def guest
|
||||||
|
## Abilities for everyone, even guests (not logged in users)
|
||||||
|
can [:show, :gallery_photos], Conference do |conference|
|
||||||
|
conference.make_conference_public == true
|
||||||
|
end
|
||||||
|
|
||||||
|
# see commercials too
|
||||||
|
|
||||||
|
can :show, Event do |event|
|
||||||
|
event.state == 'confirmed'
|
||||||
|
end
|
||||||
|
|
||||||
|
can :index, :schedule # show?
|
||||||
|
end
|
||||||
|
|
||||||
|
def signed_in(user)
|
||||||
|
guest # Inherits abilities of guest
|
||||||
|
|
||||||
|
# Conference Registration
|
||||||
|
can :manage, Registration, user_id: user.id
|
||||||
|
|
||||||
|
## Proposals
|
||||||
|
# Users can manage their own proposals
|
||||||
|
can :manage, Event, id: user.events.pluck(:id)
|
||||||
|
|
||||||
|
# Submit proposals only for conferences that are not over yet
|
||||||
|
can :create, Event, conference_id: Conference.where('end_date >= ?', Date.today).pluck(:id)
|
||||||
|
# Users can manage their own commercials
|
||||||
|
can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id)
|
||||||
|
# View commercials of confirmed events
|
||||||
|
can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id)
|
||||||
|
|
||||||
|
can :manage, EventAttachment do |ea|
|
||||||
|
Event.find(ea.event_id).event_users.where(user_id: user.id).present?
|
||||||
|
end
|
||||||
|
can :create, EventAttachment
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
class CallForPapers < ActiveRecord::Base
|
class CallForPapers < ActiveRecord::Base
|
||||||
attr_accessible :start_date, :end_date,
|
attr_accessible :start_date, :end_date,
|
||||||
:description, :schedule_changes, :rating,
|
:description, :schedule_changes, :rating,
|
||||||
:schedule_public, :include_cfp_in_splash
|
:schedule_public, :include_cfp_in_splash, :conference_id
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
|
|
||||||
validates_presence_of :start_date, :end_date
|
validates_presence_of :start_date, :end_date
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
class Campaign < ActiveRecord::Base
|
class Campaign < ActiveRecord::Base
|
||||||
attr_accessible :name, :utm_source, :utm_medium, :utm_term,
|
attr_accessible :name, :utm_source, :utm_medium, :utm_term,
|
||||||
:utm_content, :utm_campaign, :target_ids
|
:utm_content, :utm_campaign, :target_ids, :conference_id
|
||||||
|
|
||||||
validates :name, :utm_campaign, presence: true
|
validates :name, :utm_campaign, presence: true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
class Conference < ActiveRecord::Base
|
class Conference < ActiveRecord::Base
|
||||||
require 'uri'
|
require 'uri'
|
||||||
serialize :events_per_week, Hash
|
serialize :events_per_week, Hash
|
||||||
|
resourcify # Needed to call 'Conference.with_role' in /models/ability.rb
|
||||||
|
|
||||||
attr_accessible :title, :short_title, :timezone, :html_export_path,
|
attr_accessible :title, :short_title, :timezone, :html_export_path,
|
||||||
:start_date, :end_date, :rooms_attributes, :tracks_attributes,
|
:start_date, :end_date, :rooms_attributes, :tracks_attributes,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class DifficultyLevel < ActiveRecord::Base
|
class DifficultyLevel < ActiveRecord::Base
|
||||||
attr_accessible :title, :description, :color
|
attr_accessible :title, :description, :color, :conference_id
|
||||||
|
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
has_many :events
|
has_many :events
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
class EventType < ActiveRecord::Base
|
class EventType < ActiveRecord::Base
|
||||||
attr_accessible :title, :length, :minimum_abstract_length, :maximum_abstract_length, :color
|
attr_accessible :title, :length, :minimum_abstract_length, :maximum_abstract_length, :color,
|
||||||
|
:conference_id
|
||||||
|
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class Lodging < ActiveRecord::Base
|
class Lodging < ActiveRecord::Base
|
||||||
attr_accessible :name, :description, :photo, :website_link
|
attr_accessible :name, :description, :photo, :website_link, :venue_id
|
||||||
belongs_to :venue
|
belongs_to :venue
|
||||||
has_attached_file :photo,
|
has_attached_file :photo,
|
||||||
styles: { thumb: '100x100>', large: '300x300>' }
|
styles: { thumb: '100x100>', large: '300x300>' }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class Question < ActiveRecord::Base
|
class Question < ActiveRecord::Base
|
||||||
attr_accessible :title, :global, :answers_attributes, :answer_ids, :question_type_id
|
attr_accessible :title, :global, :answers_attributes, :answer_ids, :question_type_id, :conference_id
|
||||||
|
|
||||||
belongs_to :question_type
|
belongs_to :question_type
|
||||||
has_and_belongs_to_many :conferences
|
has_and_belongs_to_many :conferences
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,10 @@
|
||||||
class Role < ActiveRecord::Base
|
class Role < ActiveRecord::Base
|
||||||
attr_accessible :name
|
attr_accessible :name, :description
|
||||||
has_and_belongs_to_many :users
|
has_and_belongs_to_many :users
|
||||||
|
belongs_to :resource, polymorphic: true
|
||||||
|
|
||||||
|
scopify
|
||||||
|
|
||||||
|
LABELS = ['Attendee', 'Volunteer', 'Speaker', 'Sponsor', 'Press', 'Keynote Speaker']
|
||||||
|
ACTIONABLES = ['Organizer', 'CfP', 'Info Desk', 'Volunteers Coordinator']
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class Room < ActiveRecord::Base
|
class Room < ActiveRecord::Base
|
||||||
attr_accessible :name, :size, :public
|
attr_accessible :name, :size, :public, :conference_id
|
||||||
|
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
has_many :events
|
has_many :events
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
class Sponsor < ActiveRecord::Base
|
class Sponsor < ActiveRecord::Base
|
||||||
attr_accessible :name, :description, :website_url, :logo,
|
attr_accessible :name, :description, :website_url, :logo, :sponsorship_level_id, :conference_id
|
||||||
:sponsorship_level_id
|
|
||||||
belongs_to :sponsorship_level
|
belongs_to :sponsorship_level
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
has_attached_file :logo,
|
has_attached_file :logo,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class SponsorshipLevel < ActiveRecord::Base
|
class SponsorshipLevel < ActiveRecord::Base
|
||||||
attr_accessible :title
|
attr_accessible :title, :conference_id
|
||||||
validates_presence_of :title
|
validates_presence_of :title
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
has_many :sponsors
|
has_many :sponsors
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,5 @@ class SupporterLevel < ActiveRecord::Base
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
has_many :supporter_registrations
|
has_many :supporter_registrations
|
||||||
|
|
||||||
attr_accessible :conference, :title, :url, :description, :ticket_price
|
attr_accessible :conference, :title, :url, :description, :ticket_price, :conference_id
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
class Target < ActiveRecord::Base
|
class Target < ActiveRecord::Base
|
||||||
include ActionView::Helpers::TextHelper
|
include ActionView::Helpers::TextHelper
|
||||||
|
|
||||||
attr_accessible :due_date, :target_count, :unit
|
attr_accessible :due_date, :target_count, :unit, :conference_id
|
||||||
|
|
||||||
default_scope { order('due_date ASC') }
|
default_scope { order('due_date ASC') }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class Track < ActiveRecord::Base
|
class Track < ActiveRecord::Base
|
||||||
attr_accessible :name, :description, :color
|
attr_accessible :name, :description, :color, :conference_id
|
||||||
|
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
class User < ActiveRecord::Base
|
class User < ActiveRecord::Base
|
||||||
|
rolify
|
||||||
include Gravtastic
|
include Gravtastic
|
||||||
gravtastic size: 32
|
gravtastic size: 32
|
||||||
|
|
||||||
|
before_create :setup_role
|
||||||
|
|
||||||
# Include default devise modules. Others available are:
|
# Include default devise modules. Others available are:
|
||||||
# :token_authenticatable, :confirmable,
|
# :token_authenticatable, :confirmable,
|
||||||
# :lockable, :timeoutable and :omniauthable
|
# :lockable, :timeoutable and :omniauthable
|
||||||
|
|
@ -13,7 +16,7 @@ class User < ActiveRecord::Base
|
||||||
has_many :openids
|
has_many :openids
|
||||||
|
|
||||||
attr_accessible :email, :password, :password_confirmation, :remember_me, :role_id, :role_ids,
|
attr_accessible :email, :password, :password_confirmation, :remember_me, :role_id, :role_ids,
|
||||||
:name, :email_public, :biography, :nickname, :affiliation
|
:name, :email_public, :biography, :nickname, :affiliation, :is_admin
|
||||||
|
|
||||||
has_many :event_users, dependent: :destroy
|
has_many :event_users, dependent: :destroy
|
||||||
has_many :events, -> { uniq }, through: :event_users
|
has_many :events, -> { uniq }, through: :event_users
|
||||||
|
|
@ -23,8 +26,6 @@ class User < ActiveRecord::Base
|
||||||
has_many :subscriptions, dependent: :destroy
|
has_many :subscriptions, dependent: :destroy
|
||||||
accepts_nested_attributes_for :roles
|
accepts_nested_attributes_for :roles
|
||||||
|
|
||||||
before_create :setup_role
|
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
|
|
||||||
# Searches for user based on email. Returns found user or new user.
|
# Searches for user based on email. Returns found user or new user.
|
||||||
|
|
@ -47,26 +48,20 @@ class User < ActiveRecord::Base
|
||||||
user
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
def role?(role)
|
|
||||||
Rails.logger.debug('Checking role in user')
|
|
||||||
!!roles.find_by_name(role.to_s.downcase.camelize)
|
|
||||||
end
|
|
||||||
|
|
||||||
def admin?
|
|
||||||
role?('Admin')
|
|
||||||
end
|
|
||||||
|
|
||||||
def organizer?
|
|
||||||
role?('Organizer')
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_roles
|
|
||||||
roles
|
|
||||||
end
|
|
||||||
|
|
||||||
def setup_role
|
def setup_role
|
||||||
roles << Role.where(name: 'Admin') if User.count == 0
|
self.is_admin = true if User.count == 0
|
||||||
roles << Role.where(name: 'Participant') if roles.empty?
|
end
|
||||||
|
|
||||||
|
# Gets the roles of the user, groups them by role.name and returns the resource(s) of each role
|
||||||
|
# ====Returns
|
||||||
|
# * +Hash+ * -> e.g. 'organizer' => "(conf1, conf2)"
|
||||||
|
def get_roles
|
||||||
|
result = {}
|
||||||
|
Role::ACTIONABLES.each do |role|
|
||||||
|
resources = self.roles.where(name: role.parameterize.underscore).map{ |myrole| Conference.find(myrole.resource_id).short_title }.join ', '
|
||||||
|
result[role.parameterize.underscore] = "(#{ resources })" unless resources.blank?
|
||||||
|
end
|
||||||
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.prepare(params)
|
def self.prepare(params)
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,11 @@
|
||||||
= commercial.commercial_type
|
= commercial.commercial_type
|
||||||
.flexvideo
|
.flexvideo
|
||||||
= render partial: 'shared/media_item', locals: { commercial_type: commercial.commercial_type, commercial_id: commercial.commercial_id }
|
= render partial: 'shared/media_item', locals: { commercial_type: commercial.commercial_type, commercial_id: commercial.commercial_id }
|
||||||
|
- if can? :update, commercial
|
||||||
= link_to 'Edit', edit_admin_conference_commercial_path(@conference.short_title, commercial.id), class: 'btn btn-primary'
|
= link_to 'Edit', edit_admin_conference_commercial_path(@conference.short_title, commercial.id), class: 'btn btn-primary'
|
||||||
|
- if can? :destroy, commercial
|
||||||
= link_to 'Delete', admin_conference_commercial_path(@conference.short_title, commercial.id),
|
= link_to 'Delete', admin_conference_commercial_path(@conference.short_title, commercial.id),
|
||||||
method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
|
method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
|
||||||
|
- if can? :create, @conference.commercials.new
|
||||||
%br
|
%br
|
||||||
= link_to 'New Commercial', new_admin_conference_commercial_path, class: 'btn btn-primary'
|
= link_to 'New Commercial', new_admin_conference_commercial_path, class: 'btn btn-primary'
|
||||||
|
|
|
||||||
29
app/views/admin/conference/_roles.html.haml
Normal file
29
app/views/admin/conference/_roles.html.haml
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#myroles.roles
|
||||||
|
- unless @role.blank?
|
||||||
|
%p.text-muted
|
||||||
|
= @role.first.description
|
||||||
|
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-6
|
||||||
|
= semantic_form_for(:user, url: add_user_admin_conference_path(@conference.short_title, role: @selection), remote: true) do |f|
|
||||||
|
%h4
|
||||||
|
= f.input :email, label: "Add role '#{@selection.humanize.titleize}' to user: ", placeholder: "User's email", input_html: { required: 'required' }
|
||||||
|
= f.action :submit, as: :button, label: 'Add User', button_html: {value: 'Add', class: 'btn btn-primary'}
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
%h3 Users with role #{@selection.humanize.titleize}
|
||||||
|
%table.table.table-striped.table-bordered.table-hover
|
||||||
|
%thead
|
||||||
|
%th ID
|
||||||
|
%th Name
|
||||||
|
%th Email
|
||||||
|
%tbody
|
||||||
|
- @role_users[@selection].each do |user|
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
= link_to remove_user_admin_conference_path(@conference.short_title, user_id: user.id, role: @selection), method: :delete, remote: true, title: 'Remove user' do
|
||||||
|
%i{class: 'fa fa-times'}
|
||||||
|
= user.id
|
||||||
|
%td= user.name
|
||||||
|
%td= user.email
|
||||||
|
|
@ -8,25 +8,49 @@
|
||||||
= conference_progress['process'] + '%'
|
= conference_progress['process'] + '%'
|
||||||
%li{'class'=>class_for_todo(conference_progress['registration'])}
|
%li{'class'=>class_for_todo(conference_progress['registration'])}
|
||||||
%span{'class'=>icon_for_todo(conference_progress['registration'])}
|
%span{'class'=>icon_for_todo(conference_progress['registration'])}
|
||||||
|
- if can? :update, @conference.registrations.build
|
||||||
= link_to 'Set up registration period', edit_admin_conference_path(conference_progress['short_title'], :anchor => 'conference-end-datepicker')
|
= link_to 'Set up registration period', edit_admin_conference_path(conference_progress['short_title'], :anchor => 'conference-end-datepicker')
|
||||||
|
- else
|
||||||
|
Set up registration period
|
||||||
%li{'class'=>class_for_todo(conference_progress['cfp'])}
|
%li{'class'=>class_for_todo(conference_progress['cfp'])}
|
||||||
%span{'class'=>icon_for_todo(conference_progress['cfp'])}
|
%span{'class'=>icon_for_todo(conference_progress['cfp'])}
|
||||||
|
- if can? :update, CallForPapers.new(conference_id: @conference.id)
|
||||||
= link_to 'Set up call for papers', admin_conference_callforpapers_path(conference_progress['short_title'])
|
= link_to 'Set up call for papers', admin_conference_callforpapers_path(conference_progress['short_title'])
|
||||||
|
- else
|
||||||
|
Set up call for papers
|
||||||
%li{'class'=>class_for_todo(conference_progress['venue'])}
|
%li{'class'=>class_for_todo(conference_progress['venue'])}
|
||||||
%span{'class'=>icon_for_todo(conference_progress['venue'])}
|
%span{'class'=>icon_for_todo(conference_progress['venue'])}
|
||||||
|
- if can? :update, @conference.venue
|
||||||
= link_to 'Add venue', admin_conference_venue_info_path(conference_progress['short_title'])
|
= link_to 'Add venue', admin_conference_venue_info_path(conference_progress['short_title'])
|
||||||
|
- else
|
||||||
|
Add venue
|
||||||
%li{'class'=>class_for_todo(conference_progress['rooms'])}
|
%li{'class'=>class_for_todo(conference_progress['rooms'])}
|
||||||
%span{'class'=>icon_for_todo(conference_progress['rooms'])}
|
%span{'class'=>icon_for_todo(conference_progress['rooms'])}
|
||||||
|
- if can? :update, @conference.rooms.build
|
||||||
= link_to 'Add rooms', admin_conference_rooms_path(conference_progress['short_title'])
|
= link_to 'Add rooms', admin_conference_rooms_path(conference_progress['short_title'])
|
||||||
|
- else
|
||||||
|
Add rooms
|
||||||
%li{'class'=>class_for_todo(conference_progress['tracks'])}
|
%li{'class'=>class_for_todo(conference_progress['tracks'])}
|
||||||
%span{'class'=>icon_for_todo(conference_progress['tracks'])}
|
%span{'class'=>icon_for_todo(conference_progress['tracks'])}
|
||||||
|
- if can? :update, @conference.tracks.build
|
||||||
= link_to 'Add tracks', admin_conference_tracks_path(conference_progress['short_title'])
|
= link_to 'Add tracks', admin_conference_tracks_path(conference_progress['short_title'])
|
||||||
|
- else
|
||||||
|
Add tracks
|
||||||
%li{'class'=>class_for_todo(conference_progress['event_types'])}
|
%li{'class'=>class_for_todo(conference_progress['event_types'])}
|
||||||
%span{'class'=>icon_for_todo(conference_progress['event_types'])}
|
%span{'class'=>icon_for_todo(conference_progress['event_types'])}
|
||||||
= link_to 'Add event types', admin_conference_eventtypes_path(conference_progress['short_title'])
|
- if can? :update, @conference.event_types.build
|
||||||
|
= link_to 'Add event types', admin_conference_event_types_path(conference_progress['short_title'])
|
||||||
|
- else
|
||||||
|
Add event types
|
||||||
%li{'class'=>class_for_todo(conference_progress['difficulty_levels'])}
|
%li{'class'=>class_for_todo(conference_progress['difficulty_levels'])}
|
||||||
%span{'class'=>icon_for_todo(conference_progress['difficulty_levels'])}
|
%span{'class'=>icon_for_todo(conference_progress['difficulty_levels'])}
|
||||||
|
- if can? :update, @conference.difficulty_levels.build
|
||||||
= link_to 'Add difficulty levels', admin_conference_difficulty_levels_path(conference_progress['short_title'])
|
= link_to 'Add difficulty levels', admin_conference_difficulty_levels_path(conference_progress['short_title'])
|
||||||
|
- else
|
||||||
|
Add difficulty levels
|
||||||
%li{class: class_for_todo(conference_progress['make_conference_public'])}
|
%li{class: class_for_todo(conference_progress['make_conference_public'])}
|
||||||
%span{'class'=>icon_for_todo(conference_progress['make_conference_public'])}
|
%span{'class'=>icon_for_todo(conference_progress['make_conference_public'])}
|
||||||
|
- if can? :update, @conference
|
||||||
= link_to 'Make Splash Page Public for Visitors', edit_admin_conference_path(conference_progress['short_title'])
|
= link_to 'Make Splash Page Public for Visitors', edit_admin_conference_path(conference_progress['short_title'])
|
||||||
|
- else
|
||||||
|
Make Splash Page Public for Visitors
|
||||||
|
|
|
||||||
22
app/views/admin/conference/roles.html.haml
Normal file
22
app/views/admin/conference/roles.html.haml
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
.row
|
||||||
|
.col-md-6
|
||||||
|
= semantic_form_for(:user, url: roles_admin_conference_path(@conference.short_title), remote: true) do |f|
|
||||||
|
%h4
|
||||||
|
= f.input :roles, collection: @roles, label: 'Show users for role: '
|
||||||
|
|
||||||
|
= render partial: 'roles'
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
|
||||||
|
$("#user_roles_input").change(function () {
|
||||||
|
|
||||||
|
var url = document.forms[0].action;
|
||||||
|
var selected_role = $(this).find('option:selected').attr('value');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
type: "POST",
|
||||||
|
data: {user: { roles: selected_role } },
|
||||||
|
dataType: "script"
|
||||||
|
});
|
||||||
|
});
|
||||||
1
app/views/admin/conference/roles.js.erb
Normal file
1
app/views/admin/conference/roles.js.erb
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
$('#myroles').html("<%= escape_javascript(render partial: 'roles').html_safe %>");
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
.row
|
.row
|
||||||
.col-md-8
|
.col-md-8
|
||||||
= semantic_form_for(@conference, url: admin_conference_eventtypes_path(@conference.short_title, @conference.event_types)) do |f|
|
= semantic_form_for(@conference, url: admin_conference_event_types_path(@conference.short_title, @conference.event_types)) do |f|
|
||||||
= dynamic_association :event_types, "Event Types", f
|
= dynamic_association :event_types, "Event Types", f
|
||||||
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
|
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
|
||||||
|
|
@ -19,10 +19,8 @@
|
||||||
= label_tag dom_id(q), "Answers: #{q.answers.map {|a| a.title}.join(', ')}"
|
= label_tag dom_id(q), "Answers: #{q.answers.map {|a| a.title}.join(', ')}"
|
||||||
|
|
||||||
%td= link_to 'Edit', edit_admin_conference_question_path(@conference.short_title, q),
|
%td= link_to 'Edit', edit_admin_conference_question_path(@conference.short_title, q),
|
||||||
class: 'btn btn-primary',
|
class: 'btn btn-primary', disabled: !(can? :update, q)
|
||||||
disabled: q.global == true && !has_role?(current_user, 'Admin')
|
|
||||||
|
|
||||||
%td= link_to 'Delete', admin_conference_question_path(@conference.short_title, q),
|
%td= link_to 'Delete', admin_conference_question_path(@conference.short_title, q),
|
||||||
method: :delete, remote: true, class: 'btn btn-danger',
|
method: :delete, remote: true, class: 'btn btn-danger',
|
||||||
confirm: "Delete question '#{q.title}'?",
|
confirm: "Delete question '#{q.title}'?", disabled: !(can? :destroy, q)
|
||||||
disabled: q.global == true && !has_role?(current_user, "Admin")
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
.row
|
.row
|
||||||
.col-md-8
|
.col-md-8
|
||||||
.pull-right
|
.pull-right
|
||||||
|
- if can? :create, Question.new(conference_id: @conference.id)
|
||||||
%b= link_to 'Create New Question','#', 'data-toggle' => 'modal',
|
%b= link_to 'Create New Question','#', 'data-toggle' => 'modal',
|
||||||
'data-target' => '#new-question', class: 'btn btn-success'
|
'data-target' => '#new-question', class: 'btn btn-success'
|
||||||
%br
|
%br
|
||||||
|
|
@ -9,6 +10,7 @@
|
||||||
= semantic_form_for(@conference, url: admin_conference_questions_update_conference_path(@conference.short_title)) do |f|
|
= semantic_form_for(@conference, url: admin_conference_questions_update_conference_path(@conference.short_title)) do |f|
|
||||||
.questions{id: 'myquestions'}
|
.questions{id: 'myquestions'}
|
||||||
= render partial: 'questions'
|
= render partial: 'questions'
|
||||||
|
- if can? :update, @conference
|
||||||
= f.submit "Update Questions for #{@conference.short_title}", class: 'btn btn-primary',
|
= f.submit "Update Questions for #{@conference.short_title}", class: 'btn btn-primary',
|
||||||
confirm: 'Are you sure you want to make these changes?'
|
confirm: 'Are you sure you want to make these changes?'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@
|
||||||
= "(#{@registrations.length})"
|
= "(#{@registrations.length})"
|
||||||
= " - Attended (#{@attended})"
|
= " - Attended (#{@attended})"
|
||||||
.btn-group.pull-right
|
.btn-group.pull-right
|
||||||
|
- if can? :create, Registration
|
||||||
= link_to "New", new_admin_conference_registration_path(@conference.short_title), :class => "btn btn-default"
|
= link_to "New", new_admin_conference_registration_path(@conference.short_title), :class => "btn btn-default"
|
||||||
|
- if can? :read, Registration
|
||||||
= link_to "Export PDF", admin_conference_registrations_path(@conference.short_title, :format => :pdf), :class => "btn btn-default"
|
= link_to "Export PDF", admin_conference_registrations_path(@conference.short_title, :format => :pdf), :class => "btn btn-default"
|
||||||
= link_to "Export XLS", {:format => :xlsx}, :class => "btn btn-default"
|
= link_to "Export XLS", {:format => :xlsx}, :class => "btn btn-default"
|
||||||
%table.table.table-bordered.table-striped.table-hover#registrations
|
%table.table.table-bordered.table-striped.table-hover#registrations
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
= semantic_form_for [:admin, @user] do |f|
|
= semantic_form_for [:admin, @user] do |f|
|
||||||
= f.inputs "Basic Information" do
|
= f.inputs 'Basic Information' do
|
||||||
|
= f.input :is_admin, hint: 'An admin can create a new conference, manage users and make other users admins.'
|
||||||
= f.input :name, :as => :string
|
= f.input :name, :as => :string
|
||||||
= f.input :email
|
= f.input :email
|
||||||
= f.input :affiliation, :as => :string
|
= f.input :affiliation, :as => :string
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
- if @users
|
- if @users
|
||||||
= "(#{@users.length})"
|
= "(#{@users.length})"
|
||||||
|
|
||||||
= link_to "New User", new_admin_user_path, :class => "btn btn-success pull-right"
|
= link_to "New User", new_admin_user_path, class: 'btn btn-success pull-right'
|
||||||
.well
|
.well
|
||||||
%table.table.table-striped.table-bordered.table-hover#users
|
%table.table.table-striped.table-bordered.table-hover#users
|
||||||
%thead
|
%thead
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
%th
|
%th
|
||||||
%b Name
|
%b Name
|
||||||
%th
|
%th
|
||||||
%b # of Conference Registrations
|
%b Attended Conferences
|
||||||
%th
|
%th
|
||||||
%b Roles
|
%b Roles
|
||||||
%th
|
%th
|
||||||
|
|
@ -38,34 +38,19 @@
|
||||||
%td
|
%td
|
||||||
= user.name
|
= user.name
|
||||||
%td
|
%td
|
||||||
= user.registrations.count
|
= user.registrations.where(attended: true).count
|
||||||
%td
|
%td
|
||||||
.modal.fade{:id => "user-role-selection-#{user.id}", "role" => "dialog", "aria-hidden" => "true"}
|
- unless user.get_roles.blank?
|
||||||
.modal-dialog
|
= show_roles(user.get_roles.first(2))
|
||||||
.modal-content
|
- if user.get_roles.count > 2
|
||||||
.modal-header
|
= '...'
|
||||||
%button{"type"=>"button", :class=>"close", "data-dismiss"=>"modal", "aria-hidden"=>"true"}
|
- if can? :show, user
|
||||||
×
|
|
||||||
%h3{:id => "role-selector-header-#{user.id}"}
|
|
||||||
Modifying Roles
|
|
||||||
.modal-body
|
|
||||||
- if current_user == user
|
|
||||||
You cannot modify your own role!
|
|
||||||
%br
|
|
||||||
%button{:class=> "btn btn-danger", "data-dismiss"=> "modal", "aria-hidden"=>"true"}
|
|
||||||
Cancel
|
|
||||||
- else
|
|
||||||
= "Give #{user.name} (#{user.email}) the following roles:"
|
|
||||||
= semantic_form_for(user, :url => admin_user_path(user), :method => :put) do |f|
|
|
||||||
= f.input :roles, :label => false
|
|
||||||
%button{:class=> "btn btn-danger", "data-dismiss"=> "modal", "aria-hidden"=>"true"}
|
|
||||||
Cancel
|
|
||||||
= f.action :submit, :as => :button, :button_html => {:value => "Save", :class => "btn btn-primary"}
|
|
||||||
=link_to "#{user.roles.map { |role| role.name }.join ', '}", "#", "data-toggle" => "modal", "data-target" => "#user-role-selection-#{user.id}",id: "user-modify-role-#{user.id}"
|
|
||||||
%td
|
%td
|
||||||
= link_to "Edit", edit_admin_user_path(user)
|
= link_to "View", admin_user_path(user), class: 'btn btn-success'
|
||||||
|
- if can? :update, user
|
||||||
%td
|
%td
|
||||||
= link_to "View", admin_user_path(user)
|
= link_to "Edit", edit_admin_user_path(user), class: 'btn btn-primary'
|
||||||
|
- if can? :destroy, user
|
||||||
%td
|
%td
|
||||||
- if current_user.id == user.id or user.role_ids.include? 3
|
- if current_user.id == user.id or user.role_ids.include? 3
|
||||||
=link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button"
|
=link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,14 @@
|
||||||
|
- if can? :edit, @user
|
||||||
|
.pull-right
|
||||||
|
= link_to "Edit", edit_admin_user_path(@user), class: 'btn btn-primary'
|
||||||
%table.table
|
%table.table
|
||||||
- @show_attributes.each do |attr|
|
- @show_attributes.each do |attr|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td{class: 'table20'}
|
||||||
%b
|
%b
|
||||||
= attr.capitalize.gsub('_', ' ')
|
= attr.capitalize.gsub('_', ' ')
|
||||||
|
- if attr == 'roles'
|
||||||
|
%td
|
||||||
|
= show_roles(@user.get_roles)
|
||||||
|
- else
|
||||||
%td= @user.send(attr)
|
%td= @user.send(attr)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
-else
|
-else
|
||||||
%h4 Registration is Closed, it was from #{ date_string(@conference.registration_start_date, @conference.registration_end_date) }
|
%h4 Registration is Closed, it was from #{ date_string(@conference.registration_start_date, @conference.registration_end_date) }
|
||||||
- if @conference.registration_open?
|
- if @conference.registration_open?
|
||||||
= link_to "Register for #{@conference.short_title}", register_conference_path(@conference.short_title), :class =>"btn btn-success btn-lg", target: '_blank'
|
= link_to "Register for #{@conference.short_title}", conference_register_path(@conference.short_title), :class =>"btn btn-success btn-lg", target: '_blank'
|
||||||
- if @conference.use_supporter_levels?
|
- if @conference.use_supporter_levels?
|
||||||
- if @conference.include_tickets_in_splash?
|
- if @conference.include_tickets_in_splash?
|
||||||
= render 'tickets'
|
= render 'tickets'
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
= semantic_form_for(@registration, :url => register_conference_path(@conference.short_title), :html => { :method => :patch }) do |f|
|
= semantic_form_for(@registration, :url => conference_register_path(@conference.short_title), :html => { :method => :patch }) do |f|
|
||||||
.tabbable
|
.tabbable
|
||||||
%ul.nav.nav-tabs
|
%ul.nav.nav-tabs
|
||||||
%li.active
|
%li.active
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
= render 'conference_registration/volunteer', :f => f
|
= render 'conference_registration/volunteer', :f => f
|
||||||
- if @registered
|
- if @registered
|
||||||
= f.action :submit, :button_html => { :value => "Update Registration", :class => "btn btn-primary" }
|
= f.action :submit, :button_html => { :value => "Update Registration", :class => "btn btn-primary" }
|
||||||
= link_to "Unregister", register_conference_path(@conference.short_title),:method => :delete, :class => "btn btn-danger",
|
= link_to "Unregister", conference_register_path(@conference.short_title),:method => :delete, :class => "btn btn-danger",
|
||||||
:confirm => "Are you sure you want to unregister?"
|
:confirm => "Are you sure you want to unregister?"
|
||||||
- else
|
- else
|
||||||
= f.action :submit, :button_html => { :value => "Register", :class => "btn btn-primary", id: 'register' }
|
= f.action :submit, :button_html => { :value => "Register", :class => "btn btn-primary", id: 'register' }
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@
|
||||||
= link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default"
|
= link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default"
|
||||||
- if conference.registration_open?
|
- if conference.registration_open?
|
||||||
- if conference.user_registered?(current_user)
|
- if conference.user_registered?(current_user)
|
||||||
= link_to "Modify Registration", register_conference_path(conference.short_title), :class =>"btn btn-default"
|
= link_to "Modify Registration", conference_register_path(conference.short_title), :class =>"btn btn-default"
|
||||||
- else
|
- else
|
||||||
= link_to "Register", register_conference_path(conference.short_title), :class =>"btn btn-success"
|
= link_to "Register", conference_register_path(conference.short_title), :class =>"btn btn-success"
|
||||||
= link_to "Schedule", conference_schedule_path(conference.short_title), :class =>"btn btn-default" if conference.call_for_papers and conference.call_for_papers.schedule_public
|
= link_to "Schedule", conference_schedule_path(conference.short_title), :class =>"btn btn-default" if conference.call_for_papers and conference.call_for_papers.schedule_public
|
||||||
- if !current_user.nil? && current_user.proposal_count(conference) > 0
|
- if !current_user.nil? && current_user.proposal_count(conference) > 0
|
||||||
= link_to "View My Proposals", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default"
|
= link_to "View My Proposals", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default"
|
||||||
|
|
|
||||||
|
|
@ -10,97 +10,124 @@
|
||||||
%span.glyphicon.glyphicon-home
|
%span.glyphicon.glyphicon-home
|
||||||
All Conferences
|
All Conferences
|
||||||
- @conferences.each do |conference|
|
- @conferences.each do |conference|
|
||||||
|
- if can? :show, conference
|
||||||
%li
|
%li
|
||||||
= link_to(admin_conference_path(conference.short_title)) do
|
= link_to(admin_conference_path(conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-cog
|
%span.glyphicon.glyphicon-cog
|
||||||
Manage
|
Manage
|
||||||
= conference.short_title
|
= conference.short_title
|
||||||
|
- if (current_user.is_admin) || (current_user.has_role? :organizer, :any)
|
||||||
%li
|
%li
|
||||||
= link_to(new_admin_conference_path) do
|
= link_to(new_admin_conference_path) do
|
||||||
%span.glyphicon.glyphicon-plus
|
%span.glyphicon.glyphicon-plus
|
||||||
New Conference
|
New Conference
|
||||||
%hr
|
%hr
|
||||||
|
- if can? :show, @conference
|
||||||
%li{:class=> "#{active_nav_li(admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"}
|
%li{:class=> "#{active_nav_li(admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"}
|
||||||
= link_to(admin_conference_path(@conference.short_title)) do
|
= link_to(admin_conference_path(@conference.short_title)) do
|
||||||
%span.fa.fa-tachometer
|
%span.fa.fa-tachometer
|
||||||
Dashboard
|
Dashboard
|
||||||
|
- if can? :show, @conference
|
||||||
%li{:class=> "#{active_nav_li(edit_admin_conference_path(@conference.short_title))}"}
|
%li{:class=> "#{active_nav_li(edit_admin_conference_path(@conference.short_title))}"}
|
||||||
= link_to(edit_admin_conference_path(@conference.short_title)) do
|
= link_to(edit_admin_conference_path(@conference.short_title)) do
|
||||||
%span.fa.fa-home
|
%span.fa.fa-home
|
||||||
Basics
|
Basics
|
||||||
%ul
|
%ul
|
||||||
|
- if can? :update, Contact.new(conference_id: @conference.id)
|
||||||
%li{:class=> "#{active_nav_li(edit_admin_conference_contact_path(@conference.short_title))}"}
|
%li{:class=> "#{active_nav_li(edit_admin_conference_contact_path(@conference.short_title))}"}
|
||||||
= link_to(edit_admin_conference_contact_path(@conference.short_title)) do
|
= link_to(edit_admin_conference_contact_path(@conference.short_title)) do
|
||||||
%span.fa.fa-envelope-o
|
%span.fa.fa-envelope-o
|
||||||
Contact
|
Contact
|
||||||
|
- if can? :index, @conference.commercials.build
|
||||||
%li{:class=> "#{active_nav_li(admin_conference_commercials_path(@conference.short_title))}"}
|
%li{:class=> "#{active_nav_li(admin_conference_commercials_path(@conference.short_title))}"}
|
||||||
= link_to(admin_conference_commercials_path(@conference.short_title)) do
|
= link_to(admin_conference_commercials_path(@conference.short_title)) do
|
||||||
%span.fa.fa-film
|
%span.fa.fa-film
|
||||||
Commercials
|
Commercials
|
||||||
|
- if can? :update, @conference.photos.build
|
||||||
%li{:class=> "#{active_nav_li(admin_conference_photos_path(@conference.short_title))}"}
|
%li{:class=> "#{active_nav_li(admin_conference_photos_path(@conference.short_title))}"}
|
||||||
= link_to(admin_conference_photos_path(@conference.short_title)) do
|
= link_to(admin_conference_photos_path(@conference.short_title)) do
|
||||||
%span.fa.fa-picture-o
|
%span.fa.fa-picture-o
|
||||||
Photos
|
Photos
|
||||||
|
- if can? :update, @conference.events.build
|
||||||
%li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))}
|
%li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))}
|
||||||
= link_to(admin_conference_events_path(@conference.short_title)) do
|
= link_to(admin_conference_events_path(@conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-comment
|
%span.glyphicon.glyphicon-comment
|
||||||
Events
|
Events
|
||||||
|
- if can? :update, Registration.new(conference_id: @conference.id)
|
||||||
%li{:class=> active_nav_li(admin_conference_registrations_path(@conference.short_title))}
|
%li{:class=> active_nav_li(admin_conference_registrations_path(@conference.short_title))}
|
||||||
= link_to(admin_conference_registrations_path(@conference.short_title)) do
|
= link_to(admin_conference_registrations_path(@conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-user
|
%span.glyphicon.glyphicon-user
|
||||||
Registrations
|
Registrations
|
||||||
|
- if can? :update, @conference.events.build
|
||||||
%li{class: active_nav_li(admin_conference_schedule_path(@conference.short_title))}
|
%li{class: active_nav_li(admin_conference_schedule_path(@conference.short_title))}
|
||||||
= link_to(admin_conference_schedule_path(@conference.short_title), target: '_blank') do
|
= link_to(admin_conference_schedule_path(@conference.short_title), target: '_blank') do
|
||||||
%span.glyphicon.glyphicon-calendar
|
%span.glyphicon.glyphicon-calendar
|
||||||
Schedule
|
Schedule
|
||||||
|
- if can? :update, @conference
|
||||||
%li{class: active_nav_li(admin_conference_campaigns_path(@conference.short_title))}
|
%li{class: active_nav_li(admin_conference_campaigns_path(@conference.short_title))}
|
||||||
= link_to(admin_conference_campaigns_path(@conference.short_title)) do
|
= link_to(admin_conference_campaigns_path(@conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-bullhorn
|
%span.glyphicon.glyphicon-bullhorn
|
||||||
Campaigns
|
Campaigns
|
||||||
%hr
|
%hr
|
||||||
|
- if can? :update, @conference.targets.build
|
||||||
%li{:class=> "#{active_nav_li(admin_conference_targets_path(@conference.short_title))}"}
|
%li{:class=> "#{active_nav_li(admin_conference_targets_path(@conference.short_title))}"}
|
||||||
= link_to(admin_conference_targets_path(@conference.short_title)) do
|
= link_to(admin_conference_targets_path(@conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-flag
|
%span.glyphicon.glyphicon-flag
|
||||||
Targets
|
Targets
|
||||||
|
- if can? :index, @conference.venue
|
||||||
%li{:class=> "#{active_nav_li(admin_conference_venue_info_path(@conference.short_title))} myAccordion"}
|
%li{:class=> "#{active_nav_li(admin_conference_venue_info_path(@conference.short_title))} myAccordion"}
|
||||||
= link_to(admin_conference_venue_info_path(@conference.short_title)) do
|
= link_to(admin_conference_venue_info_path(@conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-road
|
%span.glyphicon.glyphicon-road
|
||||||
Venue
|
Venue
|
||||||
%span.small.glyphicon.glyphicon-chevron-right
|
%span.small.glyphicon.glyphicon-chevron-right
|
||||||
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav
|
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav
|
||||||
|
- if can? :update, @conference.rooms.build
|
||||||
%li{:class=> active_nav_li(admin_conference_rooms_path(@conference.short_title))}
|
%li{:class=> active_nav_li(admin_conference_rooms_path(@conference.short_title))}
|
||||||
= link_to 'Rooms', admin_conference_rooms_path(@conference.short_title)
|
= link_to 'Rooms', admin_conference_rooms_path(@conference.short_title)
|
||||||
|
- if can? :update, @conference.venue.lodgings.build
|
||||||
%li{ class: active_nav_li(admin_conference_lodgings_path(@conference.short_title)) }
|
%li{ class: active_nav_li(admin_conference_lodgings_path(@conference.short_title)) }
|
||||||
= link_to 'Lodgings', admin_conference_lodgings_path(@conference.short_title)
|
= link_to 'Lodgings', admin_conference_lodgings_path(@conference.short_title)
|
||||||
|
- if can? :update, @conference.sponsorship_levels.build
|
||||||
%li{:class=> "#{active_nav_li(admin_conference_sponsorship_levels_path(@conference.short_title))} myAccordion" }
|
%li{:class=> "#{active_nav_li(admin_conference_sponsorship_levels_path(@conference.short_title))} myAccordion" }
|
||||||
= link_to(admin_conference_sponsorship_levels_path(@conference.short_title)) do
|
= link_to(admin_conference_sponsorship_levels_path(@conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-star
|
%span.glyphicon.glyphicon-star
|
||||||
Sponsorship
|
Sponsorship
|
||||||
%span.small.glyphicon.glyphicon-chevron-right
|
%span.small.glyphicon.glyphicon-chevron-right
|
||||||
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav
|
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav
|
||||||
|
- if can? :update, @conference.sponsors.build
|
||||||
%li{:class=> active_nav_li(admin_conference_sponsors_path(@conference.short_title))}
|
%li{:class=> active_nav_li(admin_conference_sponsors_path(@conference.short_title))}
|
||||||
= link_to 'Sponsors', admin_conference_sponsors_path(@conference.short_title)
|
= link_to 'Sponsors', admin_conference_sponsors_path(@conference.short_title)
|
||||||
|
- if can? :update, @conference.supporter_levels.build
|
||||||
%li{ class: active_nav_li(admin_conference_supporter_levels_path(@conference.short_title)) }
|
%li{ class: active_nav_li(admin_conference_supporter_levels_path(@conference.short_title)) }
|
||||||
= link_to(admin_conference_supporter_levels_path(@conference.short_title)) do
|
= link_to(admin_conference_supporter_levels_path(@conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-usd
|
%span.glyphicon.glyphicon-usd
|
||||||
Supporter Levels
|
Supporter Levels
|
||||||
|
- if can? :update, @conference.email_settings
|
||||||
%li{:class=> active_nav_li(admin_conference_emails_path(@conference.short_title))}
|
%li{:class=> active_nav_li(admin_conference_emails_path(@conference.short_title))}
|
||||||
= link_to(admin_conference_emails_path(@conference.short_title)) do
|
= link_to(admin_conference_emails_path(@conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-envelope
|
%span.glyphicon.glyphicon-envelope
|
||||||
E-Mails
|
E-Mails
|
||||||
|
- if can? :update, CallForPapers.new(conference_id: @conference.id)
|
||||||
%li{:class=> "#{active_nav_li(admin_conference_callforpapers_path(@conference.short_title))} myAccordion"}
|
%li{:class=> "#{active_nav_li(admin_conference_callforpapers_path(@conference.short_title))} myAccordion"}
|
||||||
= link_to(admin_conference_callforpapers_path(@conference.short_title)) do
|
= link_to(admin_conference_callforpapers_path(@conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-comment
|
%span.glyphicon.glyphicon-comment
|
||||||
Call for papers
|
Call for papers
|
||||||
%span.small.glyphicon.glyphicon-chevron-right
|
%span.small.glyphicon.glyphicon-chevron-right
|
||||||
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav
|
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav
|
||||||
|
- if can? :update, @conference.tracks.build
|
||||||
%li{:class=> active_nav_li(admin_conference_tracks_path(@conference.short_title))}
|
%li{:class=> active_nav_li(admin_conference_tracks_path(@conference.short_title))}
|
||||||
= link_to 'Tracks', admin_conference_tracks_path(@conference.short_title)
|
= link_to 'Tracks', admin_conference_tracks_path(@conference.short_title)
|
||||||
%li{:class=> active_nav_li(admin_conference_eventtypes_path(@conference.short_title))}
|
- if can? :update, @conference.event_types.build
|
||||||
= link_to 'Event types', admin_conference_eventtypes_path(@conference.short_title)
|
%li{:class=> active_nav_li(admin_conference_event_types_path(@conference.short_title))}
|
||||||
|
= link_to 'Event types', admin_conference_event_types_path(@conference.short_title)
|
||||||
|
- if can? :update, @conference.difficulty_levels.build, conference_id: @conference.id
|
||||||
%li{:class=> active_nav_li(admin_conference_difficulty_levels_path(@conference.short_title))}
|
%li{:class=> active_nav_li(admin_conference_difficulty_levels_path(@conference.short_title))}
|
||||||
= link_to 'Difficulty levels', admin_conference_difficulty_levels_path(@conference.short_title)
|
= link_to 'Difficulty levels', admin_conference_difficulty_levels_path(@conference.short_title)
|
||||||
|
- if can? :update, Question.new(conference_id: @conference.id)
|
||||||
%li{:class=> active_nav_li(admin_conference_questions_path(@conference.short_title))}
|
%li{:class=> active_nav_li(admin_conference_questions_path(@conference.short_title))}
|
||||||
= link_to(admin_conference_questions_path(@conference.short_title)) do
|
= link_to(admin_conference_questions_path(@conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-question-sign
|
%span.glyphicon.glyphicon-question-sign
|
||||||
Questions
|
Questions
|
||||||
|
- if can? :manage, @conference
|
||||||
|
%li{:class=> active_nav_li(roles_admin_conference_path(@conference.short_title))}
|
||||||
|
= link_to 'Roles', roles_admin_conference_path(@conference.short_title)
|
||||||
|
|
|
||||||
|
|
@ -10,15 +10,18 @@
|
||||||
%span.glyphicon.glyphicon-home
|
%span.glyphicon.glyphicon-home
|
||||||
All Conferences
|
All Conferences
|
||||||
- @conferences.each do |conference|
|
- @conferences.each do |conference|
|
||||||
|
- if can? :show, conference
|
||||||
%li
|
%li
|
||||||
= link_to(admin_conference_path(conference.short_title)) do
|
= link_to(admin_conference_path(conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-cog
|
%span.glyphicon.glyphicon-cog
|
||||||
Manage
|
Manage
|
||||||
= conference.short_title
|
= conference.short_title
|
||||||
|
- if (current_user.is_admin) || (current_user.has_role? :organizer, :any)
|
||||||
%li
|
%li
|
||||||
= link_to(new_admin_conference_path) do
|
= link_to(new_admin_conference_path) do
|
||||||
%span.glyphicon.glyphicon-plus
|
%span.glyphicon.glyphicon-plus
|
||||||
New Conference
|
New Conference
|
||||||
|
- if can? :index, User
|
||||||
%hr
|
%hr
|
||||||
%li
|
%li
|
||||||
= link_to(admin_users_path) do
|
= link_to(admin_users_path) do
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,13 @@
|
||||||
= link_to(destroy_user_session_path, :method=>'delete') do
|
= link_to(destroy_user_session_path, :method=>'delete') do
|
||||||
%span.glyphicon.glyphicon-minus
|
%span.glyphicon.glyphicon-minus
|
||||||
Sign out
|
Sign out
|
||||||
-if has_role?(current_user, "admin") || has_role?(current_user, "organizer")
|
- if can? :index, Conference
|
||||||
%li.divider
|
%li.divider
|
||||||
%li
|
%li
|
||||||
= link_to(admin_conference_index_path()) do
|
= link_to(admin_conference_index_path()) do
|
||||||
%span.glyphicon.glyphicon-home
|
%span.glyphicon.glyphicon-home
|
||||||
Administration
|
Administration
|
||||||
-if @conference and @conference.id
|
-if @conference and @conference.id and can? :show, @conference
|
||||||
%li
|
%li
|
||||||
= link_to(admin_conference_path(@conference.short_title)) do
|
= link_to(admin_conference_path(@conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-cog
|
%span.glyphicon.glyphicon-cog
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,12 @@
|
||||||
= commercial.commercial_type
|
= commercial.commercial_type
|
||||||
.flexvideo
|
.flexvideo
|
||||||
= render partial: 'shared/media_item', locals: { commercial_type: commercial.commercial_type, commercial_id: commercial.commercial_id }
|
= render partial: 'shared/media_item', locals: { commercial_type: commercial.commercial_type, commercial_id: commercial.commercial_id }
|
||||||
|
- if can? :update, commercial
|
||||||
= link_to 'Edit', edit_conference_proposal_commercial_path(@conference.short_title, @event.id, commercial.id), class: 'btn btn-primary'
|
= link_to 'Edit', edit_conference_proposal_commercial_path(@conference.short_title, @event.id, commercial.id), class: 'btn btn-primary'
|
||||||
|
- if can? :destrooy, commercial
|
||||||
= link_to 'Delete', conference_proposal_commercial_path(@conference.short_title, @event.id, commercial.id),
|
= link_to 'Delete', conference_proposal_commercial_path(@conference.short_title, @event.id, commercial.id),
|
||||||
:method => :delete, :data => { :confirm => 'Are you sure?' }, class: 'btn btn-danger'
|
:method => :delete, :data => { :confirm => 'Are you sure?' }, class: 'btn btn-danger'
|
||||||
|
- if can? :create, @event.commercials.new
|
||||||
%hr
|
%hr
|
||||||
= link_to 'Add Commercial', new_conference_proposal_commercial_path(@conference.short_title, @event.id), class: 'btn btn-primary'
|
= link_to 'Add Commercial', new_conference_proposal_commercial_path(@conference.short_title, @event.id), class: 'btn btn-primary'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
= semantic_form_for(@event, :url => @url) do |f|
|
= semantic_form_for(@event, :url => @url) do |f|
|
||||||
%section#basic
|
%section#basic
|
||||||
= f.inputs :name => "Session Information" do
|
= f.inputs :name => "Session Information" do
|
||||||
- if !@conference.call_for_papers.schedule_changes && @event.state == "confirmed" && !organizer_or_admin?
|
- if can? :update, @event or can? :create, @event
|
||||||
|
= f.input :title, :as => :string, :required => true
|
||||||
|
- else
|
||||||
Title: #{@event.title}
|
Title: #{@event.title}
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
- else
|
|
||||||
= f.input :title, :as => :string, :required => true
|
|
||||||
= f.input :subtitle, :as => :string
|
= f.input :subtitle, :as => :string
|
||||||
%section#details
|
%section#details
|
||||||
- if (@event.state === "unconfirmed" || @event.state === "confirmed") && !organizer_or_admin? && !@conference.call_for_papers.schedule_changes
|
- if can? :update, @event or can? :create, @event
|
||||||
|
= f.input :event_type_id,:as => :select, :collection => @conference.event_types.map {|x| ["#{x.title} - #{show_time(x.length)}", x.id]}, :include_blank => false, :label => "Session Type"
|
||||||
|
- else
|
||||||
Event type: #{@event.event_type.title}
|
Event type: #{@event.event_type.title}
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
- else
|
|
||||||
= f.input :event_type_id,:as => :select, :collection => @conference.event_types.map {|x| ["#{x.title} - #{show_time(x.length)}", x.id]}, :include_blank => false, :label => "Session Type"
|
|
||||||
= f.input :difficulty_level, :as => :select, :collection => @conference.difficulty_levels, :include_blank => "(Please select)" if @conference.use_difficulty_levels
|
= f.input :difficulty_level, :as => :select, :collection => @conference.difficulty_levels, :include_blank => "(Please select)" if @conference.use_difficulty_levels
|
||||||
= f.input :require_registration
|
= f.input :require_registration
|
||||||
= f.input :abstract, :input_html => {:rows => 5, :class => "span11"},
|
= f.input :abstract, :input_html => {:rows => 5, :class => "span11"},
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
.col-md-12.page-header
|
.col-md-12.page-header
|
||||||
%h1
|
%h1
|
||||||
= "My Proposals for #{@conference.title}"
|
= "My Proposals for #{@conference.title}"
|
||||||
- if @conference.cfp_open? || organizer_or_admin?
|
- if @conference.cfp_open? || (current_user.has_role? :organizer, @conference)
|
||||||
= link_to "New Proposal", new_conference_proposal_path(@conference.short_title), :class => "btn btn-success pull-right"
|
= link_to "New Proposal", new_conference_proposal_path(@conference.short_title), :class => "btn btn-success pull-right"
|
||||||
- if current_user.proposal_count(@conference) > 0
|
- if current_user.proposal_count(@conference) > 0
|
||||||
.row
|
.row
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
(Pre-registered: #{pre_registered(event).count})
|
(Pre-registered: #{pre_registered(event).count})
|
||||||
- if event.confirmed? && !@conference.user_registered?(current_user)
|
- if event.confirmed? && !@conference.user_registered?(current_user)
|
||||||
%br
|
%br
|
||||||
= link_to "Register to attend", register_conference_path(@conference.short_title), :style => "font-size:10px;"
|
= link_to "Register to attend", conference_register_path(@conference.short_title), :style => "font-size:10px;"
|
||||||
%td
|
%td
|
||||||
.pull-right
|
.pull-right
|
||||||
- if event.transition_possible? :confirm
|
- if event.transition_possible? :confirm
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
%small
|
%small
|
||||||
= @event.subtitle
|
= @event.subtitle
|
||||||
= link_to "Schedule", conference_schedule_path(@conference.short_title), :class =>"btn btn-success pull-right"
|
= link_to "Schedule", conference_schedule_path(@conference.short_title), :class =>"btn btn-success pull-right"
|
||||||
- if has_role?(current_user, "admin")
|
- if can? :edit, @event
|
||||||
= link_to "Edit", edit_admin_conference_event_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary pull-right"
|
= link_to "Edit", edit_admin_conference_event_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary pull-right"
|
||||||
.row
|
.row
|
||||||
.col-md-3
|
.col-md-3
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
%span.label{:style =>"background-color: #{@event.difficulty_level.color};"}
|
%span.label{:style =>"background-color: #{@event.difficulty_level.color};"}
|
||||||
= @event.difficulty_level.title
|
= @event.difficulty_level.title
|
||||||
- if @event.require_registration
|
- if @event.require_registration
|
||||||
= link_to "Registration required!", register_conference_path(@conference.short_title), :class => "btn btn-xs btn-warning"
|
= link_to "Registration required!", conference_register_path(@conference.short_title), :class => "btn btn-xs btn-warning"
|
||||||
.col-md-9
|
.col-md-9
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
|
|
|
||||||
8
config/initializers/rolify.rb
Normal file
8
config/initializers/rolify.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
Rolify.configure do |config|
|
||||||
|
# By default ORM adapter is ActiveRecord. uncomment to use mongoid
|
||||||
|
# config.use_mongoid
|
||||||
|
|
||||||
|
# Dynamic shortcuts for User class (user.is_admin? like methods). Default is: false
|
||||||
|
# Enable this feature _after_ running rake db:migrate as it relies on the roles table
|
||||||
|
config.use_dynamic_shortcuts
|
||||||
|
end
|
||||||
|
|
@ -8,6 +8,12 @@ Osem::Application.routes.draw do
|
||||||
resources :users
|
resources :users
|
||||||
resources :people
|
resources :people
|
||||||
resources :conference do
|
resources :conference do
|
||||||
|
member do
|
||||||
|
get :roles
|
||||||
|
post :roles
|
||||||
|
post :add_user
|
||||||
|
delete :remove_user
|
||||||
|
end
|
||||||
resource :contact, except: [:index, :new, :create, :show, :destroy]
|
resource :contact, except: [:index, :new, :create, :show, :destroy]
|
||||||
resources :photos, except: [:show]
|
resources :photos, except: [:show]
|
||||||
resource :schedule, only: [:show, :update]
|
resource :schedule, only: [:show, :update]
|
||||||
|
|
@ -40,7 +46,7 @@ Osem::Application.routes.draw do
|
||||||
|
|
||||||
resources :campaigns
|
resources :campaigns
|
||||||
|
|
||||||
resources :eventtypes, only: [:show, :index] do
|
resources :event_types, only: [:show, :index] do
|
||||||
collection do
|
collection do
|
||||||
patch :update
|
patch :update
|
||||||
end
|
end
|
||||||
|
|
@ -92,10 +98,11 @@ Osem::Application.routes.draw do
|
||||||
resource :schedule, only: [] do
|
resource :schedule, only: [] do
|
||||||
get "/" => "schedule#index"
|
get "/" => "schedule#index"
|
||||||
end
|
end
|
||||||
member do
|
|
||||||
get "/register" => "conference_registration#register"
|
get "/register" => "conference_registration#register"
|
||||||
patch "/register" => "conference_registration#update"
|
patch "/register" => "conference_registration#update"
|
||||||
delete "/register" => "conference_registration#unregister"
|
delete "/register" => "conference_registration#unregister"
|
||||||
|
member do
|
||||||
get "gallery_photos"
|
get "gallery_photos"
|
||||||
patch "subscription" => "conference#subscribe"
|
patch "subscription" => "conference#subscribe"
|
||||||
delete "subscription" => "conference#unsubscribe"
|
delete "subscription" => "conference#unsubscribe"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
class AddDescriptionAndResourceToRoles < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :roles, :description, :string
|
||||||
|
add_reference :roles, :resource, polymorphic: true
|
||||||
|
|
||||||
|
add_index(:roles, :name)
|
||||||
|
add_index(:roles, [:name, :resource_type, :resource_id])
|
||||||
|
add_index(:roles_users, [:user_id, :role_id])
|
||||||
|
end
|
||||||
|
end
|
||||||
5
db/migrate/20140718103856_add_is_admin_to_users.rb
Normal file
5
db/migrate/20140718103856_add_is_admin_to_users.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddIsAdminToUsers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :users, :is_admin, :boolean, default: false
|
||||||
|
end
|
||||||
|
end
|
||||||
27
db/migrate/20140730104658_migrate_roles_for_cancancan.rb
Normal file
27
db/migrate/20140730104658_migrate_roles_for_cancancan.rb
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
class MigrateRolesForCancancan < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
# Store the number of existing roles
|
||||||
|
old_roles = Role.count
|
||||||
|
|
||||||
|
Role.all.each do |role|
|
||||||
|
role.users.each do |user|
|
||||||
|
Conference.all.each do |conference|
|
||||||
|
if role.name == 'Admin' || role.name == 'Organizer'
|
||||||
|
user.add_role :organizer, conference
|
||||||
|
else
|
||||||
|
user.add_role role.name.parameterize.underscore.to_sym, conference
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Delete old roles
|
||||||
|
Role.first(old_roles).each do |role|
|
||||||
|
role.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
raise ActiveRecord::IrreversibleMigration.new('Cannot reverse migration. Deleted events cannot be re-created')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -363,15 +363,23 @@ ActiveRecord::Schema.define(version: 20140801170430) do
|
||||||
|
|
||||||
create_table "roles", force: true do |t|
|
create_table "roles", force: true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
|
t.string "description"
|
||||||
|
t.integer "resource_id"
|
||||||
|
t.string "resource_type"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
|
||||||
|
add_index "roles", ["name"], name: "index_roles_on_name"
|
||||||
|
|
||||||
create_table "roles_users", id: false, force: true do |t|
|
create_table "roles_users", id: false, force: true do |t|
|
||||||
t.integer "role_id"
|
t.integer "role_id"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index "roles_users", ["user_id", "role_id"], name: "index_roles_users_on_user_id_and_role_id"
|
||||||
|
|
||||||
create_table "rooms", force: true do |t|
|
create_table "rooms", force: true do |t|
|
||||||
t.string "guid", null: false
|
t.string "guid", null: false
|
||||||
t.integer "conference_id"
|
t.integer "conference_id"
|
||||||
|
|
@ -484,6 +492,7 @@ ActiveRecord::Schema.define(version: 20140801170430) do
|
||||||
t.string "tshirt"
|
t.string "tshirt"
|
||||||
t.string "languages"
|
t.string "languages"
|
||||||
t.text "volunteer_experience"
|
t.text "volunteer_experience"
|
||||||
|
t.boolean "is_admin", default: false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||||
|
|
|
||||||
18
db/seeds.rb
18
db/seeds.rb
|
|
@ -5,18 +5,18 @@
|
||||||
#
|
#
|
||||||
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
||||||
# Mayor.create(name: 'Emanuel', city: cities.first)
|
# Mayor.create(name: 'Emanuel', city: cities.first)
|
||||||
Role.create(name: "Participant")
|
|
||||||
Role.create(name: "Organizer")
|
|
||||||
Role.create(name: "Admin")
|
|
||||||
|
|
||||||
qtype_yesno = QuestionType.create(title: "Yes/No")
|
# Questions
|
||||||
QuestionType.create(title: "Single Choice")
|
qtype_yesno = QuestionType.create(title: 'Yes/No')
|
||||||
QuestionType.create(title: "Multiple Choice")
|
QuestionType.create(title: 'Single Choice')
|
||||||
|
QuestionType.create(title: 'Multiple Choice')
|
||||||
|
|
||||||
answer_yes = Answer.create(title: "Yes")
|
answer_yes = Answer.create(title: 'Yes')
|
||||||
answer_no = Answer.create(title: "No")
|
answer_no = Answer.create(title: 'No')
|
||||||
|
|
||||||
questions_yes_no = ["Do you need handicapped access to the venue?", "Are you attending with partner?", "Will you attend the social event(s)?", "Will you stay at suggested hotel?"]
|
questions_yes_no = ['Do you need handicapped access to the venue?',
|
||||||
|
'Are you attending with partner?', 'Will you attend the social event(s)?',
|
||||||
|
'Will you stay at suggested hotel?']
|
||||||
|
|
||||||
questions_yes_no.each do |i|
|
questions_yes_no.each do |i|
|
||||||
q = Question.create(title: i, question_type_id: qtype_yesno.id, global: true)
|
q = Question.create(title: i, question_type_id: qtype_yesno.id, global: true)
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,15 @@ require 'spec_helper'
|
||||||
describe Admin::ConferenceController do
|
describe Admin::ConferenceController do
|
||||||
|
|
||||||
# It is necessary to use bang version of let to build roles before user
|
# It is necessary to use bang version of let to build roles before user
|
||||||
let!(:organizer_role) { create(:organizer_role) }
|
|
||||||
let!(:participant_role) { create(:participant_role) }
|
|
||||||
let!(:admin_role) { create(:admin_role) }
|
|
||||||
|
|
||||||
let(:conference) { create(:conference) }
|
let(:conference) { create(:conference) }
|
||||||
let(:admin) { create(:admin) }
|
let!(:first_user) { create(:user) }
|
||||||
let(:organizer) { create(:organizer) }
|
let!(:organizer_role) { create(:role, name: 'organizer', resource: conference) }
|
||||||
let(:participant) { create(:participant) }
|
|
||||||
|
|
||||||
shared_examples 'access as administration or organizer' do
|
let(:organizer) { create(:user, role_ids: organizer_role.id) }
|
||||||
|
let(:organizer2) { create(:user, email: 'organizer2@email.osem', role_ids: organizer_role.id) }
|
||||||
|
let(:participant) { create(:user) }
|
||||||
|
|
||||||
|
shared_examples 'access as organizer' do
|
||||||
|
|
||||||
describe 'PATCH #update' do
|
describe 'PATCH #update' do
|
||||||
|
|
||||||
|
|
@ -45,8 +44,7 @@ describe Admin::ConferenceController do
|
||||||
mailer = double
|
mailer = double
|
||||||
allow(mailer).to receive(:deliver)
|
allow(mailer).to receive(:deliver)
|
||||||
conference.email_settings = create(:email_settings)
|
conference.email_settings = create(:email_settings)
|
||||||
patch :update, id: conference.short_title, conference:
|
patch :update, id: conference.short_title, conference: attributes_for(:conference, start_date: Date.today + 2.days, end_date: Date.today + 4.days)
|
||||||
attributes_for(:conference, start_date: Date.today + 2.days, end_date: Date.today + 4.days)
|
|
||||||
conference.reload
|
conference.reload
|
||||||
allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer)
|
allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer)
|
||||||
end
|
end
|
||||||
|
|
@ -193,8 +191,12 @@ describe Admin::ConferenceController do
|
||||||
|
|
||||||
context 'no conferences' do
|
context 'no conferences' do
|
||||||
it 'redirect to new conference' do
|
it 'redirect to new conference' do
|
||||||
|
Conference.all.each do |c|
|
||||||
|
c.destroy
|
||||||
|
end
|
||||||
|
sign_in create(:admin)
|
||||||
get :index
|
get :index
|
||||||
expect(response).to redirect_to(redirect_to new_admin_conference_path)
|
expect(response).to redirect_to new_admin_conference_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -210,64 +212,193 @@ describe Admin::ConferenceController do
|
||||||
expect(response).to render_template :new
|
expect(response).to render_template :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'GET #roles' do
|
||||||
|
before(:each) do
|
||||||
|
get :roles, id: conference.short_title
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'administrator access' do
|
it 'assigns default value to selection' do
|
||||||
|
expect(assigns(:selection)).to eq('organizer')
|
||||||
before do
|
|
||||||
sign_in(admin)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'access as administration or organizer'
|
it 'finds the correct role' do
|
||||||
|
expect(assigns(:role)).to eq([organizer_role])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'properly assigns role_users hash' do
|
||||||
|
expect(assigns(:role_users)).to eq('organizer' => [organizer, organizer2])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'properly assigns roles variable' do
|
||||||
|
expect(assigns(:roles)).to eq(['Organizer', 'CfP', 'Info Desk', 'Volunteers Coordinator', 'Attendee', 'Volunteer', 'Speaker', 'Sponsor', 'Press', 'Keynote Speaker', ])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'POST #roles' do
|
||||||
|
before(:each) do
|
||||||
|
post :roles, id: conference.short_title, user: { roles: 'CfP' }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'assigns selected value to selection' do
|
||||||
|
expect(assigns(:selection)).to eq('cfp')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sets role variable' do
|
||||||
|
post :roles, id: conference.short_title, user: { roles: 'Organizer' }
|
||||||
|
role = Role.where(name: 'organizer', resource: conference)
|
||||||
|
expect(assigns(:role)).to eq(role)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sets role variable (returns blank for nil role)' do
|
||||||
|
expect(assigns(:role)).to eq([])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sets role_users hash with blank' do
|
||||||
|
expect(assigns(:role_users)).to eq('cfp' => [])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sets role_users has with data' do
|
||||||
|
organizer.add_role :cfp, conference
|
||||||
|
post :roles, id: conference.short_title, user: { roles: 'CfP' }
|
||||||
|
expect(assigns(:role_users)).to eq('cfp' => [organizer])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sets roles variable' do
|
||||||
|
expect(assigns(:roles)).to eq(['Organizer', 'CfP', 'Info Desk', 'Volunteers Coordinator', 'Attendee', 'Volunteer', 'Speaker', 'Sponsor', 'Press', 'Keynote Speaker', ])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'POST #add_user' do
|
||||||
|
before(:each) do
|
||||||
|
@new_user = create(:user, email: 'new_user@email.osem')
|
||||||
|
post :add_user, id: conference.short_title, user: { email: 'new_user@email.osem' }, role: 'organizer'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'finds correct user' do
|
||||||
|
expect(assigns(:user)).to eq(@new_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sets role_users variable' do
|
||||||
|
expect(assigns(:role_users)).to eq('organizer' => organizer_role.users)
|
||||||
|
|
||||||
|
post :add_user, id: conference.short_title, user: { email: 'new_user@email.osem' }, role: 'cfp'
|
||||||
|
expect(assigns(:role_users)).to eq('cfp' => [@new_user])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'assigns role to user' do
|
||||||
|
expect(@new_user.roles).to eq([organizer_role])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'assigns second role to user' do
|
||||||
|
post :add_user, id: conference.short_title, user: { email: @new_user.email }, role: 'cfp'
|
||||||
|
cfp_role = Role.find_by(name: 'cfp', resource: conference)
|
||||||
|
expect(@new_user.roles).to eq([organizer_role, cfp_role])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'DELETE #remove_user' do
|
||||||
|
before(:each) do
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sets selection variable' do
|
||||||
|
delete :remove_user, id: conference.short_title, user_id: organizer2.id, role: 'organizer'
|
||||||
|
expect(assigns(:selection)).to eq('organizer')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sets role_users hash' do
|
||||||
|
delete :remove_user, id: conference.short_title, user_id: organizer2.id, role: 'organizer'
|
||||||
|
expect(assigns(:role_users)).to eq('organizer' => [organizer])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'removes role from user' do
|
||||||
|
delete :remove_user, id: conference.short_title, user_id: organizer2.id, role: 'organizer'
|
||||||
|
organizer2.reload
|
||||||
|
expect(organizer2.roles).to eq([])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'removes second role from user' do
|
||||||
|
# Add cfp role
|
||||||
|
organizer2.add_role :cfp, conference
|
||||||
|
cfp_role = Role.find_by(name: 'cfp', resource: conference)
|
||||||
|
# Remove role organizer
|
||||||
|
delete :remove_user, id: conference.short_title, user_id: organizer2.id, role: 'organizer'
|
||||||
|
|
||||||
|
organizer2.reload
|
||||||
|
expect(organizer2.roles).to include(cfp_role)
|
||||||
|
expect(organizer2.roles[0]).to eq(cfp_role)
|
||||||
|
expect(organizer2.roles.count).to eq(1)
|
||||||
|
expect(assigns(:role_users)).to eq('organizer' => [organizer])
|
||||||
|
|
||||||
|
delete :remove_user, id: conference.short_title, user_id: organizer2.id, role: 'cfp'
|
||||||
|
organizer2.reload
|
||||||
|
expect(organizer2.roles).to eq([])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'organizer access' do
|
describe 'organizer access' do
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
sign_in(organizer)
|
sign_in(organizer)
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'access as administration or organizer'
|
it_behaves_like 'access as organizer'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples 'access as participant or guest' do |success_path|
|
shared_examples 'access as participant or guest' do |path, message|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
it 'requires admin privileges' do
|
it 'requires organizer privileges' do
|
||||||
get :show, id: conference.short_title
|
get :show, id: conference.short_title
|
||||||
expect(response).to redirect_to(send(success_path))
|
expect(response).to redirect_to(send(path))
|
||||||
|
if message
|
||||||
|
expect(flash[:alert]).to match(/#{message}/)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #index' do
|
describe 'GET #index' do
|
||||||
it 'requires admin privileges' do
|
it 'requires organizer privileges' do
|
||||||
get :index
|
get :index
|
||||||
expect(response).to redirect_to(send(success_path))
|
expect(response).to redirect_to(send(path))
|
||||||
|
if message
|
||||||
|
expect(flash[:alert]).to match(/#{message}/)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #new' do
|
describe 'GET #new' do
|
||||||
it 'requires admin privileges' do
|
it 'requires organizer privileges' do
|
||||||
get :new
|
get :new
|
||||||
expect(response).to redirect_to(send(success_path))
|
expect(response).to redirect_to(send(path))
|
||||||
|
if message
|
||||||
|
expect(flash[:alert]).to match(/#{message}/)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
it 'requires admin privileges' do
|
it 'requires organizer privileges' do
|
||||||
post :create, conference: attributes_for(:conference,
|
post :create, conference: attributes_for(:conference,
|
||||||
short_title: 'ExCon')
|
short_title: 'ExCon')
|
||||||
expect(response).to redirect_to(send(success_path))
|
expect(response).to redirect_to(send(path))
|
||||||
|
if message
|
||||||
|
expect(flash[:alert]).to match(/#{message}/)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'PATCH #update' do
|
describe 'PATCH #update' do
|
||||||
it 'requires admin privileges' do
|
it 'requires organizer privileges' do
|
||||||
patch :update, id: conference.short_title,
|
patch :update, id: conference.short_title,
|
||||||
conference: attributes_for(:conference,
|
conference: attributes_for(:conference,
|
||||||
short_title: 'ExCon')
|
short_title: 'ExCon')
|
||||||
expect(response).to redirect_to(send(success_path))
|
expect(response).to redirect_to(send(path))
|
||||||
|
if message
|
||||||
|
expect(flash[:alert]).to match(/#{message}/)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -277,7 +408,7 @@ describe Admin::ConferenceController do
|
||||||
sign_in(participant)
|
sign_in(participant)
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'access as participant or guest', :root_path
|
it_behaves_like 'access as participant or guest', :root_path, 'You are not authorized to access this area!'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
describe Admin::UsersController do
|
describe Admin::UsersController do
|
||||||
let!(:admin_role) { create(:admin_role) }
|
|
||||||
let!(:participant_role) { create(:participant_role) }
|
|
||||||
let(:admin) { create(:admin) }
|
let(:admin) { create(:admin) }
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
before(:each) do
|
before(:each) do
|
||||||
|
|
@ -31,7 +29,7 @@ describe Admin::UsersController do
|
||||||
:user, email: 'example@incoherent.de', id: user.id).email).
|
:user, email: 'example@incoherent.de', id: user.id).email).
|
||||||
to eq('example@incoherent.de')
|
to eq('example@incoherent.de')
|
||||||
end
|
end
|
||||||
it "redirects to the updated user" do
|
it 'redirects to the updated user' do
|
||||||
patch :update, id: user.id
|
patch :update, id: user.id
|
||||||
expect(response).to redirect_to admin_users_path
|
expect(response).to redirect_to admin_users_path
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe ConferenceController do
|
describe ConferenceController do
|
||||||
let(:conference) { create(:conference) }
|
let(:conference) { create(:conference, make_conference_public: true) }
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
context 'conference made public' do
|
context 'conference made public' do
|
||||||
it 'assigns the requested conference to conference' do
|
it 'assigns the requested conference to conference' do
|
||||||
|
|
@ -24,7 +25,7 @@ describe ConferenceController do
|
||||||
|
|
||||||
it 'renders flash saying conference not ready' do
|
it 'renders flash saying conference not ready' do
|
||||||
get :show, id: conference.short_title
|
get :show, id: conference.short_title
|
||||||
expect(flash[:notice]).to eq("Conference not ready yet!!")
|
expect(flash[:alert]).to eq('You are not authorized to access this page.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context 'gallery photos for splash' do
|
context 'gallery photos for splash' do
|
||||||
|
|
|
||||||
8
spec/factories/commercials.rb
Normal file
8
spec/factories/commercials.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||||
|
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :commercial do
|
||||||
|
commercial_type 'YouTube'
|
||||||
|
commercial_id 'test'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :role do
|
factory :role do
|
||||||
|
|
||||||
factory :admin_role do
|
|
||||||
name 'Admin'
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :organizer_role do
|
factory :organizer_role do
|
||||||
name 'Organizer'
|
name 'organizer'
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :participant_role do
|
factory :cfp_role do
|
||||||
name 'Participant'
|
name 'cfp'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,8 @@ FactoryGirl.define do
|
||||||
gravida.
|
gravida.
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
factory :participant do
|
|
||||||
after(:create) { |user| user.role_ids = create(:participant_role).id }
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :admin do
|
factory :admin do
|
||||||
after(:create) { |user| user.role_ids = create(:admin_role).id }
|
is_admin true
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :organizer do
|
factory :organizer do
|
||||||
|
|
|
||||||
302
spec/features/ability_spec.rb
Normal file
302
spec/features/ability_spec.rb
Normal file
|
|
@ -0,0 +1,302 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'Has correct abilities' do
|
||||||
|
# It is necessary to use bang version of let to build roles before user
|
||||||
|
let(:conference1) { create(:conference) } # user is organizer
|
||||||
|
let(:conference2) { create(:conference) } # user is cfp
|
||||||
|
let(:conference3) { create(:conference) } # user is info_desk
|
||||||
|
let(:conference4) { create(:conference) } # user is volunteer coordinator
|
||||||
|
let(:conference5) { create(:conference) } # user has no role
|
||||||
|
|
||||||
|
let(:role_organizer) { create(:role, name: 'organizer', resource: conference1) }
|
||||||
|
let(:role_cfp) { create(:role, name: 'cfp', resource: conference2) }
|
||||||
|
let(:role_info_desk) { create(:role, name: 'info_desk', resource: conference3) }
|
||||||
|
let(:role_volunteer_coordinator) { create(:role, name: 'volunteer_coordinator', resource: conference4) }
|
||||||
|
|
||||||
|
let(:user) { create(:user, role_ids: [role_organizer.id, role_cfp.id, role_info_desk.id, role_volunteer_coordinator.id]) }
|
||||||
|
|
||||||
|
scenario 'when user is organizer' do
|
||||||
|
sign_in user
|
||||||
|
visit admin_conference_path(conference1.short_title)
|
||||||
|
|
||||||
|
expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard')
|
||||||
|
expect(page).to have_link('Basics', href: "/admin/conference/#{conference1.short_title}/edit")
|
||||||
|
expect(page).to have_link('Contact', href: "/admin/conference/#{conference1.short_title}/contact/edit")
|
||||||
|
expect(page).to have_link('Commercials', href: "/admin/conference/#{conference1.short_title}/commercials")
|
||||||
|
expect(page).to have_link('Photos', href: "/admin/conference/#{conference1.short_title}/photos")
|
||||||
|
expect(page).to have_link('Events', href: "/admin/conference/#{conference1.short_title}/events")
|
||||||
|
expect(page).to have_link('Registrations', href: "/admin/conference/#{conference1.short_title}/registrations")
|
||||||
|
expect(page).to have_link('Schedule', href: "/admin/conference/#{conference1.short_title}/schedule")
|
||||||
|
expect(page).to have_link('Campaigns', href: "/admin/conference/#{conference1.short_title}/campaigns")
|
||||||
|
expect(page).to have_link('Targets', href: "/admin/conference/#{conference1.short_title}/targets")
|
||||||
|
expect(page).to have_link('Venue', href: "/admin/conference/#{conference1.short_title}/venue")
|
||||||
|
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference1.short_title}/rooms")
|
||||||
|
expect(page).to have_link('Lodgings', href: "/admin/conference/#{conference1.short_title}/lodgings")
|
||||||
|
expect(page).to have_link('Sponsorship', href: "/admin/conference/#{conference1.short_title}/sponsorship_levels")
|
||||||
|
expect(page).to have_link('Sponsors', href: "/admin/conference/#{conference1.short_title}/sponsors")
|
||||||
|
expect(page).to have_link('Supporter Levels', href: "/admin/conference/#{conference1.short_title}/supporter_levels")
|
||||||
|
expect(page).to have_link('E-Mails', href: "/admin/conference/#{conference1.short_title}/emails")
|
||||||
|
expect(page).to have_link('Call for papers', href: "/admin/conference/#{conference1.short_title}/callforpapers")
|
||||||
|
expect(page).to have_link('Tracks', href: "/admin/conference/#{conference1.short_title}/tracks")
|
||||||
|
expect(page).to have_link('Event types', href: "/admin/conference/#{conference1.short_title}/event_types")
|
||||||
|
expect(page).to have_link('Difficulty levels', href: "/admin/conference/#{conference1.short_title}/difficulty_levels")
|
||||||
|
expect(page).to have_link('Questions', href: "/admin/conference/#{conference1.short_title}/questions")
|
||||||
|
expect(page).to have_link('Roles', href: "/admin/conference/#{conference1.short_title}/roles")
|
||||||
|
|
||||||
|
visit edit_admin_conference_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(edit_admin_conference_path(conference1.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_path(conference1.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_registrations_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_registrations_path(conference1.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_events_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_events_path(conference1.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_schedule_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_schedule_path(conference1.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_campaigns_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_campaigns_path(conference1.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_targets_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_targets_path(conference1.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_venue_info_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_venue_info_path(conference1.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_sponsorship_levels_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_sponsorship_levels_path(conference1.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_supporter_levels_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_supporter_levels_path(conference1.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_emails_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_emails_path(conference1.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_callforpapers_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_callforpapers_path(conference1.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_questions_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_questions_path(conference1.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_commercials_path(conference1.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_commercials_path(conference1.short_title))
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'when user is cfp' do
|
||||||
|
sign_in user
|
||||||
|
visit admin_conference_path(conference2.short_title)
|
||||||
|
|
||||||
|
expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard')
|
||||||
|
expect(page).to have_link('Basics', href: "/admin/conference/#{conference2.short_title}/edit")
|
||||||
|
expect(page).to_not have_link('Contact', href: "/admin/conference/#{conference2.short_title}/contact/edit")
|
||||||
|
expect(page).to have_link('Commercials', href: "/admin/conference/#{conference2.short_title}/commercials")
|
||||||
|
expect(page).to_not have_link('Photos', href: "/admin/conference/#{conference2.short_title}/photos")
|
||||||
|
expect(page).to have_link('Events', href: "/admin/conference/#{conference2.short_title}/events")
|
||||||
|
expect(page).to_not have_link('Registrations', href: "/admin/conference/#{conference2.short_title}/registrations")
|
||||||
|
expect(page).to have_link('Schedule', href: "/admin/conference/#{conference2.short_title}/schedule")
|
||||||
|
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference2.short_title}/campaigns")
|
||||||
|
expect(page).to_not have_link('Targets', href: "/admin/conference/#{conference2.short_title}/targets")
|
||||||
|
expect(page).to have_link('Venue', href: "/admin/conference/#{conference2.short_title}/venue")
|
||||||
|
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference2.short_title}/rooms")
|
||||||
|
expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference2.short_title}/lodgings")
|
||||||
|
expect(page).to_not have_link('Sponsorship', href: "/admin/conference/#{conference2.short_title}/sponsorship_levels")
|
||||||
|
expect(page).to_not have_link('Sponsors', href: "/admin/conference/#{conference2.short_title}/sponsors")
|
||||||
|
expect(page).to_not have_link('Supporter Levels', href: "/admin/conference/#{conference2.short_title}/supporter_levels")
|
||||||
|
expect(page).to have_link('E-Mails', href: "/admin/conference/#{conference2.short_title}/emails")
|
||||||
|
expect(page).to have_link('Call for papers', href: "/admin/conference/#{conference2.short_title}/callforpapers")
|
||||||
|
expect(page).to have_link('Tracks', href: "/admin/conference/#{conference2.short_title}/tracks")
|
||||||
|
expect(page).to have_link('Event types', href: "/admin/conference/#{conference2.short_title}/event_types")
|
||||||
|
expect(page).to have_link('Difficulty levels', href: "/admin/conference/#{conference2.short_title}/difficulty_levels")
|
||||||
|
expect(page).to_not have_link('Questions', href: "/admin/conference/#{conference2.short_title}/questions")
|
||||||
|
expect(page).to_not have_link('Roles', href: "/admin/conference/#{conference2.short_title}/roles")
|
||||||
|
|
||||||
|
visit edit_admin_conference_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_path(conference2.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_registrations_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_events_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_events_path(conference2.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_schedule_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_schedule_path(conference2.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_campaigns_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_targets_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_venue_info_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_sponsorship_levels_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_supporter_levels_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_emails_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_emails_path(conference2.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_callforpapers_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_callforpapers_path(conference2.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_questions_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_commercials_path(conference2.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_commercials_path(conference2.short_title))
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'when user is info desk' do
|
||||||
|
sign_in user
|
||||||
|
visit admin_conference_path(conference3.short_title)
|
||||||
|
|
||||||
|
expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard')
|
||||||
|
expect(page).to have_link('Basics', href: "/admin/conference/#{conference3.short_title}/edit")
|
||||||
|
expect(page).to_not have_link('Contact', href: "/admin/conference/#{conference3.short_title}/contact/edit")
|
||||||
|
expect(page).to have_link('Commercials', href: "/admin/conference/#{conference3.short_title}/commercials")
|
||||||
|
expect(page).to_not have_link('Photos', href: "/admin/conference/#{conference3.short_title}/photos")
|
||||||
|
expect(page).to_not have_link('Events', href: "/admin/conference/#{conference3.short_title}/events")
|
||||||
|
expect(page).to have_link('Registrations', href: "/admin/conference/#{conference3.short_title}/registrations")
|
||||||
|
expect(page).to_not have_link('Schedule', href: "/admin/conference/#{conference3.short_title}/schedule")
|
||||||
|
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference3.short_title}/campaigns")
|
||||||
|
expect(page).to_not have_link('Targets', href: "/admin/conference/#{conference3.short_title}/targets")
|
||||||
|
expect(page).to_not have_link('Venue', href: "/admin/conference/#{conference3.short_title}/venue")
|
||||||
|
expect(page).to_not have_link('Rooms', href: "/admin/conference/#{conference3.short_title}/rooms")
|
||||||
|
expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference3.short_title}/lodgings")
|
||||||
|
expect(page).to_not have_link('Sponsorship', href: "/admin/conference/#{conference3.short_title}/sponsorship_levels")
|
||||||
|
expect(page).to_not have_link('Sponsors', href: "/admin/conference/#{conference3.short_title}/sponsors")
|
||||||
|
expect(page).to_not have_link('Supporter Levels', href: "/admin/conference/#{conference3.short_title}/supporter_levels")
|
||||||
|
expect(page).to_not have_link('E-Mails', href: "/admin/conference/#{conference3.short_title}/emails")
|
||||||
|
expect(page).to_not have_link('Call for papers', href: "/admin/conference/#{conference3.short_title}/callforpapers")
|
||||||
|
expect(page).to_not have_link('Tracks', href: "/admin/conference/#{conference3.short_title}/tracks")
|
||||||
|
expect(page).to_not have_link('Event types', href: "/admin/conference/#{conference3.short_title}/event_types")
|
||||||
|
expect(page).to_not have_link('Difficulty levels', href: "/admin/conference/#{conference3.short_title}/difficulty_levels")
|
||||||
|
expect(page).to have_link('Questions', href: "/admin/conference/#{conference3.short_title}/questions")
|
||||||
|
expect(page).to_not have_link('Roles', href: "/admin/conference/#{conference3.short_title}/roles")
|
||||||
|
|
||||||
|
visit edit_admin_conference_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_path(conference3.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_registrations_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_registrations_path(conference3.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_events_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_schedule_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_campaigns_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_targets_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_venue_info_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_sponsorship_levels_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_supporter_levels_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_emails_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_callforpapers_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_questions_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_questions_path(conference3.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_commercials_path(conference3.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_commercials_path(conference3.short_title))
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'when user is volunteer coordinator' do
|
||||||
|
sign_in user
|
||||||
|
visit admin_conference_path(conference4.short_title)
|
||||||
|
|
||||||
|
expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard')
|
||||||
|
expect(page).to have_link('Basics', href: "/admin/conference/#{conference4.short_title}/edit")
|
||||||
|
expect(page).to_not have_link('Contact', href: "/admin/conference/#{conference4.short_title}/contact/edit")
|
||||||
|
expect(page).to have_link('Commercials', href: "/admin/conference/#{conference4.short_title}/commercials")
|
||||||
|
expect(page).to_not have_link('Photos', href: "/admin/conference/#{conference4.short_title}/photos")
|
||||||
|
expect(page).to_not have_link('Events', href: "/admin/conference/#{conference4.short_title}/events")
|
||||||
|
expect(page).to_not have_link('Registrations', href: "/admin/conference/#{conference4.short_title}/registrations")
|
||||||
|
expect(page).to_not have_link('Schedule', href: "/admin/conference/#{conference4.short_title}/schedule")
|
||||||
|
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference4.short_title}/campaigns")
|
||||||
|
expect(page).to_not have_link('Targets', href: "/admin/conference/#{conference4.short_title}/targets")
|
||||||
|
expect(page).to_not have_link('Venue', href: "/admin/conference/#{conference4.short_title}/venue")
|
||||||
|
expect(page).to_not have_link('Rooms', href: "/admin/conference/#{conference4.short_title}/rooms")
|
||||||
|
expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference4.short_title}/lodgings")
|
||||||
|
expect(page).to_not have_link('Sponsorship', href: "/admin/conference/#{conference4.short_title}/sponsorship_levels")
|
||||||
|
expect(page).to_not have_link('Sponsors', href: "/admin/conference/#{conference4.short_title}/sponsors")
|
||||||
|
expect(page).to_not have_link('Supporter Levels', href: "/admin/conference/#{conference4.short_title}/supporter_levels")
|
||||||
|
expect(page).to_not have_link('E-Mails', href: "/admin/conference/#{conference4.short_title}/emails")
|
||||||
|
expect(page).to_not have_link('Call for papers', href: "/admin/conference/#{conference4.short_title}/callforpapers")
|
||||||
|
expect(page).to_not have_link('Tracks', href: "/admin/conference/#{conference4.short_title}/tracks")
|
||||||
|
expect(page).to_not have_link('Event types', href: "/admin/conference/#{conference4.short_title}/event_types")
|
||||||
|
expect(page).to_not have_link('Difficulty levels', href: "/admin/conference/#{conference4.short_title}/difficulty_levels")
|
||||||
|
expect(page).to_not have_link('Questions', href: "/admin/conference/#{conference4.short_title}/questions")
|
||||||
|
expect(page).to_not have_link('Roles', href: "/admin/conference/#{conference4.short_title}/roles")
|
||||||
|
|
||||||
|
visit edit_admin_conference_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_path(conference4.short_title))
|
||||||
|
|
||||||
|
visit admin_conference_registrations_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_events_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_schedule_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_campaigns_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_targets_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_venue_info_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_sponsorship_levels_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_supporter_levels_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_emails_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_callforpapers_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_questions_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
visit admin_conference_commercials_path(conference4.short_title)
|
||||||
|
expect(current_path).to eq(admin_conference_commercials_path(conference4.short_title))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -2,16 +2,14 @@ require 'spec_helper'
|
||||||
|
|
||||||
feature Campaign do
|
feature Campaign do
|
||||||
|
|
||||||
# It is necessary to use bang version of let to build roles before user
|
let!(:conference) { create(:conference, short_title: 'osc14') }
|
||||||
let!(:organizer_role) { create(:organizer_role) }
|
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
||||||
let!(:participant_role) { create(:participant_role) }
|
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
|
||||||
let!(:admin_role) { create(:admin_role) }
|
|
||||||
|
|
||||||
shared_examples 'add and update campaign' do |user|
|
shared_examples 'add and update campaign' do
|
||||||
scenario 'adds and update a campaign', feature: true, js: true do
|
scenario 'adds and update a campaign', feature: true, js: true do
|
||||||
expected_count = Campaign.count + 1
|
expected_count = Campaign.count + 1
|
||||||
conference = create(:conference, short_title: 'osc14')
|
sign_in organizer
|
||||||
sign_in create(user)
|
|
||||||
|
|
||||||
visit admin_conference_campaigns_path(conference.short_title)
|
visit admin_conference_campaigns_path(conference.short_title)
|
||||||
|
|
||||||
|
|
@ -52,8 +50,7 @@ feature Campaign do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'admin' do
|
describe 'organizer' do
|
||||||
it_behaves_like 'add and update campaign', :admin
|
it_behaves_like 'add and update campaign'
|
||||||
it_behaves_like 'add and update campaign', :organizer
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,15 @@ require 'spec_helper'
|
||||||
|
|
||||||
feature Conference do
|
feature Conference do
|
||||||
|
|
||||||
# It is necessary to use bang version of let to build roles before user
|
let!(:conference) { create(:conference) }
|
||||||
let!(:organizer_role) { create(:organizer_role) }
|
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
||||||
let!(:participant_role) { create(:participant_role) }
|
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
|
||||||
let!(:admin_role) { create(:admin_role) }
|
|
||||||
|
|
||||||
shared_examples 'add and update cfp' do |user|
|
shared_examples 'add and update cfp' do
|
||||||
scenario 'adds a new cfp', feature: true, js: true do
|
scenario 'adds a new cfp', feature: true, js: true do
|
||||||
expected_count = CallForPapers.count + 1
|
expected_count = CallForPapers.count + 1
|
||||||
conference = create(:conference)
|
|
||||||
sign_in create(user)
|
sign_in organizer
|
||||||
|
|
||||||
visit admin_conference_callforpapers_path(conference.short_title)
|
visit admin_conference_callforpapers_path(conference.short_title)
|
||||||
|
|
||||||
|
|
@ -47,11 +46,10 @@ feature Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'update cfp', feature: true, js: true do
|
scenario 'update cfp', feature: true, js: true do
|
||||||
conference = create(:conference)
|
|
||||||
conference.call_for_papers = create(:call_for_papers)
|
conference.call_for_papers = create(:call_for_papers)
|
||||||
expected_count = CallForPapers.count
|
expected_count = CallForPapers.count
|
||||||
|
|
||||||
sign_in create(user)
|
sign_in organizer
|
||||||
visit admin_conference_callforpapers_path(conference.short_title)
|
visit admin_conference_callforpapers_path(conference.short_title)
|
||||||
|
|
||||||
# Validate update with empty start date will not saved
|
# Validate update with empty start date will not saved
|
||||||
|
|
@ -87,8 +85,7 @@ feature Conference do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'admin' do
|
describe 'organizer' do
|
||||||
it_behaves_like 'add and update cfp', :admin
|
it_behaves_like 'add and update cfp'
|
||||||
it_behaves_like 'add and update cfp', :organizer
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,17 @@ require 'spec_helper'
|
||||||
|
|
||||||
feature Commercial do
|
feature Commercial do
|
||||||
# It is necessary to use bang version of let to build roles before user
|
# It is necessary to use bang version of let to build roles before user
|
||||||
let!(:organizer_role) { create(:organizer_role) }
|
let!(:conference) { create(:conference) }
|
||||||
let!(:participant_role) { create(:participant_role) }
|
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
||||||
let!(:admin_role) { create(:admin_role) }
|
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
|
||||||
|
|
||||||
shared_examples 'adds and updates a commercial' do |user|
|
shared_examples 'adds and updates a commercial' do
|
||||||
scenario 'of a conference',
|
scenario 'of a conference',
|
||||||
feature: true, js: true do
|
feature: true, js: true do
|
||||||
|
|
||||||
conference = create(:conference)
|
|
||||||
expected_count = conference.commercials.count + 1
|
expected_count = conference.commercials.count + 1
|
||||||
|
|
||||||
sign_in create(user)
|
sign_in organizer
|
||||||
|
|
||||||
visit admin_conference_commercials_path(conference.short_title)
|
visit admin_conference_commercials_path(conference.short_title)
|
||||||
|
|
||||||
|
|
@ -61,11 +60,7 @@ feature Commercial do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'admin' do
|
|
||||||
it_behaves_like 'adds and updates a commercial', :admin
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'organizer' do
|
describe 'organizer' do
|
||||||
it_behaves_like 'adds and updates a commercial', :organizer
|
it_behaves_like 'adds and updates a commercial'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
feature Conference do
|
feature Conference do
|
||||||
|
let!(:user) { create(:admin) }
|
||||||
|
|
||||||
# It is necessary to use bang version of let to build roles before user
|
shared_examples 'add and update conference' do
|
||||||
let!(:organizer_role) { create(:organizer_role) }
|
|
||||||
let!(:participant_role) { create(:participant_role) }
|
|
||||||
let!(:admin_role) { create(:admin_role) }
|
|
||||||
|
|
||||||
shared_examples 'add and update conference' do |user|
|
|
||||||
scenario 'adds a new conference', feature: true, js: true do
|
scenario 'adds a new conference', feature: true, js: true do
|
||||||
expected_count = Conference.count + 1
|
expected_count = Conference.count + 1
|
||||||
sign_in create(user)
|
sign_in user
|
||||||
|
|
||||||
visit new_admin_conference_path
|
visit new_admin_conference_path
|
||||||
fill_in 'conference_title', with: 'Example Con'
|
fill_in 'conference_title', with: 'Example Con'
|
||||||
|
|
@ -31,12 +27,18 @@ feature Conference do
|
||||||
expect(flash).
|
expect(flash).
|
||||||
to eq('Conference was successfully created.')
|
to eq('Conference was successfully created.')
|
||||||
expect(Conference.count).to eq(expected_count)
|
expect(Conference.count).to eq(expected_count)
|
||||||
|
|
||||||
|
expect(user.has_role? :organizer, Conference.last).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'update conference', feature: true, js: true do
|
scenario 'update conference', feature: true, js: true do
|
||||||
conference = create(:conference)
|
conference = create(:conference)
|
||||||
|
organizer_role = create(:organizer_role, resource: conference)
|
||||||
|
organizer = create(:user, role_ids: [organizer_role.id])
|
||||||
|
|
||||||
expected_count = Conference.count
|
expected_count = Conference.count
|
||||||
sign_in create(user)
|
|
||||||
|
sign_in organizer
|
||||||
|
|
||||||
visit edit_admin_conference_path(conference.short_title)
|
visit edit_admin_conference_path(conference.short_title)
|
||||||
click_link 'Edit'
|
click_link 'Edit'
|
||||||
|
|
@ -63,11 +65,6 @@ feature Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'admin' do
|
describe 'admin' do
|
||||||
it_behaves_like 'add and update conference', :admin
|
it_behaves_like 'add and update conference'
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'organizer' do
|
|
||||||
it_behaves_like 'add and update conference', :organizer
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,16 @@ require 'spec_helper'
|
||||||
|
|
||||||
feature Contact do
|
feature Contact do
|
||||||
|
|
||||||
# It is necessary to use bang version of let to build roles before user
|
let!(:conference) { create(:conference) }
|
||||||
let!(:organizer_role) { create(:organizer_role) }
|
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
||||||
let!(:participant_role) { create(:participant_role) }
|
let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) }
|
||||||
let!(:admin_role) { create(:admin_role) }
|
|
||||||
|
|
||||||
shared_examples 'update a contact' do |user|
|
shared_examples 'update a contact' do
|
||||||
|
|
||||||
scenario 'sucessfully', feature: true, js: true do
|
scenario 'sucessfully', feature: true, js: true do
|
||||||
conference = create(:conference)
|
|
||||||
contact = conference.contact
|
contact = conference.contact
|
||||||
expected_count = Contact.count
|
expected_count = Contact.count
|
||||||
sign_in create(user)
|
sign_in organizer
|
||||||
|
|
||||||
visit edit_admin_conference_contact_path(conference.short_title)
|
visit edit_admin_conference_contact_path(conference.short_title)
|
||||||
click_link 'Edit'
|
click_link 'Edit'
|
||||||
|
|
@ -39,10 +37,6 @@ feature Contact do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'admin' do
|
|
||||||
it_behaves_like 'update a contact', :admin
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'organizer' do
|
describe 'organizer' do
|
||||||
it_behaves_like 'update a contact', :organizer
|
it_behaves_like 'update a contact', :organizer
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue