Rooms belong to venue
This commit is contained in:
parent
feabbfbc99
commit
f840f2b3f0
31 changed files with 221 additions and 166 deletions
|
|
@ -1,22 +1,22 @@
|
||||||
module Admin
|
module Admin
|
||||||
class RoomsController < Admin::BaseController
|
class RoomsController < Admin::BaseController
|
||||||
load_and_authorize_resource :conference, find_by: :short_title
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
load_and_authorize_resource :program, through: :conference, singleton: true
|
load_and_authorize_resource :venue, through: :conference, singleton: true
|
||||||
load_and_authorize_resource through: :program
|
load_and_authorize_resource through: :venue
|
||||||
|
|
||||||
def index; end
|
def index; end
|
||||||
|
|
||||||
def edit; end
|
def edit; end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@room = @program.rooms.new
|
@room = @venue.rooms.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@room = @program.rooms.new(room_params)
|
@room = @venue.rooms.new(room_params)
|
||||||
if @room.save
|
if @room.save
|
||||||
flash[:notice] = 'Room successfully created.'
|
flash[:notice] = 'Room successfully created.'
|
||||||
redirect_to(admin_conference_program_rooms_path(conference_id: @conference.short_title))
|
redirect_to(admin_conference_venue_rooms_path(conference_id: @conference.short_title))
|
||||||
else
|
else
|
||||||
flash[:error] = "Creating Room failed: #{@room.errors.full_messages.join('. ')}."
|
flash[:error] = "Creating Room failed: #{@room.errors.full_messages.join('. ')}."
|
||||||
render :new
|
render :new
|
||||||
|
|
@ -26,7 +26,7 @@ module Admin
|
||||||
def update
|
def update
|
||||||
if @room.update_attributes(room_params)
|
if @room.update_attributes(room_params)
|
||||||
flash[:notice] = 'Room successfully updated.'
|
flash[:notice] = 'Room successfully updated.'
|
||||||
redirect_to(admin_conference_program_rooms_path(conference_id: @conference.short_title))
|
redirect_to(admin_conference_venue_rooms_path(conference_id: @conference.short_title))
|
||||||
else
|
else
|
||||||
flash[:error] = "Update Room failed: #{@room.errors.full_messages.join('. ')}."
|
flash[:error] = "Update Room failed: #{@room.errors.full_messages.join('. ')}."
|
||||||
render :edit
|
render :edit
|
||||||
|
|
@ -36,10 +36,10 @@ module Admin
|
||||||
def destroy
|
def destroy
|
||||||
if @room.destroy
|
if @room.destroy
|
||||||
flash[:notice] = 'Room successfully deleted.'
|
flash[:notice] = 'Room successfully deleted.'
|
||||||
redirect_to(admin_conference_program_rooms_path(conference_id: @conference.short_title))
|
redirect_to(admin_conference_venue_rooms_path(conference_id: @conference.short_title))
|
||||||
else
|
else
|
||||||
flash[:error] = "Destroying room failed! #{@room.errors.full_messages.join('. ')}."
|
flash[:error] = "Destroying room failed! #{@room.errors.full_messages.join('. ')}."
|
||||||
redirect_to(admin_conference_program_rooms_path(conference_id: @conference.short_title))
|
redirect_to(admin_conference_venue_rooms_path(conference_id: @conference.short_title))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ module Admin
|
||||||
# the schedule of a conference, which should not be accessed in the first place
|
# the schedule of a conference, which should not be accessed in the first place
|
||||||
load_and_authorize_resource :conference, find_by: :short_title
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
load_and_authorize_resource :program, through: :conference, singleton: true
|
load_and_authorize_resource :program, through: :conference, singleton: true
|
||||||
|
load_resource :venue, through: :conference, singleton: true
|
||||||
|
|
||||||
skip_before_filter :verify_authenticity_token, only: [:update]
|
skip_before_filter :verify_authenticity_token, only: [:update]
|
||||||
layout 'schedule'
|
layout 'schedule'
|
||||||
|
|
@ -15,7 +16,7 @@ module Admin
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@dates = @conference.start_date..@conference.end_date
|
@dates = @conference.start_date..@conference.end_date
|
||||||
@rooms = @program.rooms
|
@rooms = @venue.rooms
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,12 @@ module Api
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@conference ? (rooms = @conference.rooms) : (rooms = Room.all)
|
if params[:conference_id].blank?
|
||||||
|
rooms = Room.all
|
||||||
|
else
|
||||||
|
conference = Conference.find_by_guid(params[:conference_id])
|
||||||
|
rooms = conference.venue.rooms if conference.venue
|
||||||
|
end
|
||||||
respond_with rooms
|
respond_with rooms
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class ConferenceController < ApplicationController
|
||||||
def show; end
|
def show; end
|
||||||
|
|
||||||
def schedule
|
def schedule
|
||||||
@rooms = @conference.program.rooms
|
@rooms = @conference.venue.rooms if @conference.venue
|
||||||
@events = @conference.program.events
|
@events = @conference.program.events
|
||||||
@dates = @conference.start_date..@conference.end_date
|
@dates = @conference.start_date..@conference.end_date
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,10 @@ class Ability
|
||||||
can :manage, :all if user.is_admin
|
can :manage, :all if user.is_admin
|
||||||
|
|
||||||
cannot :destroy, Program
|
cannot :destroy, Program
|
||||||
|
# Do not delete venue, when there are rooms being used
|
||||||
|
cannot :destroy, Venue do |venue|
|
||||||
|
venue.conference.program.events.where.not(room_id: nil).any?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def signed_in_with_organizer_role(user)
|
def signed_in_with_organizer_role(user)
|
||||||
|
|
@ -141,7 +145,7 @@ class Ability
|
||||||
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)
|
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)
|
||||||
can :manage, Venue, conference_id: conf_ids_for_organizer
|
can :manage, Venue, conference_id: conf_ids_for_organizer
|
||||||
can :manage, Lodging, conference_id: conf_ids_for_organizer
|
can :manage, Lodging, conference_id: conf_ids_for_organizer
|
||||||
can :manage, Room, program: { conference_id: conf_ids_for_organizer}
|
can :manage, Room, venue: { conference_id: conf_ids_for_organizer}
|
||||||
can :manage, Sponsor, conference_id: conf_ids_for_organizer
|
can :manage, Sponsor, conference_id: conf_ids_for_organizer
|
||||||
can :manage, SponsorshipLevel, conference_id: conf_ids_for_organizer
|
can :manage, SponsorshipLevel, conference_id: conf_ids_for_organizer
|
||||||
can :manage, Ticket, conference_id: conf_ids_for_organizer
|
can :manage, Ticket, conference_id: conf_ids_for_organizer
|
||||||
|
|
@ -160,7 +164,7 @@ class Ability
|
||||||
can :manage, Track, program: { conference_id: conf_ids_for_cfp }
|
can :manage, Track, program: { conference_id: conf_ids_for_cfp }
|
||||||
can :manage, DifficultyLevel, program: { conference_id: conf_ids_for_cfp }
|
can :manage, DifficultyLevel, program: { conference_id: conf_ids_for_cfp }
|
||||||
can :manage, EmailSettings, conference_id: conf_ids_for_cfp
|
can :manage, EmailSettings, conference_id: conf_ids_for_cfp
|
||||||
can :manage, Room, program: { conference_id: conf_ids_for_cfp }
|
can :manage, Room, venue: { conference_id: conf_ids_for_cfp }
|
||||||
can :index, Venue, conference_id: conf_ids_for_cfp
|
can :index, Venue, conference_id: conf_ids_for_cfp
|
||||||
can :manage, Cfp, program: { conference_id: conf_ids_for_cfp }
|
can :manage, Cfp, program: { conference_id: conf_ids_for_cfp }
|
||||||
can :manage, Program, conference_id: conf_ids_for_cfp
|
can :manage, Program, conference_id: conf_ids_for_cfp
|
||||||
|
|
|
||||||
|
|
@ -707,7 +707,7 @@ class Conference < ActiveRecord::Base
|
||||||
# * +True+ -> One room or more
|
# * +True+ -> One room or more
|
||||||
# * +False+ -> No room
|
# * +False+ -> No room
|
||||||
def rooms_set?
|
def rooms_set?
|
||||||
program.rooms.count > 0
|
venue.present? && venue.rooms.count > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks if the conference has a venue object.
|
# Checks if the conference has a venue object.
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ class Program < ActiveRecord::Base
|
||||||
has_many :event_types, dependent: :destroy
|
has_many :event_types, dependent: :destroy
|
||||||
has_many :tracks, dependent: :destroy
|
has_many :tracks, dependent: :destroy
|
||||||
has_many :difficulty_levels, dependent: :destroy
|
has_many :difficulty_levels, dependent: :destroy
|
||||||
has_many :rooms, dependent: :destroy
|
|
||||||
has_many :events, dependent: :destroy do
|
has_many :events, dependent: :destroy do
|
||||||
def workshops
|
def workshops
|
||||||
where(require_registration: true, state: :confirmed)
|
where(require_registration: true, state: :confirmed)
|
||||||
|
|
@ -36,11 +35,10 @@ class Program < ActiveRecord::Base
|
||||||
accepts_nested_attributes_for :event_types, allow_destroy: true
|
accepts_nested_attributes_for :event_types, allow_destroy: true
|
||||||
accepts_nested_attributes_for :tracks, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true
|
accepts_nested_attributes_for :tracks, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true
|
||||||
accepts_nested_attributes_for :difficulty_levels, allow_destroy: true
|
accepts_nested_attributes_for :difficulty_levels, allow_destroy: true
|
||||||
accepts_nested_attributes_for :rooms, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true
|
|
||||||
|
|
||||||
attr_accessible :schedule_fluid, :rating,
|
attr_accessible :schedule_fluid, :rating,
|
||||||
:schedule_public, :include_cfp_in_splash, :conference_id,
|
:schedule_public, :include_cfp_in_splash, :conference_id,
|
||||||
:event_types_attributes, :difficulty_levels_attributes, :rooms_attributes, :tracks_attributes
|
:event_types_attributes, :difficulty_levels_attributes, :tracks_attributes
|
||||||
|
|
||||||
# validates :conference_id, presence: true, uniqueness: true
|
# validates :conference_id, presence: true, uniqueness: true
|
||||||
validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 }
|
validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 }
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
class Room < ActiveRecord::Base
|
class Room < ActiveRecord::Base
|
||||||
belongs_to :program
|
belongs_to :venue
|
||||||
has_many :events, dependent: :nullify
|
has_many :events, dependent: :nullify
|
||||||
|
|
||||||
before_create :generate_guid
|
before_create :generate_guid
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, :venue_id, presence: true
|
||||||
|
|
||||||
validates :size, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true
|
validates :size, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
class Venue < ActiveRecord::Base
|
class Venue < ActiveRecord::Base
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
has_many :lodgings
|
has_many :rooms, dependent: :destroy
|
||||||
before_create :generate_guid
|
before_create :generate_guid
|
||||||
|
|
||||||
validates :name, :street, :city, :country, presence: true
|
validates :name, :street, :city, :country, presence: true
|
||||||
|
validates :conference_id, presence: true, uniqueness: true
|
||||||
|
|
||||||
has_attached_file :photo,
|
has_attached_file :photo,
|
||||||
styles: { thumb: '100x100>', large: '300x300>' }
|
styles: { thumb: '100x100>', large: '300x300>' }
|
||||||
|
|
@ -11,8 +12,6 @@ class Venue < ActiveRecord::Base
|
||||||
content_type: [/jpg/, /jpeg/, /png/, /gif/],
|
content_type: [/jpg/, /jpeg/, /png/, /gif/],
|
||||||
size: { in: 0..500.kilobytes }
|
size: { in: 0..500.kilobytes }
|
||||||
|
|
||||||
accepts_nested_attributes_for :lodgings, allow_destroy: true
|
|
||||||
|
|
||||||
after_update :send_mail_notification
|
after_update :send_mail_notification
|
||||||
|
|
||||||
def address
|
def address
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@
|
||||||
Add venue
|
Add venue
|
||||||
%li{'class'=>"list-group-item #{class_for_todo(conference_progress['rooms'])}"}
|
%li{'class'=>"list-group-item #{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.program.rooms.build
|
- if @conference.venue && (can? :update, @conference.venue.rooms.build)
|
||||||
= link_to 'Add rooms', admin_conference_program_rooms_path(conference_progress['short_title'])
|
= link_to 'Add rooms', admin_conference_venue_rooms_path(conference_progress['short_title'])
|
||||||
- else
|
- else
|
||||||
Add rooms
|
Add rooms
|
||||||
%li{'class'=>"list-group-item #{class_for_todo(conference_progress['tracks'])}"}
|
%li{'class'=>"list-group-item #{class_for_todo(conference_progress['tracks'])}"}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
= @room.name
|
= @room.name
|
||||||
.row
|
.row
|
||||||
.col-md-8
|
.col-md-8
|
||||||
= semantic_form_for(@room, :url => (@room.new_record? ? admin_conference_program_rooms_path : admin_conference_program_room_path(@conference.short_title, @room))) do |f|
|
= semantic_form_for(@room, :url => (@room.new_record? ? admin_conference_venue_rooms_path : admin_conference_venue_room_path(@conference.short_title, @room))) do |f|
|
||||||
= f.input :name
|
= f.input :name, input_html: { autofocus: true}
|
||||||
= f.input :size, :input_html => {:size => 5}
|
= f.input :size, :input_html => {:size => 5}
|
||||||
%p.text-right
|
%p.text-right
|
||||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
%p.text-muted
|
%p.text-muted
|
||||||
The rooms of your conference venue
|
The rooms of your conference venue
|
||||||
|
|
||||||
- if @conference.program.rooms.any?
|
- if @rooms.any?
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
%table.table.table-hover#rooms
|
%table.table.table-hover#rooms
|
||||||
|
|
@ -14,18 +14,18 @@
|
||||||
%th Size
|
%th Size
|
||||||
%th Actions
|
%th Actions
|
||||||
%tbody
|
%tbody
|
||||||
- @conference.program.rooms.each_with_index do |room, index|
|
- @rooms.each_with_index do |room, index|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
= room.name
|
= room.name
|
||||||
%td
|
%td
|
||||||
= room.size
|
= room.size
|
||||||
%td
|
%td
|
||||||
= link_to 'Edit', edit_admin_conference_program_room_path(@conference.short_title, room.id),
|
= link_to 'Edit', edit_admin_conference_venue_room_path(@conference.short_title, room.id),
|
||||||
method: :get, class: 'btn btn-primary'
|
method: :get, class: 'btn btn-primary'
|
||||||
= link_to 'Delete', admin_conference_program_room_path(@conference.short_title, room.id),
|
= link_to 'Delete', admin_conference_venue_room_path(@conference.short_title, room.id),
|
||||||
method: :delete, class: 'btn btn-danger',
|
method: :delete, class: 'btn btn-danger',
|
||||||
data: { confirm: "Do you really want to delete #{room.name}? Attention: This room will be removed from all Events that have it set"}
|
data: { confirm: "Do you really want to delete #{room.name}? Attention: This room will be removed from all Events that have it set"}
|
||||||
.row
|
.row
|
||||||
.col-md-12.text-right
|
.col-md-12.text-right
|
||||||
= link_to 'Add Room', new_admin_conference_program_room_path(@conference.short_title), class: 'btn btn-primary'
|
= link_to 'Add Room', new_admin_conference_venue_room_path(@conference.short_title), class: 'btn btn-primary'
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,12 @@
|
||||||
= @venue.country_name
|
= @venue.country_name
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
= link_to 'Edit Venue', edit_admin_conference_venue_path(@conference.short_title), class: 'btn btn-primary', disabled: !(can? :edit, @conference.venue)
|
= link_to(edit_admin_conference_venue_path(@conference.short_title), class: 'btn btn-primary', disabled: !(can? :update, @venue) ) do
|
||||||
= link_to 'Delete Venue', admin_conference_venue_path(@conference.short_title), method: 'delete', class: 'btn btn-danger', disabled: !(can? :edit, @conference.venue)
|
Edit Venue
|
||||||
|
= link_to(admin_conference_venue_path(@conference.short_title), method: 'delete', class: 'btn btn-danger', disabled: !(can? :destroy, @venue)) do
|
||||||
|
Delete Venue
|
||||||
-else
|
-else
|
||||||
.row
|
.row
|
||||||
.col-md-12.text-right
|
.col-md-12.text-right
|
||||||
= link_to 'Create Venue', new_admin_conference_venue_path(@conference.short_title), class: 'btn btn-primary', disabled: !(can? :edit, @conference.venue)
|
= link_to(new_admin_conference_venue_path(@conference.short_title), class: 'btn btn-primary') do
|
||||||
|
Create Venue
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,9 @@
|
||||||
%span.fa.fa-road
|
%span.fa.fa-road
|
||||||
Venue
|
Venue
|
||||||
%ul
|
%ul
|
||||||
- if can? :update, @conference.program.rooms.build
|
- if @conference.venue && @conference.venue.persisted? && (can? :update, @conference.venue.rooms.build)
|
||||||
%li{:class=> active_nav_li(admin_conference_program_rooms_path(@conference.short_title))}
|
%li{:class=> active_nav_li(admin_conference_venue_rooms_path(@conference.short_title))}
|
||||||
= link_to 'Rooms', admin_conference_program_rooms_path(@conference.short_title)
|
= link_to 'Rooms', admin_conference_venue_rooms_path(@conference.short_title)
|
||||||
- if can? :update, @conference.lodgings.build
|
- if can? :update, @conference.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)
|
||||||
|
|
|
||||||
|
|
@ -44,14 +44,15 @@ Osem::Application.routes.draw do
|
||||||
|
|
||||||
# Singletons
|
# Singletons
|
||||||
resource :splashpage
|
resource :splashpage
|
||||||
resource :venue
|
resource :venue do
|
||||||
|
resources :rooms, except: [:show]
|
||||||
|
end
|
||||||
resource :registration_period
|
resource :registration_period
|
||||||
resource :program do
|
resource :program do
|
||||||
resource :cfp
|
resource :cfp
|
||||||
resources :tracks
|
resources :tracks
|
||||||
resources :event_types
|
resources :event_types
|
||||||
resources :difficulty_levels
|
resources :difficulty_levels
|
||||||
resources :rooms, except: [:show]
|
|
||||||
resources :events do
|
resources :events do
|
||||||
member do
|
member do
|
||||||
post :comment
|
post :comment
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ class CreateProgramsTable< ActiveRecord::Migration
|
||||||
t.integer :rating, default: 0
|
t.integer :rating, default: 0
|
||||||
t.boolean :schedule_public, default: false
|
t.boolean :schedule_public, default: false
|
||||||
t.boolean :schedule_fluid, default: false
|
t.boolean :schedule_fluid, default: false
|
||||||
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
||||||
add_column :call_for_papers, :program_id, :integer
|
add_column :call_for_papers, :program_id, :integer
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
class RenameConferenceIdToProgramIdInEventsRoomsTracksDifficultyLevels < ActiveRecord::Migration
|
class RenameConferenceIdToProgramIdInEventsTracksDifficultyLevels < ActiveRecord::Migration
|
||||||
class TempConference < ActiveRecord::Base
|
class TempConference < ActiveRecord::Base
|
||||||
self.table_name = 'conferences'
|
self.table_name = 'conferences'
|
||||||
end
|
end
|
||||||
|
|
@ -19,10 +19,6 @@ class RenameConferenceIdToProgramIdInEventsRoomsTracksDifficultyLevels < ActiveR
|
||||||
self.table_name = 'difficulty_levels'
|
self.table_name = 'difficulty_levels'
|
||||||
end
|
end
|
||||||
|
|
||||||
class TempRoom < ActiveRecord::Base
|
|
||||||
self.table_name = 'rooms'
|
|
||||||
end
|
|
||||||
|
|
||||||
class TempProgram < ActiveRecord::Base
|
class TempProgram < ActiveRecord::Base
|
||||||
self.table_name = 'programs'
|
self.table_name = 'programs'
|
||||||
end
|
end
|
||||||
|
|
@ -32,7 +28,6 @@ class RenameConferenceIdToProgramIdInEventsRoomsTracksDifficultyLevels < ActiveR
|
||||||
add_column :event_types, :program_id, :integer
|
add_column :event_types, :program_id, :integer
|
||||||
add_column :tracks, :program_id, :integer
|
add_column :tracks, :program_id, :integer
|
||||||
add_column :difficulty_levels, :program_id, :integer
|
add_column :difficulty_levels, :program_id, :integer
|
||||||
add_column :rooms, :program_id, :integer
|
|
||||||
|
|
||||||
TempConference.all.each do |conference|
|
TempConference.all.each do |conference|
|
||||||
program = Program.find_by(conference_id: conference.id)
|
program = Program.find_by(conference_id: conference.id)
|
||||||
|
|
@ -56,18 +51,12 @@ class RenameConferenceIdToProgramIdInEventsRoomsTracksDifficultyLevels < ActiveR
|
||||||
difficulty_level.program_id = program.id
|
difficulty_level.program_id = program.id
|
||||||
difficulty_level.save!
|
difficulty_level.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
TempRoom.where(conference_id: conference.id).each do |room|
|
|
||||||
room.program_id = program.id
|
|
||||||
room.save!
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
remove_column :events, :conference_id
|
remove_column :events, :conference_id
|
||||||
remove_column :event_types, :conference_id
|
remove_column :event_types, :conference_id
|
||||||
remove_column :tracks, :conference_id
|
remove_column :tracks, :conference_id
|
||||||
remove_column :difficulty_levels, :conference_id
|
remove_column :difficulty_levels, :conference_id
|
||||||
remove_column :rooms, :conference_id
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
|
@ -75,7 +64,6 @@ class RenameConferenceIdToProgramIdInEventsRoomsTracksDifficultyLevels < ActiveR
|
||||||
add_column :event_types, :conference_id, :integer
|
add_column :event_types, :conference_id, :integer
|
||||||
add_column :tracks, :conference_id, :integer
|
add_column :tracks, :conference_id, :integer
|
||||||
add_column :difficulty_levels, :conference_id, :integer
|
add_column :difficulty_levels, :conference_id, :integer
|
||||||
add_column :rooms, :conference_id, :integer
|
|
||||||
|
|
||||||
TempConference.all.each do |conference|
|
TempConference.all.each do |conference|
|
||||||
program = TempProgram.find_by(conference_id: conference.id)
|
program = TempProgram.find_by(conference_id: conference.id)
|
||||||
|
|
@ -100,11 +88,6 @@ class RenameConferenceIdToProgramIdInEventsRoomsTracksDifficultyLevels < ActiveR
|
||||||
difficulty_level.conference_id = conference.id
|
difficulty_level.conference_id = conference.id
|
||||||
difficulty_level.save!
|
difficulty_level.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
TempRoom.where(program_id: program.id).each do |room|
|
|
||||||
room.conference_id = conference.id
|
|
||||||
room.save!
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -112,6 +95,5 @@ class RenameConferenceIdToProgramIdInEventsRoomsTracksDifficultyLevels < ActiveR
|
||||||
remove_column :event_types, :program_id
|
remove_column :event_types, :program_id
|
||||||
remove_column :tracks, :program_id
|
remove_column :tracks, :program_id
|
||||||
remove_column :difficulty_levels, :program_id
|
remove_column :difficulty_levels, :program_id
|
||||||
remove_column :rooms, :program_id
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
class ChangeConferenceIdToVenueIdInRooms < ActiveRecord::Migration
|
||||||
|
class TempConference < ActiveRecord::Base
|
||||||
|
self.table_name = 'conferences'
|
||||||
|
|
||||||
|
has_one :temp_venue
|
||||||
|
end
|
||||||
|
|
||||||
|
class TempVenue < ActiveRecord::Base
|
||||||
|
self.table_name = 'venues'
|
||||||
|
|
||||||
|
belongs_to :temp_conference
|
||||||
|
has_many :temp_rooms
|
||||||
|
end
|
||||||
|
|
||||||
|
class TempRoom < ActiveRecord::Base
|
||||||
|
self.table_name = 'rooms'
|
||||||
|
|
||||||
|
belongs_to :temp_venue
|
||||||
|
end
|
||||||
|
|
||||||
|
def up
|
||||||
|
add_column :rooms, :venue_id, :integer, null: false
|
||||||
|
|
||||||
|
TempRoom.all.each do |room|
|
||||||
|
venue = TempVenue.find_by(conference_id: room.conference_id)
|
||||||
|
if venue
|
||||||
|
room.venue_id = venue.id
|
||||||
|
else
|
||||||
|
test_venue = Venue.find_or_create_by!(conference_id: room.conference_id, name: 'test venue', street: 'test street', city: 'test city', country: 'test')
|
||||||
|
room.venue_id = test_venue.id
|
||||||
|
end
|
||||||
|
room.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
remove_column :rooms, :conference_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
add_column :rooms, :conference_id, :integer, null: false
|
||||||
|
|
||||||
|
TempRoom.all.each do |room|
|
||||||
|
venue = TempVenue.find(room.venue_id)
|
||||||
|
conference = TempConference.find(venue.conference_id)
|
||||||
|
|
||||||
|
if conference
|
||||||
|
room.conference_id = conference.id
|
||||||
|
end
|
||||||
|
|
||||||
|
room.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
remove_column :rooms, :venue_id
|
||||||
|
end
|
||||||
|
end
|
||||||
18
db/schema.rb
18
db/schema.rb
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20151021113015) do
|
ActiveRecord::Schema.define(version: 20151031092713) do
|
||||||
|
|
||||||
create_table "ahoy_events", force: true do |t|
|
create_table "ahoy_events", force: true do |t|
|
||||||
t.uuid "visit_id"
|
t.uuid "visit_id"
|
||||||
|
|
@ -274,10 +274,12 @@ ActiveRecord::Schema.define(version: 20151021113015) do
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "programs", force: true do |t|
|
create_table "programs", force: true do |t|
|
||||||
t.integer "conference_id"
|
t.integer "conference_id"
|
||||||
t.integer "rating", default: 0
|
t.integer "rating", default: 0
|
||||||
t.boolean "schedule_public", default: false
|
t.boolean "schedule_public", default: false
|
||||||
t.boolean "schedule_fluid", default: false
|
t.boolean "schedule_fluid", default: false
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "qanswers", force: true do |t|
|
create_table "qanswers", force: true do |t|
|
||||||
|
|
@ -360,10 +362,10 @@ ActiveRecord::Schema.define(version: 20151021113015) do
|
||||||
add_index "roles_users", ["user_id", "role_id"], name: "index_roles_users_on_user_id_and_role_id", using: :btree
|
add_index "roles_users", ["user_id", "role_id"], name: "index_roles_users_on_user_id_and_role_id", using: :btree
|
||||||
|
|
||||||
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.string "name", null: false
|
t.string "name", null: false
|
||||||
t.integer "size"
|
t.integer "size"
|
||||||
t.integer "program_id"
|
t.integer "venue_id", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "social_events", force: true do |t|
|
create_table "social_events", force: true do |t|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ var scheduleDayEvents = {};
|
||||||
var Schedule = {
|
var Schedule = {
|
||||||
loadEvents: function(conference_id, start_date) {
|
loadEvents: function(conference_id, start_date) {
|
||||||
var eventDates = {};
|
var eventDates = {};
|
||||||
var url = '/admin/conference/' + conference_id + '/events';
|
var url = '/admin/conference/' + conference_id + '/program/events';
|
||||||
var params = { start: $('#start').text(), end: $('#end').text()};
|
var params = { start: $('#start').text(), end: $('#end').text()};
|
||||||
var callback = function(data) {
|
var callback = function(data) {
|
||||||
$.each(data, function(key, val) {
|
$.each(data, function(key, val) {
|
||||||
|
|
|
||||||
|
|
@ -7,22 +7,21 @@ FactoryGirl.define do
|
||||||
timezone 'Amsterdam'
|
timezone 'Amsterdam'
|
||||||
start_date { Date.today }
|
start_date { Date.today }
|
||||||
end_date { 6.days.from_now }
|
end_date { 6.days.from_now }
|
||||||
program
|
|
||||||
|
|
||||||
factory :full_conference do
|
factory :full_conference do
|
||||||
venue
|
|
||||||
splashpage
|
splashpage
|
||||||
registration_period
|
registration_period
|
||||||
|
|
||||||
after(:build) do |conference|
|
after :create do |conference|
|
||||||
conference.commercials << build(:conference_commercial, commercialable: conference)
|
create(:venue, conference_id: conference.id)
|
||||||
conference.campaigns << build(:campaign, conference: conference)
|
conference.commercials << create(:conference_commercial, commercialable: conference)
|
||||||
conference.targets << build(:target, conference: conference)
|
conference.campaigns << create(:campaign, conference: conference)
|
||||||
conference.questions << build(:question, conference_id: conference.id)
|
conference.targets << create(:target, conference: conference)
|
||||||
conference.lodgings << build(:lodging, conference: conference)
|
conference.questions << create(:question, conference_id: conference.id)
|
||||||
conference.sponsors << build(:sponsor, conference: conference)
|
conference.lodgings << create(:lodging, conference: conference)
|
||||||
conference.sponsorship_levels << build(:sponsorship_level, conference: conference)
|
conference.sponsors << create(:sponsor, conference: conference)
|
||||||
conference.tickets << build(:ticket, conference: conference)
|
conference.sponsorship_levels << create(:sponsorship_level, conference: conference)
|
||||||
|
conference.tickets << create(:ticket, conference: conference)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,10 @@ FactoryGirl.define do
|
||||||
event.commercials << build(:event_commercial, commercialable: event)
|
event.commercials << build(:event_commercial, commercialable: event)
|
||||||
event.difficulty_level = build(:difficulty_level, program: event.program)
|
event.difficulty_level = build(:difficulty_level, program: event.program)
|
||||||
event.track = build(:track, program: event.program)
|
event.track = build(:track, program: event.program)
|
||||||
event.room = build(:room, program: event.program)
|
unless (venue = event.program.conference.venue)
|
||||||
|
venue = create(:venue, conference: event.program.conference)
|
||||||
|
end
|
||||||
|
event.room = build(:room, venue: venue)
|
||||||
event.comment_threads << build(:comment, commentable: event)
|
event.comment_threads << build(:comment, commentable: event)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,6 @@ FactoryGirl.define do
|
||||||
factory :program do
|
factory :program do
|
||||||
schedule_public false
|
schedule_public false
|
||||||
schedule_fluid false
|
schedule_fluid false
|
||||||
# conference
|
conference
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -3,7 +3,7 @@ FactoryGirl.define do
|
||||||
factory :room do
|
factory :room do
|
||||||
name 'Example Room'
|
name 'Example Room'
|
||||||
size 4
|
size 4
|
||||||
program
|
venue
|
||||||
|
|
||||||
factory :room_for_100 do
|
factory :room_for_100 do
|
||||||
name 'Room for 100'
|
name 'Room for 100'
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,6 @@ FactoryGirl.define do
|
||||||
country 'DE'
|
country 'DE'
|
||||||
website 'www.opensuse.org'
|
website 'www.opensuse.org'
|
||||||
description 'Lorem Ipsum Dolor'
|
description 'Lorem Ipsum Dolor'
|
||||||
|
conference
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@ require 'spec_helper'
|
||||||
|
|
||||||
feature 'Has correct abilities' do
|
feature 'Has correct abilities' 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(:conference1) { create(:conference) } # user is organizer
|
let(:conference1) { create(:full_conference) } # user is organizer
|
||||||
let(:conference2) { create(:conference) } # user is cfp
|
let(:conference2) { create(:full_conference) } # user is cfp
|
||||||
let(:conference3) { create(:conference) } # user is info_desk
|
let(:conference3) { create(:full_conference) } # user is info_desk
|
||||||
let(:conference4) { create(:conference) } # user is volunteer coordinator
|
let(:conference4) { create(:full_conference) } # user is volunteer coordinator
|
||||||
let(:conference5) { create(:conference) } # user has no role
|
let(:conference5) { create(:full_conference) } # user has no role
|
||||||
|
|
||||||
let(:role_organizer) { create(:role, name: 'organizer', resource: conference1) }
|
let(:role_organizer) { create(:role, name: 'organizer', resource: conference1) }
|
||||||
let(:role_cfp) { create(:role, name: 'cfp', resource: conference2) }
|
let(:role_cfp) { create(:role, name: 'cfp', resource: conference2) }
|
||||||
|
|
@ -43,7 +43,7 @@ feature 'Has correct abilities' do
|
||||||
expect(page).to have_link('Campaigns', href: "/admin/conference/#{conference1.short_title}/campaigns")
|
expect(page).to have_link('Campaigns', href: "/admin/conference/#{conference1.short_title}/campaigns")
|
||||||
expect(page).to have_link('Goals', href: "/admin/conference/#{conference1.short_title}/targets")
|
expect(page).to have_link('Goals', 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('Venue', href: "/admin/conference/#{conference1.short_title}/venue")
|
||||||
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference1.short_title}/program/rooms")
|
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference1.short_title}/venue/rooms")
|
||||||
expect(page).to have_link('Lodgings', href: "/admin/conference/#{conference1.short_title}/lodgings")
|
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('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('Sponsors', href: "/admin/conference/#{conference1.short_title}/sponsors")
|
||||||
|
|
@ -120,7 +120,7 @@ feature 'Has correct abilities' do
|
||||||
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference2.short_title}/campaigns")
|
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference2.short_title}/campaigns")
|
||||||
expect(page).to_not have_link('Goals', href: "/admin/conference/#{conference2.short_title}/targets")
|
expect(page).to_not have_link('Goals', 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('Venue', href: "/admin/conference/#{conference2.short_title}/venue")
|
||||||
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference2.short_title}/program/rooms")
|
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference2.short_title}/venue/rooms")
|
||||||
expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference2.short_title}/lodgings")
|
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('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('Sponsors', href: "/admin/conference/#{conference2.short_title}/sponsors")
|
||||||
|
|
@ -193,7 +193,7 @@ feature 'Has correct abilities' do
|
||||||
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference3.short_title}/campaigns")
|
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('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('Venue', href: "/admin/conference/#{conference3.short_title}/venue")
|
||||||
expect(page).to_not have_link('Rooms', href: "/admin/conference/#{conference3.short_title}/program/rooms")
|
expect(page).to_not have_link('Rooms', href: "/admin/conference/#{conference3.short_title}/venue/rooms")
|
||||||
expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference3.short_title}/lodgings")
|
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('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('Sponsors', href: "/admin/conference/#{conference3.short_title}/sponsors")
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,14 @@ require 'spec_helper'
|
||||||
|
|
||||||
feature Room do
|
feature Room do
|
||||||
let!(:conference) { create(:conference) }
|
let!(:conference) { create(:conference) }
|
||||||
|
let!(:venue) { create(:venue, conference: conference) }
|
||||||
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
||||||
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
|
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
|
||||||
|
|
||||||
shared_examples 'rooms' do
|
shared_examples 'rooms' do
|
||||||
scenario 'adds a room', feature: true, js: true do
|
scenario 'adds a room', feature: true, js: true do
|
||||||
sign_in organizer
|
sign_in organizer
|
||||||
visit admin_conference_program_rooms_path(
|
visit admin_conference_venue_rooms_path(
|
||||||
conference_id: conference.short_title)
|
conference_id: conference.short_title)
|
||||||
|
|
||||||
expect(page.has_no_table?('#rooms')).to be true
|
expect(page.has_no_table?('#rooms')).to be true
|
||||||
|
|
@ -30,9 +31,9 @@ feature Room do
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'updates a room', feature: true, js: true do
|
scenario 'updates a room', feature: true, js: true do
|
||||||
room = create(:room, program_id: conference.program.id)
|
room = create(:room, venue: venue)
|
||||||
sign_in organizer
|
sign_in organizer
|
||||||
visit edit_admin_conference_program_room_path(
|
visit edit_admin_conference_venue_room_path(
|
||||||
conference_id: conference.short_title, id: room.id)
|
conference_id: conference.short_title, id: room.id)
|
||||||
|
|
||||||
fill_in 'room_name', with: 'Auditorium'
|
fill_in 'room_name', with: 'Auditorium'
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,17 @@ describe 'User' do
|
||||||
subject(:ability){ Ability.new(user) }
|
subject(:ability){ Ability.new(user) }
|
||||||
let(:user){ nil }
|
let(:user){ nil }
|
||||||
|
|
||||||
|
let!(:my_conference) { create(:full_conference) }
|
||||||
|
let!(:my_cfp) { create(:cfp, program: my_conference.program) }
|
||||||
|
let(:my_venue) { my_conference.venue || create(:venue, conference: my_conference) }
|
||||||
|
let(:my_registration) { create(:registration, conference: my_conference, user: first_user) }
|
||||||
|
|
||||||
|
let(:other_registration) { create(:registration, conference: conference_public) }
|
||||||
|
let(:my_event) { create(:event_full, program: my_conference.program) }
|
||||||
|
let(:my_room) { create(:room, venue: my_conference.venue) }
|
||||||
|
let!(:my_event_scheduled) { create(:event_full, program: my_conference.program, room_id: my_room.id) }
|
||||||
|
let(:other_event) { create(:event_full, program: conference_public.program) }
|
||||||
|
|
||||||
let(:conference_not_public) { create(:conference, splashpage: create(:splashpage, public: false)) }
|
let(:conference_not_public) { create(:conference, splashpage: create(:splashpage, public: false)) }
|
||||||
let(:conference_public) { create(:full_conference, splashpage: create(:splashpage, public: true)) }
|
let(:conference_public) { create(:full_conference, splashpage: create(:splashpage, public: true)) }
|
||||||
let!(:conference_public_cfp) { create(:cfp, program: conference_public.program) }
|
let!(:conference_public_cfp) { create(:cfp, program: conference_public.program) }
|
||||||
|
|
@ -62,10 +73,8 @@ describe 'User' do
|
||||||
let(:registration_public) { create(:registration, conference: conference_public, user: user) }
|
let(:registration_public) { create(:registration, conference: conference_public, user: user) }
|
||||||
let(:registration_not_public) { create(:registration, conference: conference_not_public, user: user) }
|
let(:registration_not_public) { create(:registration, conference: conference_not_public, user: user) }
|
||||||
|
|
||||||
let(:my_event) { create(:event, users: [user]) }
|
let(:user_event) { create(:event, users: [user]) }
|
||||||
|
let(:user_commercial) { create(:commercial, commercialable: user_event) }
|
||||||
let(:commercial) { create(:commercial, commercialable: event_unconfirmed) }
|
|
||||||
let(:my_commercial) { create(:commercial, commercialable: my_event) }
|
|
||||||
|
|
||||||
it{ should be_able_to(:manage, user) }
|
it{ should be_able_to(:manage, user) }
|
||||||
|
|
||||||
|
|
@ -79,28 +88,39 @@ describe 'User' do
|
||||||
it{ should be_able_to(:destroy, subscription) }
|
it{ should be_able_to(:destroy, subscription) }
|
||||||
|
|
||||||
it{ should be_able_to(:create, Event) }
|
it{ should be_able_to(:create, Event) }
|
||||||
it{ should be_able_to(:manage, my_event) }
|
it{ should be_able_to(:manage, user_event) }
|
||||||
it{ should_not be_able_to(:manage, event_unconfirmed) }
|
it{ should_not be_able_to(:manage, event_unconfirmed) }
|
||||||
|
|
||||||
it{ should be_able_to(:create, my_event.commercials.new) }
|
it{ should be_able_to(:create, user_event.commercials.new) }
|
||||||
it{ should be_able_to(:manage, my_commercial) }
|
it{ should be_able_to(:manage, user_commercial) }
|
||||||
it{ should_not be_able_to(:manage, commercial) }
|
it{ should_not be_able_to(:manage, commercial_event_unconfirmed) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'user #is_admin?' do
|
context 'user #is_admin?' do
|
||||||
|
let(:venue) { my_conference.venue }
|
||||||
|
let(:room) { create(:room, venue: venue) }
|
||||||
|
let!(:event) { create(:event_full, program: my_conference.program, room_id: room.id) }
|
||||||
let(:user) { create(:admin) }
|
let(:user) { create(:admin) }
|
||||||
it{ should be_able_to(:manage, :all) }
|
it{ should be_able_to(:manage, :all) }
|
||||||
|
it{ should_not be_able_to(:destroy, my_conference.program) }
|
||||||
|
it{ should_not be_able_to(:destroy, my_venue) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user has the role organizer' do
|
context 'when user has the role organizer' do
|
||||||
let!(:my_conference) { create(:full_conference) }
|
|
||||||
let!(:my_cfp) { create(:cfp, program: my_conference.program) }
|
|
||||||
let(:role) { create(:organizer_role, resource: my_conference) }
|
let(:role) { create(:organizer_role, resource: my_conference) }
|
||||||
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
|
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
|
||||||
let(:registration) { create(:registration, conference: my_conference) }
|
|
||||||
let(:other_registration) { create(:registration, conference: conference_public) }
|
it{ should_not be_able_to(:destroy, my_conference.program) }
|
||||||
let(:event) { create(:event_full, program: my_conference.program) }
|
it 'when there is a room assigned to an event' do
|
||||||
let(:other_event) { create(:event_full, program: conference_public.program) }
|
should_not be_able_to(:destroy, my_venue)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'when there are no rooms used' do
|
||||||
|
my_event_scheduled.room_id = nil
|
||||||
|
my_event_scheduled.save!
|
||||||
|
my_event_scheduled.reload
|
||||||
|
should be_able_to(:destroy, my_venue)
|
||||||
|
end
|
||||||
|
|
||||||
it{ should be_able_to([:create, :new], Conference) }
|
it{ should be_able_to([:create, :new], Conference) }
|
||||||
it{ should be_able_to(:manage, my_conference) }
|
it{ should be_able_to(:manage, my_conference) }
|
||||||
|
|
@ -134,32 +154,26 @@ describe 'User' do
|
||||||
it{ should be_able_to(:manage, my_conference.tickets.first) }
|
it{ should be_able_to(:manage, my_conference.tickets.first) }
|
||||||
it{ should_not be_able_to(:manage, conference_public.tickets.first) }
|
it{ should_not be_able_to(:manage, conference_public.tickets.first) }
|
||||||
|
|
||||||
it{ should be_able_to(:manage, registration) }
|
it{ should be_able_to(:manage, my_registration) }
|
||||||
it{ should_not be_able_to(:manage, other_registration) }
|
it{ should_not be_able_to(:manage, other_registration) }
|
||||||
|
|
||||||
it{ should be_able_to(:manage, event) }
|
it{ should be_able_to(:manage, my_event) }
|
||||||
it{ should_not be_able_to(:manage, other_event) }
|
it{ should_not be_able_to(:manage, other_event) }
|
||||||
it{ should be_able_to(:manage, event.event_type) }
|
it{ should be_able_to(:manage, my_event.event_type) }
|
||||||
it{ should_not be_able_to(:manage, other_event.event_type) }
|
it{ should_not be_able_to(:manage, other_event.event_type) }
|
||||||
it{ should be_able_to(:manage, event.track) }
|
it{ should be_able_to(:manage, my_event.track) }
|
||||||
it{ should_not be_able_to(:manage, other_event.track) }
|
it{ should_not be_able_to(:manage, other_event.track) }
|
||||||
it{ should be_able_to(:manage, event.difficulty_level) }
|
it{ should be_able_to(:manage, my_event.difficulty_level) }
|
||||||
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
|
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
|
||||||
it{ should be_able_to(:manage, event.commercials.first) }
|
it{ should be_able_to(:manage, my_event.commercials.first) }
|
||||||
it{ should_not be_able_to(:manage, other_event.commercials.first) }
|
it{ should_not be_able_to(:manage, other_event.commercials.first) }
|
||||||
it{ should be_able_to(:index, event.comment_threads.first) }
|
it{ should be_able_to(:index, my_event.comment_threads.first) }
|
||||||
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
|
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user has the role cfp' do
|
context 'when user has the role cfp' do
|
||||||
let!(:my_conference) { create(:full_conference) }
|
|
||||||
let!(:my_cfp) { create(:cfp, program: my_conference.program) }
|
|
||||||
let(:role) { create(:cfp_role, resource: my_conference) }
|
let(:role) { create(:cfp_role, resource: my_conference) }
|
||||||
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
|
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
|
||||||
let(:registration) { create(:registration, conference: my_conference) }
|
|
||||||
let(:other_registration) { create(:registration, conference: conference_public) }
|
|
||||||
let(:event) { create(:event_full, program: my_conference.program) }
|
|
||||||
let(:other_event) { create(:event_full, program: conference_public.program) }
|
|
||||||
|
|
||||||
it{ should_not be_able_to([:create, :new], Conference.new) }
|
it{ should_not be_able_to([:create, :new], Conference.new) }
|
||||||
it{ should_not be_able_to(:manage, my_conference) }
|
it{ should_not be_able_to(:manage, my_conference) }
|
||||||
|
|
@ -194,32 +208,26 @@ describe 'User' do
|
||||||
it{ should_not be_able_to(:manage, my_conference.tickets.first) }
|
it{ should_not be_able_to(:manage, my_conference.tickets.first) }
|
||||||
it{ should_not be_able_to(:manage, conference_public.tickets.first) }
|
it{ should_not be_able_to(:manage, conference_public.tickets.first) }
|
||||||
|
|
||||||
it{ should_not be_able_to(:manage, registration) }
|
it{ should_not be_able_to(:manage, my_registration) }
|
||||||
it{ should_not be_able_to(:manage, other_registration) }
|
it{ should_not be_able_to(:manage, other_registration) }
|
||||||
|
|
||||||
it{ should be_able_to(:manage, event) }
|
it{ should be_able_to(:manage, my_event) }
|
||||||
it{ should_not be_able_to(:manage, other_event) }
|
it{ should_not be_able_to(:manage, other_event) }
|
||||||
it{ should be_able_to(:manage, event.event_type) }
|
it{ should be_able_to(:manage, my_event.event_type) }
|
||||||
it{ should_not be_able_to(:manage, other_event.event_type) }
|
it{ should_not be_able_to(:manage, other_event.event_type) }
|
||||||
it{ should be_able_to(:manage, event.track) }
|
it{ should be_able_to(:manage, my_event.track) }
|
||||||
it{ should_not be_able_to(:manage, other_event.track) }
|
it{ should_not be_able_to(:manage, other_event.track) }
|
||||||
it{ should be_able_to(:manage, event.difficulty_level) }
|
it{ should be_able_to(:manage, my_event.difficulty_level) }
|
||||||
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
|
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
|
||||||
it{ should be_able_to(:manage, event.commercials.first) }
|
it{ should be_able_to(:manage, my_event.commercials.first) }
|
||||||
it{ should_not be_able_to(:manage, other_event.commercials.first) }
|
it{ should_not be_able_to(:manage, other_event.commercials.first) }
|
||||||
it{ should be_able_to(:index, event.comment_threads.first) }
|
it{ should be_able_to(:index, my_event.comment_threads.first) }
|
||||||
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
|
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user has the role info_desk' do
|
context 'when user has the role info_desk' do
|
||||||
let!(:my_conference) { create(:full_conference) }
|
|
||||||
let!(:my_cfp) { create(:cfp, program: my_conference.program) }
|
|
||||||
let(:role) { create(:info_desk_role, resource: my_conference) }
|
let(:role) { create(:info_desk_role, resource: my_conference) }
|
||||||
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
|
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
|
||||||
let(:registration) { create(:registration, conference: my_conference) }
|
|
||||||
let(:other_registration) { create(:registration, conference: conference_public) }
|
|
||||||
let(:event) { create(:event_full, program: my_conference.program) }
|
|
||||||
let(:other_event) { create(:event_full, program: conference_public.program) }
|
|
||||||
|
|
||||||
it{ should_not be_able_to([:create, :new], Conference.new) }
|
it{ should_not be_able_to([:create, :new], Conference.new) }
|
||||||
it{ should_not be_able_to(:manage, my_conference) }
|
it{ should_not be_able_to(:manage, my_conference) }
|
||||||
|
|
@ -254,32 +262,26 @@ describe 'User' do
|
||||||
it{ should_not be_able_to(:manage, my_conference.tickets.first) }
|
it{ should_not be_able_to(:manage, my_conference.tickets.first) }
|
||||||
it{ should_not be_able_to(:manage, conference_public.tickets.first) }
|
it{ should_not be_able_to(:manage, conference_public.tickets.first) }
|
||||||
|
|
||||||
it{ should be_able_to(:manage, registration) }
|
it{ should be_able_to(:manage, my_registration) }
|
||||||
it{ should_not be_able_to(:manage, other_registration) }
|
it{ should_not be_able_to(:manage, other_registration) }
|
||||||
|
|
||||||
it{ should_not be_able_to(:manage, event) }
|
it{ should_not be_able_to(:manage, my_event) }
|
||||||
it{ should_not be_able_to(:manage, other_event) }
|
it{ should_not be_able_to(:manage, other_event) }
|
||||||
it{ should_not be_able_to(:manage, event.event_type) }
|
it{ should_not be_able_to(:manage, my_event.event_type) }
|
||||||
it{ should_not be_able_to(:manage, other_event.event_type) }
|
it{ should_not be_able_to(:manage, other_event.event_type) }
|
||||||
it{ should_not be_able_to(:manage, event.track) }
|
it{ should_not be_able_to(:manage, my_event.track) }
|
||||||
it{ should_not be_able_to(:manage, other_event.track) }
|
it{ should_not be_able_to(:manage, other_event.track) }
|
||||||
it{ should_not be_able_to(:manage, event.difficulty_level) }
|
it{ should_not be_able_to(:manage, my_event.difficulty_level) }
|
||||||
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
|
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
|
||||||
it{ should_not be_able_to(:manage, event.commercials.first) }
|
it{ should_not be_able_to(:manage, my_event.commercials.first) }
|
||||||
it{ should_not be_able_to(:manage, other_event.commercials.first) }
|
it{ should_not be_able_to(:manage, other_event.commercials.first) }
|
||||||
it{ should_not be_able_to(:index, event.comment_threads.first) }
|
it{ should_not be_able_to(:index, my_event.comment_threads.first) }
|
||||||
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
|
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user has the role volunteers_coordinator' do
|
context 'when user has the role volunteers_coordinator' do
|
||||||
let!(:my_conference) { create(:full_conference) }
|
|
||||||
let!(:my_cfp) { create(:cfp, program: my_conference.program) }
|
|
||||||
let(:role) { create(:volunteers_coordinator_role, resource: my_conference) }
|
let(:role) { create(:volunteers_coordinator_role, resource: my_conference) }
|
||||||
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
|
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
|
||||||
let(:registration) { create(:registration, conference: my_conference) }
|
|
||||||
let(:other_registration) { create(:registration, conference: conference_public) }
|
|
||||||
let(:event) { create(:event_full, program: my_conference.program) }
|
|
||||||
let(:other_event) { create(:event_full, program: conference_public.program) }
|
|
||||||
|
|
||||||
it{ should_not be_able_to([:create, :new], Conference.new) }
|
it{ should_not be_able_to([:create, :new], Conference.new) }
|
||||||
it{ should_not be_able_to(:manage, my_conference) }
|
it{ should_not be_able_to(:manage, my_conference) }
|
||||||
|
|
@ -317,17 +319,17 @@ describe 'User' do
|
||||||
it{ should_not be_able_to(:manage, registration) }
|
it{ should_not be_able_to(:manage, registration) }
|
||||||
it{ should_not be_able_to(:manage, other_registration) }
|
it{ should_not be_able_to(:manage, other_registration) }
|
||||||
|
|
||||||
it{ should_not be_able_to(:manage, event) }
|
it{ should_not be_able_to(:manage, my_event) }
|
||||||
it{ should_not be_able_to(:manage, other_event) }
|
it{ should_not be_able_to(:manage, other_event) }
|
||||||
it{ should_not be_able_to(:manage, event.event_type) }
|
it{ should_not be_able_to(:manage, my_event.event_type) }
|
||||||
it{ should_not be_able_to(:manage, other_event.event_type) }
|
it{ should_not be_able_to(:manage, other_event.event_type) }
|
||||||
it{ should_not be_able_to(:manage, event.track) }
|
it{ should_not be_able_to(:manage, my_event.track) }
|
||||||
it{ should_not be_able_to(:manage, other_event.track) }
|
it{ should_not be_able_to(:manage, other_event.track) }
|
||||||
it{ should_not be_able_to(:manage, event.difficulty_level) }
|
it{ should_not be_able_to(:manage, my_event.difficulty_level) }
|
||||||
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
|
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
|
||||||
it{ should_not be_able_to(:manage, event.commercials.first) }
|
it{ should_not be_able_to(:manage, my_event.commercials.first) }
|
||||||
it{ should_not be_able_to(:manage, other_event.commercials.first) }
|
it{ should_not be_able_to(:manage, other_event.commercials.first) }
|
||||||
it{ should_not be_able_to(:index, event.comment_threads.first) }
|
it{ should_not be_able_to(:index, my_event.comment_threads.first) }
|
||||||
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
|
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
|
||||||
it 'should be_able to :manage Vposition'
|
it 'should be_able to :manage Vposition'
|
||||||
it 'should be_able to :manage Vday'
|
it 'should be_able to :manage Vday'
|
||||||
|
|
|
||||||
|
|
@ -972,7 +972,6 @@ describe Conference do
|
||||||
it 'calculates correct for new conference' do
|
it 'calculates correct for new conference' do
|
||||||
subject.program.cfp = nil
|
subject.program.cfp = nil
|
||||||
subject.venue = nil
|
subject.venue = nil
|
||||||
subject.program.rooms = []
|
|
||||||
subject.program.tracks = []
|
subject.program.tracks = []
|
||||||
subject.program.event_types = []
|
subject.program.event_types = []
|
||||||
subject.program.difficulty_levels = []
|
subject.program.difficulty_levels = []
|
||||||
|
|
@ -1005,7 +1004,6 @@ describe Conference do
|
||||||
end_date: Date.today + 14)
|
end_date: Date.today + 14)
|
||||||
subject.program.cfp = create(:cfp)
|
subject.program.cfp = create(:cfp)
|
||||||
subject.venue = nil
|
subject.venue = nil
|
||||||
subject.program.rooms = []
|
|
||||||
subject.program.tracks = []
|
subject.program.tracks = []
|
||||||
subject.program.event_types = []
|
subject.program.event_types = []
|
||||||
subject.program.difficulty_levels = []
|
subject.program.difficulty_levels = []
|
||||||
|
|
@ -1023,8 +1021,8 @@ describe Conference do
|
||||||
start_date: Date.today,
|
start_date: Date.today,
|
||||||
end_date: Date.today + 14)
|
end_date: Date.today + 14)
|
||||||
subject.program.cfp = create(:cfp)
|
subject.program.cfp = create(:cfp)
|
||||||
subject.venue = create(:venue)
|
subject.venue = create(:venue, conference: subject)
|
||||||
subject.program.rooms = []
|
subject.venue.rooms = []
|
||||||
subject.program.tracks = []
|
subject.program.tracks = []
|
||||||
subject.program.event_types = []
|
subject.program.event_types = []
|
||||||
subject.program.difficulty_levels = []
|
subject.program.difficulty_levels = []
|
||||||
|
|
@ -1039,12 +1037,12 @@ describe Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates correct for conference with registration, cfp, venue, rooms' do
|
it 'calculates correct for conference with registration, cfp, venue, rooms' do
|
||||||
subject.program.rooms = [create(:room)]
|
|
||||||
subject.registration_period = create(:registration_period,
|
subject.registration_period = create(:registration_period,
|
||||||
start_date: Date.today,
|
start_date: Date.today,
|
||||||
end_date: Date.today + 14)
|
end_date: Date.today + 14)
|
||||||
subject.program.cfp = create(:cfp)
|
subject.program.cfp = create(:cfp)
|
||||||
subject.venue = create(:venue)
|
subject.venue = create(:venue, conference: subject)
|
||||||
|
subject.venue.rooms = [create(:room, venue: subject.venue)]
|
||||||
subject.program.tracks = []
|
subject.program.tracks = []
|
||||||
subject.program.event_types = []
|
subject.program.event_types = []
|
||||||
subject.program.difficulty_levels = []
|
subject.program.difficulty_levels = []
|
||||||
|
|
@ -1060,13 +1058,13 @@ describe Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates correct for conference with registration, cfp, venue, rooms, tracks' do
|
it 'calculates correct for conference with registration, cfp, venue, rooms, tracks' do
|
||||||
subject.program.rooms = [create(:room)]
|
subject.venue = create(:venue, conference: subject)
|
||||||
|
subject.venue.rooms = [create(:room, venue: subject.venue)]
|
||||||
subject.program.tracks = [create(:track)]
|
subject.program.tracks = [create(:track)]
|
||||||
subject.registration_period = create(:registration_period,
|
subject.registration_period = create(:registration_period,
|
||||||
start_date: Date.today,
|
start_date: Date.today,
|
||||||
end_date: Date.today + 14)
|
end_date: Date.today + 14)
|
||||||
subject.program.cfp = create(:cfp)
|
subject.program.cfp = create(:cfp)
|
||||||
subject.venue = create(:venue)
|
|
||||||
subject.program.event_types = []
|
subject.program.event_types = []
|
||||||
subject.program.difficulty_levels = []
|
subject.program.difficulty_levels = []
|
||||||
subject.splashpage = create(:splashpage, public: false)
|
subject.splashpage = create(:splashpage, public: false)
|
||||||
|
|
@ -1083,14 +1081,14 @@ describe Conference do
|
||||||
|
|
||||||
it 'calculates correct for conference with registration, cfp,
|
it 'calculates correct for conference with registration, cfp,
|
||||||
venue, rooms, tracks, event_types' do
|
venue, rooms, tracks, event_types' do
|
||||||
subject.program.rooms = [create(:room)]
|
|
||||||
subject.program.tracks = [create(:track)]
|
subject.program.tracks = [create(:track)]
|
||||||
subject.program.event_types = [create(:event_type)]
|
subject.program.event_types = [create(:event_type)]
|
||||||
subject.registration_period = create(:registration_period,
|
subject.registration_period = create(:registration_period,
|
||||||
start_date: Date.today,
|
start_date: Date.today,
|
||||||
end_date: Date.today + 14)
|
end_date: Date.today + 14)
|
||||||
subject.program.cfp = create(:cfp)
|
subject.program.cfp = create(:cfp)
|
||||||
subject.venue = create(:venue)
|
subject.venue = create(:venue, conference: subject)
|
||||||
|
subject.venue.rooms = [create(:room, venue: subject.venue)]
|
||||||
subject.program.difficulty_levels = []
|
subject.program.difficulty_levels = []
|
||||||
subject.splashpage = create(:splashpage, public: false)
|
subject.splashpage = create(:splashpage, public: false)
|
||||||
|
|
||||||
|
|
@ -1106,7 +1104,6 @@ describe Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates correct for conference with all mandatory options' do
|
it 'calculates correct for conference with all mandatory options' do
|
||||||
subject.program.rooms = [create(:room)]
|
|
||||||
subject.program.tracks = [create(:track)]
|
subject.program.tracks = [create(:track)]
|
||||||
subject.program.event_types = [create(:event_type)]
|
subject.program.event_types = [create(:event_type)]
|
||||||
subject.program.difficulty_levels = [create(:difficulty_level)]
|
subject.program.difficulty_levels = [create(:difficulty_level)]
|
||||||
|
|
@ -1114,7 +1111,8 @@ describe Conference do
|
||||||
start_date: Date.today,
|
start_date: Date.today,
|
||||||
end_date: Date.today + 14)
|
end_date: Date.today + 14)
|
||||||
subject.program.cfp = create(:cfp)
|
subject.program.cfp = create(:cfp)
|
||||||
subject.venue = create(:venue)
|
subject.venue = create(:venue, conference: subject)
|
||||||
|
subject.venue.rooms = [create(:room, venue: subject.venue)]
|
||||||
subject.splashpage = create(:splashpage, public: true)
|
subject.splashpage = create(:splashpage, public: true)
|
||||||
|
|
||||||
expect(subject.get_status).to eq(@result)
|
expect(subject.get_status).to eq(@result)
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@ describe 'admin/rooms/index' do
|
||||||
|
|
||||||
it 'renders rooms list' do
|
it 'renders rooms list' do
|
||||||
conference = create(:conference)
|
conference = create(:conference)
|
||||||
create(:room, name: 'Example Room', size: 4, program: conference.program)
|
venue = create(:venue, conference: conference)
|
||||||
|
room = create(:room, name: 'Example Room', size: 4, venue: venue)
|
||||||
assign :conference, conference
|
assign :conference, conference
|
||||||
|
assign :rooms, [room]
|
||||||
render
|
render
|
||||||
expect(rendered).to include('Example Room')
|
expect(rendered).to include('Example Room')
|
||||||
expect(rendered).to include('4')
|
expect(rendered).to include('4')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue