This commit is contained in:
Stella Rouzi 2015-12-08 21:20:00 +00:00
commit 2eddbdb614
38 changed files with 222 additions and 191 deletions

View file

@ -15,8 +15,8 @@ module Admin
@call_for_paper = @conference.build_call_for_paper(call_for_paper_params)
if @call_for_paper.save
redirect_to admin_conference_call_for_paper_path,
notice: 'Call for papers successfully created.'
flash[:notice] = 'Call for papers successfully created.'
redirect_to admin_conference_call_for_paper_path
else
flash[:error] = "Creating the call for papers failed. #{@call_for_paper.errors.full_messages.join('. ')}."
render :new
@ -34,8 +34,9 @@ module Admin
if @cfp.update_attributes(params[:call_for_paper])
Mailbot.delay.send_on_call_for_papers_dates_updated(@conference) if send_mail_on_cfp_dates_updated
Mailbot.delay.send_on_schedule_public(@conference) if send_mail_on_schedule_public
redirect_to(admin_conference_call_for_paper_path(@conference.short_title),
notice: 'Call for papers successfully updated.')
flash[:notice] = 'Call for papers successfully updated.'
redirect_to admin_conference_call_for_paper_path(@conference.short_title)
else
flash[:error] = "Updating call for papers failed. #{@cfp.errors.to_a.join('. ')}."
render :new
@ -44,10 +45,12 @@ module Admin
def destroy
if @call_for_paper.destroy
redirect_to admin_conference_call_for_paper_path, notice: 'Call for Papers was successfully deleted.'
flash[:notice] = 'Call for Papers was successfully deleted.'
redirect_to admin_conference_call_for_paper_path
else
redirect_to admin_conference_call_for_paper_path, error: 'An error prohibited this Call for Papers from being destroyed: '\
"#{@call_for_paper.errors.full_messages.join('. ')}."
flash[:error] = 'An error prohibited this Call for Papers from being destroyed: '\
"#{@call_for_paper.errors.full_messages.join('. ')}."
redirect_to admin_conference_call_for_paper_path
end
end

View file

@ -13,7 +13,7 @@ module Admin
if @conference.save
flash[:notice] = 'Campaign successfully created.'
redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title))
redirect_to admin_conference_campaigns_path(conference_id: @conference.short_title)
else
flash[:error] = 'Campaign creation failed. ' + @campaign.errors.full_messages.to_sentence
render action: 'new'
@ -27,7 +27,7 @@ module Admin
def update
if @campaign.update_attributes(params[:campaign])
flash[:notice] = "Campaign '#{@campaign.name}' successfully updated."
redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title))
redirect_to admin_conference_campaigns_path(conference_id: @conference.short_title)
else
flash[:error] = "Campaign update failed. #{@campaign.errors.full_messages.to_sentence}"
render action: 'edit'
@ -37,11 +37,11 @@ module Admin
def destroy
if @campaign.destroy
flash[:notice] = "Campaign '#{@campaign.name}' successfully deleted."
redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title))
redirect_to admin_conference_campaigns_path(conference_id: @conference.short_title)
else
flash[:error] = "Delete of Campaign for #{@conference.short_title} failed." \
"#{@campaign.errors.full_messages.join('. ')}."
redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title))
"#{@campaign.errors.full_messages.join('. ')}."
redirect_to admin_conference_campaigns_path(conference_id: @conference.short_title)
end
end
end

View file

@ -19,8 +19,8 @@ module Admin
authorize! :create, @commercial
if @commercial.save
redirect_to admin_conference_commercials_path,
notice: 'Commercial was successfully created.'
flash[:notice] = 'Commercial was successfully created.'
redirect_to admin_conference_commercials_path
else
flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}."
render :new
@ -29,8 +29,8 @@ module Admin
def update
if @commercial.update(commercial_params)
redirect_to admin_conference_commercials_path,
notice: 'Commercial was successfully updated.'
flash[:notice] = 'Commercial was successfully updated.'
redirect_to admin_conference_commercials_path
else
flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}."
render :edit
@ -38,8 +38,14 @@ module Admin
end
def destroy
@commercial.destroy
redirect_to admin_conference_commercials_path, notice: 'Commercial was successfully destroyed.'
if @commercial.destroy
flash[:notice] = 'Commercial was successfully destroyed.'
redirect_to admin_conference_commercials_path
else
flash[:error] = 'Commercial was not destroyed.'\
"#{@commercial.errors.full_messages.join('. ')}"
redirect_to admin_conference_commercials_path
end
end
private

View file

@ -69,8 +69,9 @@ module Admin
@conference.save
# user that creates the conference becomes organizer of that conference
current_user.add_role :organizer, @conference
redirect_to(admin_conference_path(id: @conference.short_title),
notice: 'Conference was successfully created.')
flash[:notice] = 'Conference was successfully created.'
redirect_to admin_conference_path(id: @conference.short_title)
else
render action: 'new'
end
@ -84,12 +85,13 @@ module Admin
if @conference.update_attributes(params[:conference])
Mailbot.delay.conference_date_update_mail(@conference) if send_mail_on_conf_update
redirect_to(edit_admin_conference_path(id: @conference.short_title),
notice: 'Conference was successfully updated.')
flash[:notice] = 'Conference was successfully updated.'
redirect_to edit_admin_conference_path(id: @conference.short_title)
else
redirect_to(edit_admin_conference_path(id: short_title),
alert: 'Updating conference failed. ' \
"#{@conference.errors.full_messages.join('. ')}.")
flash[:error] = 'Updating conference failed. ' \
"#{@conference.errors.full_messages.join('. ')}."
redirect_to edit_admin_conference_path(id: short_title)
end
end

View file

@ -12,8 +12,10 @@ module Admin
# PATCH/PUT /:conference/contact
def update
if @contact.update(contact_params)
redirect_to edit_admin_conference_contact_path, notice: 'Contact details were successfully updated.'
flash[:notice] = 'Contact details were successfully updated.'
redirect_to edit_admin_conference_contact_path
else
flash[:error] = 'Contact details were not updated.'
render :edit
end
end

View file

@ -17,7 +17,7 @@ module Admin
@difficulty_level = @conference.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_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 +27,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_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 +37,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_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))
"#{@difficulty_level.errors.full_messages.join('. ')}."
redirect_to admin_conference_difficulty_levels_path(conference_id: @conference.short_title)
end
end

View file

@ -5,9 +5,9 @@ module Admin
def update
@conference.email_settings.update_attributes(params[:email_settings])
redirect_to(admin_conference_emails_path(
@conference.short_title),
notice: 'Settings have been successfully updated.')
flash[:notice] = 'Settings have been successfully updated.'
redirect_to admin_conference_emails_path(@conference.short_title)
end
def index

View file

@ -17,7 +17,7 @@ module Admin
@event_type = @conference.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_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 +27,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_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 +37,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_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))
"#{@event_type.errors.full_messages.join('. ')}."
redirect_to admin_conference_event_types_path(conference_id: @conference.short_title)
end
end

View file

@ -170,8 +170,8 @@ module Admin
def get_event
@event = @conference.events.find_by_id(params[:id])
if !@event
redirect_to(admin_conference_events_path(conference_id: @conference.short_title),
alert: 'Error! Could not find event!') && return
flash[:error] = 'Error! Could not find event!'
redirect_to admin_conference_events_path(conference_id: @conference.short_title) && return
end
@event
end

View file

@ -13,8 +13,8 @@ module Admin
def create
@lodging = @conference.lodgings.new(lodging_params)
if @lodging.save
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
notice: 'Lodging successfully created.')
flash[:notice] = 'Lodging successfully created.'
redirect_to admin_conference_lodgings_path(conference_id: @conference.short_title)
else
flash[:error] = "Creating Lodging failed: #{@lodging.errors.full_messages.join('. ')}."
render :new
@ -25,8 +25,8 @@ module Admin
def update
if @lodging.update_attributes(lodging_params)
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
notice: 'Lodging successfully updated.')
flash[:notice] = 'Lodging successfully updated.'
redirect_to admin_conference_lodgings_path(conference_id: @conference.short_title)
else
flash[:error] = "Update Lodging failed: #{@lodging.errors.full_messages.join('. ')}."
render :edit
@ -35,12 +35,12 @@ module Admin
def destroy
if @lodging.destroy
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
notice: 'Lodging successfully deleted.')
flash[:notice] = 'Lodging successfully deleted.'
redirect_to admin_conference_lodgings_path(conference_id: @conference.short_title)
else
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
error: 'Deleting lodging failed.' \
"#{@lodging.errors.full_messages.join('. ')}.")
flash[:error] = 'Deleting lodging failed.' \
"#{@lodging.errors.full_messages.join('. ')}."
redirect_to admin_conference_lodgings_path(conference_id: @conference.short_title)
end
end

View file

@ -13,8 +13,9 @@ module Admin
if @registration_period.save
Mailbot.delay.conference_registration_date_update_mail(@conference) if send_mail_on_reg_update
redirect_to admin_conference_registration_period_path(@conference.short_title),
notice: 'Registration Period successfully updated.'
flash[:notice] = 'Registration Period successfully updated.'
redirect_to admin_conference_registration_period_path(@conference.short_title)
else
flash[:error] = "An error prohibited the Registration Period from being saved: #{@registration_period.errors.full_messages.join('. ')}."
render :new
@ -33,19 +34,21 @@ module Admin
if @registration_period.update(registration_period)
Mailbot.delay.conference_registration_date_update_mail(@conference) if send_mail_on_reg_update
redirect_to admin_conference_registration_period_path(@conference.short_title),
notice: 'Registration Period successfully updated.'
flash[:notice] = 'Registration Period successfully updated.'
redirect_to admin_conference_registration_period_path(@conference.short_title)
else
flash[:error] = 'An error prohibited the Registration Period from being saved: ' \
"#{@registration_period.errors.full_messages.join('. ')}."
"#{@registration_period.errors.full_messages.join('. ')}."
render :edit
end
end
def destroy
@registration_period.destroy
redirect_to admin_conference_registration_period_path,
notice: 'Registration Period was successfully destroyed.'
flash[:notice] = 'Registration Period was successfully destroyed.'
redirect_to admin_conference_registration_period_path
end
private

View file

@ -16,8 +16,8 @@ module Admin
def update
@registration.update_attributes(registration_params)
if @registration.save
redirect_to admin_conference_registrations_path(@conference.short_title),
notice: "Successfully updated registration for #{@registration.user.email}!"
flash[:notice] = "Successfully updated registration for #{@registration.user.email}!"
redirect_to admin_conference_registrations_path(@conference.short_title)
else
flash[:error] = "An error prohibited the Registration for #{@registration.user.email}: "\
"#{@registration.errors.full_messages.join('. ')}."
@ -28,11 +28,12 @@ module Admin
def destroy
if can? :destroy, @registration
@registration.destroy
redirect_to admin_conference_registrations_path(@conference.short_title),
notice: "Deleted registration for #{@user.name}!"
flash[:notice] = "Deleted registration for #{@user.name}!"
redirect_to admin_conference_registrations_path(@conference.short_title)
else
redirect_to(admin_conference_registrations_path(@conference.short_title),
error: 'You must be an admin to delete a registration.')
flash[:error] = 'You must be an admin to delete a registration.'
redirect_to admin_conference_registrations_path(@conference.short_title)
end
end

View file

@ -17,7 +17,7 @@ module Admin
@room = @conference.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_rooms_path(conference_id: @conference.short_title)
else
flash[:error] = "Creating Room failed: #{@room.errors.full_messages.join('. ')}."
render :new
@ -27,7 +27,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_rooms_path(conference_id: @conference.short_title)
else
flash[:error] = "Update Room failed: #{@room.errors.full_messages.join('. ')}."
render :edit
@ -37,10 +37,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_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_rooms_path(conference_id: @conference.short_title)
end
end

View file

@ -15,9 +15,11 @@ module Admin
@splashpage = @conference.build_splashpage(splashpage_params)
if @splashpage.save
redirect_to admin_conference_splashpage_path,
notice: 'Splashpage successfully created.'
flash[:notice] = 'Splashpage successfully created.'
redirect_to admin_conference_splashpage_path
else
flash[:error] = 'Splashpage could not be created.'\
"#{@splashpage.errors.full_messages.join('. ')}."
render :new
end
end
@ -33,10 +35,12 @@ module Admin
def destroy
if @splashpage.destroy
redirect_to admin_conference_splashpage_path, notice: 'Splashpage was successfully destroyed.'
flash[:notice] = 'Splashpage was successfully destroyed.'
redirect_to admin_conference_splashpage_path
else
redirect_to admin_conference_splashpage_path, alert: 'An error prohibited this Splashpage from being destroyed: '\
"#{@splashpage.errors.full_messages.join('. ')}."
flash[:error] = 'An error prohibited this Splashpage from being destroyed: '\
"#{@splashpage.errors.full_messages.join('. ')}."
redirect_to admin_conference_splashpage_path
end
end

View file

@ -16,8 +16,8 @@ module Admin
def create
@sponsor = @conference.sponsors.new(sponsor_params)
if @sponsor.save
redirect_to(admin_conference_sponsors_path(conference_id: @conference.short_title),
notice: 'Sponsor successfully created.')
flash[:notice] = 'Sponsor successfully created.'
redirect_to admin_conference_sponsors_path(conference_id: @conference.short_title)
else
flash[:error] = "Creating sponsor failed: #{@sponsor.errors.full_messages.join('. ')}."
render :new
@ -26,9 +26,8 @@ module Admin
def update
if @sponsor.update_attributes(sponsor_params)
redirect_to(admin_conference_sponsors_path(
conference_id: @conference.short_title),
notice: 'Sponsor successfully updated.')
flash[:notice] = 'Sponsor successfully updated.'
redirect_to admin_conference_sponsors_path(conference_id: @conference.short_title)
else
flash[:error] = "Update sponsor failed: #{@sponsor.errors.full_messages.join('. ')}."
render :edit
@ -37,12 +36,12 @@ module Admin
def destroy
if @sponsor.destroy
redirect_to(admin_conference_sponsors_path(conference_id: @conference.short_title),
notice: 'Sponsor successfully deleted.')
flash[:notice] = 'Sponsor successfully deleted.'
redirect_to admin_conference_sponsors_path(conference_id: @conference.short_title)
else
redirect_to(admin_conference_sponsors_path(conference_id: @conference.short_title),
error: 'Deleting sponsor failed! ' \
"#{@sponsor.errors.full_messages.join('. ')}.")
flash[:error] = 'Deleting sponsor failed! ' \
"#{@sponsor.errors.full_messages.join('. ')}."
redirect_to admin_conference_sponsors_path(conference_id: @conference.short_title)
end
end

View file

@ -16,8 +16,8 @@ module Admin
def create
@sponsorship_level = @conference.sponsorship_levels.new(sponsorship_level_params)
if @sponsorship_level.save
redirect_to(admin_conference_sponsorship_levels_path(conference_id: @conference.short_title),
notice: 'Sponsorship level successfully created.')
flash[:notice] = 'Sponsorship level successfully created.'
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title)
else
flash[:error] = "Creating Sponsorship Level failed: #{@sponsorship_level.errors.full_messages.join('. ')}."
render :new
@ -26,9 +26,8 @@ module Admin
def update
if @sponsorship_level.update_attributes(sponsorship_level_params)
redirect_to(admin_conference_sponsorship_levels_path(
conference_id: @conference.short_title),
notice: 'Sponsorship level successfully updated.')
flash[:notice] = 'Sponsorship level successfully updated.'
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title)
else
flash[:error] = "Update Sponsorship level failed: #{@sponsorship_level.errors.full_messages.join('. ')}."
render :edit
@ -37,23 +36,23 @@ module Admin
def destroy
if @sponsorship_level.destroy
redirect_to(admin_conference_sponsorship_levels_path(conference_id: @conference.short_title),
notice: 'Sponsorship level successfully deleted.')
flash[:notice] = 'Sponsorship level successfully deleted.'
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title)
else
redirect_to(admin_conference_sponsorship_levels_path(conference_id: @conference.short_title),
error: 'Deleting sponsorship level failed! ' \
"#{@sponsorship_level.errors.full_messages.join('. ')}.")
flash[:error] = 'Deleting sponsorship level failed! ' \
"#{@sponsorship_level.errors.full_messages.join('. ')}."
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title)
end
end
def up
@sponsorship_level.move_higher
redirect_to(admin_conference_sponsorship_levels_path(conference_id: @conference.short_title))
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title)
end
def down
@sponsorship_level.move_lower
redirect_to(admin_conference_sponsorship_levels_path(conference_id: @conference.short_title))
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title)
end
private

View file

@ -14,8 +14,8 @@ module Admin
def create
@target = @conference.targets.new(target_params)
if @target.save(target_params)
redirect_to(admin_conference_targets_path(conference_id: @conference.short_title),
notice: 'Target successfully created.')
flash[:notice] = 'Target successfully created.'
redirect_to admin_conference_targets_path(conference_id: @conference.short_title)
else
flash[:error] = "Creating target failed: #{@target.errors.full_messages.join('. ')}."
render :new
@ -26,8 +26,8 @@ module Admin
def update
if @target.update_attributes(target_params)
redirect_to(admin_conference_targets_path(conference_id: @conference.short_title),
notice: 'Target successfully updated.')
flash[:notice] = 'Target successfully updated.'
redirect_to admin_conference_targets_path(conference_id: @conference.short_title)
else
flash[:error] = "Target update failed: #{@target.errors.full_messages.join('. ')}."
render :edit
@ -36,12 +36,12 @@ module Admin
def destroy
if @target.destroy
redirect_to(admin_conference_targets_path(conference_id: @conference.short_title),
notice: 'Target successfully destroyed.')
flash[:notice] = 'Target successfully destroyed.'
redirect_to admin_conference_targets_path(conference_id: @conference.short_title)
else
redirect_to(admin_conference_targets_path(conference_id: @conference.short_title),
error: 'Target was successfully destroyed.' \
"#{@target.errors.full_messages.join('. ')}.")
flash[:error] = 'Target was successfully destroyed.' \
"#{@target.errors.full_messages.join('. ')}."
redirect_to admin_conference_targets_path(conference_id: @conference.short_title)
end
end

View file

@ -14,8 +14,8 @@ module Admin
def create
@ticket = @conference.tickets.new(ticket_params)
if @ticket.save(ticket_params)
redirect_to(admin_conference_tickets_path(conference_id: @conference.short_title),
notice: 'Ticket successfully created.')
flash[:notice] = 'Ticket successfully created.'
redirect_to admin_conference_tickets_path(conference_id: @conference.short_title)
else
flash[:error] = "Creating Ticket failed: #{@ticket.errors.full_messages.join('. ')}."
render :new
@ -26,8 +26,8 @@ module Admin
def update
if @ticket.update_attributes(ticket_params)
redirect_to(admin_conference_tickets_path(conference_id: @conference.short_title),
notice: 'Ticket successfully updated.')
flash[:notice] = 'Ticket successfully updated.'
redirect_to admin_conference_tickets_path(conference_id: @conference.short_title)
else
flash[:error] = "Ticket update failed: #{@ticket.errors.full_messages.join('. ')}."
render :edit
@ -36,12 +36,12 @@ module Admin
def destroy
if @ticket.destroy
redirect_to(admin_conference_tickets_path(conference_id: @conference.short_title),
notice: 'Ticket successfully destroyed.')
flash[:notice] = 'Ticket successfully destroyed.'
redirect_to admin_conference_tickets_path(conference_id: @conference.short_title)
else
redirect_to(admin_conference_tickets_path(conference_id: @conference.short_title),
error: 'Ticket was successfully destroyed.' \
"#{@ticket.errors.full_messages.join('. ')}.")
flash[:error] = 'Ticket was successfully destroyed.' \
"#{@ticket.errors.full_messages.join('. ')}."
redirect_to admin_conference_tickets_path(conference_id: @conference.short_title)
end
end

View file

@ -20,7 +20,7 @@ module Admin
@track = @conference.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_tracks_path(conference_id: @conference.short_title)
else
flash[:error] = "Creating Track failed: #{@track.errors.full_messages.join('. ')}."
render :new
@ -32,7 +32,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_tracks_path(conference_id: @conference.short_title)
else
flash[:error] = "Track update failed: #{@track.errors.full_messages.join('. ')}."
render :edit
@ -42,10 +42,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_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_tracks_path(conference_id: @conference.short_title)
end
end

View file

@ -28,9 +28,11 @@ module Admin
end
if @user.update_attributes(params[:user])
redirect_to admin_users_path, notice: "Updated #{@user.name} (#{@user.email})!" + message
flash[:notice] = "Updated #{@user.name} (#{@user.email})!" + message
redirect_to admin_users_path
else
redirect_to admin_users_path, alert: "Could not update #{@user.name} (#{@user.email}). #{@user.errors.full_messages.join('. ')}."
flash[:error] = "Could not update #{@user.name} (#{@user.email}). #{@user.errors.full_messages.join('. ')}."
render :edit
end
end

View file

@ -15,8 +15,8 @@ module Admin
@venue = @conference.build_venue(venue_params)
if @venue.save
redirect_to admin_conference_venue_path,
notice: 'Venue was successfully created.'
flash[:notice] = 'Venue was successfully created.'
redirect_to admin_conference_venue_path
else
render :new
end
@ -24,8 +24,8 @@ module Admin
def update
if @venue.update_attributes(venue_params)
redirect_to(admin_conference_venue_path(conference_id: @conference.short_title),
notice: 'Venue was successfully updated.')
flash[:notice] = 'Venue was successfully updated.'
redirect_to admin_conference_venue_path(conference_id: @conference.short_title)
else
flash[:error] = "Update venue failed: #{@venue.errors.full_messages.join('. ')}."
render :edit
@ -34,10 +34,12 @@ module Admin
def destroy
if @venue.destroy
redirect_to admin_conference_venue_path, notice: 'Venue was successfully deleted.'
flash[:notice] = 'Venue was successfully deleted.'
redirect_to admin_conference_venue_path
else
redirect_to admin_conference_venue_path, alert: 'An error prohibited this Venue from being destroyed: '\
"#{@venue.errors.full_messages.join('. ')}."
flash[:error] = 'An error prohibited this Venue from being destroyed: '\
"#{@venue.errors.full_messages.join('. ')}."
redirect_to admin_conference_venue_path
end
end

View file

@ -25,9 +25,11 @@ module Admin
def update
if can_manage_volunteers(@conference)
if @conference.update_attributes(params[:conference])
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: 'Volunteering options were successfully updated.')
flash[:notice] = 'Volunteering options were successfully updated.'
redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id])
else
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}")
flash[:error] = "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}"
redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id])
end
else
authorize! :index, :volunteer

View file

@ -7,7 +7,7 @@ module Api
if params[:conference_id].blank?
conferences = Conference.all
else
conferences = Conference.find_all_by_guid(params[:conference_id])
conferences = Conference.find_by(short_title: params[:conference_id])
end
render json: conferences, serializer: ConferencesArraySerializer
end

View file

@ -1,6 +1,6 @@
class ApplicationController < ActionController::Base
include ApplicationHelper
protect_from_forgery
protect_from_forgery with: :exception
before_filter :get_conferences
before_filter :store_location
helper_method :date_string

View file

@ -15,8 +15,8 @@ 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'),
notice: 'Commercial was successfully created.'
flash[:notice] = 'Commercial was successfully created.'
redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content')
else
flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}."
render :new
@ -25,8 +25,8 @@ 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'),
notice: 'Commercial was successfully updated.'
flash[:notice] = 'Commercial was successfully updated.'
redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content')
else
flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}."
render :edit
@ -35,8 +35,8 @@ class CommercialsController < ApplicationController
def destroy
@commercial.destroy
redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id),
notice: 'Commercial was successfully destroyed.'
flash[:notice] = 'Commercial was successfully destroyed.'
redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id)
end
private
@ -46,7 +46,6 @@ class CommercialsController < ApplicationController
end
def commercial_params
#params.require(:commercial).permit(:commercial_id, :commercial_type)
params[:commercial]
params.require(:commercial).permit(:commercial_id, :commercial_type)
end
end

View file

@ -28,9 +28,9 @@ class ConferenceController < ApplicationController
private
def respond_to_options
respond_to do |format|
format.html { head :ok }
end if request.options?
end
def respond_to_options
respond_to do |format|
format.html { head :ok }
end if request.options?
end
end

View file

@ -95,7 +95,7 @@ class ConferenceRegistrationsController < ApplicationController
def set_registration
@registration = Registration.find_by(conference: @conference, user: current_user)
if !@registration
flash[:alert] = "Can't find a registration for #{@conference.title} for you. Please register."
flash[:error] = "Can't find a registration for #{@conference.title} for you. Please register."
redirect_to new_conference_conference_registrations_path(@conference.short_title)
end
end

View file

@ -78,8 +78,8 @@ class ProposalController < ApplicationController
return
end
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
notice: 'Proposal was successfully updated.')
flash[:notice] = 'Proposal was successfully updated.'
redirect_to conference_proposal_index_path(conference_id: @conference.short_title)
end
def destroy
@ -94,8 +94,8 @@ class ProposalController < ApplicationController
end
@event.save(validate: false)
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
notice: 'Proposal was successfully withdrawn.')
flash[:notice] = 'Proposal was successfully withdrawn.'
redirect_to conference_proposal_index_path(conference_id: @conference.short_title)
end
def confirm
@ -116,11 +116,11 @@ class ProposalController < ApplicationController
end
if @conference.user_registered?(current_user)
redirect_to(conference_proposal_index_path(@conference.short_title),
notice: 'The proposal was confirmed.')
flash[:notice] = 'The proposal was confirmed.'
redirect_to conference_proposal_index_path(@conference.short_title)
else
redirect_to(new_conference_conference_registrations_path(conference_id: @conference.short_title),
alert: 'The proposal was confirmed. Please register to attend the conference.')
flash[:error] = 'The proposal was confirmed. Please register to attend the conference.'
redirect_to new_conference_conference_registrations_path(conference_id: @conference.short_title)
end
end
@ -131,8 +131,8 @@ class ProposalController < ApplicationController
begin
@event.restart
rescue Transitions::InvalidTransition
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
error: "The proposal can't be re-submitted.")
flash[:error] = "The proposal can't be re-submitted."
redirect_to conference_proposal_index_path(conference_id: @conference.short_title)
return
end
@ -142,8 +142,9 @@ class ProposalController < ApplicationController
return
end
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
notice: "The proposal was re-submitted. The #{@conference.short_title} organizers will review it again.")
flash[:notice] = "The proposal was re-submitted. The #{@conference.short_title} organizers will review it again."
redirect_to conference_proposal_index_path(conference_id: @conference.short_title)
end
end

View file

@ -7,26 +7,23 @@ class TicketPurchasesController < ApplicationController
message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0])
if message.blank?
if current_user.ticket_purchases.any?
redirect_to conference_conference_registrations_path(@conference.short_title),
notice: "Thank you for supporting #{@conference.title} by purchasing a ticket."
else
redirect_to conference_conference_registrations_path(@conference.short_title)
flash[:notice] = "Thank you for supporting #{@conference.title} by purchasing a ticket."
end
redirect_to conference_conference_registrations_path(@conference.short_title)
else
redirect_to conference_conference_registrations_path(@conference.short_title),
alert: "Oops, something went wrong with your purchase! #{message}"
flash[:error] = "Oops, something went wrong with your purchase! #{message}"
redirect_to conference_conference_registrations_path(@conference.short_title)
end
end
def destroy
@ticket_purchases = current_user.ticket_purchases.find(params[:id])
if @ticket_purchases.destroy
redirect_to conference_conference_registrations_path(@conference.short_title),
notice: 'Ticket successfully deleted.'
flash[:notice] = 'Ticket successfully deleted.'
redirect_to conference_conference_registrations_path(@conference.short_title)
else
redirect_to conference_conference_registrations_path(@conference.short_title),
alert: 'An error prohibited deleting your purchase! '\
"#{@ticket_purchases.errors.full_messages.join('. ')}."
flash[:error] = "An error prohibited deleting your purchase! #{@ticket_purchases.errors.full_messages.join('. ')}."
redirect_to conference_conference_registrations_path(@conference.short_title)
end
end
end

View file

@ -9,7 +9,8 @@ class TicketsController < ApplicationController
def check_load_resource
if @tickets.empty?
redirect_to root_path, notice: "There are no tickets available for #{@conference.title}!"
flash[:notice] = "There are no tickets available for #{@conference.title}!"
redirect_to root_path
end
end
end

View file

@ -13,7 +13,8 @@ class UsersController < ApplicationController
# PATCH/PUT /users/1
def update
if @user.update(user_params)
redirect_to @user, notice: 'User was successfully updated.'
flash[notice] = 'User was successfully updated.'
redirect_to @user
else
flash[:error] = "An error prohibited your Profile from being saved: #{@user.errors.full_messages.join('. ')}."
render :edit

View file

@ -12,7 +12,7 @@ class Ticket < ActiveRecord::Base
validates :price_cents, :price_currency, :title, presence: true
validates_numericality_of :price_cents, greater_than: 0
validates :price_cents, numericality: { greater_than_or_equal_to: 0 }
def bought?(user)
buyers.include?(user)

View file

@ -1,23 +1,37 @@
- if event.transition_possible? :accept
%li= link_to 'Accept event',
accept_admin_conference_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 (with email)',
accept_admin_conference_event_path(@conference.short_title, event, send_mail: true),
hint: 'Accept this event and send an automated email.',
method: :patch, id: "accept_event_#{event.id}"
%li= link_to 'Accept event (without email)',
accept_admin_conference_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}"
hint: 'Accept this event without sending an automated email.',
method: :patch, id: "accept_event_without_mail_#{event.id}"
- else
%li= link_to 'Accept event (without email)',
accept_admin_conference_event_path(@conference.short_title, event),
hint: 'Accept this event without sending an automated email. You have not set an email template.',
method: :patch, id: "accept_event_#{event.id}"
- if event.transition_possible? :reject
%li= link_to 'Reject event',
reject_admin_conference_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 (with email)',
reject_admin_conference_event_path(@conference.short_title, event, send_mail: true),
hint: 'Reject this event and send an automated email.',
method: :patch, confirm: 'Are you sure?', id: "reject_event_#{event.id}"
%li= link_to 'Reject event (without email)',
reject_admin_conference_event_path(@conference.short_title, event, send_mail: false),
hint: 'Reject this event without sending an automated email.',
method: :patch, confirm: 'Are you sure?', id: "reject_event_without_mail_#{event.id}"
- else
%li= link_to 'Reject event (without email)',
reject_admin_conference_event_path(@conference.short_title, event),
hint: 'Reject this event without sending an automated email. You have not set an email template.',
method: :patch, confirm: 'Are you sure?', id: "reject_event_#{event.id}"
- if event.transition_possible? :restart
%li= link_to 'Start review',
@ -34,4 +48,4 @@
%li= link_to 'Cancel event',
cancel_admin_conference_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.'
hint: 'Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance.'

View file

@ -9,7 +9,7 @@
.row
.col-md-8
= semantic_form_for(@ticket, :url => (@ticket.new_record? ? admin_conference_tickets_path : admin_conference_ticket_path(@conference.short_title, @ticket))) do |f|
= f.input :title
= f.input :title, input_html: { required: true, autofocus: true }
= f.input :description, input_html: { rows: 5, data: { provide: "markdown-editable" } }
= f.input :price
= f.input :price_currency, as: :select, class: 'form-control', collection: ['USD', 'EUR', 'GBP', 'INR', 'CNY'], include_blank: false

View file

@ -27,7 +27,6 @@ Osem::Application.routes.draw do
resources :photos, except: [:show]
resource :schedule, only: [:show, :update]
resources :commercials, except: [:show]
get '/stats' => 'stats#index'
get '/dietary_choices' => 'dietchoices#show', as: 'dietary_list'
patch '/dietary_choices' => 'dietchoices#update', as: 'dietary_update'
get '/volunteers_list' => 'volunteers#show'

View file

@ -57,7 +57,7 @@ describe Admin::ConferenceController do
short_title: nil)
conference.reload
expect(flash[:alert]).
expect(flash[:error]).
to eq("Updating conference failed. Short title can't be blank.")
expect(conference.title).to eq('The dog and pony show')
expect(conference.short_title).to eq("#{conference.short_title}")
@ -68,7 +68,7 @@ describe Admin::ConferenceController do
attributes_for(:conference, title: 'Example Con',
short_title: nil)
expect(flash[:alert]).
expect(flash[:error]).
to eq("Updating conference failed. Short title can't be blank.")
expect(response).to redirect_to edit_admin_conference_path(
conference.short_title)

View file

@ -35,7 +35,6 @@ feature Ticket do
fill_in 'ticket_price', with: '-1'
click_button 'Create Ticket'
expect(flash).to eq("Creating Ticket failed: Title can't be blank. Price cents must be greater than 0.")
expect(Ticket.count).to eq(0)
end
@ -70,7 +69,6 @@ feature Ticket do
ticket.reload
expect(ticket.price).to eq(100)
expect(ticket.title).to eq('Business Ticket')
expect(flash).to eq("Ticket update failed: Title can't be blank. Price cents must be greater than 0.")
expect(Ticket.count).to eq(1)
end

View file

@ -22,11 +22,7 @@ describe Ticket do
should validate_presence_of(:price_currency)
end
it 'is not valid with a price_cents equals zero' do
should_not allow_value(0).for(:price_cents)
end
it 'is not valid with a price_cents smaller than zero' do
it 'is not valid with a price_cents less than zero' do
should_not allow_value(-1).for(:price_cents)
end