From 444356fbc78d76898a37e57cd0db0f6740fcab72 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Sun, 25 Oct 2015 13:29:02 +0200 Subject: [PATCH] Introduce Program to include cfp/rooms/tracks/events/event_types/difficulty_levels --- app/controllers/admin/cfps_controller.rb | 58 +++ app/controllers/admin/comments_controller.rb | 2 +- .../admin/conference_controller.rb | 12 +- .../admin/difficulty_levels_controller.rb | 17 +- .../admin/event_types_controller.rb | 19 +- app/controllers/admin/events_controller.rb | 49 ++- app/controllers/admin/programs_controller.rb | 32 ++ app/controllers/admin/rooms_controller.rb | 19 +- app/controllers/admin/schedules_controller.rb | 9 +- app/controllers/admin/tracks_controller.rb | 15 +- app/controllers/commercials_controller.rb | 8 +- app/controllers/conference_controller.rb | 5 +- app/controllers/proposal_controller.rb | 33 +- app/helpers/application_helper.rb | 20 +- app/mailers/mailbot.rb | 10 +- app/models/ability.rb | 48 ++- app/models/ahoy/program.rb | 117 ++++++ app/models/cfp.rb | 73 ++++ app/models/conference.rb | 130 ++----- app/models/difficulty_level.rb | 2 +- app/models/email_settings.rb | 6 +- app/models/event.rb | 28 +- app/models/event_type.rb | 2 +- app/models/program.rb | 103 ++++++ app/models/room.rb | 2 +- app/models/target.rb | 2 +- app/models/track.rb | 2 +- app/models/user.rb | 2 +- .../admin/call_for_papers/_form.html.haml | 14 - app/views/admin/cfps/_form.html.haml | 11 + .../{call_for_papers => cfps}/show.html.haml | 20 +- .../admin/comments/_all_comments.html.haml | 2 +- .../admin/comments/_posted_comments.html.haml | 2 +- .../admin/comments/_unread_comments.html.haml | 2 +- .../conference/_recent_submissions.html.haml | 4 +- .../admin/conference/_todo_list.html.haml | 20 +- .../admin/difficulty_levels/_form.html.haml | 2 +- .../admin/difficulty_levels/index.html.haml | 10 +- app/views/admin/emails/_help.html.haml | 4 +- app/views/admin/emails/index.html.haml | 16 +- app/views/admin/event_types/_form.html.haml | 2 +- app/views/admin/event_types/index.html.haml | 8 +- .../events/_change_state_dropdown.html.haml | 16 +- .../admin/events/_nested_comments.html.haml | 2 +- app/views/admin/events/_proposal.html.haml | 16 +- app/views/admin/events/_voting.html.haml | 14 +- app/views/admin/events/index.html.haml | 22 +- app/views/admin/programs/_form.html.haml | 12 + app/views/admin/programs/show.html.haml | 61 ++++ app/views/admin/rooms/_form.html.haml | 2 +- app/views/admin/rooms/index.html.haml | 10 +- app/views/admin/tracks/_form.html.haml | 2 +- app/views/admin/tracks/index.html.haml | 10 +- app/views/admin/tracks/show.html.haml | 2 +- app/views/admin/users/_submissions.html.haml | 8 +- app/views/commercials/edit.html.haml | 9 + app/views/commercials/new.html.haml | 9 + app/views/conference/_all_events.html.erb | 6 +- .../conference/_call_for_paper.html.haml | 16 +- .../conference/_conference_details.html.haml | 8 +- app/views/conference/_program.html.haml | 40 ++ app/views/conference/_schedule_item.html.haml | 2 +- .../conference/_schedule_splashpage.html.haml | 12 +- app/views/conference/schedule.html.erb | 4 +- app/views/conference/show.html.haml | 2 +- .../_registration_info.html.haml | 4 +- .../conference_registrations/show.html.haml | 8 +- app/views/layouts/_admin_sidebar.html.haml | 42 +-- app/views/layouts/_navigation.html.haml | 2 +- app/views/layouts/_user_menu.html.haml | 4 +- .../proposal/_encouragement_text.html.haml | 14 +- app/views/proposal/_form.html.haml | 6 +- app/views/proposal/_proposal_form.html.haml | 12 +- app/views/proposal/_tooltip.html.haml | 17 +- app/views/proposal/index.html.haml | 16 +- app/views/proposal/new.html.haml | 6 +- app/views/proposal/show.html.haml | 4 +- config/routes.rb | 55 +-- .../20151018152439_create_programs_table.rb | 75 ++++ ...n_events_rooms_tracks_difficulty_levels.rb | 117 ++++++ ...ame_email_settings_with_cfp_and_program.rb | 10 + db/schema.rb | 221 +++++------ .../admin/comments_controller_spec.rb | 4 +- .../admin/conferences_controller_spec.rb | 7 +- .../admin/programs_controller_spec.rb | 33 ++ spec/factories/{call_for_papers.rb => cfp.rb} | 3 +- spec/factories/conferences.rb | 3 +- spec/factories/difficulty_levels.rb | 3 +- spec/factories/email_settings.rb | 12 +- spec/factories/event_types.rb | 2 +- spec/factories/events.rb | 10 +- spec/factories/program.rb | 9 + spec/factories/rooms.rb | 2 +- spec/factories/tracks.rb | 2 +- spec/features/ability_spec.rb | 59 +-- spec/features/cfp_spec.rb | 27 +- spec/features/commercials_spec.rb | 10 +- spec/features/difficulty_levels_spec.rb | 6 +- spec/features/event_types_spec.rb | 2 +- spec/features/program_spec.rb | 30 ++ spec/features/proposal_spec.rb | 26 +- spec/features/rooms_spec.rb | 6 +- spec/features/tracks_spec.rb | 10 +- spec/models/ability_spec.rb | 45 ++- spec/models/cfp_spec.rb | 90 ++++- spec/models/conference_spec.rb | 343 +++++++++--------- spec/models/program_spec.rb | 61 ++++ spec/models/target_spec.rb | 8 +- .../show.html.haml_spec.rb | 8 +- .../admin/conference/show.html.haml_spec.rb | 1 + .../difficulty_levels/index.html.haml_spec.rb | 5 +- .../admin/event_types/index.html.haml_spec.rb | 5 +- .../admin/events/index.html.haml_spec.rb | 14 +- .../admin/programs/show.html.haml_spec.rb | 16 + .../views/admin/rooms/index.html.haml_spec.rb | 6 +- .../admin/tracks/index.html.haml_spec.rb | 6 +- spec/views/conference/show.html.haml_spec.rb | 3 +- 117 files changed, 1812 insertions(+), 905 deletions(-) create mode 100644 app/controllers/admin/cfps_controller.rb create mode 100644 app/controllers/admin/programs_controller.rb create mode 100644 app/models/ahoy/program.rb create mode 100644 app/models/cfp.rb create mode 100644 app/models/program.rb delete mode 100644 app/views/admin/call_for_papers/_form.html.haml create mode 100644 app/views/admin/cfps/_form.html.haml rename app/views/admin/{call_for_papers => cfps}/show.html.haml (55%) create mode 100644 app/views/admin/programs/_form.html.haml create mode 100644 app/views/admin/programs/show.html.haml create mode 100644 app/views/commercials/edit.html.haml create mode 100644 app/views/commercials/new.html.haml create mode 100644 app/views/conference/_program.html.haml create mode 100644 db/migrate/20151018152439_create_programs_table.rb create mode 100644 db/migrate/20151018154513_rename_conference_id_to_program_id_in_events_rooms_tracks_difficulty_levels.rb create mode 100644 db/migrate/20151021113015_rename_email_settings_with_cfp_and_program.rb create mode 100644 spec/controllers/admin/programs_controller_spec.rb rename spec/factories/{call_for_papers.rb => cfp.rb} (84%) create mode 100644 spec/factories/program.rb create mode 100644 spec/features/program_spec.rb create mode 100644 spec/models/program_spec.rb rename spec/views/admin/{call_for_papers => cfps}/show.html.haml_spec.rb (61%) create mode 100644 spec/views/admin/programs/show.html.haml_spec.rb diff --git a/app/controllers/admin/cfps_controller.rb b/app/controllers/admin/cfps_controller.rb new file mode 100644 index 00000000..481b67ab --- /dev/null +++ b/app/controllers/admin/cfps_controller.rb @@ -0,0 +1,58 @@ +module Admin + class CfpsController < Admin::BaseController + load_and_authorize_resource :conference, find_by: :short_title + load_and_authorize_resource :program, through: :conference, singleton: true + load_and_authorize_resource through: :program, singleton: true + + def show; end + + def new + @cfp = @program.build_cfp + end + + def edit; end + + def create + @cfp = @program.build_cfp(cfp_params) + + if @cfp.save + redirect_to admin_conference_program_cfp_path, + notice: 'Call for papers successfully created.' + else + flash[:error] = "Creating the call for papers failed. #{@cfp.errors.full_messages.join('. ')}." + render :new + end + end + + def update + @cfp = @program.cfp + @cfp.assign_attributes(params[:cfp]) + + send_mail_on_cfp_dates_updates = @cfp.notify_on_cfp_date_update? + + if @cfp.update_attributes(params[:cfp]) + Mailbot.delay.send_on_cfps_dates_updates(@conference) if send_mail_on_cfp_dates_updates + redirect_to(admin_conference_program_cfp_path(@conference.short_title), + notice: 'Call for papers successfully updated.') + else + flash[:error] = "Updating call for papers failed. #{@cfp.errors.to_a.join('. ')}." + render :new + end + end + + def destroy + if @cfp.destroy + redirect_to admin_conference_program_cfp_path, notice: 'Call for Papers was successfully deleted.' + else + redirect_to admin_conference_program_cfp_path, error: 'An error prohibited this Call for Papers from being destroyed: '\ + "#{@cfp.errors.full_messages.join('. ')}." + end + end + + private + + def cfp_params + params[:cfp] + end + end +end diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index 874439df..cb57464d 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -22,7 +22,7 @@ module Admin # Grouping all comments by conference, and by event. It returns {:conference => {:event => [{comment_2}, {comment_1 }]}} def grouped_comments(remarks) - remarks.group_by{ |comment| comment.commentable.conference }.map {|conference, comments| [conference, comments.group_by{|comment| comment.commentable}]}.to_h + remarks.group_by{ |comment| comment.commentable.program.conference }.map {|conference, comments| [conference, comments.group_by{|comment| comment.commentable}]}.to_h end end end diff --git a/app/controllers/admin/conference_controller.rb b/app/controllers/admin/conference_controller.rb index abaaae38..7ab374b9 100644 --- a/app/controllers/admin/conference_controller.rb +++ b/app/controllers/admin/conference_controller.rb @@ -1,6 +1,7 @@ module Admin class ConferenceController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title + load_resource :program, through: :conference, singleton: true, except: :index load_resource :user, only: [:remove_user] def index @@ -94,14 +95,17 @@ module Admin end def show - @conference = Conference.find_by(short_title: params[:id]) + @program = @conference.program + unless @conference.program + @program = Program.new(conference_id: @conference.id) + end # Overview and since last login information @total_reg = @conference.registrations.count @new_reg = @conference.registrations.where('created_at > ?', current_user.last_sign_in_at).count - @total_submissions = @conference.events.count - @new_submissions = @conference.events. + @total_submissions = @program.events.count + @new_submissions = @program.events. where('created_at > ?', current_user.last_sign_in_at).count @program_length = @conference.current_program_hours @@ -141,7 +145,7 @@ module Admin @tracks_distribution_confirmed = @conference.tracks_distribution(:confirmed) # Recent actions information - @recent_events = @conference.events.limit(5).order(created_at: :desc) + @recent_events = @conference.program.events.limit(5).order(created_at: :desc) @recent_registrations = @conference.registrations.limit(5).order(created_at: :desc) @top_submitter = @conference.get_top_submitter diff --git a/app/controllers/admin/difficulty_levels_controller.rb b/app/controllers/admin/difficulty_levels_controller.rb index 2ebcb2e4..154fd3b6 100644 --- a/app/controllers/admin/difficulty_levels_controller.rb +++ b/app/controllers/admin/difficulty_levels_controller.rb @@ -1,23 +1,24 @@ module Admin class DifficultyLevelsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource :difficulty_level, through: :conference + load_and_authorize_resource :program, through: :conference, singleton: true + load_and_authorize_resource through: :program def index - authorize! :index, DifficultyLevel.new(conference_id: @conference.id) +# authorize! :index, DifficultyLevel.new(program_id: @program.id) end def edit; end def new - @difficulty_level = @conference.difficulty_levels.new + @difficulty_level = @conference.program.difficulty_levels.new end def create - @difficulty_level = @conference.difficulty_levels.new(difficulty_level_params) + @difficulty_level = @conference.program.difficulty_levels.new(difficulty_level_params) if @difficulty_level.save flash[:notice] = 'Difficulty level successfully created.' - redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title)) else flash[:error] = "Creating difficulty level failed: #{@difficulty_level.errors.full_messages.join('. ')}." render :new @@ -27,7 +28,7 @@ module Admin def update if @difficulty_level.update_attributes(difficulty_level_params) flash[:notice] = 'Difficulty level successfully updated.' - redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title)) else flash[:error] = "Update difficulty level failed: #{@difficulty_level.errors.full_messages.join('. ')}." render :edit @@ -37,11 +38,11 @@ module Admin def destroy if @difficulty_level.destroy flash[:notice] = 'Difficulty level successfully deleted.' - redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title)) else flash[:error] = 'Deleting difficulty level type failed! ' \ "#{@difficulty_level.errors.full_messages.join('. ')}." - redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title)) end end diff --git a/app/controllers/admin/event_types_controller.rb b/app/controllers/admin/event_types_controller.rb index 38f0ed91..18077040 100644 --- a/app/controllers/admin/event_types_controller.rb +++ b/app/controllers/admin/event_types_controller.rb @@ -1,23 +1,22 @@ module Admin class EventTypesController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource :event_type, through: :conference + load_and_authorize_resource :program, through: :conference, singleton: true + load_and_authorize_resource :event_type, through: :program - def index - authorize! :index, EventType.new(conference_id: @conference.id) - end + def index; end def edit; end def new - @event_type = @conference.event_types.new + @event_type = @conference.program.event_types.new end def create - @event_type = @conference.event_types.new(event_type_params) + @event_type = @conference.program.event_types.new(event_type_params) if @event_type.save flash[:notice] = 'Event type successfully created.' - redirect_to(admin_conference_event_types_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_event_types_path(conference_id: @conference.short_title)) else flash[:error] = "Creating event type failed: #{@event_type.errors.full_messages.join('. ')}." render :new @@ -27,7 +26,7 @@ module Admin def update if @event_type.update_attributes(event_type_params) flash[:notice] = 'Event type successfully updated.' - redirect_to(admin_conference_event_types_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_event_types_path(conference_id: @conference.short_title)) else flash[:error] = "Update event type failed: #{@event_type.errors.full_messages.join('. ')}." render :edit @@ -37,11 +36,11 @@ module Admin def destroy if @event_type.destroy flash[:notice] = 'Event type successfully deleted.' - redirect_to(admin_conference_event_types_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_event_types_path(conference_id: @conference.short_title)) else flash[:error] = 'Destroying event type failed! ' \ "#{@event_type.errors.full_messages.join('. ')}." - redirect_to(admin_conference_event_types_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_event_types_path(conference_id: @conference.short_title)) end end diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index d25f610a..c131943a 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -1,7 +1,8 @@ module Admin class EventsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource :event, through: :conference + load_and_authorize_resource :program, through: :conference, singleton: true + load_and_authorize_resource :event, through: :program before_action :get_event, except: [:index, :create] @@ -14,13 +15,11 @@ module Admin end def index - authorize! :index, @conference.events.build - @conference = Conference.find_by(short_title: params[:conference_id]) - @events = @conference.events - @tracks = @conference.tracks - @difficulty_levels = @conference.difficulty_levels + @events = @program.events + @tracks = @program.tracks + @difficulty_levels = @program.difficulty_levels @machine_states = @events.state_machine.states.map - @event_types = @conference.event_types + @event_types = @program.event_types @mystates = [] @mytypes = [] @@ -72,26 +71,26 @@ module Admin respond_to do |format| format.html # Explicity call #to_json to avoid the use of EventSerializer - format.json { render json: Event.where(state: :confirmed, conference: @conference).to_json } + format.json { render json: Event.where(state: :confirmed, program: @program).to_json } end end def show - @tracks = @conference.tracks - @event_types = @conference.event_types + @tracks = @program.tracks + @event_types = @program.event_types @comments = @event.root_comments @comment_count = @event.comment_threads.count @ratings = @event.votes.includes(:user) - @difficulty_levels = @conference.difficulty_levels + @difficulty_levels = @program.difficulty_levels end def edit - @event_types = @conference.event_types + @event_types = @program.event_types @tracks = Track.all @comments = @event.root_comments @comment_count = @event.comment_threads.count @user = @event.submitter - @url = admin_conference_event_path(@conference.short_title, @event) + @url = admin_conference_program_event_path(@conference.short_title, @event) end def comment @@ -101,7 +100,7 @@ module Admin comment.move_to_child_of(params[:parent]) end - redirect_to admin_conference_event_path(conference_id: @conference.short_title) + redirect_to admin_conference_program_event_path(@conference.short_title, @event) end def update @@ -111,10 +110,10 @@ module Admin render js: 'index' else flash[:notice] = "Successfully updated event with ID #{@event.id}." - redirect_back_or_to(admin_conference_event_path(@conference.short_title, @event)) + redirect_back_or_to(admin_conference_program_event_path(@conference.short_title, @event)) end else - @url = admin_conference_event_path(@conference.short_title, @event) + @url = admin_conference_program_event_path(@conference.short_title, @event) flash[:notice] = 'Update not successful. ' + @event.errors.full_messages.to_sentence render :edit end @@ -123,8 +122,8 @@ module Admin def create; end def accept - send_mail = @event.conference.email_settings.send_on_accepted - subject = @event.conference.email_settings.accepted_subject.blank? + send_mail = @event.program.conference.email_settings.send_on_accepted + subject = @event.program.conference.email_settings.accepted_subject.blank? update_state(:accept, 'Event accepted!', true, subject, send_mail) end @@ -137,8 +136,8 @@ module Admin end def reject - send_mail = @event.conference.email_settings.send_on_rejected - subject = @event.conference.email_settings.rejected_subject.blank? + send_mail = @event.program.conference.email_settings.send_on_rejected + subject = @event.program.conference.email_settings.rejected_subject.blank? update_state(:reject, 'Event rejected!', true, subject, send_mail) end @@ -159,7 +158,7 @@ module Admin end respond_to do |format| - format.html { redirect_to admin_conference_event_path(@conference.short_title, @event) } + format.html { redirect_to admin_conference_program_event_path(@conference.short_title, @event) } format.js end end @@ -181,9 +180,9 @@ module Admin end def get_event - @event = @conference.events.find_by_id(params[:id]) + @event = @conference.program.events.find(params[:id]) if !@event - redirect_to(admin_conference_events_path(conference_id: @conference.short_title), + redirect_to(admin_conference_program_events_path(conference_id: @conference.short_title), alert: 'Error! Could not find event!') && return end @event @@ -194,10 +193,10 @@ module Admin if alert.blank? flash[:notice] = notice - redirect_back_or_to(admin_conference_events_path(conference_id: @conference.short_title)) && return + redirect_back_or_to(admin_conference_program_events_path(conference_id: @conference.short_title)) && return else flash[:error] = alert - return redirect_back_or_to(admin_conference_events_path(conference_id: @conference.short_title)) && return + return redirect_back_or_to(admin_conference_program_events_path(conference_id: @conference.short_title)) && return end end end diff --git a/app/controllers/admin/programs_controller.rb b/app/controllers/admin/programs_controller.rb new file mode 100644 index 00000000..ec64d7a3 --- /dev/null +++ b/app/controllers/admin/programs_controller.rb @@ -0,0 +1,32 @@ +module Admin + class ProgramsController < Admin::BaseController + load_and_authorize_resource :conference, find_by: :short_title + load_and_authorize_resource through: :conference, singleton: true + + def show; end + + def edit; end + + def update + authorize! :update, @conference.program + @program = @conference.program + @program.assign_attributes(params[:program]) +# send_mail_on_schedule_public = @program.notify_on_schedule_public? + + if @program.update_attributes(params[:program]) +# Mailbot.delay.send_on_schedule_public(@conference) if send_mail_on_schedule_public + redirect_to(admin_conference_program_path(@conference.short_title), + notice: 'The program was successfully updated.') + else + flash[:error] = "Updating program failed. #{@program.errors.to_a.join('. ')}." + render :new + end + end + + private + + def program_params + params[:program] + end + end +end diff --git a/app/controllers/admin/rooms_controller.rb b/app/controllers/admin/rooms_controller.rb index 1e4029f7..d9857e36 100644 --- a/app/controllers/admin/rooms_controller.rb +++ b/app/controllers/admin/rooms_controller.rb @@ -1,23 +1,22 @@ module Admin class RoomsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource through: :conference + load_and_authorize_resource :program, through: :conference, singleton: true + load_and_authorize_resource through: :program - def index - authorize! :index, Room.new(conference_id: @conference.id) - end + def index; end def edit; end def new - @room = @conference.rooms.new + @room = @program.rooms.new end def create - @room = @conference.rooms.new(room_params) + @room = @program.rooms.new(room_params) if @room.save flash[:notice] = 'Room successfully created.' - redirect_to(admin_conference_rooms_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_rooms_path(conference_id: @conference.short_title)) else flash[:error] = "Creating Room failed: #{@room.errors.full_messages.join('. ')}." render :new @@ -27,7 +26,7 @@ module Admin def update if @room.update_attributes(room_params) flash[:notice] = 'Room successfully updated.' - redirect_to(admin_conference_rooms_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_rooms_path(conference_id: @conference.short_title)) else flash[:error] = "Update Room failed: #{@room.errors.full_messages.join('. ')}." render :edit @@ -37,10 +36,10 @@ module Admin def destroy if @room.destroy flash[:notice] = 'Room successfully deleted.' - redirect_to(admin_conference_rooms_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_rooms_path(conference_id: @conference.short_title)) else flash[:error] = "Destroying room failed! #{@room.errors.full_messages.join('. ')}." - redirect_to(admin_conference_rooms_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_rooms_path(conference_id: @conference.short_title)) end end diff --git a/app/controllers/admin/schedules_controller.rb b/app/controllers/admin/schedules_controller.rb index 4b8de9f3..155b1710 100644 --- a/app/controllers/admin/schedules_controller.rb +++ b/app/controllers/admin/schedules_controller.rb @@ -3,23 +3,24 @@ module Admin # 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 + load_and_authorize_resource :program, through: :conference, singleton: true skip_before_filter :verify_authenticity_token, only: [:update] layout 'schedule' def show - authorize! :update, @conference.events.new + authorize! :update, @program.events.new if @conference.nil? redirect_to admin_conference_index_path return end @dates = @conference.start_date..@conference.end_date - @rooms = @conference.rooms + @rooms = @program.rooms end def update - authorize! :update, @conference.events.new - event = Event.where(guid: event_params).first + authorize! :update, @program.events.new + event = Event.where(guid: params[:event]).first error_message = nil if event.nil? error_message = "Could not find event GUID: #{params[:event]}" diff --git a/app/controllers/admin/tracks_controller.rb b/app/controllers/admin/tracks_controller.rb index db69b574..68777913 100644 --- a/app/controllers/admin/tracks_controller.rb +++ b/app/controllers/admin/tracks_controller.rb @@ -1,7 +1,8 @@ module Admin class TracksController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource :track, through: :conference + load_and_authorize_resource :program, through: :conference, singleton: true + load_and_authorize_resource through: :program def index; end @@ -13,14 +14,14 @@ module Admin end def new - @track = @conference.tracks.new + @track = @program.tracks.new end def create - @track = @conference.tracks.new(track_params) + @track = @program.tracks.new(track_params) if @track.save flash[:notice] = 'Track successfully created.' - redirect_to(admin_conference_tracks_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_tracks_path(conference_id: @conference.short_title)) else flash[:error] = "Creating Track failed: #{@track.errors.full_messages.join('. ')}." render :new @@ -32,7 +33,7 @@ module Admin def update if @track.update_attributes(track_params) flash[:notice] = 'Track successfully updated.' - redirect_to(admin_conference_tracks_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_tracks_path(conference_id: @conference.short_title)) else flash[:error] = "Track update failed: #{@track.errors.full_messages.join('. ')}." render :edit @@ -42,10 +43,10 @@ module Admin def destroy if @track.destroy flash[:notice] = 'Track successfully deleted.' - redirect_to(admin_conference_tracks_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_tracks_path(conference_id: @conference.short_title)) else flash[:error] = "Track couldn't be deleted. #{@track.errors.full_messages.join('. ')}." - redirect_to(admin_conference_tracks_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_tracks_path(conference_id: @conference.short_title)) end end diff --git a/app/controllers/commercials_controller.rb b/app/controllers/commercials_controller.rb index cf9b2ca3..c36feedc 100644 --- a/app/controllers/commercials_controller.rb +++ b/app/controllers/commercials_controller.rb @@ -8,7 +8,7 @@ class CommercialsController < ApplicationController authorize! :create, @commercial if @commercial.save - redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), + redirect_to edit_conference_program_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), notice: 'Commercial was successfully created.' else flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." @@ -18,7 +18,7 @@ class CommercialsController < ApplicationController def update if @commercial.update(commercial_params) - redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), + redirect_to edit_conference_program_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), notice: 'Commercial was successfully updated.' else flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." @@ -28,7 +28,7 @@ class CommercialsController < ApplicationController def destroy @commercial.destroy - redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), + redirect_to edit_conference_program_proposal_path(conference_id: @conference.short_title, id: @event.id), notice: 'Commercial was successfully destroyed.' end @@ -44,7 +44,7 @@ class CommercialsController < ApplicationController private def set_event - @event = @conference.events.find(params[:proposal_id]) + @event = @conference.program.events.find(params[:proposal_id]) end def commercial_params diff --git a/app/controllers/conference_controller.rb b/app/controllers/conference_controller.rb index 3923d6e7..b1724874 100644 --- a/app/controllers/conference_controller.rb +++ b/app/controllers/conference_controller.rb @@ -1,6 +1,7 @@ class ConferenceController < ApplicationController before_filter :respond_to_options load_and_authorize_resource find_by: :short_title + load_resource :program, through: :conference, singleton: true, except: :index def index @current = Conference.where('end_date >= ?', Date.current).order('start_date ASC') @@ -10,8 +11,8 @@ class ConferenceController < ApplicationController def show; end def schedule - @rooms = @conference.rooms - @events = @conference.events + @rooms = @conference.program.rooms + @events = @conference.program.events @dates = @conference.start_date..@conference.end_date if @dates == Date.current diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index 18d985b3..1b3c42f0 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -1,7 +1,8 @@ class ProposalController < ApplicationController before_filter :authenticate_user!, except: [:show, :new, :create] load_resource :conference, find_by: :short_title - load_and_authorize_resource :event, parent: false, through: :conference + load_resource :program, through: :conference, singleton: true + load_and_authorize_resource :event, parent: false, through: :program def index @events = current_user.proposals(@conference) @@ -14,16 +15,16 @@ class ProposalController < ApplicationController def new @user = User.new - @url = conference_proposal_index_path(@conference.short_title) + @url = conference_program_proposal_index_path(@conference.short_title) end def edit authorize! :edit, @event - @url = conference_proposal_path(@conference.short_title, params[:id]) + @url = conference_program_proposal_path(@conference.short_title, params[:id]) end def create - @url = conference_proposal_index_path(@conference.short_title) + @url = conference_program_proposal_index_path(@conference.short_title) unless current_user @user = User.new(user_params) @@ -38,8 +39,8 @@ class ProposalController < ApplicationController params[:event].delete :user - @event = Event.new(event_params) - @event.conference = @conference + @event = Event.new(params[:event]) + @event.program = @program @event.event_users.new(user: current_user, event_role: 'submitter') @@ -55,12 +56,12 @@ class ProposalController < ApplicationController ahoy.track 'Event submission', title: 'New submission' flash[:notice] = 'Proposal was successfully submitted.' - redirect_to conference_proposal_index_path(@conference.short_title) + redirect_to conference_program_proposal_index_path(@conference.short_title) end def update authorize! :update, @event - @url = conference_proposal_path(@conference.short_title, params[:id]) + @url = conference_program_proposal_path(@conference.short_title, params[:id]) if !@event.update(event_params) flash[:error] = "Could not update proposal: #{@event.errors.full_messages.join(', ')}" @@ -68,13 +69,13 @@ class ProposalController < ApplicationController return end - redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), + redirect_to(conference_program_proposal_index_path(conference_id: @conference.short_title), notice: 'Proposal was successfully updated.') end def destroy authorize! :destroy, @event - @url = conference_proposal_path(@conference.short_title, params[:id]) + @url = conference_program_proposal_path(@conference.short_title, params[:id]) begin @event.withdraw @@ -84,13 +85,13 @@ class ProposalController < ApplicationController end @event.save(validate: false) - redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), + redirect_to(conference_program_proposal_index_path(conference_id: @conference.short_title), notice: 'Proposal was successfully withdrawn.') end def confirm authorize! :update, @event - @url = conference_proposal_path(@conference.short_title, params[:id]) + @url = conference_program_proposal_path(@conference.short_title, params[:id]) begin @event.confirm! @@ -106,7 +107,7 @@ class ProposalController < ApplicationController end if @conference.user_registered?(current_user) - redirect_to(conference_proposal_index_path(@conference.short_title), + redirect_to(conference_program_proposal_index_path(@conference.short_title), notice: 'The proposal was confirmed.') else redirect_to(new_conference_conference_registrations_path(conference_id: @conference.short_title), @@ -116,12 +117,12 @@ class ProposalController < ApplicationController def restart authorize! :update, @event - @url = conference_proposal_path(@conference.short_title, params[:id]) + @url = conference_program_proposal_path(@conference.short_title, params[:id]) begin @event.restart rescue Transitions::InvalidTransition - redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), + redirect_to(conference_program_proposal_index_path(conference_id: @conference.short_title), error: "The proposal can't be re-submitted.") return end @@ -132,7 +133,7 @@ class ProposalController < ApplicationController return end - redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), + redirect_to(conference_program_proposal_index_path(conference_id: @conference.short_title), notice: "The proposal was re-submitted. The #{@conference.short_title} organizers will review it again.") end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4c72b3dc..35f127b9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -159,7 +159,7 @@ module ApplicationHelper end def pre_registered(event) - @conference.events.joins(:registrations).where('events.id = ?', event.id) + @conference.program.events.joins(:registrations).where('events.id = ?', event.id) end def add_association_link(association_name, form_builder, div_class, html_options = {}) @@ -184,7 +184,7 @@ module ApplicationHelper end def event_types(conference) - all = conference.event_types.map { |et | et.title.pluralize } + all = conference.program.event_types.map { |et | et.title.pluralize } first = all[0...-1] last = all[-1] ets = '' @@ -198,7 +198,21 @@ module ApplicationHelper end def tracks(conference) - all = conference.tracks.map {|t| t.name} + all = conference.program.tracks.map {|t| t.name} + first = all[0...-1] + last = all[-1] + ts = '' + if all.length > 1 + ts << first.join(', ') + ts << " and #{last}" + else + ts = all.join + end + return ts + end + + def difficulty_levels(conference) + all = conference.program.difficulty_levels.map {|t| t.title} first = all[0...-1] last = all[-1] ts = '' diff --git a/app/mailers/mailbot.rb b/app/mailers/mailbot.rb index bdf47d0b..5c378e09 100644 --- a/app/mailers/mailbot.rb +++ b/app/mailers/mailbot.rb @@ -66,17 +66,17 @@ class Mailbot < ActionMailer::Base User.joins(:subscriptions).merge(conference.subscriptions) do |user| build_email(conference, user.email, - conference.email_settings.call_for_papers_schedule_public_subject, - conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.call_for_papers_schedule_public_body)) + conference.email_settings.program_schedule_public_subject, + conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.program_schedule_public_body)) end end - def send_on_call_for_papers_dates_updated(conference) + def send_on_cfp_dates_updates(conference) User.joins(:subscriptions).merge(conference.subscriptions) do |user| build_email(conference, user.email, - conference.email_settings.call_for_papers_dates_updated_subject, - conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.call_for_papers_dates_updated_body)) + conference.email_settings.cfp_dates_updated_subject, + conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.cfp_dates_updated_body)) end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 3f07fe43..ccbd4655 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -39,7 +39,7 @@ class Ability end # Can view the schedule can [:schedule], Conference do |conference| - conference.call_for_paper && conference.call_for_paper.schedule_public + conference.program.cfp && conference.program.schedule_public end can :show, Event do |event| @@ -53,9 +53,13 @@ class Ability can [:show, :create], Registration do |registration| registration.new_record? end - can [:show, :create], Event do |event| + can :show, Event do |event| event.new_record? end + + can [:new, :create], Event do |event| + event.program.cfp_open? && event.new_record? + end end end @@ -77,7 +81,7 @@ class Ability event.users.include?(user) end # can create an event until the last day of a conference - can :create, Event, conference_id: Conference.where('end_date >= ?', Date.today).pluck(:id) + can :create, Event, program_id: Conference.where('end_date >= ?', Date.today).map { |conference| conference.program.id}.compact # can manage the commercials of their own events can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id) @@ -100,6 +104,8 @@ class Ability cannot [:edit, :update, :destroy], Question, global: true # for admins can :manage, :all if user.is_admin + + cannot :destroy, Program end def signed_in_with_organizer_role(user) @@ -125,21 +131,22 @@ class Ability end can :manage, Vposition, conference_id: conf_ids_for_organizer can :manage, Vday, conference_id: conf_ids_for_organizer - can :manage, CallForPaper, conference_id: conf_ids_for_organizer - can :manage, Event, conference_id: conf_ids_for_organizer - can :manage, EventType, conference_id: conf_ids_for_organizer - can :manage, Track, conference_id: conf_ids_for_organizer - can :manage, DifficultyLevel, conference_id: conf_ids_for_organizer + can :manage, Program, conference_id: conf_ids_for_organizer + can :manage, Cfp, program: { conference_id: conf_ids_for_organizer} + can :manage, Event, program: { conference_id: conf_ids_for_organizer} + can :manage, EventType, program: { conference_id: conf_ids_for_organizer} + can :manage, Track, program: { conference_id: conf_ids_for_organizer} + can :manage, DifficultyLevel, program: { conference_id: conf_ids_for_organizer} can :manage, Commercial, commercialable_type: 'Event', - commercialable_id: Event.where(conference_id: conf_ids_for_organizer).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, Lodging, conference_id: conf_ids_for_organizer - can :manage, Room, conference_id: conf_ids_for_organizer + can :manage, Room, program: { 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, Ticket, conference_id: conf_ids_for_organizer can :index, Comment, commentable_type: 'Event', - commentable_id: Event.where(conference_id: conf_ids_for_organizer).pluck(:id) + commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id) end def signed_in_with_cfp_role(user) @@ -148,18 +155,19 @@ class Ability conf_ids_for_cfp = Conference.with_role(:cfp, user).pluck(:id) if user.has_role? :cfp, :any - can :manage, Event, conference_id: conf_ids_for_cfp - can :manage, EventType, conference_id: conf_ids_for_cfp - can :manage, Track, conference_id: conf_ids_for_cfp - can :manage, DifficultyLevel, conference_id: conf_ids_for_cfp + can :manage, Event, program: { conference_id: conf_ids_for_cfp } + can :manage, EventType, 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, EmailSettings, conference_id: conf_ids_for_cfp - can :manage, Room, conference_id: conf_ids_for_cfp - can :show, Venue, conference_id: conf_ids_for_cfp - can :manage, CallForPaper, conference_id: conf_ids_for_cfp + can :manage, Room, program: { 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, Program, conference_id: conf_ids_for_cfp can :manage, Commercial, commercialable_type: 'Event', - commercialable_id: Event.where(conference_id: conf_ids_for_cfp).pluck(:id) + commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id) can :index, Comment, commentable_type: 'Event', - commentable_id: Event.where(conference_id: conf_ids_for_cfp).pluck(:id) + commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id) end def signed_in_with_info_desk_role(user) diff --git a/app/models/ahoy/program.rb b/app/models/ahoy/program.rb new file mode 100644 index 00000000..9165ae5d --- /dev/null +++ b/app/models/ahoy/program.rb @@ -0,0 +1,117 @@ +# cannot delete program if there are events submitted + +class Program < ActiveRecord::Base + belongs_to :conference + + has_one :cfp, dependent: :destroy + has_many :event_types, dependent: :destroy + has_many :tracks, dependent: :destroy + has_many :difficulty_levels, dependent: :destroy + has_many :rooms, dependent: :destroy + has_many :events, dependent: :destroy do + def workshops + where(require_registration: true, state: :confirmed) + end + + def confirmed + where(state: :confirmed) + end + + def scheduled + where.not(start_time: nil) + end + + def highlights + where(state: :confirmed, is_highlight: true) + end + end + + has_many :event_users, through: :events + has_many :speakers, -> { distinct }, through: :event_users, source: :user do + def confirmed + joins(:events).where(events: { state: :confirmed }) + end + end + + 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 :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, + :schedule_public, :include_cfp_in_splash, :conference_id, + :event_types_attributes, :difficulty_levels_attributes, :rooms_attributes, :tracks_attributes + +# validates :conference_id, presence: true, uniqueness: true + validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 } + + before_create :create_event_types + before_create :create_difficulty_levels + + ## + # Checcks if the program has rating enabled + # + # ====Returns + # * +false+ -> If rating is not enabled + # * +true+ -> If rating is enabled + def rating_enabled? + self.rating && self.rating > 0 + end + + ## + # Checks if the call for papers for the conference is currently open + # + # ====Returns + # * +false+ -> If the CFP is not set or today isn't in the CFP period. + # * +true+ -> If today is in the CFP period. + def cfp_open? + cfp = self.cfp + + cfp.present? && (cfp.start_date..cfp.end_date).cover?(Date.current) + end + + ## + # Checks whether cfp dates is updated + # + # ====Returns + # * +True+ -> If cfp dates is updated and all other parameters are set + # * +False+ -> Either cfp date is not updated or one or more parameter is not set + def notify_on_schedule_public? + self.cfp && !self.cfp.end_date.blank? && !self.cfp.start_date.blank?\ + && (self.cfp.start_date_changed? || self.cfp.end_date_changed?)\ + && self.conference.email_settings.send_on_cfp_dates_updates\ + && !self.conference.email_settings.cfp_dates_updates_subject.blank?\ + && !self.conference.email_settings.cfp_dates_updates_template.blank? + end + + private + + ## + # Creates default EventTypes for this Conference. Used as before_create. + # + def create_event_types + event_types << EventType.create(title: 'Talk', length: 30, color: '#FF0000', description: 'Presentation in lecture format', + minimum_abstract_length: 0, + maximum_abstract_length: 500) + event_types << EventType.create(title: 'Workshop', length: 60, color: '#0000FF', description: 'Interactive hands-on practice', + minimum_abstract_length: 0, + maximum_abstract_length: 500) + true + end + + ## + # Creates default DifficultyLevels for this Conference. Used as before_create. + # + def create_difficulty_levels + difficulty_levels << DifficultyLevel.create(title: 'Easy', + description: 'Events are understandable for everyone without knowledge of the topic.', + color: '#70EF69') + difficulty_levels << DifficultyLevel.create(title: 'Medium', + description: 'Events require a basic understanding of the topic.', + color: '#EEEF69') + difficulty_levels << DifficultyLevel.create(title: 'Hard', + description: 'Events require expert knowledge of the topic.', + color: '#EF6E69') + true + end +end diff --git a/app/models/cfp.rb b/app/models/cfp.rb new file mode 100644 index 00000000..46366794 --- /dev/null +++ b/app/models/cfp.rb @@ -0,0 +1,73 @@ +# cannot delete program if there are events submitted + +class Cfp < ActiveRecord::Base + belongs_to :program + + attr_accessible :start_date, :end_date, :program_id + + validates :program_id, presence: true, uniqueness: true + validates :start_date, :end_date, presence: true + validate :before_end_of_conference + validate :start_after_end_date + + ## + # Checks whether cfp date is updated + # + # ====Returns + # * +True+ -> If cfp dates is updated and all other parameters are set + # * +False+ -> Either cfp date is not updated or one or more parameter is not set + def notify_on_cfp_date_update? + !self.end_date.blank? && !self.start_date.blank?\ + && (self.start_date_changed? || self.end_date_changed?)\ + && self.program.conference.email_settings.send_on_cfp_dates_updates\ + && !self.program.conference.email_settings.cfp_dates_updates_subject.blank?\ + && !self.program.conference.email_settings.cfp_dates_updates_template.blank? + end + + ## + # Calculates how many weeks the call for paper is. + # + # ====Returns + # * +Integer+ -> start week + def weeks + result = end_week - start_week + 1 + weeks = Date.new(start_date.year, 12, 31).strftime('%W').to_i + result < 0 ? result + weeks : result + end + + ## + # Calculates the end week of the cfp + # + # ====Returns + def start_week + start_date.strftime('%W').to_i + end + + ## + # Calculates the end week of the cfp + # + # ====Returns + def end_week + end_date.strftime('%W').to_i + end + + def remaining_days(date = Date.today) + result = (self.end_date - date).to_i + result > 0 ? result : 0 + end + + private + + def before_end_of_conference + errors. + add(:end_date, "can't be after the conference end date (#{program.conference.end_date})") if program.conference && program.conference.end_date && end_date && (end_date > program.conference.end_date) + + errors. + add(:start_date, "can't be after the conference end date (#{program.conference.end_date})") if program.conference && program.conference.end_date && start_date && (start_date > program.conference.end_date) + end + + def start_after_end_date + errors. + add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date + end +end diff --git a/app/models/conference.rb b/app/models/conference.rb index 2b3526b2..0c8f4c0e 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -16,40 +16,14 @@ class Conference < ActiveRecord::Base has_one :contact, dependent: :destroy has_one :registration_period, dependent: :destroy has_one :email_settings, dependent: :destroy - has_one :call_for_paper, dependent: :destroy + has_one :program, dependent: :destroy has_one :venue, dependent: :destroy has_many :social_events, dependent: :destroy has_many :ticket_purchases, dependent: :destroy has_many :supporters, through: :ticket_purchases, source: :user has_many :tickets, dependent: :destroy has_many :dietary_choices, dependent: :destroy - has_many :events, dependent: :destroy do - def workshops - where(require_registration: true, state: :confirmed) - end - def confirmed - where(state: :confirmed) - end - - def scheduled - where.not(start_time: nil) - end - - def highlights - where(state: :confirmed, is_highlight: true) - end - end - has_many :event_users, through: :events - has_many :speakers, -> { distinct }, through: :event_users, source: :user do - def confirmed - joins(:events).where(events: { state: :confirmed }) - end - end - has_many :event_types, dependent: :destroy - has_many :tracks, dependent: :destroy - has_many :difficulty_levels, dependent: :destroy - has_many :rooms, dependent: :destroy has_many :lodgings, dependent: :destroy has_many :registrations, dependent: :destroy has_many :participants, through: :registrations, source: :user @@ -63,16 +37,12 @@ class Conference < ActiveRecord::Base has_many :commercials, as: :commercialable, dependent: :destroy has_many :subscriptions, dependent: :destroy - accepts_nested_attributes_for :rooms, 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 :social_events, allow_destroy: true accepts_nested_attributes_for :venue accepts_nested_attributes_for :dietary_choices, allow_destroy: true accepts_nested_attributes_for :tickets, allow_destroy: true accepts_nested_attributes_for :sponsorship_levels, allow_destroy: true accepts_nested_attributes_for :sponsors, allow_destroy: true - accepts_nested_attributes_for :event_types, allow_destroy: true accepts_nested_attributes_for :email_settings accepts_nested_attributes_for :questions, allow_destroy: true accepts_nested_attributes_for :vdays, allow_destroy: true @@ -99,10 +69,8 @@ class Conference < ActiveRecord::Base # This validation is needed since a conference with a start date greater than the end date is not possible validate :valid_date_range? before_create :generate_guid - before_create :create_event_types - before_create :create_difficulty_levels - before_create :create_email_settings before_create :add_color + before_create :create_email_settings def date_range_string startstr = 'Unknown - ' @@ -158,18 +126,6 @@ class Conference < ActiveRecord::Base registration_period.end_date.present? end - ## - # Checks if the call for papers for the conference is currently open - # - # ====Returns - # * +false+ -> If the CFP is not set or today isn't in the CFP period. - # * +true+ -> If today is in the CFP period. - def cfp_open? - cfp = self.call_for_paper - - cfp.present? && (cfp.start_date..cfp.end_date).cover?(Date.current) - end - ## # Returns an array with the summarized event submissions per week. # @@ -178,10 +134,10 @@ class Conference < ActiveRecord::Base def get_submissions_per_week result = [] - if call_for_paper && events - submissions = events.group(:week).count - start_week = call_for_paper.start_week - weeks = call_for_paper.weeks + if program && program.cfp && program.events + submissions = program.events.group(:week).count + start_week = program.cfp.start_week + weeks = program.cfp.weeks result = calculate_items_per_week(start_week, weeks, submissions) end result @@ -195,10 +151,10 @@ class Conference < ActiveRecord::Base # * +Array+ -> e.g. 'Submitted' => [0, 3, 3, 5] -> first week 0 events, second week 3 events. def get_submissions_data result = {} - if call_for_paper && events + if program && program.cfp && program.events result = get_events_per_week_by_state - start_week = call_for_paper.start_week + start_week = program.cfp.start_week end_week = end_date.strftime('%W').to_i weeks = weeks(start_week, end_week) @@ -260,8 +216,8 @@ class Conference < ActiveRecord::Base # ====Returns # * +Integer+ -> weeks def cfp_weeks - if call_for_paper - call_for_paper.weeks + if program + program.cfp.weeks else 0 end @@ -344,7 +300,7 @@ class Conference < ActiveRecord::Base # * +hash+ -> user: submissions def get_top_submitter(limit = 5) submitter = EventUser.joins(:event). - where('event_role = ? and conference_id = ?', 'submitter', id). + where('event_role = ? and program_id = ?', 'submitter', Conference.find(id).program.id). limit(limit).group(:user_id) counter = submitter.order('count_all desc').count Conference.calculate_user_submission_hash(submitter, counter) @@ -366,7 +322,7 @@ class Conference < ActiveRecord::Base # ====Returns # * +hash+ -> hash def event_distribution - Conference.calculate_event_distribution_hash(events.select(:state).group(:state).count) + Conference.calculate_event_distribution_hash(program.events.select(:state).group(:state).count) end ## @@ -391,7 +347,7 @@ class Conference < ActiveRecord::Base # ====Returns # * +hash+ -> Fixnum minutes def current_program_minutes - events_grouped = events.select(:event_type_id).group(:event_type_id) + events_grouped = program.events.select(:event_type_id).group(:event_type_id) events_counted = events_grouped.count calculate_program_minutes(events_grouped, events_counted) end @@ -411,7 +367,7 @@ class Conference < ActiveRecord::Base # ====Returns # * +hash+ -> Fixnum minutes def new_program_minutes(date) - events_grouped = events.select(:event_type_id).where('created_at > ?', date).group(:event_type_id) + events_grouped = program.events.select(:event_type_id).where('created_at > ?', date).group(:event_type_id) events_counted = events_grouped.count calculate_program_minutes(events_grouped, events_counted) end @@ -450,9 +406,9 @@ class Conference < ActiveRecord::Base # * +hash+ -> track => {color, value} def tracks_distribution(state = nil) if state - tracks_grouped = events.select(:track_id).where('state = ?', state).group(:track_id) + tracks_grouped = program.events.select(:track_id).where('state = ?', state).group(:track_id) else - tracks_grouped = events.select(:track_id).group(:track_id) + tracks_grouped = program.events.select(:track_id).group(:track_id) end tracks_counted = tracks_grouped.count @@ -539,7 +495,7 @@ class Conference < ActiveRecord::Base Conference.where('end_date > ?', Date.today).each do |conference| result = {} Event.state_machine.states.each do |state| - count = conference.events.where('state = ?', state.name).count + count = conference.program.events.where('state = ?', state.name).count result[state.name] = count end @@ -584,6 +540,7 @@ class Conference < ActiveRecord::Base after_create do self.create_contact + self.create_program end ## @@ -631,10 +588,10 @@ class Conference < ActiveRecord::Base # Actual week this_week = Date.today.end_of_week.strftime('%W').to_i - result['Confirmed'][this_week] = events.where('state = ?', :confirmed).count - result['Unconfirmed'][this_week] = events.where('state = ?', :unconfirmed).count - result['Submitted'] = events.select(:week).group(:week).count - result['Submitted'][this_week] = events.where(week: this_week).count + result['Confirmed'][this_week] = program.events.where('state = ?', :confirmed).count + result['Unconfirmed'][this_week] = program.events.where('state = ?', :unconfirmed).count + result['Submitted'] = program.events.select(:week).group(:week).count + result['Submitted'][this_week] = program.events.where(week: this_week).count result end @@ -720,7 +677,7 @@ class Conference < ActiveRecord::Base # * +True+ -> One difficulty level or more # * +False+ -> No diffculty level def difficulty_levels_set? - difficulty_levels.count > 0 + program.difficulty_levels.count > 0 end ## @@ -730,7 +687,7 @@ class Conference < ActiveRecord::Base # * +True+ -> One difficulty level or more # * +False+ -> No diffculty level def event_types_set? - event_types.count > 0 + program.event_types.count > 0 end ## @@ -740,7 +697,7 @@ class Conference < ActiveRecord::Base # * +True+ -> One track or more # * +False+ -> No track def tracks_set? - tracks.count > 0 + program.tracks.count > 0 end ## @@ -750,7 +707,7 @@ class Conference < ActiveRecord::Base # * +True+ -> One room or more # * +False+ -> No room def rooms_set? - rooms.count > 0 + program.rooms.count > 0 end # Checks if the conference has a venue object. @@ -769,7 +726,7 @@ class Conference < ActiveRecord::Base # * +True+ -> If conference has a cfp object. # * +False+ -> If conference has no cfp object. def cfp_set? - !!call_for_paper + !!program.cfp end ## @@ -788,9 +745,9 @@ class Conference < ActiveRecord::Base # * +hash+ -> object_type => {color, value} def calculate_event_distribution(group_by_id, association_symbol, state = nil) if state - grouped = events.select(group_by_id).where('state = ?', 'confirmed').group(group_by_id) + grouped = program.events.select(group_by_id).where('state = ?', 'confirmed').group(group_by_id) else - grouped = events.select(group_by_id).group(group_by_id) + grouped = program.events.select(group_by_id).group(group_by_id) end counted = grouped.count @@ -910,35 +867,6 @@ class Conference < ActiveRecord::Base result end - ## - # Creates default EventTypes for this Conference. Used as before_create. - # - def create_event_types - event_types << EventType.create(title: 'Talk', length: 30, color: '#FF0000', description: 'Presentation in lecture format', - minimum_abstract_length: 0, - maximum_abstract_length: 500) - event_types << EventType.create(title: 'Workshop', length: 60, color: '#0000FF', description: 'Interactive hands-on practice', - minimum_abstract_length: 0, - maximum_abstract_length: 500) - true - end - - ## - # Creates default DifficultyLevels for this Conference. Used as before_create. - # - def create_difficulty_levels - difficulty_levels << DifficultyLevel.create(title: 'Easy', - description: 'Events are understandable for everyone without knowledge of the topic.', - color: '#70EF69') - difficulty_levels << DifficultyLevel.create(title: 'Medium', - description: 'Events require a basic understanding of the topic.', - color: '#EEEF69') - difficulty_levels << DifficultyLevel.create(title: 'Hard', - description: 'Events require expert knowledge of the topic.', - color: '#EF6E69') - true - end - ## # Creates a EmailSettings association proxy. Used as before_create. # diff --git a/app/models/difficulty_level.rb b/app/models/difficulty_level.rb index 58f9862c..b544c8d6 100644 --- a/app/models/difficulty_level.rb +++ b/app/models/difficulty_level.rb @@ -1,5 +1,5 @@ class DifficultyLevel < ActiveRecord::Base - belongs_to :conference + belongs_to :program has_many :events, dependent: :nullify validates :title, presence: true diff --git a/app/models/email_settings.rb b/app/models/email_settings.rb index 60889a15..be1fc1cb 100644 --- a/app/models/email_settings.rb +++ b/app/models/email_settings.rb @@ -15,9 +15,9 @@ class EmailSettings < ActiveRecord::Base conference.short_title, host: CONFIG['url_for_emails']) } - if conference.call_for_paper - h['cfp_start_date'] = conference.call_for_paper.start_date - h['cfp_end_date'] = conference.call_for_paper.end_date + if conference.program.cfp + h['cfp_start_date'] = conference.program.cfp.start_date + h['cfp_end_date'] = conference.program.cfp.end_date else h['cfp_start_date'] = 'Unknown' h['cfp_end_date'] = 'Unknown' diff --git a/app/models/event.rb b/app/models/event.rb index ed67b07b..7ac0336c 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -19,7 +19,7 @@ class Event < ActiveRecord::Base belongs_to :track belongs_to :room belongs_to :difficulty_level - belongs_to :conference + belongs_to :program accepts_nested_attributes_for :event_users, allow_destroy: true accepts_nested_attributes_for :users @@ -31,7 +31,7 @@ class Event < ActiveRecord::Base validates :title, presence: true validates :abstract, presence: true validates :event_type, presence: true - validates :conference, presence: true + validates :program, presence: true scope :confirmed, -> { where(state: 'confirmed') } scope :highlighted, -> { where(is_highlight: true) } @@ -108,9 +108,9 @@ class Event < ActiveRecord::Base end def process_confirmation - if conference.email_settings.send_on_confirmed_without_registration? && - conference.email_settings.confirmed_without_registration_body && - conference.email_settings.confirmed_without_registration_subject + if program.conference.email_settings.send_on_confirmed_without_registration? && + program.conference.email_settings.confirmed_without_registration_body && + program.conference.email_settings.confirmed_without_registration_subject if conference.registrations.where(user_id: submitter.id).first.nil? Mailbot.delay.confirm_reminder_mail(self) end @@ -118,9 +118,9 @@ class Event < ActiveRecord::Base end def process_acceptance(options) - if conference.email_settings.send_on_accepted && - conference.email_settings.accepted_body && - conference.email_settings.accepted_subject && + if program.conference.email_settings.send_on_accepted && + program.conference.email_settings.accepted_body && + program.conference.email_settings.accepted_subject && !options[:send_mail].blank? Rails.logger.debug 'Sending event acceptance mail' Mailbot.delay.acceptance_mail(self) @@ -128,9 +128,9 @@ class Event < ActiveRecord::Base end def process_rejection(options) - if conference.email_settings.send_on_rejected && - conference.email_settings.rejected_body && - conference.email_settings.rejected_subject && + if program.conference.email_settings.send_on_rejected && + program.conference.email_settings.rejected_body && + program.conference.email_settings.rejected_subject && !options[:send_mail].blank? Rails.logger.debug 'Sending rejected mail' Mailbot.delay.rejection_mail(self) @@ -190,7 +190,7 @@ class Event < ActiveRecord::Base # Returns +Hash+ def progress_status { - registered: self.conference.user_registered?(self.submitter), + registered: self.program.conference.user_registered?(self.submitter), commercials: self.commercials.any?, biography: !self.submitter.biography.blank?, subtitle: !self.subtitle.blank?, @@ -241,7 +241,7 @@ class Event < ActiveRecord::Base def before_end_of_conference errors. - add(:created_at, "can't be after the conference end date!") if conference.end_date && - (Date.today > conference.end_date) + add(:created_at, "can't be after the conference end date!") if program.conference && program.conference.end_date && + (Date.today > program.conference.end_date) end end diff --git a/app/models/event_type.rb b/app/models/event_type.rb index d0a4a8f3..69a54d10 100644 --- a/app/models/event_type.rb +++ b/app/models/event_type.rb @@ -1,5 +1,5 @@ class EventType < ActiveRecord::Base - belongs_to :conference + belongs_to :program has_many :events, dependent: :restrict_with_error validates :title, presence: true diff --git a/app/models/program.rb b/app/models/program.rb new file mode 100644 index 00000000..fc93e169 --- /dev/null +++ b/app/models/program.rb @@ -0,0 +1,103 @@ +# cannot delete program if there are events submitted + +class Program < ActiveRecord::Base + belongs_to :conference + + has_one :cfp, dependent: :destroy + has_many :event_types, dependent: :destroy + has_many :tracks, dependent: :destroy + has_many :difficulty_levels, dependent: :destroy + has_many :rooms, dependent: :destroy + has_many :events, dependent: :destroy do + def workshops + where(require_registration: true, state: :confirmed) + end + + def confirmed + where(state: :confirmed) + end + + def scheduled + where.not(start_time: nil) + end + + def highlights + where(state: :confirmed, is_highlight: true) + end + end + + has_many :event_users, through: :events + has_many :speakers, -> { distinct }, through: :event_users, source: :user do + def confirmed + joins(:events).where(events: { state: :confirmed }) + end + end + + 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 :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, + :schedule_public, :include_cfp_in_splash, :conference_id, + :event_types_attributes, :difficulty_levels_attributes, :rooms_attributes, :tracks_attributes + +# validates :conference_id, presence: true, uniqueness: true + validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 } + + before_create :create_event_types + before_create :create_difficulty_levels + + ## + # Checcks if the program has rating enabled + # + # ====Returns + # * +false+ -> If rating is not enabled + # * +true+ -> If rating is enabled + def rating_enabled? + self.rating && self.rating > 0 + end + + ## + # Checks if the call for papers for the conference is currently open + # + # ====Returns + # * +false+ -> If the CFP is not set or today isn't in the CFP period. + # * +true+ -> If today is in the CFP period. + def cfp_open? + cfp = self.cfp + + cfp.present? && (cfp.start_date..cfp.end_date).cover?(Date.current) + end + + private + + ## + # Creates default EventTypes for this Conference. Used as before_create. + # + def create_event_types + event_types << EventType.create(title: 'Talk', length: 30, color: '#FF0000', description: 'Presentation in lecture format', + minimum_abstract_length: 0, + maximum_abstract_length: 500) + event_types << EventType.create(title: 'Workshop', length: 60, color: '#0000FF', description: 'Interactive hands-on practice', + minimum_abstract_length: 0, + maximum_abstract_length: 500) + true + end + + ## + # Creates default DifficultyLevels for this Conference. Used as before_create. + # + def create_difficulty_levels + difficulty_levels << DifficultyLevel.create(title: 'Easy', + description: 'Events are understandable for everyone without knowledge of the topic.', + color: '#70EF69') + difficulty_levels << DifficultyLevel.create(title: 'Medium', + description: 'Events require a basic understanding of the topic.', + color: '#EEEF69') + difficulty_levels << DifficultyLevel.create(title: 'Hard', + description: 'Events require expert knowledge of the topic.', + color: '#EF6E69') + true + end +end diff --git a/app/models/room.rb b/app/models/room.rb index 5fee24ee..e617ff60 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -1,5 +1,5 @@ class Room < ActiveRecord::Base - belongs_to :conference + belongs_to :program has_many :events, dependent: :nullify before_create :generate_guid diff --git a/app/models/target.rb b/app/models/target.rb index 9045a792..a1b496a2 100644 --- a/app/models/target.rb +++ b/app/models/target.rb @@ -29,7 +29,7 @@ class Target < ActiveRecord::Base numerator = case unit when Target.units[:submissions] - conference.events.where('created_at < ?', due_date).count + conference.program.events.where('created_at < ?', due_date).count when Target.units[:registrations] conference.registrations.where('created_at < ?', due_date).count when Target.units[:program_minutes] diff --git a/app/models/track.rb b/app/models/track.rb index c1c774a2..6949ebdb 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -1,5 +1,5 @@ class Track < ActiveRecord::Base - belongs_to :conference + belongs_to :program has_many :events, dependent: :nullify before_create :generate_guid diff --git a/app/models/user.rb b/app/models/user.rb index fff4b120..567b0e41 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -177,7 +177,7 @@ class User < ActiveRecord::Base end def proposals(conference) - events.where('conference_id = ? AND event_users.event_role=?', conference.id, 'submitter') + events.where('program_id = ? AND event_users.event_role=?', conference.program.id, 'submitter') end def proposal_count(conference) diff --git a/app/views/admin/call_for_papers/_form.html.haml b/app/views/admin/call_for_papers/_form.html.haml deleted file mode 100644 index f18e6a07..00000000 --- a/app/views/admin/call_for_papers/_form.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -.row - .col-md-12 - .page-header - %h1 Call for Papers -.row - .col-md-8 - = semantic_form_for(@call_for_paper, :url => admin_conference_call_for_paper_path(@conference.short_title),:html => {:multipart => true}) do |f| - = f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" } - = f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" } - = f.input :schedule_public, label: "Show Schedule on the home and splash page" - = f.input :schedule_changes, label: "Allow submitters to change their event after it is scheduled" - = f.input :rating, :hint => "Enter the number of different rating levels you want to have for voting on proposals. Enter 0 if you do not want to vote on proposals." - %p.text-right - = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/admin/cfps/_form.html.haml b/app/views/admin/cfps/_form.html.haml new file mode 100644 index 00000000..c216c422 --- /dev/null +++ b/app/views/admin/cfps/_form.html.haml @@ -0,0 +1,11 @@ +.row + .col-md-12 + .page-header + %h1 Call for Papers +.row + .col-md-8 + = semantic_form_for(@cfp, :url => admin_conference_program_cfp_path(@conference.short_title),:html => {:multipart => true}) do |f| + = f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" } + = f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" } + %p.text-right + = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/admin/call_for_papers/show.html.haml b/app/views/admin/cfps/show.html.haml similarity index 55% rename from app/views/admin/call_for_papers/show.html.haml rename to app/views/admin/cfps/show.html.haml index a2aacfb2..af7a2415 100644 --- a/app/views/admin/call_for_papers/show.html.haml +++ b/app/views/admin/cfps/show.html.haml @@ -4,22 +4,22 @@ %h1 Call for Papers %p.text-muted Call for people to submit events to your conference -- if @call_for_paper +- if @cfp .row .col-md-8 %dl.dl-horizontal %dt Start Date: %dd#start_date - = @call_for_paper.start_date.strftime('%A, %B %-d. %Y') + = @cfp.start_date.strftime('%A, %B %-d. %Y') %dt End Date: %dd#end_date - = @call_for_paper.end_date.strftime('%A, %B %-d. %Y') + = @cfp.end_date.strftime('%A, %B %-d. %Y') %dt Days Left: %dd - = pluralize(@call_for_paper.remaining_days, 'day') + = pluralize(@cfp.remaining_days, 'day') %dt Event types: %dd @@ -31,28 +31,28 @@ %dt Public Schedule %dd#schedule_public - - if @call_for_paper.schedule_public + - if @program.schedule_public Yes - else No %dt Schedule changeable? %dd#schedule_changes - - if @call_for_paper.schedule_changes + - if @program.schedule_fluid Yes - else No %dt Rating Levels %dd#rating - = @call_for_paper.rating + = @program.rating .row .col-md-12.text-right - = link_to(edit_admin_conference_call_for_paper_path(@conference.short_title), class: 'btn btn-primary') do + = link_to(edit_admin_conference_program_cfp_path(@conference.short_title), class: 'btn btn-primary') do Edit - = link_to(admin_conference_call_for_paper_path(@conference.short_title), method: 'delete', class: 'btn btn-danger') do + = link_to(admin_conference_program_cfp_path(@conference.short_title), method: 'delete', class: 'btn btn-danger', data: { confirm: 'Are you sure you want to delete the CfP?' }) do Delete -else .row .col-md-12.text-right - = link_to 'Create Call for Papers', new_admin_conference_call_for_paper_path(@conference.short_title), class: 'btn btn-primary' + = link_to 'Create Call for Papers', new_admin_conference_program_cfp_path(@conference.short_title), class: 'btn btn-primary' diff --git a/app/views/admin/comments/_all_comments.html.haml b/app/views/admin/comments/_all_comments.html.haml index 02ad15e8..eb3a8093 100644 --- a/app/views/admin/comments/_all_comments.html.haml +++ b/app/views/admin/comments/_all_comments.html.haml @@ -5,7 +5,7 @@ .panel-body - events.each do |event, comments| .notifications - %h4.title= link_to event.title, admin_conference_event_path(event.conference.short_title, event) + %h4.title= link_to event.title, admin_conference_program_event_path(event.program.conference.short_title, event) %hr - comments.each do |comment| %h5.strong Posted by: #{comment.user.name} | Created at: #{comment.created_at} diff --git a/app/views/admin/comments/_posted_comments.html.haml b/app/views/admin/comments/_posted_comments.html.haml index 89c90519..d274f929 100644 --- a/app/views/admin/comments/_posted_comments.html.haml +++ b/app/views/admin/comments/_posted_comments.html.haml @@ -5,7 +5,7 @@ .panel-body - events.each do |event, comments| .notifications - %h4.title= link_to event.title, admin_conference_event_path(event.conference.short_title, event) + %h4.title= link_to event.title, admin_conference_program_event_path(event.program.conference.short_title, event) %hr - comments.each do |comment| %h5.strong Created at: #{comment.created_at} diff --git a/app/views/admin/comments/_unread_comments.html.haml b/app/views/admin/comments/_unread_comments.html.haml index 9291aa83..5facdc4b 100644 --- a/app/views/admin/comments/_unread_comments.html.haml +++ b/app/views/admin/comments/_unread_comments.html.haml @@ -5,7 +5,7 @@ .panel-body - events.each do |event, comments| .notifications - %h4.title= link_to event.title, admin_conference_event_path(event.conference.short_title, event) + %h4.title= link_to event.title, admin_conference_program_event_path(event.program.conference.short_title, event) %hr - comments.each do |comment| %h5.strong Posted by: #{comment.user.name} | Created at: #{comment.created_at} diff --git a/app/views/admin/conference/_recent_submissions.html.haml b/app/views/admin/conference/_recent_submissions.html.haml index 08823ff8..0f6c0037 100644 --- a/app/views/admin/conference/_recent_submissions.html.haml +++ b/app/views/admin/conference/_recent_submissions.html.haml @@ -16,8 +16,8 @@ %td= link_to event.submitter.name, admin_user_path(event.submitter.id) - else %td Unknown Submitter - %td= link_to event.title, admin_conference_event_path(event.conference.short_title, event) - %td= link_to event.conference.title, admin_conference_path(event.conference.short_title) + %td= link_to event.title, admin_conference_program_event_path(event.program.conference.short_title, event) + %td= link_to event.program.conference.title, admin_conference_path(event.program.conference.short_title) %td .span{'class'=>label_for(event.state)} #{event.state.humanize} - else diff --git a/app/views/admin/conference/_todo_list.html.haml b/app/views/admin/conference/_todo_list.html.haml index 1ed13f51..6b4ddb96 100644 --- a/app/views/admin/conference/_todo_list.html.haml +++ b/app/views/admin/conference/_todo_list.html.haml @@ -17,8 +17,8 @@ Set up registration period %li{'class'=>"list-group-item #{class_for_todo(conference_progress['cfp'])}"} %span{'class'=>icon_for_todo(conference_progress['cfp'])} - - if can? :update, CallForPaper.new(conference_id: @conference.id) - = link_to 'Set up call for papers', admin_conference_call_for_paper_path(conference_progress['short_title']) + - if can? :update, Cfp.new(program_id: @program.id) + = link_to 'Set up call for papers', admin_conference_program_cfp_path(conference_progress['short_title']) - else Set up call for papers %li{'class'=>"list-group-item #{class_for_todo(conference_progress['venue'])}"} @@ -32,26 +32,26 @@ Add venue %li{'class'=>"list-group-item #{class_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']) + - if can? :update, @conference.program.rooms.build + = link_to 'Add rooms', admin_conference_program_rooms_path(conference_progress['short_title']) - else Add rooms %li{'class'=>"list-group-item #{class_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']) + - if can? :update, @conference.program.tracks.build + = link_to 'Add tracks', admin_conference_program_tracks_path(conference_progress['short_title']) - else Add tracks %li{'class'=>"list-group-item #{class_for_todo(conference_progress['event_types'])}"} %span{'class'=>icon_for_todo(conference_progress['event_types'])} - - if can? :update, @conference.event_types.build - = link_to 'Add event types', admin_conference_event_types_path(conference_progress['short_title']) + - if can? :update, @conference.program.event_types.build + = link_to 'Add event types', admin_conference_program_event_types_path(conference_progress['short_title']) - else Add event types %li{'class'=>"list-group-item #{class_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']) + - if can? :update, @conference.program.difficulty_levels.build + = link_to 'Add difficulty levels', admin_conference_program_difficulty_levels_path(conference_progress['short_title']) - else Add difficulty levels %li{class: "list-group-item #{class_for_todo(conference_progress['splashpage'])}"} diff --git a/app/views/admin/difficulty_levels/_form.html.haml b/app/views/admin/difficulty_levels/_form.html.haml index f0b43cd0..534fa179 100644 --- a/app/views/admin/difficulty_levels/_form.html.haml +++ b/app/views/admin/difficulty_levels/_form.html.haml @@ -8,7 +8,7 @@ = @difficulty_level.title .row .col-md-8 - = semantic_form_for(@difficulty_level, :url => (@difficulty_level.new_record? ? admin_conference_difficulty_levels_path : admin_conference_difficulty_level_path(@conference.short_title, @difficulty_level))) do |f| + = semantic_form_for(@difficulty_level, :url => (@difficulty_level.new_record? ? admin_conference_program_difficulty_levels_path : admin_conference_program_difficulty_level_path(@conference.short_title, @difficulty_level))) do |f| = f.input :title, :required => true = f.input :description, :input_html => {:rows => 3, :class => "span6"} = f.input :color, :input_html => {:size => 6, :type => "color"} diff --git a/app/views/admin/difficulty_levels/index.html.haml b/app/views/admin/difficulty_levels/index.html.haml index 1b02d446..70d6e2d8 100644 --- a/app/views/admin/difficulty_levels/index.html.haml +++ b/app/views/admin/difficulty_levels/index.html.haml @@ -3,7 +3,7 @@ .page-header %h1 Difficulty Levels %p.text-muted - Classify your conference events by difficulty + Classify your conference.program.events by difficulty .row .col-md-12 %table.table.table-hover#difficulty_levels @@ -13,7 +13,7 @@ %th Color %th Actions %tbody - - @conference.difficulty_levels.each do |difficulty_level| + - @conference.program.difficulty_levels.each do |difficulty_level| %tr %td = difficulty_level.title @@ -24,11 +24,11 @@ = difficulty_level.color %td .btn-group{role: "group"} - = link_to 'Edit', edit_admin_conference_difficulty_level_path(@conference.short_title, difficulty_level.id), + = link_to 'Edit', edit_admin_conference_program_difficulty_level_path(@conference.short_title, difficulty_level.id), method: :get, class: 'btn btn-primary' - = link_to 'Delete', admin_conference_difficulty_level_path(@conference.short_title, difficulty_level.id), + = link_to 'Delete', admin_conference_program_difficulty_level_path(@conference.short_title, difficulty_level.id), method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete #{difficulty_level.title}? Attention: This difficulty level will be removed from all Events that have it set" } .row .col-md-12.text-right - = link_to 'Add Difficulty Level', new_admin_conference_difficulty_level_path(@conference.short_title), class: 'btn btn-primary' + = link_to 'Add Difficulty Level', new_admin_conference_program_difficulty_level_path(@conference.short_title), class: 'btn btn-primary' diff --git a/app/views/admin/emails/_help.html.haml b/app/views/admin/emails/_help.html.haml index 5555988d..d71b6f9e 100644 --- a/app/views/admin/emails/_help.html.haml +++ b/app/views/admin/emails/_help.html.haml @@ -41,14 +41,14 @@ %tr %td {venue_address} %td The address of the venue - - unless @conference.call_for_paper.blank? || @conference.call_for_paper.start_date.blank? || @conference.call_for_paper.end_date.blank? + - unless @conference.program.cfp.blank? || @conference.program.cfp.start_date.blank? || @conference.program.cfp.end_date.blank? %tr %td {cfp_start_date} %td The call for papers start date %tr %td {cfp_end_date} %td The call for papers end date - -if @conference.call_for_paper.schedule_public + -if @conference.program.schedule_public %td {schedule_link} %td The link to complete schedule of the conference - if @conference.splashpage && @conference.splashpage.public diff --git a/app/views/admin/emails/index.html.haml b/app/views/admin/emails/index.html.haml index 9f96e761..006d2720 100644 --- a/app/views/admin/emails/index.html.haml +++ b/app/views/admin/emails/index.html.haml @@ -69,18 +69,18 @@ %a.btn.btn-link.control_label.template_help_link{"data-name"=>"updated_venue_help"} Show Help = render partial: 'help', locals: {id: 'updated_venue_help', show_event_variables: false} #cfp.tab-pane{:role => "tabpanel"} - = f.input :send_on_call_for_papers_schedule_public, hint: "This will notify all participants when the dates are updated or when the schedule is made public" - = f.input :call_for_papers_schedule_public_subject, hint: "This subject will used whenever dates are updated or when the schedule is made public" - = f.input :call_for_papers_schedule_public_body, :input_html => { :rows => 10, :cols => 20 } + = f.input :send_on_program_schedule_public, hint: "This will notify all participants when the dates are updated or when the schedule is made public" + = f.input :program_schedule_public_subject, hint: "This subject will used whenever dates are updated or when the schedule is made public" + = f.input :program_schedule_public_template, :input_html => { :rows => 10, :cols => 20 } %a.btn.btn-link.control_label.load_template{"data-template"=>"Dear {name},\n\nThe Conference Call for Papers Details of {conference} has changed.The schedule is being made public.\n Link to Schedule {schedule_link} \n\nBest wishes\n\n{conference} Team", - "data-name"=>"email_settings_call_for_papers_schedule_public_body"} Load Template + "data-name"=>"email_settings_program_schedule_public_template"} Load Template %a.btn.btn-link.control_label.template_help_link{"data-name"=>"updated_cfp_help"} Show Help = render partial: 'help', locals: {id: 'updated_cfp_help', show_event_variables: false} - = f.input :send_on_call_for_papers_dates_updated, hint: "This will notify all participants when the dates are updated or when the schedule is made public" - = f.input :call_for_papers_dates_updated_subject, hint: "This subject will used whenever dates are updated or when the schedule is made public" - = f.input :call_for_papers_dates_updated_body, :input_html => { :rows => 10, :cols => 20 } + = f.input :send_on_cfp_dates_updated, hint: "This will notify all participants when the dates are updated or when the schedule is made public" + = f.input :cfp_dates_updated_subject, hint: "This subject will used whenever dates are updated or when the schedule is made public" + = f.input :cfp_dates_updated_template, :input_html => { :rows => 10, :cols => 20 } %a.btn.btn-link.control_label.load_template{"data-template"=>"Dear {name},\n\nThe Conference Call for Papers Details of {conference} has changed.\nNew Dates : {cfp_start_date} - {cfp_end_date}.\n Link to Schedule {schedule_link} \n\nBest wishes\n\n{conference} Team", - "data-name"=>"email_settings_call_for_papers_dates_updated_body"} Load Template + "data-name"=>"email_settings_cfp_dates_updates_template"} Load Template %a.btn.btn-link.control_label.template_help_link{"data-name"=>"updated_cfp_help"} Show Help = render partial: 'help', locals: {id: 'updated_cfp_help', show_event_variables: false} .row diff --git a/app/views/admin/event_types/_form.html.haml b/app/views/admin/event_types/_form.html.haml index 0e0db179..397e9871 100644 --- a/app/views/admin/event_types/_form.html.haml +++ b/app/views/admin/event_types/_form.html.haml @@ -8,7 +8,7 @@ = @event_type.title .row .col-md-12 - = semantic_form_for(@event_type, :url => (@event_type.new_record? ? admin_conference_event_types_path : admin_conference_event_type_path(@conference.short_title, @event_type))) do |f| + = semantic_form_for(@event_type, :url => (@event_type.new_record? ? admin_conference_program_event_types_path : admin_conference_program_event_type_path(@conference.short_title, @event_type))) do |f| = f.input :title = f.input :length, :input_html => {:size => 3} = f.input :description diff --git a/app/views/admin/event_types/index.html.haml b/app/views/admin/event_types/index.html.haml index e5513eff..3187282f 100644 --- a/app/views/admin/event_types/index.html.haml +++ b/app/views/admin/event_types/index.html.haml @@ -15,7 +15,7 @@ %th Color %th Actions %tbody - - @conference.event_types.each do |event_type| + - @conference.program.event_types.each do |event_type| %tr %td = event_type.title @@ -32,11 +32,11 @@ = event_type.color %td .btn-group{role: "group"} - = link_to 'Edit', edit_admin_conference_event_type_path(@conference.short_title, event_type.id), + = link_to 'Edit', edit_admin_conference_program_event_type_path(@conference.short_title, event_type.id), method: :get, class: 'btn btn-primary' - = link_to 'Delete', admin_conference_event_type_path(@conference.short_title, event_type.id), + = link_to 'Delete', admin_conference_program_event_type_path(@conference.short_title, event_type.id), method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete #{event_type.name}?" } .row .col-md-12.text-right - = link_to 'Add Event Type', new_admin_conference_event_type_path(@conference.short_title), class: 'btn btn-primary' + = link_to 'Add Event Type', new_admin_conference_program_event_type_path(@conference.short_title), class: 'btn btn-primary' diff --git a/app/views/admin/events/_change_state_dropdown.html.haml b/app/views/admin/events/_change_state_dropdown.html.haml index dd0a96f8..f8dde305 100644 --- a/app/views/admin/events/_change_state_dropdown.html.haml +++ b/app/views/admin/events/_change_state_dropdown.html.haml @@ -1,37 +1,37 @@ - if event.transition_possible? :accept %li= link_to 'Accept event', - accept_admin_conference_event_path(@conference.short_title, event), + accept_admin_conference_program_event_path(@conference.short_title, event), method: :patch, id: "accept_event_#{event.id}" - if @conference.email_settings.send_on_accepted? %li= link_to 'Accept event (without email)', - accept_admin_conference_event_path(@conference.short_title, event, send_mail: false), + accept_admin_conference_program_event_path(@conference.short_title, event, send_mail: false), method: :patch, hint: 'Accept this event without sending an automated email.', id: "accept_event_without_mail_#{event.id}" - if event.transition_possible? :reject %li= link_to 'Reject event', - reject_admin_conference_event_path(@conference.short_title, event), + reject_admin_conference_program_event_path(@conference.short_title, event), method: :patch, confirm: 'Are you sure?', id: "reject_event_#{event.id}" - if @conference.email_settings.send_on_rejected? %li= link_to 'Reject event (without email)', - reject_admin_conference_event_path(@conference.short_title, event, send_mail: false), + reject_admin_conference_program_event_path(@conference.short_title, event, send_mail: false), method: :patch, confirm: 'Are you sure?', id: "reject_event_without_mail_#{event.id}" - if event.transition_possible? :restart %li= link_to 'Start review', - restart_admin_conference_event_path(@conference.short_title, event), + restart_admin_conference_program_event_path(@conference.short_title, event), method: :patch, id: "restart_event_#{event.id}" - if event.transition_possible? :confirm %li= link_to 'Confirm event', - confirm_admin_conference_event_path(@conference.short_title, event), + confirm_admin_conference_program_event_path(@conference.short_title, event), method: :patch, id: "confirm_event_#{event.id}", hint: 'Confirm that the speaker(s) will be present and that the event will actually take place.' - if event.transition_possible? :cancel %li= link_to 'Cancel event', - cancel_admin_conference_event_path(@conference.short_title, event), + cancel_admin_conference_program_event_path(@conference.short_title, event), method: :patch, id: "cancel_event_#{event.id}", - hint: 'Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance.' \ No newline at end of file + hint: 'Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance.' diff --git a/app/views/admin/events/_nested_comments.html.haml b/app/views/admin/events/_nested_comments.html.haml index 24c641f8..de0044d7 100644 --- a/app/views/admin/events/_nested_comments.html.haml +++ b/app/views/admin/events/_nested_comments.html.haml @@ -6,7 +6,7 @@ %div %a.pull-right.comment-reply-link{href: "#"} Reply .comment-reply - = form_tag "#{comment_admin_conference_event_path(@conference.short_title, comment.commentable_id)}", method: :post do + = form_tag "#{comment_admin_conference_program_event_path(@conference.short_title, comment.commentable_id)}", method: :post do %input{name: "parent", type: "hidden", value: "#{comment.id}"} %input{name: "authenticity_token", type: "hidden", value: "#{form_authenticity_token}"} %textarea{name: "comment"} diff --git a/app/views/admin/events/_proposal.html.haml b/app/views/admin/events/_proposal.html.haml index a29282a4..4e51b312 100644 --- a/app/views/admin/events/_proposal.html.haml +++ b/app/views/admin/events/_proposal.html.haml @@ -5,7 +5,7 @@ %br %small = @event.subtitle - = 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_program_event_path(@conference.short_title, @event), class: 'btn btn-mini btn-primary pull-right' .row .col-md-12 @@ -24,7 +24,7 @@ %ul.dropdown-menu - @event_types.each do |type| %li= link_to type.title, - admin_conference_event_path(@conference.short_title, + admin_conference_program_event_path(@conference.short_title, @event, event: { event_type_id: type.id }), method: :patch @@ -33,7 +33,7 @@ %b Highlight %td = check_box_tag @conference.short_title, @event.id, @event.is_highlight, - method: :patch, url: "/admin/conference/#{@conference.short_title}/events/#{@event.id}?event[is_highlight]=", + method: :patch, url: "/admin/conference/#{@conference.short_title}/program/events/#{@event.id}?event[is_highlight]=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', @@ -63,7 +63,7 @@ %ul.dropdown-menu - @tracks.each do |track| %li= link_to track.name, - admin_conference_event_path(@conference.short_title, + admin_conference_program_event_path(@conference.short_title, @event, event: { track_id: track.id }), method: :patch @@ -80,7 +80,7 @@ %ul.dropdown-menu - @difficulty_levels.each do |difficulty| - %li= link_to difficulty.title, admin_conference_event_path(@conference.short_title, + %li= link_to difficulty.title, admin_conference_program_event_path(@conference.short_title, @event, event: { difficulty_level_id: difficulty.id }), method: :patch @@ -89,7 +89,7 @@ %b Requires Registration %td = check_box_tag @conference.short_title, @event.id, @event.require_registration, - method: :patch, url: "/admin/conference/#{@conference.short_title}/events/#{@event.id}?event[require_registration]=", + method: :patch, url: "/admin/conference/#{@conference.short_title}/program/events/#{@event.id}?event[require_registration]=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', @@ -137,7 +137,7 @@ %b Description %td= simple_format(@event.description) - - if @conference.call_for_paper && @conference.call_for_paper.rating && @conference.call_for_paper.rating > 0 + - if @conference.program && @conference.program.rating && @conference.program.rating > 0 = render partial: 'voting' .row @@ -147,7 +147,7 @@ %ul.media %div .row-fluid - = form_tag(comment_admin_conference_event_path(@conference.short_title, @event.id), method: :post) do + = form_tag(comment_admin_conference_program_event_path(@conference.short_title, @event.id), method: :post) do = text_area_tag(:comment, '') = submit_tag 'Add Comment', class: 'btn btn-primary pull-right' %br diff --git a/app/views/admin/events/_voting.html.haml b/app/views/admin/events/_voting.html.haml index 43b44cea..bc281d87 100644 --- a/app/views/admin/events/_voting.html.haml +++ b/app/views/admin/events/_voting.html.haml @@ -4,11 +4,11 @@ %b Rating %td - if @event.average_rating.to_f > 0 - #{@event.average_rating}/#{@conference.call_for_paper.rating} + #{@event.average_rating}/#{@conference.program.rating} - else - Rating: 0/#{@conference.call_for_paper.rating} + Rating: 0/#{@conference.program.rating} - - @conference.call_for_paper.rating.times do |counter| + - @conference.program.rating.times do |counter| - if @event.average_rating.to_f.round == counter+1 = label_tag "label_rating", "", :class => "avgrating", :avgrate => true = javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');" @@ -27,12 +27,12 @@ %td %b Your vote %td - - @conference.call_for_paper.rating.times do |counter| + - @conference.program.rating.times do |counter| - voted = @event.voted?(@event, current_user) - if voted && voted.rating == counter+1 - = link_to "", vote_admin_conference_event_path(@conference.short_title, @event, :rating => counter+1), :remote => true, :id =>"label#{counter+1}", :class => "myrating", :voted => true + = link_to "", vote_admin_conference_program_event_path(@conference.short_title, @event, :rating => counter+1), :remote => true, :id =>"label#{counter+1}", :class => "myrating", :voted => true - else - = link_to "", vote_admin_conference_event_path(@conference.short_title, @event, :rating => counter+1), :remote => true, :id =>"label#{counter+1}", :class => "myrating" + = link_to "", vote_admin_conference_program_event_path(@conference.short_title, @event, :rating => counter+1), :remote => true, :id =>"label#{counter+1}", :class => "myrating" %br - if @ratings.length > 0 @@ -42,7 +42,7 @@ %td = rate.name %td - - @conference.call_for_paper.rating.times do |counter| + - @conference.program.rating.times do |counter| - voted = @event.voted?(@event, rate.user) - if voted && voted.rating == counter+1 = label_tag "label#{counter+1}", "", :class => "othersrating", :voted => true diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index 10a99f6d..6b3ff1e7 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -15,7 +15,7 @@ %b ID %th %b Title - - if @conference.call_for_paper && @conference.call_for_paper.rating && @conference.call_for_paper.rating > 0 + - if @program.rating_enabled? %th %b Rating %th @@ -39,16 +39,16 @@ %td = event.id %td - =link_to event.title, admin_conference_event_path(@conference.short_title, event) + =link_to event.title, admin_conference_program_event_path(@conference.short_title, event) - - if @conference.call_for_paper && @conference.call_for_paper.rating && @conference.call_for_paper.rating > 0 + - if @program.rating_enabled? %td.col-md-1{'data-order' => "#{event.average_rating}"} - if event.average_rating.to_f > 0 - #{event.average_rating}/#{@conference.call_for_paper.rating} + #{event.average_rating}/#{@program.rating} %br #{pluralize(event.voters.length, 'voter')} %br - - @conference.call_for_paper.rating.times do |counter| + - @program.cfp.rating.times do |counter| - if event.average_rating.to_f.round == counter+1 = label_tag "label_rating", "", :class => "avgrating", :avgrate => true = javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');" @@ -63,7 +63,7 @@ %span.label.label-danger Not rated - else - 0/#{@conference.call_for_paper.rating} + 0/#{@program.rating} %br - if event.submitter && event.submitter.registrations && event.submitter.registrations.count < 1 @@ -85,7 +85,7 @@ %td{'data-order' => "#{event.require_registration}"} = check_box_tag @conference.short_title, event.id, event.require_registration, - method: :patch, url: "/admin/conference/#{@conference.short_title}/events/#{event.id}?event[require_registration]=", + method: :patch, url: "/admin/conference/#{@conference.short_title}/program/events/#{event.id}?event[require_registration]=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', @@ -93,7 +93,7 @@ %td{'data-order' => "#{event.is_highlight}"} = check_box_tag @conference.short_title, event.id, event.is_highlight, - method: :patch, url: "/admin/conference/#{@conference.short_title}/events/#{event.id}?event[is_highlight]=", + method: :patch, url: "/admin/conference/#{@conference.short_title}/program/events/#{event.id}?event[is_highlight]=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', @@ -110,7 +110,7 @@ %ul.dropdown-menu - @event_types.each do |type| %li= link_to type.title, - admin_conference_event_path(@conference.short_title, + admin_conference_program_event_path(@conference.short_title, event, event: { event_type_id: type.id }), method: :patch @@ -125,7 +125,7 @@ %ul.dropdown-menu - @tracks.each do |track| %li= link_to track.name, - admin_conference_event_path(@conference.short_title, + admin_conference_program_event_path(@conference.short_title, event, event: { track_id: track.id }), method: :patch @@ -140,7 +140,7 @@ %ul.dropdown-menu - @difficulty_levels.each do |difficulty_level| %li= link_to difficulty_level.title, - admin_conference_event_path(@conference.short_title, + admin_conference_program_event_path(@conference.short_title, event, event: { difficulty_level_id: difficulty_level.id }), method: :patch diff --git a/app/views/admin/programs/_form.html.haml b/app/views/admin/programs/_form.html.haml new file mode 100644 index 00000000..13b1ce72 --- /dev/null +++ b/app/views/admin/programs/_form.html.haml @@ -0,0 +1,12 @@ +.row + .col-md-12 + .page-header + %h1 Program +.row + .col-md-8 + = semantic_form_for(@program, :url => admin_conference_program_path(@conference.short_title),:html => {:multipart => true}) do |f| + = f.input :schedule_public, label: "Show Schedule on the home and splash page" + = f.input :schedule_fluid, label: "Allow submitters to change their event after it is scheduled" + = f.input :rating, :hint => "Enter the number of different rating levels you want to have for voting on proposals. Enter 0 if you do not want to vote on proposals." + %p.text-right + = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/admin/programs/show.html.haml b/app/views/admin/programs/show.html.haml new file mode 100644 index 00000000..feff0205 --- /dev/null +++ b/app/views/admin/programs/show.html.haml @@ -0,0 +1,61 @@ +.row + .col-md-12 + .page-header + %h1 Program +- if @program + .row + .col-md-8 + %dl.dl-horizontal + - if @cfp + %dt + Start Date: + %dd#start_date + = @cfp.start_date.strftime('%A, %B %-d. %Y') + %dt + End Date: + %dd#end_date + = @cfp.end_date.strftime('%A, %B %-d. %Y') + %dt + Days Left: + %dd + = pluralize(@cfp.remaining_days, 'day') + %dt + Event types: + %dd + = event_types(@conference) + %dt + Tracks: + %dd + = tracks(@conference) + %dt + Difficulty Levels: + %dd + = difficulty_levels(@conference) + %dt + Public Schedule + %dd#schedule_public + - if @program.schedule_public + Yes + - else + No + %dt + Schedule changeable? + %dd#schedule_changes + - if @program.schedule_fluid + Yes + - else + No + %dt + Rating Levels + %dd#rating + = @program.rating + + + .row + .col-md-12.text-right + - if can? :edit, @progam + = link_to edit_admin_conference_program_path(@conference.short_title), class: 'btn btn-primary' do + Edit + - if can? :destroy, @program + = link_to admin_conference_program_path(@conference.short_title), method: 'delete', class: 'btn btn-danger', data: { confirm: 'Are you sure you want to delete this program?' } do + Delete diff --git a/app/views/admin/rooms/_form.html.haml b/app/views/admin/rooms/_form.html.haml index 05cf1b0d..345e0972 100644 --- a/app/views/admin/rooms/_form.html.haml +++ b/app/views/admin/rooms/_form.html.haml @@ -8,7 +8,7 @@ = @room.name .row .col-md-8 - = semantic_form_for(@room, :url => (@room.new_record? ? admin_conference_rooms_path : admin_conference_room_path(@conference.short_title, @room))) do |f| + = semantic_form_for(@room, :url => (@room.new_record? ? admin_conference_program_rooms_path : admin_conference_program_room_path(@conference.short_title, @room))) do |f| = f.input :name = f.input :size, :input_html => {:size => 5} %p.text-right diff --git a/app/views/admin/rooms/index.html.haml b/app/views/admin/rooms/index.html.haml index 52f00f18..1649e43f 100644 --- a/app/views/admin/rooms/index.html.haml +++ b/app/views/admin/rooms/index.html.haml @@ -5,7 +5,7 @@ %p.text-muted The rooms of your conference venue -- if @conference.rooms.any? +- if @conference.program.rooms.any? .row .col-md-12 %table.table.table-hover#rooms @@ -14,18 +14,18 @@ %th Size %th Actions %tbody - - @conference.rooms.each_with_index do |room, index| + - @conference.program.rooms.each_with_index do |room, index| %tr %td = room.name %td = room.size %td - = link_to 'Edit', edit_admin_conference_room_path(@conference.short_title, room.id), + = link_to 'Edit', edit_admin_conference_program_room_path(@conference.short_title, room.id), method: :get, class: 'btn btn-primary' - = link_to 'Delete', admin_conference_room_path(@conference.short_title, room.id), + = link_to 'Delete', admin_conference_program_room_path(@conference.short_title, room.id), 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"} .row .col-md-12.text-right - = link_to 'Add Room', new_admin_conference_room_path(@conference.short_title), class: 'btn btn-primary' + = link_to 'Add Room', new_admin_conference_program_room_path(@conference.short_title), class: 'btn btn-primary' diff --git a/app/views/admin/tracks/_form.html.haml b/app/views/admin/tracks/_form.html.haml index db18e963..d637af26 100644 --- a/app/views/admin/tracks/_form.html.haml +++ b/app/views/admin/tracks/_form.html.haml @@ -8,7 +8,7 @@ Track .row .col-md-12 - = semantic_form_for(@track, :url => (@track.new_record? ? admin_conference_tracks_path : admin_conference_track_path(@conference.short_title, @track))) do |f| + = semantic_form_for(@track, :url => (@track.new_record? ? admin_conference_program_tracks_path : admin_conference_program_track_path(@conference.short_title, @track))) do |f| = f.input :name = f.input :color, :input_html => {:size => 6, :type => "color"}, :required=> true = f.input :description, :input_html => {:rows => 2, data: { provide: "markdown-editable" } }, hint: markdown_hint diff --git a/app/views/admin/tracks/index.html.haml b/app/views/admin/tracks/index.html.haml index 8ba3a41b..73b7979d 100644 --- a/app/views/admin/tracks/index.html.haml +++ b/app/views/admin/tracks/index.html.haml @@ -13,10 +13,10 @@ %th Color %th Actions %tbody - - @conference.tracks.each do |track| + - @tracks.each do |track| %tr %td - = link_to(admin_conference_track_path(@conference.short_title, track)) do + = link_to(admin_conference_program_track_path(@conference.short_title, track)) do = track.name %td %p @@ -26,12 +26,12 @@ = track.color %td .btn-group{role: "group"} - = link_to 'Edit', edit_admin_conference_track_path(@conference.short_title, track.id), + = link_to 'Edit', edit_admin_conference_program_track_path(@conference.short_title, track.id), method: :get, class: 'btn btn-primary' - = link_to 'Delete', admin_conference_track_path(@conference.short_title, track.id), + = link_to 'Delete', admin_conference_program_track_path(@conference.short_title, track.id), method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete #{track.name}? Attention: This track will be removed from all Events that have it set" } .row .col-md-12.text-right - = link_to 'New Track', new_admin_conference_track_path(@conference.short_title), class: 'btn btn-success' + = link_to 'New Track', new_admin_conference_program_track_path(@conference.short_title), class: 'btn btn-success' diff --git a/app/views/admin/tracks/show.html.haml b/app/views/admin/tracks/show.html.haml index 5f6ffc04..240b9725 100644 --- a/app/views/admin/tracks/show.html.haml +++ b/app/views/admin/tracks/show.html.haml @@ -19,7 +19,7 @@ - @track.events.each_with_index do |event| %tr %td - =link_to event.title, admin_conference_event_path(@conference.short_title, event) + =link_to event.title, admin_conference_program_event_path(@conference.short_title, event) %td = event.event_type.title %td diff --git a/app/views/admin/users/_submissions.html.haml b/app/views/admin/users/_submissions.html.haml index 0daa1368..c3b05119 100644 --- a/app/views/admin/users/_submissions.html.haml +++ b/app/views/admin/users/_submissions.html.haml @@ -17,13 +17,13 @@ - @user.events.each do |event| %tr %td= event.id - %td= link_to event.conference.short_title, admin_conference_path(event.conference.short_title) - %td= link_to event.title, admin_conference_event_path(event.conference.short_title, event) + %td= link_to event.program.conference.short_title, admin_conference_path(event.program.conference.short_title) + %td= link_to event.title, admin_conference_program_event_path(event.program.conference.short_title, event) %td= event.state %td= "#{event.event_type.title} (#{show_time(event.event_type.length)})" %td - - if event.conference.call_for_paper && event.conference.call_for_paper.rating && event.conference.call_for_paper.rating > 0 - - event.conference.call_for_paper.rating.times do |counter| + - if event.program && event.program.rating && event.program.rating > 0 + - event.program.rating.times do |counter| - if event.average_rating.to_f.round == counter+1 = label_tag 'label_rating', '', class: 'avgrating', avgrate: true = javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');" diff --git a/app/views/commercials/edit.html.haml b/app/views/commercials/edit.html.haml new file mode 100644 index 00000000..174a1a60 --- /dev/null +++ b/app/views/commercials/edit.html.haml @@ -0,0 +1,9 @@ +.container + .row + .col-md-12 + .page-header + %h1 Editing Commercial + .row + .col-md-12 + = semantic_form_for @commercial, url: conference_program_proposal_commercial_path(conference_id: @conference.short_title, proposal_id: @event.id, id: @commercial.id) do |f| + = render 'form', f: f diff --git a/app/views/commercials/new.html.haml b/app/views/commercials/new.html.haml new file mode 100644 index 00000000..da726e89 --- /dev/null +++ b/app/views/commercials/new.html.haml @@ -0,0 +1,9 @@ +.container + .row + .col-md-12 + .page-header + %h1 New Commercial + .row + .col-md-12 + = semantic_form_for @commercial, url: conference_program_proposal_commercials_path(conference_id: @conference.short_title, proposal_id: @event.id) do |f| + = render 'form', f: f diff --git a/app/views/conference/_all_events.html.erb b/app/views/conference/_all_events.html.erb index 130dceca..f7fd7fc0 100644 --- a/app/views/conference/_all_events.html.erb +++ b/app/views/conference/_all_events.html.erb @@ -1,8 +1,8 @@

Program for <%= @conference.title %>

-<% @conference.events.confirmed.each do |event| %> +<% @conference.program.events.confirmed.each do |event| %>

- <%= link_to event.title, conference_proposal_path(@conference.short_title, event.id) %> + <%= link_to event.title, conference_program_proposal_path(@conference.short_title, event.id) %>
<%= event.subtitle %> @@ -13,7 +13,7 @@

<%= truncate(event.abstract, :length => 400) -%> - <%= link_to 'more', conference_proposal_path(@conference.short_title, event.id) if event.abstract.length > 400 %> + <%= link_to 'more', conference_program_proposal_path(@conference.short_title, @conference.program.id, event.id) if event.abstract.length > 400 %>

<% end %> diff --git a/app/views/conference/_call_for_paper.html.haml b/app/views/conference/_call_for_paper.html.haml index 32e2efe2..dd45ad60 100644 --- a/app/views/conference/_call_for_paper.html.haml +++ b/app/views/conference/_call_for_paper.html.haml @@ -12,22 +12,22 @@ .row .col-md-6.col-md-offset-3.col-sm-10.col-sm-offset-1 %p - - if @conference.event_types.any? + - if @program.event_types.any? You can submit proposals for = "#{event_types(@conference)}." - - if @conference.tracks.any? + - if @program.tracks.any? Proposals should fit in one of the - = "#{pluralize(@conference.tracks.count, 'track')}:" + = "#{pluralize(@program.tracks.count, 'track')}:" = "#{tracks(@conference)}." The submission period has begun %em - = @conference.call_for_paper.start_date.strftime('%A, %B %-d. %Y') + = @program.cfp.start_date.strftime('%A, %B %-d. %Y') and closes %em - = @conference.call_for_paper.end_date.strftime('%A, %B %-d. %Y.') - - if @conference.cfp_open? + = @program.cfp.end_date.strftime('%A, %B %-d. %Y.') + - if @program.cfp_open? That means you have only - %b= pluralize(@conference.call_for_paper.remaining_days, 'day') + %b= pluralize(@program.cfp.remaining_days, 'day') left! Remember = @conference.short_title @@ -37,4 +37,4 @@ .row .col-md-12.text-center %p.cta-button - = link_to "Submit your paper now", conference_proposal_index_path(@conference.short_title), class: 'btn btn-success btn-lg text-center' + = link_to "Submit your paper now", conference_program_proposal_index_path(@conference.short_title), class: 'btn btn-success btn-lg text-center' diff --git a/app/views/conference/_conference_details.html.haml b/app/views/conference/_conference_details.html.haml index 07704360..165dc6f1 100644 --- a/app/views/conference/_conference_details.html.haml +++ b/app/views/conference/_conference_details.html.haml @@ -21,7 +21,7 @@ - if !@conference || @conference != conference - if conference.splashpage && conference.splashpage.public = link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default" - - if conference.call_for_paper and conference.call_for_paper.schedule_public + - if conference.program and conference.program.schedule_public = link_to "Schedule", schedule_conference_path(conference.short_title), :class =>"btn btn-default" - if conference.registration_open? - if conference.user_registered?(current_user) @@ -29,9 +29,9 @@ - else = link_to "Register", new_conference_conference_registrations_path(conference.short_title), :class =>"btn btn-default" - if !current_user.nil? && current_user.proposal_count(conference) > 0 - = link_to "My Proposals", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default" - - elsif conference.cfp_open? - = link_to "Submit Proposal", new_conference_proposal_path(conference.short_title), :class =>"btn btn-default" + = link_to "My Proposals", conference_program_proposal_index_path(conference.short_title), :class =>"btn btn-default" + - elsif conference.program.cfp_open? + = link_to "Submit Proposal", new_conference_program_proposal_path(conference.short_title), :class =>"btn btn-default" - if current_user.nil? || !current_user.subscribed?(conference) = link_to 'Subscribe', conference_subscriptions_path(conference.short_title), method: :post, class: 'btn btn-default' - else diff --git a/app/views/conference/_program.html.haml b/app/views/conference/_program.html.haml new file mode 100644 index 00000000..aaa699a9 --- /dev/null +++ b/app/views/conference/_program.html.haml @@ -0,0 +1,40 @@ += content_for :splash_nav do + %li + %a.smoothscroll{ href: '#callforpapers' } Call For Papers + +.container + .row + .col-md-12.text-center + %h2 + Call for Papers + %p.lead + We are ready to accept your proposals for sessions! + .row + .col-md-6.col-md-offset-3.col-sm-10.col-sm-offset-1 + %p + - if @conference.program.event_types.any? + You can submit proposals for + = "#{event_types(@conference)}." + - if @conference.tracks.any? + Proposals should fit in one of the + = "#{pluralize(@conference.tracks.count, 'track')}:" + = "#{tracks(@conference)}." + The submission period has begun + %em + = @program.cfp.start_date.strftime('%A, %B %-d. %Y') + and closes + %em + = @program.cfp.end_date.strftime('%A, %B %-d. %Y.') + - if @conference.cfp_open? + That means you have only + %b= pluralize(@program.cfp.remaining_days, 'day') + left! + Remember + = @conference.short_title + will only be as good as the sessions you present. Submit early, submit often! + - else + The submission period is closed. + .row + .col-md-12.text-center + %p.cta-button + = link_to "Submit your paper now", conference_proposal_index_path(@conference.short_title), class: 'btn btn-success btn-lg text-center' diff --git a/app/views/conference/_schedule_item.html.haml b/app/views/conference/_schedule_item.html.haml index 01db4cac..743095ca 100644 --- a/app/views/conference/_schedule_item.html.haml +++ b/app/views/conference/_schedule_item.html.haml @@ -1,7 +1,7 @@ %td.event{ style: "width: #{95 / @rooms.length}%; cursor:pointer", | rowspan: span[room.id], | role: "button" } | - %a.unstyled-link{href: url_for(conference_proposal_path(@conference.short_title, event[0].id))} + %a.unstyled-link{href: url_for(conference_program_proposal_path(@conference.short_title, event[0].id))} - if speaker = event[0].speakers.first = image_tag speaker.gravatar_url, :class => "img-circle pull-right", | :alt => speaker.name, | diff --git a/app/views/conference/_schedule_splashpage.html.haml b/app/views/conference/_schedule_splashpage.html.haml index b4c6eab1..1517f5db 100644 --- a/app/views/conference/_schedule_splashpage.html.haml +++ b/app/views/conference/_schedule_splashpage.html.haml @@ -6,10 +6,10 @@ %p.lead.text-center = @conference.short_title has the most awesome program ever! - - if @conference.splashpage and @conference.tracks.any? and @conference.splashpage.include_tracks + - if @conference.splashpage and @conference.program.tracks.any? and @conference.splashpage.include_tracks See rock-star speakers cover the topics of - if @conference.splashpage and @conference.splashpage.include_tracks - - @conference.tracks.each_slice(3) do |slice| + - @conference.program.tracks.each_slice(3) do |slice| .row.row-centered - slice.each do |track| .col-md-4.col-sm-4.col-centered.col-top.track @@ -17,7 +17,7 @@ = track.name = markdown(track.description) - - if @conference.call_for_paper and @conference.call_for_paper.schedule_public + - if @conference.program and @conference.program.schedule_public .row .col-md-12 %p.cta-button.text-center @@ -28,10 +28,10 @@ %h3.text-center Don't miss out! %br - - if @conference.events.highlights.any? + - if @conference.program.events.highlights.any? .row .col-md-12 - - @conference.events.highlights.each_slice(2) do |slice| + - @conference.program.events.highlights.each_slice(2) do |slice| .row.row-centered - slice.each do |event| .col-md-6.col-centered.col-top.highlights @@ -39,7 +39,7 @@ %b= event.title %h5.text-center = simple_format truncate(event.abstract, length: 500, separator: ' ') - = link_to "Read More", conference_proposal_path(@conference.short_title, event) + = link_to "Read More", conference_program_proposal_path(@conference.short_title, event) = content_for :splash_nav do %li diff --git a/app/views/conference/schedule.html.erb b/app/views/conference/schedule.html.erb index d7c30da7..9390cf5d 100644 --- a/app/views/conference/schedule.html.erb +++ b/app/views/conference/schedule.html.erb @@ -1,5 +1,5 @@
- <% if @conference.events.scheduled.any? %> + <% if @conference.program.events.scheduled.any? %>
\ No newline at end of file +
diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index d3dcc8fa..15544cb9 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -36,7 +36,7 @@ %section#program = render 'schedule_splashpage' - - if @conference.cfp_open? and @conference.splashpage.include_cfp + - if @program.cfp_open? and @conference.splashpage.include_cfp %section#callforpapers = render 'call_for_paper' diff --git a/app/views/conference_registrations/_registration_info.html.haml b/app/views/conference_registrations/_registration_info.html.haml index 9653862d..2a852992 100644 --- a/app/views/conference_registrations/_registration_info.html.haml +++ b/app/views/conference_registrations/_registration_info.html.haml @@ -1,8 +1,8 @@ - if @conference.questions.any? = render partial: 'conference_registrations/questions', locals: { f: f } -- if @conference.events.workshops.any? +- if @conference.program.events.workshops.any? =f.inputs 'Pre-registration required for the following:' do - = f.input :events, as: :check_boxes, label: false, collection: @conference.events.workshops + = f.input :events, as: :check_boxes, label: false, collection: @conference.program.events.workshops = f.inputs 'Your Travel Info' do = f.input :arrival, as: :string, label: 'Your arrival time', input_html: { value: (f.object.arrival.to_formatted_s(:db_without_seconds) unless f.object.arrival.nil?), id: 'registration-arrival-datepicker', readonly: 'readonly' } = f.input :departure, as: :string, label: 'Your departure time', input_html: { value: (f.object.departure.to_formatted_s(:db_without_seconds) unless f.object.departure.nil?), id: 'registration-departure-datepicker', readonly: 'readonly' } diff --git a/app/views/conference_registrations/show.html.haml b/app/views/conference_registrations/show.html.haml index 298a1da3..7378190c 100644 --- a/app/views/conference_registrations/show.html.haml +++ b/app/views/conference_registrations/show.html.haml @@ -126,13 +126,13 @@ - @conference.participants.each do |participant| = image_tag(participant.gravatar_url(size: '25'), title: "#{participant.name}!", class: 'img-circle') .col-md-4.col-md-offset-2 - - if @conference.speakers.confirmed.any? + - if @conference.program.speakers.confirmed.any? %h4 %span.fa-stack %i.fa.fa-square-o.fa-stack-2x %i.fa.fa-microphone.fa-stack-1x - = @conference.speakers.confirmed.count + = @conference.program.speakers.confirmed.count Confirmed - = word_pluralize(@conference.speakers.confirmed.count, 'Speaker') - - @conference.speakers.confirmed.each do |speaker| + = word_pluralize(@conference.program.speakers.confirmed.count, 'Speaker') + - @conference.program.speakers.confirmed.each do |speaker| = image_tag(speaker.gravatar_url(size: '25'), title: "#{speaker.name}!", class: 'img-circle') diff --git a/app/views/layouts/_admin_sidebar.html.haml b/app/views/layouts/_admin_sidebar.html.haml index ea9931df..8dd18cbb 100644 --- a/app/views/layouts/_admin_sidebar.html.haml +++ b/app/views/layouts/_admin_sidebar.html.haml @@ -53,33 +53,33 @@ %span.fa.fa-road Venue %ul - - if can? :update, @conference.rooms.build - %li{:class=> active_nav_li(admin_conference_rooms_path(@conference.short_title))} - = link_to 'Rooms', admin_conference_rooms_path(@conference.short_title) + - if can? :update, @conference.program.rooms.build + %li{:class=> active_nav_li(admin_conference_program_rooms_path(@conference.short_title))} + = link_to 'Rooms', admin_conference_program_rooms_path(@conference.short_title) - if can? :update, @conference.lodgings.build %li{ class: active_nav_li(admin_conference_lodgings_path(@conference.short_title)) } = link_to 'Lodgings', admin_conference_lodgings_path(@conference.short_title) - - if can? :update, @conference.events.build - %li - %a + %li{:class=> "#{active_nav_li(admin_conference_program_path(@conference.short_title))}"} + = link_to admin_conference_program_path(@conference.short_title) do %span.fa.fa-calendar Program %ul - %li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))} - = link_to 'Events', admin_conference_events_path(@conference.short_title) - - if can? :update, CallForPaper.new(conference_id: @conference.id) - %li{:class=> "#{active_nav_li(admin_conference_call_for_paper_path(@conference.short_title))}"} - = link_to 'Call for Papers', admin_conference_call_for_paper_path(@conference.short_title) - - if can? :update, @conference.tracks.build - %li{:class=> active_nav_li(admin_conference_tracks_path(@conference.short_title))} - = link_to 'Tracks', admin_conference_tracks_path(@conference.short_title) - - if can? :update, @conference.event_types.build - %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))} - = link_to 'Difficulty Levels', admin_conference_difficulty_levels_path(@conference.short_title) - - if can? :update, @conference.events.build + - if can? :update, Cfp.new(program_id: @conference.program.id) + %li{:class=> active_nav_li(admin_conference_program_cfp_path(@conference.short_title))} + = link_to 'Call for Papers', admin_conference_program_cfp_path(@conference.short_title) + - if can? :update, @conference.program.events.build + %li{:class=> active_nav_li(admin_conference_program_events_path(@conference.short_title))} + = link_to 'Events', admin_conference_program_events_path(@conference.short_title) + - if can? :update, @conference.program.tracks.build + %li{:class=> active_nav_li(admin_conference_program_tracks_path(@conference.short_title))} + = link_to 'Tracks', admin_conference_program_tracks_path(@conference.short_title) + - if can? :update, @conference.program.event_types.build + %li{:class=> active_nav_li(admin_conference_program_event_types_path(@conference.short_title))} + = link_to 'Event Types', admin_conference_program_event_types_path(@conference.short_title) + - if can? :update, @conference.program.difficulty_levels.build, conference_id: @conference.id + %li{:class=> active_nav_li(admin_conference_program_difficulty_levels_path(@conference.short_title))} + = link_to 'Difficulty Levels', admin_conference_program_difficulty_levels_path(@conference.short_title) + - if can? :update, @conference.program.events.build %li{class: active_nav_li(admin_conference_schedule_path(@conference.short_title))} = link_to 'Schedule', admin_conference_schedule_path(@conference.short_title), target: '_blank' diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index cf2b3b44..e94a0c92 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -37,7 +37,7 @@ - if unread_notifications(current_user).length > 0 %li.dropdown-header Last 5 Comments for: - unread_notifications(current_user).limit(5).group_by{ |comment| comment.commentable}.each do |event, comments| - %li= link_to("#{event.title}(#{comments.count})", admin_conference_event_path(event.conference.short_title, event.id)) + %li= link_to("#{event.title}(#{comments.count})", admin_conference_program_event_path(event.program.conference.short_title, event.id)) %li.divider %li= link_to "See all unread Comments (#{unread_notifications(current_user).length})", admin_comments_path %li= link_to 'See all Comments', admin_comments_path(anchor: 'all_comments') diff --git a/app/views/layouts/_user_menu.html.haml b/app/views/layouts/_user_menu.html.haml index 1764d9d0..ca4c7ef3 100644 --- a/app/views/layouts/_user_menu.html.haml +++ b/app/views/layouts/_user_menu.html.haml @@ -7,9 +7,9 @@ = link_to(edit_user_path(current_user.id)) do %span.fa.fa-user Edit Profile --if @conference and @conference.call_for_paper +-if @conference and @conference.program %li - = link_to(conference_proposal_index_path(@conference.short_title)) do + = link_to(conference_program_proposal_index_path(@conference.short_title)) do %span.fa.fa-comment My Submissions %li diff --git a/app/views/proposal/_encouragement_text.html.haml b/app/views/proposal/_encouragement_text.html.haml index 52fed803..cf108019 100644 --- a/app/views/proposal/_encouragement_text.html.haml +++ b/app/views/proposal/_encouragement_text.html.haml @@ -1,20 +1,20 @@ %p.lead - - if @conference.event_types.any? + - if @program.event_types.any? You can submit proposals for = "#{event_types(@conference)}." - - if @conference.tracks.any? + - if @program.tracks.any? Proposals should fit in one of the - = "#{pluralize(@conference.tracks.count, 'track')}:" + = "#{pluralize(@program.tracks.count, 'track')}:" = "#{tracks(@conference)}." - - if @conference.cfp_open? + - if @program.cfp_open? The submission period has begun %em - = @conference.call_for_paper.start_date.strftime('%A, %B %-d. %Y') + = @program.cfp.start_date.strftime('%A, %B %-d. %Y') and closes %em - = @conference.call_for_paper.end_date.strftime('%A, %B %-d. %Y.') + = @program.cfp.end_date.strftime('%A, %B %-d. %Y.') That means you have - %b= pluralize(@conference.call_for_paper.remaining_days, 'day') + %b= pluralize(@program.cfp.remaining_days, 'day') left! Remember = @conference.title diff --git a/app/views/proposal/_form.html.haml b/app/views/proposal/_form.html.haml index 7405c4b6..e19bbb7f 100644 --- a/app/views/proposal/_form.html.haml +++ b/app/views/proposal/_form.html.haml @@ -13,7 +13,7 @@ #commercials-content.tab-pane %p.text-muted You can add commercials for your proposal. These commercials will be displayed on the - = link_to 'public proposal page.', conference_proposal_path(@conference.short_title, @event) + = link_to 'public proposal page.', conference_program_proposal_path(@conference.short_title, @event) If you don't add a commercial, the conference commercial will be displayed! - if can? :create, @event.commercials.new .row @@ -37,9 +37,9 @@ = render partial: 'shared/media_item', locals: { commercial: commercial } .caption - if can? :update, commercial - = semantic_form_for commercial, url: conference_proposal_commercial_path(conference_id: @conference.short_title, proposal_id: @event, id: commercial) do |f| + = semantic_form_for commercial, url: conference_program_proposal_commercial_path(conference_id: @conference.short_title, proposal_id: @event, id: commercial) do |f| = f.input :url, label: 'URL', as: :string, input_html: { id: "commercial_url_#{commercial.id}", required: 'required', type: 'url' } = f.action :submit, as: :button, button_html: { class: 'btn btn-success' }, label: 'Update' - if can? :destroy, commercial - = link_to 'Delete', conference_proposal_commercial_path(@conference.short_title, @event.id, commercial.id), + = link_to 'Delete', conference_program_proposal_commercial_path(@conference.short_title, @event.id, commercial.id), :method => :delete, :data => { :confirm => 'Are you sure?' }, class: 'btn btn-danger' diff --git a/app/views/proposal/_proposal_form.html.haml b/app/views/proposal/_proposal_form.html.haml index 83b34a5f..d30ad689 100644 --- a/app/views/proposal/_proposal_form.html.haml +++ b/app/views/proposal/_proposal_form.html.haml @@ -5,21 +5,21 @@ = f.input :subtitle, as: :string = f.input :event_type_id, as: :select, - collection: @conference.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, + collection: @conference.program.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length }]}, include_blank: false, label: 'Type', input_html: { class: 'select-help-toggle' } - - @conference.event_types.each do |event_type| + - @conference.program.event_types.each do |event_type| %span{ class: 'help-block select-help-text event_event_type_id collapse', id: "#{event_type.id}-help" } = event_type.description :javascript - $("##{@conference.event_types.first.id}-help").collapse('show'); + $("##{@conference.program.event_types.first.id}-help").collapse('show'); - = f.input :difficulty_level, as: :select, collection: @conference.difficulty_levels, input_html: { class: 'select-help-toggle' }, - include_blank: '(Please select)' if @conference.difficulty_levels.any? + = f.input :difficulty_level, as: :select, collection: @conference.program.difficulty_levels, input_html: { class: 'select-help-toggle' }, + include_blank: '(Please select)' if @conference.program.difficulty_levels.any? - - @conference.difficulty_levels.each do |difficulty_level| + - @conference.program.difficulty_levels.each do |difficulty_level| %span{ class: 'help-block select-help-text collapse event_difficulty_level_id', id: "#{difficulty_level.id}-help" } = difficulty_level.description diff --git a/app/views/proposal/_tooltip.html.haml b/app/views/proposal/_tooltip.html.haml index 4e9fd243..ed45e8e5 100644 --- a/app/views/proposal/_tooltip.html.haml +++ b/app/views/proposal/_tooltip.html.haml @@ -3,9 +3,9 @@ %li{'class'=>class_for_todo(progress_status['registered'])} %span{'class'=>icon_for_todo(progress_status['registered'])} - if progress_status['registered'] - = link_to 'Edit your registration', edit_conference_conference_registrations_path(event.conference.short_title) + = link_to 'Edit your registration', edit_conference_conference_registrations_path(event.program.conference.short_title) - else - = link_to 'Register to the conference', new_conference_conference_registrations_path(event.conference.short_title) + = link_to 'Register to the conference', new_conference_conference_registrations_path(event.program.conference.short_title) %li{'class'=>class_for_todo(progress_status['biography'])} %span{'class'=>icon_for_todo(progress_status['biography'])} @@ -17,20 +17,19 @@ %li{'class'=>class_for_todo(progress_status['subtitle'])} %span{'class'=>icon_for_todo(progress_status['subtitle'])} - if progress_status['subtitle'] - = link_to 'Edit the subtitle', edit_conference_proposal_path(event.conference.short_title, event) + = link_to 'Edit the subtitle', edit_conference_program_proposal_path(event.program.conference.short_title, event) - else - = link_to 'Add a subtitle', edit_conference_proposal_path(event.conference.short_title, event) + = link_to 'Add a subtitle', edit_conference_program_proposal_path(event.program.conference.short_title, event) %li{'class'=>class_for_todo(progress_status['commercials'])} %span{'class'=>icon_for_todo(progress_status['commercials'])} - if progress_status['commercials'] - = link_to 'Edit the commercials', edit_conference_proposal_path(event.conference.short_title, event, anchor: 'commercials-content') + = link_to 'Edit the commercials', edit_conference_program_proposal_path(event.program.conference.short_title, event, anchor: 'commercials-content') - else - = link_to 'Add a commercial', edit_conference_proposal_path(event.conference.short_title, event, anchor: 'commercials-content') - + = link_to 'Add a commercial', edit_conference_program_proposal_path(event.conference.short_title, event, anchor: 'commercials-content') %li{'class'=>class_for_todo(progress_status['difficulty_level'])} %span{'class'=>icon_for_todo(progress_status['difficulty_level'])} - if progress_status['difficulty_level'] - = link_to 'Change the difficulty level', edit_conference_proposal_path(event.conference.short_title, event) + = link_to 'Change the difficulty level', edit_conference_program_proposal_path(event.program.conference.short_title, event) - else - = link_to 'Add a difficulty level', edit_conference_proposal_path(event.conference.short_title, event) + = link_to 'Add a difficulty level', edit_conference_program_proposal_path(event.program.conference.short_title, event) diff --git a/app/views/proposal/index.html.haml b/app/views/proposal/index.html.haml index 0c901f0c..0a514daa 100644 --- a/app/views/proposal/index.html.haml +++ b/app/views/proposal/index.html.haml @@ -18,7 +18,7 @@ Some of your proposals have been selected as a highlight of #{@conference.title}! %ul - @events.highlighted.each do |event| - %li= link_to event.title, conference_proposal_path(@conference.short_title, event) + %li= link_to event.title, conference_program_proposal_path(@conference.short_title, event) .row @@ -60,7 +60,7 @@ %span{ title: event.state.humanize, class: "fa #{event_status_icon(event)}" } %td.col-md-7{style: "padding:20px 8px 20px 8px;"} - = link_to event.title, conference_proposal_path(@conference.short_title, event.id) + = link_to event.title, conference_program_proposal_path(@conference.short_title, event.id) %br %small.text-muted = event.event_type.title @@ -82,20 +82,20 @@ .pull-right - if event.transition_possible? :confirm = link_to 'Confirm', - confirm_conference_proposal_path(@conference.short_title, event), + confirm_conference_program_proposal_path(@conference.short_title, event), method: :patch, class: 'btn btn-mini btn-success', id: "confirm_proposal_#{event.id}" - if event.transition_possible? :withdraw - = link_to 'Withdraw', conference_proposal_path(@conference.short_title, event.id), method: :delete, + = link_to 'Withdraw', conference_program_proposal_path(@conference.short_title, event.id), method: :delete, data: { confirm: 'Are you sure you want to withdraw this proposal?' }, class: 'btn btn-mini btn-warning', id: "delete_proposal_#{event.id}" - if event.state == 'withdrawn' || event.state == 'rejected' = link_to 'Re-Submit', - restart_conference_proposal_path(@conference.short_title, event.id), + restart_conference_program_proposal_path(@conference.short_title, event.id), method: :patch, class: 'btn btn-mini btn-success', id: "review_event_#{event.id}" - = link_to 'Edit', edit_conference_proposal_path(@conference.short_title, event.id), + = link_to 'Edit', edit_conference_program_proposal_path(@conference.short_title, event.id), class: 'btn btn-default', id: "edit_proposal_#{event.id}" .row .col-md-12 - - 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" + - if can? :create, @program.events.new + = link_to "New Proposal", new_conference_program_proposal_path(@conference.short_title), :class => "btn btn-success pull-right" diff --git a/app/views/proposal/new.html.haml b/app/views/proposal/new.html.haml index e4b4fd99..37e89b94 100644 --- a/app/views/proposal/new.html.haml +++ b/app/views/proposal/new.html.haml @@ -27,16 +27,16 @@ = f.inputs name: 'Proposal Information' do = f.input :title, as: :string, required: true, input_html: { required: true } = f.input :event_type_id, as: :select, - collection: @conference.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, + collection: @program.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length }]}, include_blank: false, label: 'Type', input_html: { class: 'select-help-toggle' } - - @conference.event_types.each do |event_type| + - @program.event_types.each do |event_type| %span{ class: 'help-block event_event_type_id collapse', id: "#{event_type.id}-help" } = event_type.description :javascript - $("##{@conference.event_types.first.id}-help").collapse('show'); + $("##{@program.event_types.first.id}-help").collapse('show'); = f.input :abstract, input_html: { rows: 5, required: true }, required: true, hint: link_to('Tips to improve your presentations', 'http://blog.hubspot.com/blog/tabid/6307/bid/5975/10-Rules-to-Instantly-Improve-Your-Presentations.aspx') diff --git a/app/views/proposal/show.html.haml b/app/views/proposal/show.html.haml index 5cb91ff8..d14d5acb 100644 --- a/app/views/proposal/show.html.haml +++ b/app/views/proposal/show.html.haml @@ -9,7 +9,7 @@ = @event.subtitle = link_to "Schedule", schedule_conference_path(@conference.short_title), :class =>"btn btn-success pull-right" - 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_program_event_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary pull-right" .row .col-md-3 %p @@ -24,7 +24,7 @@ - if @event.room_id = @event.room.name %dt Conference: - %dd= @event.conference.title + %dd= @event.program.conference.title %dt Language: %dd= @event.language if @event.language %dt Track: diff --git a/config/routes.rb b/config/routes.rb index ca96cdb0..4bf173b9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,15 +44,30 @@ Osem::Application.routes.draw do # Singletons resource :splashpage - resource :call_for_paper resource :venue resource :registration_period + resource :program do + resource :cfp + resources :tracks + resources :event_types + resources :difficulty_levels + resources :rooms, except: [:show] + resources :events do + member do + post :comment + patch :accept + patch :confirm + patch :cancel + patch :reject + patch :unconfirm + patch :restart + get :vote + end + resource :speaker, only: [:edit, :update] + end + end resources :tickets - resources :tracks - resources :event_types - resources :difficulty_levels - resources :rooms, except: [:show] resources :sponsors, except: [:show] resources :lodgings, except: [:show] resources :targets, except: [:show] @@ -71,31 +86,19 @@ Osem::Application.routes.draw do patch :update_conference end end - - resources :events do - member do - post :comment - patch :accept - patch :confirm - patch :cancel - patch :reject - patch :unconfirm - patch :restart - get :vote - end - resource :speaker, only: [:edit, :update] - end end end resources :conference, only: [:index, :show] do - resources :proposal do - get 'commercials/render_commercial' => 'commercials#render_commercial' - resources :commercials, only: [:create, :update, :destroy] - resources :event_attachment, controller: 'event_attachments' - member do - patch '/confirm' => 'proposal#confirm' - patch '/restart' => 'proposal#restart' + resource :program, except: :destroy do + resources :proposal do + get 'commercials/render_commercial' => 'commercials#render_commercial' + resources :commercials, only: [:create, :update, :destroy] + resources :event_attachment, controller: 'event_attachments' + member do + patch '/confirm' => 'proposal#confirm' + patch '/restart' => 'proposal#restart' + end end end diff --git a/db/migrate/20151018152439_create_programs_table.rb b/db/migrate/20151018152439_create_programs_table.rb new file mode 100644 index 00000000..79633ca1 --- /dev/null +++ b/db/migrate/20151018152439_create_programs_table.rb @@ -0,0 +1,75 @@ +class CreateProgramsTable< ActiveRecord::Migration + class TempConference < ActiveRecord::Base + self.table_name = 'conferences' + end + + class TempCfp < ActiveRecord::Base + self.table_name = 'cfps' + end + + class TempCallForPaper < ActiveRecord::Base + self.table_name = 'call_for_papers' + end + + class TempProgram < ActiveRecord::Base + self.table_name = 'programs' + end + + def up + create_table :programs do |t| + t.references :conference + t.integer :rating, default: 0 + t.boolean :schedule_public, default: false + t.boolean :schedule_fluid, default: false + end + + add_column :call_for_papers, :program_id, :integer + + TempConference.all.each do |conference| + unless TempProgram.find_by(conference_id: conference.id) + program = TempProgram.new + program.conference_id = conference.id + program.save! + + if (cfp = TempCallForPaper.find_by(conference_id: conference.id)) + cfp.program_id = program.id + cfp.save! + + program.rating = cfp.rating + program.schedule_public = cfp.schedule_public + program.schedule_fluid = cfp.schedule_changes + program.save! + end + end + end + remove_column :call_for_papers, :conference_id + remove_column :call_for_papers, :rating + remove_column :call_for_papers, :schedule_public + remove_column :call_for_papers, :schedule_changes + rename_table :call_for_papers, :cfps + end + + def down + rename_table :cfps, :call_for_papers + add_column :call_for_papers, :conference_id, :integer + add_column :call_for_papers, :rating, :integer, default: 0 + add_column :call_for_papers, :schedule_public, :boolean, default: false + add_column :call_for_papers, :schedule_changes, :boolean, default: false + + TempConference.all.each do |conference| + if (program = TempProgram.find_by(conference_id: conference.id)) + if (cfp = TempCallForPaper.find_by(program_id: program.id)) + cfp.conference_id = program.conference_id + cfp.rating = program.rating + cfp.schedule_public = program.schedule_public + cfp.schedule_changes = program.schedule_fluid + + cfp.save! + end + end + end + + remove_column :call_for_papers, :program_id + drop_table :programs + end +end diff --git a/db/migrate/20151018154513_rename_conference_id_to_program_id_in_events_rooms_tracks_difficulty_levels.rb b/db/migrate/20151018154513_rename_conference_id_to_program_id_in_events_rooms_tracks_difficulty_levels.rb new file mode 100644 index 00000000..3aef9999 --- /dev/null +++ b/db/migrate/20151018154513_rename_conference_id_to_program_id_in_events_rooms_tracks_difficulty_levels.rb @@ -0,0 +1,117 @@ +class RenameConferenceIdToProgramIdInEventsRoomsTracksDifficultyLevels < ActiveRecord::Migration + class TempConference < ActiveRecord::Base + self.table_name = 'conferences' + end + + class TempEvent < ActiveRecord::Base + self.table_name = 'events' + end + + class TempEventType < ActiveRecord::Base + self.table_name = 'event_types' + end + + class TempTrack < ActiveRecord::Base + self.table_name = 'tracks' + end + + class TempDifficultyLevel < ActiveRecord::Base + self.table_name = 'difficulty_levels' + end + + class TempRoom < ActiveRecord::Base + self.table_name = 'rooms' + end + + class TempProgram < ActiveRecord::Base + self.table_name = 'programs' + end + + def up + add_column :events, :program_id, :integer + add_column :event_types, :program_id, :integer + add_column :tracks, :program_id, :integer + add_column :difficulty_levels, :program_id, :integer + add_column :rooms, :program_id, :integer + + TempConference.all.each do |conference| + program = Program.find_by(conference_id: conference.id) + + TempEvent.where(conference_id: conference.id).each do |event| + event.program_id = program.id + event.save! + end + + TempEventType.where(conference_id: conference.id).each do |event_type| + event_type.program_id = program.id + event_type.save! + end + + TempTrack.where(conference_id: conference.id).each do |track| + track.program_id = program.id + track.save! + end + + TempDifficultyLevel.where(conference_id: conference.id).each do |difficulty_level| + difficulty_level.program_id = program.id + difficulty_level.save! + end + + TempRoom.where(conference_id: conference.id).each do |room| + room.program_id = program.id + room.save! + end + end + + remove_column :events, :conference_id + remove_column :event_types, :conference_id + remove_column :tracks, :conference_id + remove_column :difficulty_levels, :conference_id + remove_column :rooms, :conference_id + end + + def down + add_column :events, :conference_id, :integer + add_column :event_types, :conference_id, :integer + add_column :tracks, :conference_id, :integer + add_column :difficulty_levels, :conference_id, :integer + add_column :rooms, :conference_id, :integer + + TempConference.all.each do |conference| + program = TempProgram.find_by(conference_id: conference.id) + + if program + TempEvent.where(program_id: program.id).each do |event| + event.conference_id = conference.id + event.save! + end + + TempEventType.where(program_id: program.id).each do |event_type| + event_type.conference_id = conference.id + event_type.save! + end + + TempTrack.where(program_id: program.id).each do |track| + track.conference_id = conference.id + track.save! + end + + TempDifficultyLevel.where(program_id: program.id).each do |difficulty_level| + difficulty_level.conference_id = conference.id + difficulty_level.save! + end + + TempRoom.where(program_id: program.id).each do |room| + room.conference_id = conference.id + room.save! + end + end + end + + remove_column :events, :program_id + remove_column :event_types, :program_id + remove_column :tracks, :program_id + remove_column :difficulty_levels, :program_id + remove_column :rooms, :program_id + end +end diff --git a/db/migrate/20151021113015_rename_email_settings_with_cfp_and_program.rb b/db/migrate/20151021113015_rename_email_settings_with_cfp_and_program.rb new file mode 100644 index 00000000..f29eee9c --- /dev/null +++ b/db/migrate/20151021113015_rename_email_settings_with_cfp_and_program.rb @@ -0,0 +1,10 @@ +class RenameEmailSettingsWithCfpAndProgram < ActiveRecord::Migration + def change + rename_column :email_settings, :send_on_call_for_papers_schedule_public, :send_on_program_schedule_public + rename_column :email_settings, :call_for_papers_schedule_public_body, :program_schedule_public_template + rename_column :email_settings, :call_for_papers_schedule_public_subject, :program_schedule_public_subject + rename_column :email_settings, :send_on_call_for_papers_dates_updated, :send_on_cfp_dates_updates + rename_column :email_settings, :call_for_papers_dates_updated_subject, :cfp_dates_updates_subject + rename_column :email_settings, :call_for_papers_dates_updated_body, :cfp_dates_updates_template + end +end diff --git a/db/schema.rb b/db/schema.rb index cd241c4e..e591ddda 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,8 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema.define(version: 20151005161518) do +ActiveRecord::Schema.define(version: 20151021113015) do create_table "ahoy_events", force: true do |t| t.uuid "visit_id" @@ -22,25 +21,14 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.datetime "time" end - add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time" - add_index "ahoy_events", ["user_id"], name: "index_ahoy_events_on_user_id" - add_index "ahoy_events", ["visit_id"], name: "index_ahoy_events_on_visit_id" + add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time", using: :btree + add_index "ahoy_events", ["user_id"], name: "index_ahoy_events_on_user_id", using: :btree + add_index "ahoy_events", ["visit_id"], name: "index_ahoy_events_on_visit_id", using: :btree create_table "answers", force: true do |t| t.string "title" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "call_for_papers", force: true do |t| - t.date "start_date", null: false - t.date "end_date", null: false - t.integer "conference_id" - t.datetime "created_at" - t.datetime "updated_at" - t.boolean "schedule_changes", default: false - t.integer "rating", default: 3 - t.boolean "schedule_public" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "campaigns", force: true do |t| @@ -55,23 +43,31 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.datetime "updated_at" end + create_table "cfps", force: true do |t| + t.date "start_date", null: false + t.date "end_date", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "program_id" + end + create_table "comments", force: true do |t| - t.string "title", limit: 50, default: "" - t.text "body" + t.string "title", limit: 50, default: "" + t.text "body", limit: 16777215 t.integer "commentable_id" t.string "commentable_type" t.integer "user_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "subject" t.integer "parent_id" t.integer "lft" t.integer "rgt" end - add_index "comments", ["commentable_id"], name: "index_comments_on_commentable_id" - add_index "comments", ["commentable_type"], name: "index_comments_on_commentable_type" - add_index "comments", ["user_id"], name: "index_comments_on_user_id" + add_index "comments", ["commentable_id"], name: "index_comments_on_commentable_id", using: :btree + add_index "comments", ["commentable_type"], name: "index_comments_on_commentable_type", using: :btree + add_index "comments", ["user_id"], name: "index_comments_on_user_id", using: :btree create_table "commercials", force: true do |t| t.string "commercial_id" @@ -91,8 +87,8 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.string "html_export_path" t.date "start_date", null: false t.date "end_date", null: false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "logo_file_name" t.string "logo_content_type" t.integer "logo_file_size" @@ -140,65 +136,65 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.datetime "updated_at" end - add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority" + add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree create_table "dietary_choices", force: true do |t| t.integer "conference_id" t.string "title", null: false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "difficulty_levels", force: true do |t| - t.integer "conference_id" t.string "title" t.text "description" t.string "color" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "program_id" end create_table "email_settings", force: true do |t| t.integer "conference_id" - t.boolean "send_on_registration", default: false - t.boolean "send_on_accepted", default: false - t.boolean "send_on_rejected", default: false - t.boolean "send_on_confirmed_without_registration", default: false - t.text "registration_body" - t.text "accepted_body" - t.text "rejected_body" - t.text "confirmed_without_registration_body" - t.datetime "created_at" - t.datetime "updated_at" + t.boolean "send_on_registration", default: false + t.boolean "send_on_accepted", default: false + t.boolean "send_on_rejected", default: false + t.boolean "send_on_confirmed_without_registration", default: false + t.text "registration_body", limit: 16777215 + t.text "accepted_body", limit: 16777215 + t.text "rejected_body", limit: 16777215 + t.text "confirmed_without_registration_body", limit: 16777215 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "registration_subject" t.string "accepted_subject" t.string "rejected_subject" t.string "confirmed_without_registration_subject" - t.boolean "send_on_conference_dates_updated", default: false + t.boolean "send_on_conference_dates_updated", default: false t.string "conference_dates_updated_subject" t.text "conference_dates_updated_body" - t.boolean "send_on_conference_registration_dates_updated", default: false + t.boolean "send_on_conference_registration_dates_updated", default: false t.string "conference_registration_dates_updated_subject" t.text "conference_registration_dates_updated_body" - t.boolean "send_on_venue_updated", default: false + t.boolean "send_on_venue_updated", default: false t.string "venue_updated_subject" t.text "venue_updated_body" - t.boolean "send_on_call_for_papers_dates_updated", default: false - t.boolean "send_on_call_for_papers_schedule_public", default: false - t.string "call_for_papers_schedule_public_subject" - t.string "call_for_papers_dates_updated_subject" - t.text "call_for_papers_schedule_public_body" - t.text "call_for_papers_dates_updated_body" + t.boolean "send_on_cfp_dates_updates", default: false + t.boolean "send_on_program_schedule_public", default: false + t.string "program_schedule_public_subject" + t.string "cfp_dates_updates_subject" + t.text "program_schedule_public_template" + t.text "cfp_dates_updates_template" end create_table "event_types", force: true do |t| - t.integer "conference_id" t.string "title", null: false t.integer "length", default: 30 t.integer "minimum_abstract_length", default: 0 t.integer "maximum_abstract_length", default: 500 t.string "color" t.string "description" + t.integer "program_id" end create_table "event_users", force: true do |t| @@ -211,32 +207,32 @@ ActiveRecord::Schema.define(version: 20151005161518) do end create_table "events", force: true do |t| - t.string "guid", null: false - t.integer "conference_id" + t.string "guid", null: false t.integer "event_type_id" - t.string "title", null: false + t.string "title", null: false t.string "subtitle" t.integer "time_slots" - t.string "state", default: "new", null: false - t.string "progress", default: "new", null: false + t.string "state", default: "new", null: false + t.string "progress", default: "new", null: false t.string "language" t.datetime "start_time" - t.text "abstract" - t.text "description" - t.boolean "public", default: true + t.text "abstract", limit: 16777215 + t.text "description", limit: 16777215 + t.boolean "public", default: true t.string "logo_file_name" t.string "logo_content_type" t.integer "logo_file_size" t.datetime "logo_updated_at" - t.text "proposal_additional_speakers" + t.text "proposal_additional_speakers", limit: 16777215 t.integer "track_id" t.integer "room_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "require_registration" t.integer "difficulty_level_id" t.integer "week" - t.boolean "is_highlight", default: false + t.boolean "is_highlight", default: false + t.integer "program_id" end create_table "events_registrations", id: false, force: true do |t| @@ -277,6 +273,13 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.datetime "updated_at" end + create_table "programs", force: true do |t| + t.integer "conference_id" + t.integer "rating", default: 0 + t.boolean "schedule_public", default: false + t.boolean "schedule_fluid", default: false + end + create_table "qanswers", force: true do |t| t.integer "question_id" t.integer "answer_id" @@ -291,8 +294,8 @@ ActiveRecord::Schema.define(version: 20151005161518) do create_table "question_types", force: true do |t| t.string "title" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "questions", force: true do |t| @@ -300,8 +303,8 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.integer "question_type_id" t.integer "conference_id" t.boolean "global" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "registration_periods", force: true do |t| @@ -316,12 +319,12 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.integer "conference_id" t.datetime "arrival" t.datetime "departure" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "dietary_choice_id" - t.text "other_dietary_choice" - t.text "other_special_needs" - t.boolean "attended", default: false + t.text "other_dietary_choice", limit: 16777215 + t.text "other_special_needs", limit: 16777215 + t.boolean "attended", default: false t.boolean "volunteer" t.integer "user_id" t.integer "week" @@ -339,28 +342,28 @@ ActiveRecord::Schema.define(version: 20151005161518) do create_table "roles", force: true do |t| t.string "name" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "description" t.integer "resource_id" t.string "resource_type" 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" + add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id", using: :btree + add_index "roles", ["name"], name: "index_roles_on_name", using: :btree create_table "roles_users", id: false, force: true do |t| t.integer "role_id" t.integer "user_id" end - add_index "roles_users", ["user_id", "role_id"], name: "index_roles_users_on_user_id_and_role_id" + 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| - t.string "guid", null: false - t.integer "conference_id" - t.string "name", null: false + t.string "guid", null: false + t.string "name", null: false t.integer "size" + t.integer "program_id" end create_table "social_events", force: true do |t| @@ -443,13 +446,13 @@ ActiveRecord::Schema.define(version: 20151005161518) do end create_table "tracks", force: true do |t| - t.string "guid", null: false - t.integer "conference_id" - t.string "name", null: false - t.text "description" + t.string "guid", null: false + t.string "name", null: false + t.text "description", limit: 16777215 t.string "color" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "program_id" end create_table "users", force: true do |t| @@ -467,8 +470,8 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.datetime "confirmed_at" t.datetime "confirmation_sent_at" t.string "unconfirmed_email" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "name" t.boolean "email_public" t.text "biography" @@ -487,10 +490,10 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.boolean "is_disabled", default: false end - add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true - add_index "users", ["email"], name: "index_users_on_email", unique: true - add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true - add_index "users", ["username"], name: "index_users_on_username", unique: true + add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree + add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree + add_index "users", ["username"], name: "index_users_on_username", unique: true, using: :btree create_table "vchoices", force: true do |t| t.integer "vday_id" @@ -501,8 +504,8 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.integer "conference_id" t.date "day" t.text "description" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "venues", force: true do |t| @@ -510,8 +513,8 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.string "name" t.string "website" t.text "description" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "photo_file_name" t.string "photo_content_type" t.integer "photo_file_size" @@ -526,16 +529,16 @@ ActiveRecord::Schema.define(version: 20151005161518) do end create_table "versions", force: true do |t| - t.string "item_type", null: false - t.integer "item_id", null: false - t.string "event", null: false + t.string "item_type", null: false + t.integer "item_id", null: false + t.string "event", null: false t.string "whodunnit" - t.text "object" - t.text "object_changes" + t.text "object", limit: 16777215 + t.text "object_changes", limit: 16777215 t.datetime "created_at" end - add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id" + add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree create_table "visits", force: true do |t| t.uuid "visitor_id" @@ -560,13 +563,13 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.datetime "started_at" end - add_index "visits", ["user_id"], name: "index_visits_on_user_id" + add_index "visits", ["user_id"], name: "index_visits_on_user_id", using: :btree create_table "votes", force: true do |t| t.integer "event_id" t.integer "rating" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "user_id" end @@ -574,8 +577,8 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.integer "conference_id" t.string "title", null: false t.text "description" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end end diff --git a/spec/controllers/admin/comments_controller_spec.rb b/spec/controllers/admin/comments_controller_spec.rb index ac75b189..759f1538 100644 --- a/spec/controllers/admin/comments_controller_spec.rb +++ b/spec/controllers/admin/comments_controller_spec.rb @@ -8,7 +8,7 @@ describe Admin::CommentsController, type: :controller do let!(:organizer_role) { create(:role, name: 'organizer', resource: conference) } let(:organizer) { create(:user, role_ids: organizer_role.id, last_sign_in_at: Time.now - 1.day) } let(:participant) { create(:user) } - let(:event) { create(:event, conference: conference) } + let(:event) { create(:event, program: conference.program) } let(:comment) { create(:comment, commentable_type: 'Event', commentable_id: event.id) } context 'not logged in user' do @@ -32,7 +32,7 @@ describe Admin::CommentsController, type: :controller do expect(assigns(:comments)).to be_a(Hash) # assigns(:comments).first returns an array of first pair key-value from hash. # Calling again 'first' returns the key, meaning the Conference object. - expect(assigns(:comments).first.first.title).to eq(comment.commentable.conference.title) + expect(assigns(:comments).first.first.title).to eq(comment.commentable.program.conference.title) end it 'has status 200: OK' do get :index diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb index 4e2f0d78..fd9f2282 100644 --- a/spec/controllers/admin/conferences_controller_spec.rb +++ b/spec/controllers/admin/conferences_controller_spec.rb @@ -165,9 +165,10 @@ describe Admin::ConferenceController do it 'assigns cfp_max an array with maximum weeks' do conference date = Date.new(2014, 05, 26) - conference.call_for_paper = create(:call_for_paper, - start_date: date, - end_date: date + 14) + conference.program.cfp = create(:cfp, + program: conference.program, + start_date: date, + end_date: date + 14) get :index expect(assigns(:cfp_weeks)).to match_array([1, 2, 3]) end diff --git a/spec/controllers/admin/programs_controller_spec.rb b/spec/controllers/admin/programs_controller_spec.rb new file mode 100644 index 00000000..4fe5952c --- /dev/null +++ b/spec/controllers/admin/programs_controller_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe Admin::ProgramsController, type: :controller do + + # It is necessary to use bang version of let to build roles before user + let(:conference) { create(:conference) } + let!(:first_user) { create(:user) } + let!(:organizer_role) { create(:role, name: 'organizer', resource: conference) } + let(:organizer) { create(:user, role_ids: organizer_role.id, last_sign_in_at: Time.now - 1.day) } + + context 'not logged in user' do + describe 'GET #show' do + it 'does not render admin/programs#show' do + get :show, conference_id: conference.short_title + expect(response).to redirect_to(user_session_path) + end + end + end + + context 'logged in as admin, organizer or cfp' do + before :each do + sign_in(organizer) + end + + describe 'PATCH #update' do + it 'redirects to admin/programs#index' do + patch :update, conference_id: conference.short_title, program: attributes_for(:program) + conference.program.reload + expect(response).to redirect_to admin_conference_program_path(conference.short_title) + end + end + end +end diff --git a/spec/factories/call_for_papers.rb b/spec/factories/cfp.rb similarity index 84% rename from spec/factories/call_for_papers.rb rename to spec/factories/cfp.rb index 09ec6d8e..14b3fbc5 100644 --- a/spec/factories/call_for_papers.rb +++ b/spec/factories/cfp.rb @@ -1,7 +1,8 @@ # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do - factory :call_for_paper do + factory :cfp do + program start_date { 1.day.ago } end_date { 6.days.from_now } end diff --git a/spec/factories/conferences.rb b/spec/factories/conferences.rb index c92c10c2..99bff268 100644 --- a/spec/factories/conferences.rb +++ b/spec/factories/conferences.rb @@ -7,11 +7,12 @@ FactoryGirl.define do timezone 'Amsterdam' start_date { Date.today } end_date { 6.days.from_now } + program + factory :full_conference do venue splashpage registration_period - call_for_paper after(:build) do |conference| conference.commercials << build(:conference_commercial, commercialable: conference) diff --git a/spec/factories/difficulty_levels.rb b/spec/factories/difficulty_levels.rb index af675c86..7a1e8da5 100644 --- a/spec/factories/difficulty_levels.rb +++ b/spec/factories/difficulty_levels.rb @@ -3,7 +3,6 @@ FactoryGirl.define do title 'Example Difficulty Level' description 'Lorem Ipsum dolsum' color '#ffffff' - conference + program end - end diff --git a/spec/factories/email_settings.rb b/spec/factories/email_settings.rb index 2ba04e4f..d10a6b51 100644 --- a/spec/factories/email_settings.rb +++ b/spec/factories/email_settings.rb @@ -8,8 +8,8 @@ FactoryGirl.define do send_on_confirmed_without_registration false send_on_conference_dates_updated true send_on_conference_registration_dates_updated true - send_on_call_for_papers_schedule_public true - send_on_call_for_papers_dates_updated true + send_on_program_schedule_public true + send_on_cfp_dates_updated true conference_dates_updated_body 'Sample Conference\n New Dates: January 17 - 21 2014' conference_dates_updated_subject 'Conference dates have been updated' conference_registration_dates_updated_subject 'Conference registration dates have been updated' @@ -19,9 +19,9 @@ FactoryGirl.define do venue_updated_body 'Venue has been Updated to Sample Location' registration_subject 'Lorem Ipsum Dolsum' registration_body 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit' - call_for_papers_dates_updated_subject 'Call for Papers dates have been updated' - call_for_papers_dates_updated_body 'Please checkout the new updates to submit your proposal for Sample Conference' - call_for_papers_schedule_public_subject 'Sample Conference Cfp schedule is Public' - call_for_papers_schedule_public_body 'Call for Papers schedule is Public.Checkout the link' + cfp_dates_updated_subject 'Call for Papers dates have been updated' + cfp_dates_updated_body 'Please checkout the new updates to submit your proposal for Sample Conference' + program_schedule_public_subject 'Sample Conference Cfp schedule is Public' + program_schedule_public_body 'Call for Papers schedule is Public.Checkout the link' end end diff --git a/spec/factories/event_types.rb b/spec/factories/event_types.rb index 2601783c..3b616fa9 100644 --- a/spec/factories/event_types.rb +++ b/spec/factories/event_types.rb @@ -6,7 +6,7 @@ FactoryGirl.define do length 30 minimum_abstract_length 0 maximum_abstract_length 500 - conference + program end end diff --git a/spec/factories/events.rb b/spec/factories/events.rb index 6dc89b22..4aac0e68 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -3,7 +3,7 @@ FactoryGirl.define do factory :event do sequence(:title) { |n| "The ##{n} talk you'll ever attend." } - conference + program abstract <<-EOS Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ante lacus, mollis non urna vitae, varius semper leo. Nulla ac nibh dui. Mauris @@ -35,7 +35,7 @@ FactoryGirl.define do # set an event_type if none is passed to the factory. # needs to be created here because otherwise it doesn't belong to the # same conference as the event - event.event_type ||= build(:event_type, conference: event.conference) + event.event_type ||= build(:event_type, program: event.program) end factory :event_full do @@ -44,9 +44,9 @@ FactoryGirl.define do room after(:build) do |event| event.commercials << build(:event_commercial, commercialable: event) - event.difficulty_level = build(:difficulty_level, conference: event.conference) - event.track = build(:track, conference: event.conference) - event.room = build(:room, conference: event.conference) + event.difficulty_level = build(:difficulty_level, program: event.program) + event.track = build(:track, program: event.program) + event.room = build(:room, program: event.program) event.comment_threads << build(:comment, commentable: event) end end diff --git a/spec/factories/program.rb b/spec/factories/program.rb new file mode 100644 index 00000000..2215a6eb --- /dev/null +++ b/spec/factories/program.rb @@ -0,0 +1,9 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :program do + schedule_public false + schedule_fluid false +# conference + end +end diff --git a/spec/factories/rooms.rb b/spec/factories/rooms.rb index 5bd18ebc..d2379112 100644 --- a/spec/factories/rooms.rb +++ b/spec/factories/rooms.rb @@ -3,7 +3,7 @@ FactoryGirl.define do factory :room do name 'Example Room' size 4 - conference + program factory :room_for_100 do name 'Room for 100' diff --git a/spec/factories/tracks.rb b/spec/factories/tracks.rb index 7f3e1ecf..03167789 100644 --- a/spec/factories/tracks.rb +++ b/spec/factories/tracks.rb @@ -3,7 +3,7 @@ FactoryGirl.define do name 'Example Track' description 'Lorem Ipsum dolsum' color '#ffffff' - conference + program end end diff --git a/spec/features/ability_spec.rb b/spec/features/ability_spec.rb index b2b38cdf..94ecd36f 100644 --- a/spec/features/ability_spec.rb +++ b/spec/features/ability_spec.rb @@ -37,22 +37,23 @@ feature 'Has correct abilities' do 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('Events', href: "/admin/conference/#{conference1.short_title}/events") + expect(page).to have_link('Events', href: "/admin/conference/#{conference1.short_title}/program/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('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('Rooms', href: "/admin/conference/#{conference1.short_title}/rooms") + expect(page).to have_link('Rooms', href: "/admin/conference/#{conference1.short_title}/program/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('Tickets', href: "/admin/conference/#{conference1.short_title}/tickets") 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}/call_for_paper") - 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('Program', href: "/admin/conference/#{conference1.short_title}/program") + expect(page).to have_link('Call for Papers', href: "/admin/conference/#{conference1.short_title}/program/cfp") + expect(page).to have_link('Tracks', href: "/admin/conference/#{conference1.short_title}/program/tracks") + expect(page).to have_link('Event Types', href: "/admin/conference/#{conference1.short_title}/program/event_types") + expect(page).to have_link('Difficulty Levels', href: "/admin/conference/#{conference1.short_title}/program/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") @@ -65,8 +66,8 @@ feature 'Has correct abilities' do 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_program_events_path(conference1.short_title) + expect(current_path).to eq(admin_conference_program_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)) @@ -93,8 +94,8 @@ feature 'Has correct abilities' do visit admin_conference_emails_path(conference1.short_title) expect(current_path).to eq(admin_conference_emails_path(conference1.short_title)) - visit new_admin_conference_call_for_paper_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_call_for_paper_path(conference1.short_title)) + visit new_admin_conference_program_cfp_path(conference1.short_title) + expect(current_path).to eq(new_admin_conference_program_cfp_path(conference1.short_title)) visit admin_conference_questions_path(conference1.short_title) expect(current_path).to eq(admin_conference_questions_path(conference1.short_title)) @@ -113,22 +114,23 @@ feature 'Has correct abilities' do expect(page).to have_text('Basics') 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 have_link('Events', href: "/admin/conference/#{conference2.short_title}/events") + expect(page).to have_link('Events', href: "/admin/conference/#{conference2.short_title}/program/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('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('Rooms', href: "/admin/conference/#{conference2.short_title}/rooms") + expect(page).to have_link('Rooms', href: "/admin/conference/#{conference2.short_title}/program/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}/call_for_paper") - 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 have_link('Program', href: "/admin/conference/#{conference2.short_title}/program") + expect(page).to have_link('Call for Papers', href: "/admin/conference/#{conference2.short_title}/program/cfp") + expect(page).to have_link('Tracks', href: "/admin/conference/#{conference2.short_title}/program/tracks") + expect(page).to have_link('Event Types', href: "/admin/conference/#{conference2.short_title}/program/event_types") + expect(page).to have_link('Difficulty Levels', href: "/admin/conference/#{conference2.short_title}/program/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") @@ -141,8 +143,8 @@ feature 'Has correct abilities' do visit admin_conference_registrations_path(conference2.short_title) expect(current_path).to eq(admin_conference_registrations_path(conference2.short_title)) - visit admin_conference_events_path(conference2.short_title) - expect(current_path).to eq(admin_conference_events_path(conference2.short_title)) + visit admin_conference_program_events_path(conference2.short_title) + expect(current_path).to eq(admin_conference_program_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)) @@ -165,8 +167,8 @@ feature 'Has correct abilities' do visit admin_conference_emails_path(conference2.short_title) expect(current_path).to eq(admin_conference_emails_path(conference2.short_title)) - visit new_admin_conference_call_for_paper_path(conference2.short_title) - expect(current_path).to eq(new_admin_conference_call_for_paper_path(conference2.short_title)) + visit new_admin_conference_program_cfp_path(conference2.short_title) + expect(current_path).to eq(new_admin_conference_program_cfp_path(conference2.short_title)) visit admin_conference_questions_path(conference2.short_title) expect(current_path).to eq(root_path) @@ -185,22 +187,23 @@ feature 'Has correct abilities' do expect(page).to have_text('Basics') 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('Events', href: "/admin/conference/#{conference3.short_title}/events") + expect(page).to_not have_link('Events', href: "/admin/conference/#{conference3.short_title}/program/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('Rooms', href: "/admin/conference/#{conference3.short_title}/program/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}/call_for_paper") - 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_not have_link('Program', href: "/admin/conference/#{conference3.short_title}/program") + expect(page).to_not have_link('Call for papers', href: "/admin/conference/#{conference3.short_title}/program/cfp") + expect(page).to_not have_link('Tracks', href: "/admin/conference/#{conference3.short_title}/program/tracks") + expect(page).to_not have_link('Event types', href: "/admin/conference/#{conference3.short_title}/program/event_types") + expect(page).to_not have_link('Difficulty levels', href: "/admin/conference/#{conference3.short_title}/program/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") @@ -213,7 +216,7 @@ feature 'Has correct abilities' do 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) + visit admin_conference_program_events_path(conference3.short_title) expect(current_path).to eq(root_path) visit admin_conference_schedule_path(conference3.short_title) @@ -237,7 +240,7 @@ feature 'Has correct abilities' do visit admin_conference_emails_path(conference3.short_title) expect(current_path).to eq(root_path) - visit new_admin_conference_call_for_paper_path(conference3.short_title) + visit new_admin_conference_program_cfp_path(conference3.short_title) expect(current_path).to eq(root_path) visit admin_conference_questions_path(conference3.short_title) diff --git a/spec/features/cfp_spec.rb b/spec/features/cfp_spec.rb index d9610dcf..6f1539da 100644 --- a/spec/features/cfp_spec.rb +++ b/spec/features/cfp_spec.rb @@ -8,13 +8,13 @@ feature Conference do shared_examples 'add and update cfp' do scenario 'adds a new cfp', feature: true, js: true do - expected_count = CallForPaper.count + 1 + expected_count = Cfp.count + 1 sign_in organizer - visit new_admin_conference_call_for_paper_path(conference.short_title) + visit new_admin_conference_program_cfp_path(conference.short_title) - click_button 'Create Call for paper' + click_button 'Create Cfp' expect(flash). to eq('Creating the call for papers failed. ' + @@ -26,32 +26,29 @@ feature Conference do page.execute_script( "$('#conference-end-datepicker').val('#{(today + 6).strftime('%d/%m/%Y')}')") - fill_in 'call_for_paper_rating', with: '4' - - click_button 'Create Call for paper' + click_button 'Create Cfp' # Validations expect(flash). to eq('Call for papers successfully created.') expect(find('#start_date').text).to eq(today.strftime('%A, %B %-d. %Y')) expect(find('#end_date').text).to eq((today + 6).strftime('%A, %B %-d. %Y')) - expect(find('#rating').text).to eq('4') - expect(CallForPaper.count).to eq(expected_count) + expect(Cfp.count).to eq(expected_count) end scenario 'update cfp', feature: true, js: true do - conference.call_for_paper = create(:call_for_paper) - expected_count = CallForPaper.count + conference.program.cfp = create(:cfp) + expected_count = Cfp.count sign_in organizer - visit admin_conference_call_for_paper_path(conference.short_title) + visit admin_conference_program_cfp_path(conference.short_title) click_link 'Edit' # Validate update with empty start date will not saved page.execute_script( "$('#conference-start-datepicker').val('')") - click_button 'Update Call for paper' + click_button 'Update Cfp' expect(flash). to eq('Updating call for papers failed. ' + "Start date can't be blank.") @@ -63,16 +60,14 @@ feature Conference do page.execute_script( "$('#conference-end-datepicker').val('#{(today + 14).strftime('%d/%m/%Y')}')") - fill_in 'call_for_paper_rating', with: '0' - click_button 'Update Call for paper' + click_button 'Update Cfp' # Validations expect(flash). to eq('Call for papers successfully updated.') expect(find('#start_date').text).to eq(today.strftime('%A, %B %-d. %Y')) expect(find('#end_date').text).to eq((today + 14).strftime('%A, %B %-d. %Y')) - expect(find('#rating').text).to eq('0') - expect(CallForPaper.count).to eq(expected_count) + expect(Cfp.count).to eq(expected_count) end end diff --git a/spec/features/commercials_spec.rb b/spec/features/commercials_spec.rb index fde330c1..df50e260 100644 --- a/spec/features/commercials_spec.rb +++ b/spec/features/commercials_spec.rb @@ -42,7 +42,7 @@ feature Commercial do end context 'in public area' do - let!(:event) { create(:event, conference: conference, title: 'Example Proposal') } + let!(:event) { create(:event, program: conference.program, title: 'Example Proposal') } before(:each) do event.event_users = [create(:event_user, @@ -58,8 +58,8 @@ feature Commercial do sign_out end - scenario 'adds a commercial of an event', feature: true, js: true do - visit edit_conference_proposal_path(conference.short_title, event.id) + scenario 'adds a valid commercial of an event', feature: true, js: true do + visit edit_conference_program_proposal_path(conference.short_title, event.id) click_link 'Commercials' fill_in 'commercial_url', with: 'https://www.youtube.com/watch?v=M9bq_alk-sw' @@ -75,7 +75,7 @@ feature Commercial do commercial = create(:commercial, commercialable_id: event.id, commercialable_type: 'Event') - visit edit_conference_proposal_path(conference.short_title, event.id) + visit edit_conference_program_proposal_path(conference.short_title, event.id) click_link 'Commercials' fill_in "commercial_url_#{commercial.id}", with: 'https://www.youtube.com/watch?v=M9bq_alk-sw' click_button 'Update' @@ -89,7 +89,7 @@ feature Commercial do create(:commercial, commercialable_id: event.id, commercialable_type: 'Event') - visit edit_conference_proposal_path(conference.short_title, event.id) + visit edit_conference_program_proposal_path(conference.short_title, event.id) click_link 'Commercials' click_link 'Delete' page.driver.network_traffic diff --git a/spec/features/difficulty_levels_spec.rb b/spec/features/difficulty_levels_spec.rb index d670d29a..c155e672 100644 --- a/spec/features/difficulty_levels_spec.rb +++ b/spec/features/difficulty_levels_spec.rb @@ -9,7 +9,7 @@ feature DifficultyLevel do scenario 'adds difficulty level', feature: true, js: true do sign_in organizer - visit admin_conference_difficulty_levels_path( + visit admin_conference_program_difficulty_levels_path( conference_id: conference.short_title) # Add difficulty level @@ -32,9 +32,9 @@ feature DifficultyLevel do scenario 'updates difficulty level', feature: true, js: true do - conference.difficulty_levels << create(:difficulty_level) + conference.program.difficulty_levels << create(:difficulty_level) sign_in organizer - visit admin_conference_difficulty_levels_path( + visit admin_conference_program_difficulty_levels_path( conference_id: conference.short_title) # Remove difficulty level diff --git a/spec/features/event_types_spec.rb b/spec/features/event_types_spec.rb index b47cb73e..fee4f07b 100644 --- a/spec/features/event_types_spec.rb +++ b/spec/features/event_types_spec.rb @@ -9,7 +9,7 @@ feature EventType do scenario 'adds and updates event type', feature: true, js: true do sign_in organizer - visit admin_conference_event_types_path( + visit admin_conference_program_event_types_path( conference_id: conference.short_title) within('table#event_types') do diff --git a/spec/features/program_spec.rb b/spec/features/program_spec.rb new file mode 100644 index 00000000..b32a2854 --- /dev/null +++ b/spec/features/program_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +feature Program do + + let!(:conference) { create(:conference) } + let!(:program) { conference.program } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } + + describe 'edit program' do + before :each do + sign_in organizer + end + + scenario 'changes rating', feature: true, js: true do + visit admin_conference_program_path(conference.short_title) + + click_link 'Edit' + + fill_in 'program_rating', with: '4' + + click_button 'Update Program' + + # Validations + expect(flash). + to eq('The program was successfully updated.') + expect(find('#rating').text).to eq('4') + end + end +end diff --git a/spec/features/proposal_spec.rb b/spec/features/proposal_spec.rb index 43f4a5f2..3c5890ab 100644 --- a/spec/features/proposal_spec.rb +++ b/spec/features/proposal_spec.rb @@ -1,7 +1,8 @@ require 'spec_helper' feature Event do - let!(:conference) { create(:conference, call_for_paper: create(:call_for_paper)) } + let!(:conference) { create(:conference) } + let!(:cfp) { create(:cfp, program_id: conference.program.id) } let!(:organizer_role) { create(:organizer_role, resource: conference) } let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) } let!(:participant) { create(:user) } @@ -10,7 +11,7 @@ feature Event do before(:each) do @options = {} @options[:send_mail] = 'false' - @event = create(:event, conference: conference, title: 'Example Proposal') + @event = create(:event, program: conference.program, title: 'Example Proposal') end after(:each) do @@ -23,7 +24,7 @@ feature Event do end scenario 'rejects a proposal', feature: true, js: true do - visit admin_conference_events_path(conference.short_title) + visit admin_conference_program_events_path(conference.short_title) expect(page.has_content?('Example Proposal')).to be true click_button 'New' @@ -34,7 +35,7 @@ feature Event do end scenario 'accepts a proposal', feature: true, js: true do - visit admin_conference_events_path(conference.short_title) + visit admin_conference_program_events_path(conference.short_title) expect(page.has_content?('Example Proposal')).to be true click_button 'New' @@ -47,7 +48,7 @@ feature Event do scenario 'restarts review of a proposal', feature: true, js: true do @event.reject!(@options) - visit admin_conference_events_path(conference.short_title) + visit admin_conference_program_events_path(conference.short_title) expect(page.has_content?('Example Proposal')).to be true click_button 'Rejected' @@ -71,7 +72,7 @@ feature Event do expected_count_event = Event.count + 1 expected_count_user = User.count + 1 - visit new_conference_proposal_path(conference.short_title) + visit new_conference_program_proposal_path(conference.short_title) fill_in 'user_username', with: 'Test User' fill_in 'user_email', with: 'testuser@osem.io' @@ -90,11 +91,12 @@ feature Event do end scenario 'update a proposal' do - proposal = create(:event) + conference = create(:conference) + proposal = create(:event, program: conference.program) sign_in proposal.submitter - visit edit_conference_proposal_path(proposal.conference.short_title, proposal) + visit edit_conference_program_proposal_path(proposal.program.conference.short_title, proposal) fill_in 'event_subtitle', with: 'My event subtitle' select('Easy', from: 'event[difficulty_level_id]') @@ -106,7 +108,7 @@ feature Event do scenario 'signed_in user submits a valid proposal', feature: true, js: true do sign_in participant_without_bio expected_count = Event.count + 1 - visit conference_proposal_index_path(conference.short_title) + visit conference_program_proposal_index_path(conference.short_title) click_link 'New Proposal' fill_in 'event_title', with: 'Example Proposal' @@ -120,13 +122,13 @@ feature Event do click_button 'Create Proposal' expect(flash).to eq('Proposal was successfully submitted.') - expect(current_path).to eq(conference_proposal_index_path(conference.short_title)) + expect(current_path).to eq(conference_program_proposal_index_path(conference.short_title)) expect(Event.count).to eq(expected_count) end scenario 'confirms a proposal', feature: true, js: true do sign_in participant - visit conference_proposal_index_path(conference.short_title) + visit conference_program_proposal_index_path(conference.short_title) expect(page.has_content?('Example Proposal')).to be true expect(@event.state).to eq('unconfirmed') click_link "confirm_proposal_#{@event.id}" @@ -139,7 +141,7 @@ feature Event do scenario 'withdraw a proposal', feature: true, js: true do sign_in participant @event.confirm! - visit conference_proposal_index_path(conference.short_title) + visit conference_program_proposal_index_path(conference.short_title) expect(page.has_content?('Example Proposal')).to be true click_link "delete_proposal_#{@event.id}" expect(flash).to eq('Proposal was successfully withdrawn.') diff --git a/spec/features/rooms_spec.rb b/spec/features/rooms_spec.rb index 96480351..653f72ac 100644 --- a/spec/features/rooms_spec.rb +++ b/spec/features/rooms_spec.rb @@ -8,7 +8,7 @@ feature Room do shared_examples 'rooms' do scenario 'adds a room', feature: true, js: true do sign_in organizer - visit admin_conference_rooms_path( + visit admin_conference_program_rooms_path( conference_id: conference.short_title) expect(page.has_no_table?('#rooms')).to be true @@ -30,9 +30,9 @@ feature Room do end scenario 'updates a room', feature: true, js: true do - room = create(:room, conference_id: conference.id) + room = create(:room, program_id: conference.program.id) sign_in organizer - visit edit_admin_conference_room_path( + visit edit_admin_conference_program_room_path( conference_id: conference.short_title, id: room.id) fill_in 'room_name', with: 'Auditorium' diff --git a/spec/features/tracks_spec.rb b/spec/features/tracks_spec.rb index ecaf0789..f66bbb87 100644 --- a/spec/features/tracks_spec.rb +++ b/spec/features/tracks_spec.rb @@ -10,7 +10,7 @@ feature Track do sign_in organizer - visit admin_conference_tracks_path(conference_id: conference.short_title) + visit admin_conference_program_tracks_path(conference_id: conference.short_title) click_link 'New Track' fill_in 'track_name', with: 'Distribution' @@ -27,10 +27,10 @@ feature Track do end scenario 'deletes a track', feature: true, js: true do - track = create(:track, conference_id: conference.id) + track = create(:track, program_id: conference.program.id) sign_in organizer - visit admin_conference_tracks_path(conference_id: conference.short_title) + visit admin_conference_program_tracks_path(conference_id: conference.short_title) click_link 'Delete' @@ -43,10 +43,10 @@ feature Track do end scenario 'updates a track', feature: true, js: true do - create(:track, conference_id: conference.id) + create(:track, program_id: conference.program.id) sign_in organizer - visit admin_conference_tracks_path(conference_id: conference.short_title) + visit admin_conference_program_tracks_path(conference_id: conference.short_title) click_link 'Edit' fill_in 'track_name', with: 'Distribution' diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 192b8dac..011c8b39 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -11,7 +11,8 @@ describe 'User' do let(:user){ nil } let(:conference_not_public) { create(:conference, splashpage: create(:splashpage, public: false)) } - let(:conference_public) { create(:full_conference, splashpage: create(:splashpage, public: true), call_for_paper: create(:call_for_paper, schedule_public: true)) } + let(:conference_public) { create(:full_conference, splashpage: create(:splashpage, public: true)) } + let!(:conference_public_cfp) { create(:cfp, program: conference_public.program) } let(:event_confirmed) { create(:event, state: 'confirmed') } let(:event_unconfirmed) { create(:event) } @@ -28,7 +29,11 @@ describe 'User' do it{ should be_able_to(:show, conference_public)} it{ should_not be_able_to(:show, conference_not_public)} - it{ should be_able_to(:schedule, conference_public)} + it do + conference_public.program.schedule_public = true + conference_public.program.save + should be_able_to(:schedule, conference_public) + end it{ should_not be_able_to(:schedule, conference_not_public)} it{ should be_able_to(:show, event_confirmed)} @@ -89,12 +94,13 @@ describe 'User' 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(: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, conference: my_conference) } - let(:other_event) { create(:event_full, conference: conference_public) } + let(:event) { create(:event_full, program: my_conference.program) } + let(:other_event) { create(:event_full, program: conference_public.program) } it{ should be_able_to([:create, :new], Conference) } it{ should be_able_to(:manage, my_conference) } @@ -115,8 +121,8 @@ describe 'User' do it{ should_not be_able_to(:manage, conference_public.registration_period) } it{ should be_able_to(:manage, my_conference.questions.first) } it{ should_not be_able_to(:manage, conference_public.questions.first) } - it{ should be_able_to(:manage, my_conference.call_for_paper) } - it{ should_not be_able_to(:manage, conference_public.call_for_paper) } + it{ should be_able_to(:manage, my_conference.program.cfp) } + it{ should_not be_able_to(:manage, conference_public.program.cfp) } it{ should be_able_to(:manage, my_conference.venue) } it{ should_not be_able_to(:manage, conference_public.venue) } it{ should be_able_to(:manage, my_conference.lodgings.first) } @@ -147,12 +153,13 @@ describe 'User' 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(: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, conference: my_conference) } - let(:other_event) { create(:event_full, 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(:manage, my_conference) } @@ -173,8 +180,8 @@ describe 'User' do it{ should_not be_able_to(:manage, conference_public.registration_period) } it{ should_not be_able_to(:manage, my_conference.questions.first) } it{ should_not be_able_to(:manage, conference_public.questions.first) } - it{ should be_able_to(:manage, my_conference.call_for_paper) } - it{ should_not be_able_to(:manage, conference_public.call_for_paper) } + it{ should be_able_to(:manage, my_conference.program.cfp) } + it{ should_not be_able_to(:manage, conference_public.program.cfp) } it{ should_not be_able_to(:manage, my_conference.venue) } it{ should be_able_to(:show, my_conference.venue) } it{ should_not be_able_to(:manage, conference_public.venue) } @@ -206,12 +213,13 @@ describe 'User' 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(: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, conference: my_conference) } - let(:other_event) { create(:event_full, 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(:manage, my_conference) } @@ -232,8 +240,8 @@ describe 'User' do it{ should_not be_able_to(:manage, conference_public.registration_period) } it{ should be_able_to(:manage, my_conference.questions.first) } it{ should_not be_able_to(:manage, conference_public.questions.first) } - it{ should_not be_able_to(:manage, my_conference.call_for_paper) } - it{ should_not be_able_to(:manage, conference_public.call_for_paper) } + it{ should_not be_able_to(:manage, my_conference.program.cfp) } + it{ should_not be_able_to(:manage, conference_public.program.cfp) } it{ should_not be_able_to(:manage, my_conference.venue) } it{ should_not be_able_to(:show, my_conference.venue) } it{ should_not be_able_to(:manage, conference_public.venue) } @@ -265,12 +273,13 @@ describe 'User' 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(: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, conference: my_conference) } - let(:other_event) { create(:event_full, 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(:manage, my_conference) } @@ -291,8 +300,8 @@ describe 'User' do it{ should_not be_able_to(:manage, conference_public.registration_period) } it{ should_not be_able_to(:manage, my_conference.questions.first) } it{ should_not be_able_to(:manage, conference_public.questions.first) } - it{ should_not be_able_to(:manage, my_conference.call_for_paper) } - it{ should_not be_able_to(:manage, conference_public.call_for_paper) } + it{ should_not be_able_to(:manage, my_conference.program.cfp) } + it{ should_not be_able_to(:manage, conference_public.program.cfp) } it{ should_not be_able_to(:manage, my_conference.venue) } it{ should_not be_able_to(:show, my_conference.venue) } it{ should_not be_able_to(:manage, conference_public.venue) } diff --git a/spec/models/cfp_spec.rb b/spec/models/cfp_spec.rb index 122dca07..f71f7cbe 100644 --- a/spec/models/cfp_spec.rb +++ b/spec/models/cfp_spec.rb @@ -1,38 +1,100 @@ require 'spec_helper' -describe CallForPaper do +describe Cfp do let!(:conference) { create(:conference, end_date: Date.today) } + let!(:cfp) { build(:cfp, start_date: Date.today - 2, end_date: Date.today - 1, program_id: conference.program.id) } describe '#before_end_of_conference' do describe 'fails to save cfp' do it 'when cfp end_date is after conference end_date' do - cfp = build(:call_for_paper, end_date: Date.today + 1, conference_id: conference.id) - expect(cfp.valid?).to be false + cfp.end_date = Date.today + 1 + expect(cfp.valid?).to be false end it 'when cfp start_date is after conference end_date' do - cfp = build(:call_for_paper, end_date: Date.today + 1, conference_id: conference.id) - expect(cfp.valid?).to be false + cfp.start_date = Date.today + 1 + expect(cfp.valid?).to be false end end describe 'successfully saves cfp' do - it 'when cfp end_date and start_date are not after conference end_date' do - cfp = build(:call_for_paper, start_date: Date.today - 2, end_date: Date.today - 1, conference_id: conference.id) - expect(cfp.valid?).to be true + it 'when cfp end_date and start_date are before the conference end_date' do + expect(cfp.valid?).to be true end end end describe '#start_after_end_date' do - it 'fails when cfp start_date is after cfp end_date' do - cfp = build(:call_for_paper, start_date: Date.today - 1, end_date: Date.today - 2, conference_id: conference.id) - expect(cfp.valid?).to be false + it 'succeeds when cfp start_date is after cfp end_date' do + expect(cfp.valid?).to be true end - it 'succeeds when cfp start_date is after cfp end_date' do - cfp = build(:call_for_paper, start_date: Date.today - 2, end_date: Date.today - 1, conference_id: conference.id) - expect(cfp.valid?).to be true + it 'fails when cfp start_date is after cfp end_date' do + cfp.start_date = Date.today + expect(cfp.valid?).to be false + end + end + + describe '#notify_on_cfp_date_update?' do + before :each do + email_settings = conference.email_settings + email_settings.send_on_cfp_dates_updates = true + email_settings.cfp_dates_updates_subject = 'subject' + email_settings.cfp_dates_updates_template = 'body text' + email_settings.save! + + cfp.save! + end + + describe 'returns true' do + it 'when end_date changed' do + cfp.end_date = Date.today + expect(cfp.start_date_changed?).to eq false + expect(cfp.end_date_changed?).to eq true + expect(cfp.notify_on_cfp_date_update?).to eq true + end + + it 'when start_date changed' do + cfp.start_date = Date.today + expect(cfp.end_date_changed?).to eq false + expect(cfp.start_date_changed?).to eq true + expect(cfp.notify_on_cfp_date_update?).to eq true + end + end + + describe 'returns false' do + it 'when there is no change in cfp dates' do + expect(cfp.start_date_changed?).to eq false + expect(cfp.end_date_changed?).to eq false + expect(cfp.notify_on_cfp_date_update?).to eq false + end + + it 'when send_on_cfp_dates_updates is not set' do + conference.email_settings.send_on_cfp_dates_updates = false + conference.email_settings.save! + cfp.end_date = Date.today + + expect(cfp.end_date_changed?).to eq true + expect(cfp.notify_on_cfp_date_update?).to eq false + end + + it 'when cfp_dates_updates_subject is not set' do + conference.email_settings.cfp_dates_updates_subject = '' + conference.email_settings.save! + cfp.end_date = Date.today + + expect(cfp.end_date_changed?).to eq true + expect(cfp.notify_on_cfp_date_update?).to eq false + end + + it 'when cfp_dates_updates_template is not set' do + conference.email_settings.cfp_dates_updates_template = '' + conference.email_settings.save! + cfp.end_date = Date.today + + expect(cfp.end_date_changed?).to eq true + expect(cfp.notify_on_cfp_date_update?).to eq false + end end end end diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb index d5ffcbca..caa3e6ba 100755 --- a/spec/models/conference_spec.rb +++ b/spec/models/conference_spec.rb @@ -48,26 +48,26 @@ describe Conference do subject.start_date = Date.today + 6.weeks subject.end_date = Date.today + 7.weeks subject.save - subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 3.weeks) + subject.program.cfp = create(:cfp, start_date: Date.today - 3.weeks) - create(:event, conference: subject, created_at: Date.today) + create(:event, program: subject.program, created_at: Date.today) options = {} options[:send_mail] = 'false' - withdrawn = create(:event, conference: subject) + withdrawn = create(:event, program: subject.program) withdrawn.withdraw! - unconfirmed = create(:event, conference: subject) + unconfirmed = create(:event, program: subject.program) unconfirmed.accept!(options) - rejected = create(:event, conference: subject) + rejected = create(:event, program: subject.program) rejected.reject!(options) - confirmed = create(:event, conference: subject) + confirmed = create(:event, program: subject.program) confirmed.accept!(options) confirmed.confirm! - canceled = create(:event, conference: subject) + canceled = create(:event, program: subject.program) canceled.accept!(options) canceled.cancel! @@ -115,11 +115,11 @@ describe Conference do } subject.events_per_week = db_data subject.save - subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 3.weeks) + subject.program.cfp = create(:cfp, start_date: Date.today - 3.weeks) - create(:event, conference: subject, created_at: Date.today) - unconfirmed = create(:event, conference: subject) - confirmed = create(:event, conference: subject) + create(:event, program: subject.program, created_at: Date.today) + unconfirmed = create(:event, program: subject.program) + confirmed = create(:event, program: subject.program) options = {} options[:send_mail] = 'false' unconfirmed.accept!(options) @@ -186,9 +186,9 @@ describe Conference do subject.events_per_week = db_data subject.save - subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 2.weeks) + subject.program.cfp = create(:cfp, start_date: Date.today - 2.weeks) - create(:event, conference: subject, created_at: Date.today - 2.weeks) + create(:event, program: subject.program, created_at: Date.today - 2.weeks) result = { 'Submitted' => [1, 1, 1], @@ -203,8 +203,8 @@ describe Conference do subject.start_date = Date.today + 6.weeks subject.end_date = Date.today + 7.weeks subject.save - subject.call_for_paper = create(:call_for_paper, start_date: Date.today) - create(:event, conference: subject) + subject.program.cfp = create(:cfp, start_date: Date.today) + create(:event, program: subject.program) result = { 'Submitted' => [1], @@ -220,11 +220,11 @@ describe Conference do subject.start_date = Date.today + 6.weeks subject.end_date = Date.today + 7.weeks subject.save - subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 3.weeks) + subject.program.cfp = create(:cfp, start_date: Date.today - 3.weeks) - create(:event, conference: subject, created_at: Date.today) - unconfirmed = create(:event, conference: subject) - confirmed = create(:event, conference: subject) + create(:event, program: subject.program, created_at: Date.today) + unconfirmed = create(:event, program: subject.program) + confirmed = create(:event, program: subject.program) options = {} options[:send_mail] = 'false' unconfirmed.accept!(options) @@ -258,9 +258,9 @@ describe Conference do subject.events_per_week = db_data subject.save - subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 3.weeks) + subject.program.cfp = create(:cfp, start_date: Date.today - 3.weeks) - create(:event, conference: subject, created_at: Date.today - 3.weeks) + create(:event, program: subject.program, created_at: Date.today - 3.weeks) result = { 'Submitted' => [1, 1, 1, 1], @@ -278,7 +278,7 @@ describe Conference do let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } it 'calculates correct hash with top submitters' do - event = create(:event, conference: subject) + event = create(:event, program: subject.program) result = { event.submitter => 1 } @@ -286,11 +286,11 @@ describe Conference do end it 'returns the submitter ordered by submissions' do - e1 = create(:event, conference: subject) + e1 = create(:event, program: subject.program) - e2 = create(:event, conference: subject) - e3 = create(:event, conference: subject) - e4 = create(:event, conference: subject) + e2 = create(:event, program: subject.program) + e3 = create(:event, program: subject.program) + e4 = create(:event, program: subject.program) e3.event_users = [create(:event_user, user: e2.submitter, event_role: 'submitter')] e4.event_users = [create(:event_user, user: e2.submitter, event_role: 'submitter')] @@ -337,7 +337,7 @@ describe Conference do it 'returns 10 if there is 1 submissions of 10' do target = build(:target, target_count: 10, unit: Target.units[:submissions]) subject.targets = [target] - subject.events = [create(:event)] + subject.program.events = [create(:event)] result = { "10 Submissions by #{target.due_date}" => '10' } @@ -356,7 +356,7 @@ describe Conference do it 'returns 10 if there is 30 program minutes of 300' do target = build(:target, target_count: 300, unit: Target.units[:program_minutes]) subject.targets = [target] - subject.events = [create(:event)] + subject.program.events = [create(:event)] result = { "300 Program minutes by #{target.due_date}" => '10' } @@ -372,10 +372,10 @@ describe Conference do describe '#actual_program_minutes' do it 'calculates correct values with events' do - create(:event, conference: subject, event_type: @long) - create(:event, conference: subject, event_type: @long) - create(:event, conference: subject, event_type: @short) - create(:event, conference: subject, event_type: @short) + create(:event, program: subject.program, event_type: @long) + create(:event, program: subject.program, event_type: @long) + create(:event, program: subject.program, event_type: @short) + create(:event, program: subject.program, event_type: @short) result_in_hours = 4 result_in_minutes = 220 expect(subject.current_program_hours).to eq(result_in_hours) @@ -392,10 +392,10 @@ describe Conference do describe '#new_program_minutes' do it 'calculates correct values with events' do - create(:event, conference: subject, event_type: @long, created_at: Time.now - 3.days) - create(:event, conference: subject, event_type: @long) - create(:event, conference: subject, event_type: @short, created_at: Time.now - 3.days) - create(:event, conference: subject, event_type: @short) + create(:event, program: subject.program, event_type: @long, created_at: Time.now - 3.days) + create(:event, program: subject.program, event_type: @long) + create(:event, program: subject.program, event_type: @short, created_at: Time.now - 3.days) + create(:event, program: subject.program, event_type: @short) result_in_hours = 2 result_in_minutes = 110 expect(subject.new_program_hours(Time.now - 5.minutes)).to eq(result_in_hours) @@ -420,9 +420,9 @@ describe Conference do describe '#difficulty_levels_distribution' do it 'calculates correct for different difficulty levels' do - create(:event, conference: subject, difficulty_level: @easy) - create(:event, conference: subject, difficulty_level: @easy) - create(:event, conference: subject, difficulty_level: @hard) + create(:event, program: subject.program, difficulty_level: @easy) + create(:event, program: subject.program, difficulty_level: @easy) + create(:event, program: subject.program, difficulty_level: @hard) result = {} result['Hard'] = { 'value' => 1, @@ -436,7 +436,7 @@ describe Conference do end it 'calculates correct for one difficulty levels' do - create(:event, conference: subject, difficulty_level: @easy) + create(:event, program: subject.program, difficulty_level: @easy) result = {} result['Easy'] = { 'value' => 1, @@ -453,18 +453,18 @@ describe Conference do describe '#difficulty_levels_distribution_confirmed' do it 'calculates correct for different difficulty levels without confirmed' do - create(:event, conference: subject, difficulty_level: @easy) - create(:event, conference: subject, difficulty_level: @easy) - create(:event, conference: subject, difficulty_level: @hard) + create(:event, program: subject.program, difficulty_level: @easy) + create(:event, program: subject.program, difficulty_level: @easy) + create(:event, program: subject.program, difficulty_level: @hard) result = {} expect(subject.difficulty_levels_distribution(:confirmed)).to eq(result) end it 'calculates correct for different difficulty levels with confirmed' do - confirmed_easy = create(:event, conference: subject, difficulty_level: @easy) - create(:event, conference: subject, difficulty_level: @easy) - confirmed_hard = create(:event, conference: subject, difficulty_level: @hard) + confirmed_easy = create(:event, program: subject.program, difficulty_level: @easy) + create(:event, program: subject.program, difficulty_level: @easy) + confirmed_hard = create(:event, program: subject.program, difficulty_level: @hard) options = {} options[:send_mail] = 'false' @@ -486,7 +486,7 @@ describe Conference do end it 'calculates correct for one difficulty levels' do - confirmed = create(:event, conference: subject, difficulty_level: @easy) + confirmed = create(:event, program: subject.program, difficulty_level: @easy) options = {} options[:send_mail] = 'false' confirmed.accept!(options) @@ -510,15 +510,15 @@ describe Conference do describe 'event type distribution' do before do subject.email_settings = create(:email_settings) - @workshop = create(:event_type, title: 'Workshop', color: '#000000', conference: subject) - @lecture = create(:event_type, title: 'Lecture', color: '#ffffff', conference: subject) + @workshop = create(:event_type, title: 'Workshop', color: '#000000', program: subject.program) + @lecture = create(:event_type, title: 'Lecture', color: '#ffffff', program: subject.program) end describe '#event_type_distribution' do it 'calculates correct for different event types' do - create(:event, conference: subject, event_type: @workshop) - create(:event, conference: subject, event_type: @workshop) - create(:event, conference: subject, event_type: @lecture) + create(:event, program: subject.program, event_type: @workshop) + create(:event, program: subject.program, event_type: @workshop) + create(:event, program: subject.program, event_type: @lecture) result = {} result['Workshop'] = { 'value' => 2, @@ -532,7 +532,7 @@ describe Conference do end it 'calculates correct for one event types' do - create(:event, conference: subject, event_type: @workshop) + create(:event, program: subject.program, event_type: @workshop) result = {} result['Workshop'] = { 'value' => 1, @@ -549,18 +549,18 @@ describe Conference do describe '#event_type_distribution_confirmed' do it 'calculates correct for different event types without confirmed' do - create(:event, conference: subject, event_type: @workshop) - create(:event, conference: subject, event_type: @workshop) - create(:event, conference: subject, event_type: @lecture) + create(:event, program: subject.program, event_type: @workshop) + create(:event, program: subject.program, event_type: @workshop) + create(:event, program: subject.program, event_type: @lecture) result = {} expect(subject.event_type_distribution(:confirmed)).to eq(result) end it 'calculates correct for different event types with confirmed' do - confirmed_ws = create(:event, conference: subject, event_type: @workshop) - create(:event, conference: subject, event_type: @workshop) - confirmed_lt = create(:event, conference: subject, event_type: @lecture) + confirmed_ws = create(:event, program: subject.program, event_type: @workshop) + create(:event, program: subject.program, event_type: @workshop) + confirmed_lt = create(:event, program: subject.program, event_type: @lecture) options = {} options[:send_mail] = 'false' @@ -582,7 +582,7 @@ describe Conference do end it 'calculates correct for one event types' do - confirmed = create(:event, conference: subject, event_type: @workshop) + confirmed = create(:event, program: subject.program, event_type: @workshop) options = {} options[:send_mail] = 'false' confirmed.accept!(options) @@ -612,9 +612,9 @@ describe Conference do describe '#tracks_distribution' do it 'calculates correct for different tracks' do - create(:event, conference: subject, track: @track_one) - create(:event, conference: subject, track: @track_one) - create(:event, conference: subject, track: @track_two) + create(:event, program: subject.program, track: @track_one) + create(:event, program: subject.program, track: @track_one) + create(:event, program: subject.program, track: @track_two) result = {} result['Track One'] = { 'value' => 2, @@ -628,7 +628,7 @@ describe Conference do end it 'calculates correct for one track' do - create(:event, conference: subject, track: @track_one) + create(:event, program: subject.program, track: @track_one) result = {} result['Track One'] = { 'value' => 1, @@ -645,18 +645,18 @@ describe Conference do describe '#tracks_distribution_confirmed' do it 'calculates correct for different tracks without confirmed' do - create(:event, conference: subject, track: @track_one) - create(:event, conference: subject, track: @track_one) - create(:event, conference: subject, track: @track_two) + create(:event, program: subject.program, track: @track_one) + create(:event, program: subject.program, track: @track_one) + create(:event, program: subject.program, track: @track_two) result = {} expect(subject.tracks_distribution(:confirmed)).to eq(result) end it 'calculates correct for different tracks with confirmed' do - confirmed_one = create(:event, conference: subject, track: @track_one) - create(:event, conference: subject, track: @track_one) - confirmed_two = create(:event, conference: subject, track: @track_two) + confirmed_one = create(:event, program: subject.program, track: @track_one) + create(:event, program: subject.program, track: @track_one) + confirmed_two = create(:event, program: subject.program, track: @track_two) options = {} options[:send_mail] = 'false' @@ -678,7 +678,7 @@ describe Conference do end it 'calculates correct for one track' do - confirmed = create(:event, conference: subject, track: @track_one) + confirmed = create(:event, program: subject.program, track: @track_one) options = {} options[:send_mail] = 'false' confirmed.accept!(options) @@ -789,22 +789,22 @@ describe Conference do @options = {} @options[:send_mail] = 'false' - create(:event, conference: @conference) + create(:event, program: @conference.program) - withdrawn = create(:event, conference: @conference) + withdrawn = create(:event, program: @conference.program) withdrawn.withdraw! - unconfirmed = create(:event, conference: @conference) + unconfirmed = create(:event, program: @conference.program) unconfirmed.accept!(@options) - rejected = create(:event, conference: @conference) + rejected = create(:event, program: @conference.program) rejected.reject!(@options) - confirmed = create(:event, conference: @conference) + confirmed = create(:event, program: @conference.program) confirmed.accept!(@options) confirmed.confirm! - canceled = create(:event, conference: @conference) + canceled = create(:event, program: @conference.program) canceled.accept!(@options) canceled.cancel! @@ -822,20 +822,20 @@ describe Conference do end it '#event_distribution does calculate correct values with no events' do - @conference.events.clear + @conference.program.events.clear expect(@conference.event_distribution).to eq({}) end it 'event_distribution does calculate correct values with just a new event' do conference = create(:conference) - create(:event, conference: conference) + create(:event, program: conference.program) result = { 'New' => { 'value' => 1, 'color' => '#0000FF' } } expect(conference.event_distribution).to eq(result) end it 'event_distribution does calculate correct values with just an withdrawn event' do conference = create(:conference) - event = create(:event, conference: conference) + event = create(:event, program: conference.program) event.withdraw! result = { 'Withdrawn' => { 'value' => 1, 'color' => '#FF8000' } } expect(conference.event_distribution).to eq(result) @@ -843,7 +843,7 @@ describe Conference do it 'event_distribution does calculate correct values with just an unconfirmed event' do conference = create(:conference) - event = create(:event, conference: conference) + event = create(:event, program: conference.program) event.accept!(@options) result = { 'Unconfirmed' => { 'value' => 1, 'color' => '#FFFF00' } } expect(conference.event_distribution).to eq(result) @@ -851,7 +851,7 @@ describe Conference do it 'event_distribution does calculate correct values with just an rejected event' do conference = create(:conference) - event = create(:event, conference: conference) + event = create(:event, program: conference.program) event.reject!(@options) result = { 'Rejected' => { 'value' => 1, 'color' => '#FF0000' } } expect(conference.event_distribution).to eq(result) @@ -860,7 +860,7 @@ describe Conference do it 'event_distribution does calculate correct values with just an confirmed event' do conference = create(:conference) conference.email_settings = create(:email_settings) - event = create(:event, conference: conference) + event = create(:event, program: conference.program) event.accept!(@options) event.confirm! result = { 'Confirmed' => { 'value' => 1, 'color' => '#00FF00' } } @@ -869,7 +869,7 @@ describe Conference do it 'event_distribution does calculate correct values with just an canceled event' do conference = create(:conference) - event = create(:event, conference: conference) + event = create(:event, program: conference.program) event.accept!(@options) event.cancel! result = { 'Canceled' => { 'value' => 1, 'color' => '#848484' } } @@ -881,20 +881,20 @@ describe Conference do end it 'self#event_distribution does calculate correct values with no events' do - @conference.events.clear + @conference.program.events.clear expect(Conference.event_distribution).to eq({}) end it 'self#event_distribution does calculate correct values with just a new event' do - @conference.events.clear - create(:event, conference: @conference) + @conference.program.events.clear + create(:event, program: @conference.program) result = { 'New' => { 'value' => 1, 'color' => '#0000FF' } } expect(Conference.event_distribution).to eq(result) end it 'self#event_distribution does calculate correct values with just a new events from different conferences' do - create(:event, conference: @conference) + create(:event, program: @conference.program) @result['New'] = { 'value' => 2, 'color' => '#0000FF' } expect(Conference.event_distribution).to eq(@result) end @@ -970,12 +970,12 @@ describe Conference do end it 'calculates correct for new conference' do - subject.call_for_paper = nil + subject.program.cfp = nil subject.venue = nil - subject.rooms = [] - subject.tracks = [] - subject.event_types = [] - subject.difficulty_levels = [] + subject.program.rooms = [] + subject.program.tracks = [] + subject.program.event_types = [] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) expect(subject.get_status).to eq(@result_false) @@ -985,12 +985,12 @@ describe Conference do subject.registration_period = create(:registration_period, start_date: Date.today, end_date: Date.today + 14) - subject.call_for_paper = nil + subject.program.cfp = nil subject.venue = nil - subject.rooms = [] - subject.tracks = [] - subject.event_types = [] - subject.difficulty_levels = [] + subject.program.event_types = [] + subject.program.tracks = [] + subject.program.event_types = [] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) @result_false['registration'] = true @@ -1003,12 +1003,12 @@ describe Conference do subject.registration_period = create(:registration_period, start_date: Date.today, end_date: Date.today + 14) - subject.call_for_paper = create(:call_for_paper) + subject.program.cfp = create(:cfp) subject.venue = nil - subject.rooms = [] - subject.tracks = [] - subject.event_types = [] - subject.difficulty_levels = [] + subject.program.rooms = [] + subject.program.tracks = [] + subject.program.event_types = [] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @@ -1022,12 +1022,12 @@ describe Conference do subject.registration_period = create(:registration_period, start_date: Date.today, end_date: Date.today + 14) - subject.call_for_paper = create(:call_for_paper) + subject.program.cfp = create(:cfp) subject.venue = create(:venue) - subject.rooms = [] - subject.tracks = [] - subject.event_types = [] - subject.difficulty_levels = [] + subject.program.rooms = [] + subject.program.tracks = [] + subject.program.event_types = [] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @@ -1039,15 +1039,15 @@ describe Conference do end it 'calculates correct for conference with registration, cfp, venue, rooms' do - subject.rooms = [create(:room)] + subject.program.rooms = [create(:room)] subject.registration_period = create(:registration_period, start_date: Date.today, end_date: Date.today + 14) - subject.call_for_paper = create(:call_for_paper) + subject.program.cfp = create(:cfp) subject.venue = create(:venue) - subject.tracks = [] - subject.event_types = [] - subject.difficulty_levels = [] + subject.program.tracks = [] + subject.program.event_types = [] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @@ -1060,15 +1060,15 @@ describe Conference do end it 'calculates correct for conference with registration, cfp, venue, rooms, tracks' do - subject.rooms = [create(:room)] - subject.tracks = [create(:track)] + subject.program.rooms = [create(:room)] + subject.program.tracks = [create(:track)] subject.registration_period = create(:registration_period, start_date: Date.today, end_date: Date.today + 14) - subject.call_for_paper = create(:call_for_paper) + subject.program.cfp = create(:cfp) subject.venue = create(:venue) - subject.event_types = [] - subject.difficulty_levels = [] + subject.program.event_types = [] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @@ -1083,15 +1083,15 @@ describe Conference do it 'calculates correct for conference with registration, cfp, venue, rooms, tracks, event_types' do - subject.rooms = [create(:room)] - subject.tracks = [create(:track)] - subject.event_types = [create(:event_type)] + subject.program.rooms = [create(:room)] + subject.program.tracks = [create(:track)] + subject.program.event_types = [create(:event_type)] subject.registration_period = create(:registration_period, start_date: Date.today, end_date: Date.today + 14) - subject.call_for_paper = create(:call_for_paper) + subject.program.cfp = create(:cfp) subject.venue = create(:venue) - subject.difficulty_levels = [] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @@ -1106,15 +1106,14 @@ describe Conference do end it 'calculates correct for conference with all mandatory options' do - subject.rooms = [create(:room)] - subject.tracks = [create(:track)] - subject.event_types = [create(:event_type)] - subject.difficulty_levels = [create(:difficulty_level)] + subject.program.rooms = [create(:room)] + subject.program.tracks = [create(:track)] + subject.program.event_types = [create(:event_type)] + subject.program.difficulty_levels = [create(:difficulty_level)] subject.registration_period = create(:registration_period, start_date: Date.today, end_date: Date.today + 14) - subject.venue = create(:venue) - subject.call_for_paper = create(:call_for_paper) + subject.program.cfp = create(:cfp) subject.venue = create(:venue) subject.splashpage = create(:splashpage, public: true) @@ -1156,34 +1155,34 @@ describe Conference do describe '#cfp_weeks' do it 'calculates new year' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2013, 12, 30) cfp.end_date = Date.new(2013, 12, 30) + 6 - subject.call_for_paper = cfp + subject.program.cfp = cfp expect(subject.cfp_weeks).to eq(1) end it 'is one if start and end are 6 days apart' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 6 - subject.call_for_paper = cfp + subject.program.cfp = cfp expect(subject.cfp_weeks).to eq(1) end it 'is one if start and end are the same date' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) - subject.call_for_paper = cfp + subject.program.cfp = cfp expect(subject.cfp_weeks).to eq(1) end it 'is two if start and end are 10 days apart' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 10 - subject.call_for_paper = cfp + subject.program.cfp = cfp expect(subject.cfp_weeks).to eq(2) end end @@ -1191,88 +1190,88 @@ describe Conference do describe '#get_submissions_per_week' do it 'does calculate correct if cfp start date is altered' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) - 7)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) - 7)] expect(subject.get_submissions_per_week).to eq([1, 1, 1, 1, 1]) end it 'does calculate correct if cfp end date is altered' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 28)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 28)] expect(subject.get_submissions_per_week).to eq([0, 0, 0, 0, 1]) end it 'pads with zeros if there are no submissions' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp + subject.program.cfp = cfp expect(subject.get_submissions_per_week).to eq([0, 0, 0, 0]) end it 'summarized correct if there are no submissions in one week' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 28 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)] - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)] - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 28)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)] + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)] + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 28)] expect(subject.get_submissions_per_week).to eq([0, 1, 2, 2, 3]) end it 'summarized correct if there are submissions every week except the first' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)] - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)] + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)] expect(subject.get_submissions_per_week).to eq([0, 1, 2, 2]) end it 'summarized correct if there are submissions every week' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26))] - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)] - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26))] + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)] + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)] expect(subject.get_submissions_per_week).to eq([1, 2, 3, 3]) end it 'pads left' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 21)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 21)] expect(subject.get_submissions_per_week).to eq([0, 0, 0, 1]) end it 'pads middle' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26))] - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 21)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26))] + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 21)] expect(subject.get_submissions_per_week).to eq([1, 1, 1, 2]) end it 'pads right' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26))] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26))] expect(subject.get_submissions_per_week).to eq([1, 1, 1, 1]) end end @@ -1431,7 +1430,7 @@ describe Conference do context 'closed cfp' do it '#cfp_open? is false' do - expect(subject.cfp_open?).to be false + expect(subject.program.cfp_open?).to be false end end @@ -1439,11 +1438,11 @@ describe Conference do context 'open cfp' do before do - subject.call_for_paper = create(:call_for_paper) + subject.program.cfp = create(:cfp) end it '#registration_open? is true' do - expect(subject.cfp_open?).to be true + expect(subject.program.cfp_open?).to be true end end end diff --git a/spec/models/program_spec.rb b/spec/models/program_spec.rb new file mode 100644 index 00000000..3adad84e --- /dev/null +++ b/spec/models/program_spec.rb @@ -0,0 +1,61 @@ +require 'spec_helper' + +describe Program do + let!(:conference) { create(:conference, end_date: Date.today + 3) } + let!(:program) { conference.program } + + describe '#rating_enabled?' do + it 'returns true if proposals can be rated (program.rating > 0)' do + program.rating = 3 + expect(program.rating_enabled?).to be true + end + + it 'returns false if proposals cannot be rated (program.ratinig == 0) ' do + program = conference.program + program.rating = 3 + expect(program.rating_enabled?).to be true + end + end + + describe '#cfp_open?' do + describe 'returns true' do + it 'when there is an open Call for Papers for the conference' do + create(:cfp, start_date: Date.today - 2, end_date: Date.today, program_id: program.id) + expect(program.cfp_open?).to be true + end + end + + describe 'returns false' do + it 'when there is no Call for Papers for the conference' do + expect(program.cfp_open?).to be false + end + + it 'when the Call for Papers period is over' do + build(:cfp, start_date: Date.today - 2, end_date: Date.today - 1, program_id: program.id) + expect(program.cfp_open?).to be false + end + end + end + + describe 'excecutes before_create functions' do + it 'and creates events_types' do + program.destroy! + conference.reload + expect(conference.program).to eq nil + + create(:program, conference_id: conference.id) + conference.reload + expect(conference.program.event_types.count).to eq 2 + end + + it 'and creates difficulty_levels' do + program.destroy! + conference.reload + expect(conference.program).to eq nil + + create(:program, conference_id: conference.id) + conference.reload + expect(conference.program.difficulty_levels.count).to eq 3 + end + end +end diff --git a/spec/models/target_spec.rb b/spec/models/target_spec.rb index 53c46ae3..50a4103f 100644 --- a/spec/models/target_spec.rb +++ b/spec/models/target_spec.rb @@ -53,7 +53,7 @@ describe Target do end it 'returns zero if there are no submissions' do - conference = build(:conference) + conference = create(:conference) target = build(:target, target_count: 10, unit: Target.units[:submissions]) conference.targets = [target] @@ -66,13 +66,13 @@ describe Target do event = create(:event) conference.targets = [target] - conference.events = [event] + conference.program.events = [event] expect(target.get_progress).to eq('10') end it 'returns zero if there are no program minutes' do - conference = build(:conference) + conference = create(:conference) target = build(:target, target_count: 10, unit: Target.units[:program_minutes]) conference.targets = [target] @@ -85,7 +85,7 @@ describe Target do event = create(:event) conference.targets = [target] - conference.events = [event] + conference.program.events = [event] expect(target.get_progress).to eq('10') end diff --git a/spec/views/admin/call_for_papers/show.html.haml_spec.rb b/spec/views/admin/cfps/show.html.haml_spec.rb similarity index 61% rename from spec/views/admin/call_for_papers/show.html.haml_spec.rb rename to spec/views/admin/cfps/show.html.haml_spec.rb index de7b7fe3..f7821938 100644 --- a/spec/views/admin/call_for_papers/show.html.haml_spec.rb +++ b/spec/views/admin/cfps/show.html.haml_spec.rb @@ -1,10 +1,12 @@ require 'spec_helper' -describe 'admin/call_for_papers/show' do +describe 'admin/cfps/show' do it 'renders call for papers details' do - assign :conference, create(:conference) - assign :call_for_paper, create(:call_for_paper) + conference = create(:conference) + assign :conference, conference + assign :program, conference.program + assign :cfp, create(:cfp, program: conference.program) render expect(rendered).to include('Start Date') expect(rendered).to include('End Date') diff --git a/spec/views/admin/conference/show.html.haml_spec.rb b/spec/views/admin/conference/show.html.haml_spec.rb index 383af195..18a2efd3 100644 --- a/spec/views/admin/conference/show.html.haml_spec.rb +++ b/spec/views/admin/conference/show.html.haml_spec.rb @@ -5,6 +5,7 @@ describe 'admin/conference/show' do it 'renders conference dashboard' do conference = create(:conference, title: 'openSUSE') assign :conference, conference + assign :program, conference.program assign :conference_progress, conference.get_status render expect(rendered).to include("Dashboard for #{conference.title}") diff --git a/spec/views/admin/difficulty_levels/index.html.haml_spec.rb b/spec/views/admin/difficulty_levels/index.html.haml_spec.rb index 07dc6e04..6e7d469a 100644 --- a/spec/views/admin/difficulty_levels/index.html.haml_spec.rb +++ b/spec/views/admin/difficulty_levels/index.html.haml_spec.rb @@ -3,8 +3,9 @@ require 'spec_helper' describe 'admin/difficulty_levels/index' do it 'renders difficulty levels' do - @difficulty_level = create(:difficulty_level) - assign :conference, @difficulty_level.conference + conference = create(:conference) + @difficulty_level = create(:difficulty_level, program: conference.program) + assign :conference, conference render expect(rendered).to include('Example Difficulty Level') expect(rendered).to include('Lorem Ipsum dolsum') diff --git a/spec/views/admin/event_types/index.html.haml_spec.rb b/spec/views/admin/event_types/index.html.haml_spec.rb index 661f7156..dbfbc3b2 100644 --- a/spec/views/admin/event_types/index.html.haml_spec.rb +++ b/spec/views/admin/event_types/index.html.haml_spec.rb @@ -3,8 +3,9 @@ require 'spec_helper' describe 'admin/event_types/index' do it 'renders event types' do - @event_type = create(:event_type) - assign :conference, @event_type.conference + conference = create(:conference) + @event_type = create(:event_type, program: conference.program) + assign :conference, @event_type.program.conference render expect(rendered).to include('Example Event Type') expect(rendered).to include('30') diff --git a/spec/views/admin/events/index.html.haml_spec.rb b/spec/views/admin/events/index.html.haml_spec.rb index f9e06dad..07b9fd11 100644 --- a/spec/views/admin/events/index.html.haml_spec.rb +++ b/spec/views/admin/events/index.html.haml_spec.rb @@ -2,15 +2,17 @@ require 'spec_helper' describe 'admin/events/index' do let!(:conference) { create(:conference) } - let!(:event1) { create(:event, conference: conference, title: 'event1') } - let!(:event2) { create(:event, conference: conference, title: 'event2') } + let!(:program) { conference.program } + let!(:event1) { create(:event, program: conference.program, title: 'event1') } + let!(:event2) { create(:event, program: conference.program, title: 'event2') } it 'renders all conference events' do assign(:conference, conference) + assign(:program, conference.program) assign(:events, [ event1, event2 ]) - assign(:event_types, [ create(:event_type, conference: conference), create(:event_type, conference: conference) ]) - assign(:tracks, [ create(:track, conference: conference), create(:track, conference: conference) ]) - assign(:difficulty_levels, [ create(:difficulty_level, conference: conference), create(:difficulty_level, conference: conference) ]) + assign(:event_types, [ create(:event_type, program: conference.program), create(:event_type, program: conference.program) ]) + assign(:tracks, [ create(:track, program: conference.program), create(:track, program: conference.program) ]) + assign(:difficulty_levels, [ create(:difficulty_level, program: conference.program), create(:difficulty_level, program: conference.program) ]) render @@ -25,7 +27,7 @@ describe 'admin/events/index' do expect(rendered).to have_selector('table thead th:nth-of-type(9)', text: 'Difficulty') expect(rendered).to have_selector('table thead th:nth-of-type(10)', text: 'State') - expect(conference.events.count).to eq 2 + expect(conference.program.events.count).to eq 2 expect(rendered).to have_selector('table tr:nth-of-type(1) td:nth-of-type(1)', text: event1.id) expect(rendered).to have_selector('table tr:nth-of-type(1) td:nth-of-type(2)', text: 'event1') diff --git a/spec/views/admin/programs/show.html.haml_spec.rb b/spec/views/admin/programs/show.html.haml_spec.rb new file mode 100644 index 00000000..807d8c34 --- /dev/null +++ b/spec/views/admin/programs/show.html.haml_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe 'admin/programs/show' do + + it 'renders call for papers details' do + conference = create(:conference) + assign :conference, conference + assign :program, conference.program + render + expect(rendered).to have_css('dt', text: 'Event types:') + expect(rendered).to have_css('dd', text: 'Talks and Workshops') + expect(rendered).to have_css('dt', text: 'Tracks:') + expect(rendered).to have_css('dt', text: 'Difficulty Levels:') + expect(rendered).to have_css('dd', text: 'Easy, Medium and Hard') + end +end diff --git a/spec/views/admin/rooms/index.html.haml_spec.rb b/spec/views/admin/rooms/index.html.haml_spec.rb index 71caf7f4..cb1762b2 100644 --- a/spec/views/admin/rooms/index.html.haml_spec.rb +++ b/spec/views/admin/rooms/index.html.haml_spec.rb @@ -1,9 +1,11 @@ require 'spec_helper' + describe 'admin/rooms/index' do it 'renders rooms list' do - @room = create(:room) - assign :conference, @room.conference + conference = create(:conference) + create(:room, name: 'Example Room', size: 4, program: conference.program) + assign :conference, conference render expect(rendered).to include('Example Room') expect(rendered).to include('4') diff --git a/spec/views/admin/tracks/index.html.haml_spec.rb b/spec/views/admin/tracks/index.html.haml_spec.rb index ae75a3a1..e90275ba 100644 --- a/spec/views/admin/tracks/index.html.haml_spec.rb +++ b/spec/views/admin/tracks/index.html.haml_spec.rb @@ -3,8 +3,10 @@ require 'spec_helper' describe 'admin/tracks/index' do it 'renders tracks' do - @track = create(:track) - assign :conference, @track.conference + conference = create(:conference) + create(:track, name: 'Example Track', description: 'Lorem Ipsum dolsum', color: '#ffffff', program: conference.program) + assign :tracks, conference.program.tracks + assign :conference, conference render expect(rendered).to include('Example Track') expect(rendered).to include('Lorem Ipsum dolsum') diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index 87219c90..31b1cdea 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -3,6 +3,7 @@ describe 'conference/show.html.haml' do before(:each) do allow(view).to receive(:date_string).and_return('January 17 - 21 2014') @conference = create(:conference, description: 'Lorem Ipsum') + @program = @conference.program @conference.splashpage = create(:splashpage, include_registrations: true, @@ -25,7 +26,7 @@ describe 'conference/show.html.haml' do start_date: Date.yesterday, end_date: Date.tomorrow) - @conference.call_for_paper = create(:call_for_paper, conference: @conference) + @conference.program.cfp = create(:cfp, program: @conference.program) @conference.sponsorship_levels << create(:sponsorship_level, conference: @conference) @sponsorship_level = @conference.sponsorship_levels.first