Merge pull request #858 from nishanthvijayan/refactor-redirect-flash

Add flash type error.Rewrite controllers to use common flash style wi…
This commit is contained in:
Christian Bruckmayer 2016-03-16 08:19:43 -06:00
commit 6cde2a5f4a
33 changed files with 173 additions and 174 deletions

View file

@ -34,8 +34,8 @@ module Admin
if @cfp.update_attributes(call_for_paper_params) if @cfp.update_attributes(call_for_paper_params)
Mailbot.delay.send_on_call_for_papers_dates_updated(@conference) if send_mail_on_cfp_dates_updated 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 Mailbot.delay.send_on_schedule_public(@conference) if send_mail_on_schedule_public
redirect_to(admin_conference_call_for_paper_path(@conference.short_title), redirect_to admin_conference_call_for_paper_path(@conference.short_title),
notice: 'Call for papers successfully updated.') notice: 'Call for papers successfully updated.'
else else
flash[:error] = "Updating call for papers failed. #{@cfp.errors.to_a.join('. ')}." flash[:error] = "Updating call for papers failed. #{@cfp.errors.to_a.join('. ')}."
render :new render :new

View file

@ -12,8 +12,8 @@ module Admin
@campaign.attributes = campaign_params @campaign.attributes = campaign_params
if @conference.save 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)) notice: 'Campaign successfully created.'
else else
flash[:error] = 'Campaign creation failed. ' + @campaign.errors.full_messages.to_sentence flash[:error] = 'Campaign creation failed. ' + @campaign.errors.full_messages.to_sentence
render action: 'new' render action: 'new'
@ -26,8 +26,8 @@ module Admin
def update def update
if @campaign.update_attributes(campaign_params) if @campaign.update_attributes(campaign_params)
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)) notice: "Campaign '#{@campaign.name}' successfully updated."
else else
flash[:error] = "Campaign update failed. #{@campaign.errors.full_messages.to_sentence}" flash[:error] = "Campaign update failed. #{@campaign.errors.full_messages.to_sentence}"
render action: 'edit' render action: 'edit'
@ -36,12 +36,12 @@ module Admin
def destroy def destroy
if @campaign.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)) notice: "Campaign '#{@campaign.name}' successfully deleted."
else else
flash[:error] = "Delete of Campaign for #{@conference.short_title} failed." \ redirect_to admin_conference_campaigns_path(conference_id: @conference.short_title),
error: "Delete of Campaign for #{@conference.short_title} failed."\
"#{@campaign.errors.full_messages.join('. ')}." "#{@campaign.errors.full_messages.join('. ')}."
redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title))
end end
end end

View file

@ -32,8 +32,8 @@ module Admin
if @cfp.update_attributes(cfp_params) if @cfp.update_attributes(cfp_params)
Mailbot.delay.send_on_cfps_dates_updates(@conference) if send_mail_on_cfp_dates_updates 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), redirect_to admin_conference_program_cfp_path(@conference.short_title),
notice: 'Call for papers successfully updated.') notice: 'Call for papers successfully updated.'
else else
flash[:error] = "Updating call for papers failed. #{@cfp.errors.to_a.join('. ')}." flash[:error] = "Updating call for papers failed. #{@cfp.errors.to_a.join('. ')}."
render :new render :new

View file

@ -18,8 +18,9 @@ module Admin
redirect_to admin_conference_commercials_path, redirect_to admin_conference_commercials_path,
notice: 'Commercial was successfully created.' notice: 'Commercial was successfully created.'
else else
flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." redirect_to admin_conference_commercials_path,
redirect_to admin_conference_commercials_path error: 'An error prohibited this Commercial from being saved: '\
"#{@commercial.errors.full_messages.join('. ')}."
end end
end end
@ -29,8 +30,9 @@ module Admin
redirect_to admin_conference_commercials_path, redirect_to admin_conference_commercials_path,
notice: 'Commercial was successfully updated.' notice: 'Commercial was successfully updated.'
else else
flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." redirect_to admin_conference_commercials_path,
redirect_to admin_conference_commercials_path error: 'An error prohibited this Commercial from being saved: '\
"#{@commercial.errors.full_messages.join('. ')}."
end end
end end

View file

@ -67,12 +67,11 @@ module Admin
@conference = Conference.new(conference_params) @conference = Conference.new(conference_params)
if @conference.save if @conference.save
flash[:notice] = 'Conference was successfully created.'
# user that creates the conference becomes organizer of that conference # user that creates the conference becomes organizer of that conference
current_user.add_role :organizer, @conference current_user.add_role :organizer, @conference
redirect_to admin_conference_path(id: @conference.short_title) redirect_to admin_conference_path(id: @conference.short_title),
notice: 'Conference was successfully created.'
else else
flash[:error] = 'Could not create conference. ' + @conference.errors.full_messages.to_sentence flash[:error] = 'Could not create conference. ' + @conference.errors.full_messages.to_sentence
render action: 'new' render action: 'new'
@ -87,12 +86,12 @@ module Admin
if @conference.update_attributes(conference_params) if @conference.update_attributes(conference_params)
Mailbot.delay.conference_date_update_mail(@conference) if send_mail_on_conf_update Mailbot.delay.conference_date_update_mail(@conference) if send_mail_on_conf_update
redirect_to(edit_admin_conference_path(id: @conference.short_title), redirect_to edit_admin_conference_path(id: @conference.short_title),
notice: 'Conference was successfully updated.') notice: 'Conference was successfully updated.'
else else
redirect_to(edit_admin_conference_path(id: short_title), redirect_to edit_admin_conference_path(id: short_title),
alert: 'Updating conference failed. ' \ error: 'Updating conference failed. ' \
"#{@conference.errors.full_messages.join('. ')}.") "#{@conference.errors.full_messages.join('. ')}."
end end
end end

View file

@ -17,8 +17,8 @@ module Admin
def create def create
@difficulty_level = @conference.program.difficulty_levels.new(difficulty_level_params) @difficulty_level = @conference.program.difficulty_levels.new(difficulty_level_params)
if @difficulty_level.save if @difficulty_level.save
flash[:notice] = 'Difficulty level successfully created.' redirect_to admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title),
redirect_to(admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title)) notice: 'Difficulty level successfully created.'
else else
flash[:error] = "Creating difficulty level failed: #{@difficulty_level.errors.full_messages.join('. ')}." flash[:error] = "Creating difficulty level failed: #{@difficulty_level.errors.full_messages.join('. ')}."
render :new render :new
@ -27,8 +27,8 @@ module Admin
def update def update
if @difficulty_level.update_attributes(difficulty_level_params) if @difficulty_level.update_attributes(difficulty_level_params)
flash[:notice] = 'Difficulty level successfully updated.' redirect_to admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title),
redirect_to(admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title)) notice: 'Difficulty level successfully updated.'
else else
flash[:error] = "Update difficulty level failed: #{@difficulty_level.errors.full_messages.join('. ')}." flash[:error] = "Update difficulty level failed: #{@difficulty_level.errors.full_messages.join('. ')}."
render :edit render :edit
@ -37,12 +37,12 @@ module Admin
def destroy def destroy
if @difficulty_level.destroy if @difficulty_level.destroy
flash[:notice] = 'Difficulty level successfully deleted.' redirect_to admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title),
redirect_to(admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title)) notice: 'Difficulty level successfully deleted.'
else else
flash[:error] = 'Deleting difficulty level type failed! ' \ redirect_to admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title),
error: 'Deleting difficulty level type failed! '\
"#{@difficulty_level.errors.full_messages.join('. ')}." "#{@difficulty_level.errors.full_messages.join('. ')}."
redirect_to(admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title))
end end
end end

View file

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

View file

@ -15,8 +15,8 @@ module Admin
def create def create
@event_type = @conference.program.event_types.new(event_type_params) @event_type = @conference.program.event_types.new(event_type_params)
if @event_type.save if @event_type.save
flash[:notice] = 'Event type successfully created.' redirect_to admin_conference_program_event_types_path(conference_id: @conference.short_title),
redirect_to(admin_conference_program_event_types_path(conference_id: @conference.short_title)) notice: 'Event type successfully created.'
else else
flash[:error] = "Creating event type failed: #{@event_type.errors.full_messages.join('. ')}." flash[:error] = "Creating event type failed: #{@event_type.errors.full_messages.join('. ')}."
render :new render :new
@ -25,8 +25,8 @@ module Admin
def update def update
if @event_type.update_attributes(event_type_params) if @event_type.update_attributes(event_type_params)
flash[:notice] = 'Event type successfully updated.' redirect_to admin_conference_program_event_types_path(conference_id: @conference.short_title),
redirect_to(admin_conference_program_event_types_path(conference_id: @conference.short_title)) notice: 'Event type successfully updated.'
else else
flash[:error] = "Update event type failed: #{@event_type.errors.full_messages.join('. ')}." flash[:error] = "Update event type failed: #{@event_type.errors.full_messages.join('. ')}."
render :edit render :edit
@ -35,12 +35,12 @@ module Admin
def destroy def destroy
if @event_type.destroy if @event_type.destroy
flash[:notice] = 'Event type successfully deleted.' redirect_to admin_conference_program_event_types_path(conference_id: @conference.short_title),
redirect_to(admin_conference_program_event_types_path(conference_id: @conference.short_title)) notice: 'Event type successfully deleted.'
else else
flash[:error] = 'Destroying event type failed! ' \ redirect_to admin_conference_program_event_types_path(conference_id: @conference.short_title),
error: 'Destroying event type failed! '\
"#{@event_type.errors.full_messages.join('. ')}." "#{@event_type.errors.full_messages.join('. ')}."
redirect_to(admin_conference_program_event_types_path(conference_id: @conference.short_title))
end end
end end

View file

@ -182,8 +182,9 @@ module Admin
def get_event def get_event
@event = @conference.program.events.find(params[:id]) @event = @conference.program.events.find(params[:id])
if !@event if !@event
redirect_to(admin_conference_program_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 error: 'Error! Could not find event!'
return
end end
@event @event
end end

View file

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

View file

@ -15,8 +15,8 @@ module Admin
if @program.update_attributes(program_params) if @program.update_attributes(program_params)
# Mailbot.delay.send_on_schedule_public(@conference) if send_mail_on_schedule_public # Mailbot.delay.send_on_schedule_public(@conference) if send_mail_on_schedule_public
redirect_to(admin_conference_program_path(@conference.short_title), redirect_to admin_conference_program_path(@conference.short_title),
notice: 'The program was successfully updated.') notice: 'The program was successfully updated.'
else else
flash[:error] = "Updating program failed. #{@program.errors.to_a.join('. ')}." flash[:error] = "Updating program failed. #{@program.errors.to_a.join('. ')}."
render :new render :new

View file

@ -32,8 +32,7 @@ module Admin
if @conference.save if @conference.save
format.html { redirect_to admin_conference_questions_path, notice: 'Question was successfully created.' } format.html { redirect_to admin_conference_questions_path, notice: 'Question was successfully created.' }
else else
flash[:error] = "Oops, couldn't save Question. #{@question.errors.full_messages.join('. ')}" format.html { redirect_to admin_conference_questions_path, error: "Oops, couldn't save Question. #{@question.errors.full_messages.join('. ')}" }
format.html { redirect_to admin_conference_questions_path }
end end
end end
end end
@ -41,16 +40,16 @@ module Admin
# GET questions/1/edit # GET questions/1/edit
def edit def edit
if @question.global if @question.global
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), alert: 'Sorry, you cannot edit global questions. Create a new one.') redirect_to admin_conference_questions_path(conference_id: @conference.short_title), error: 'Sorry, you cannot edit global questions. Create a new one.'
end end
end end
# PUT questions/1 # PUT questions/1
def update def update
if @question.update_attributes(question_params) if @question.update_attributes(question_params)
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Question '#{@question.title}' for #{@conference.short_title} successfully updated.") redirect_to admin_conference_questions_path(conference_id: @conference.short_title), notice: "Question '#{@question.title}' for #{@conference.short_title} successfully updated."
else else
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed. #{@question.errors.full_messages.join('. ')}") redirect_to admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed. #{@question.errors.full_messages.join('. ')}"
end end
end end
@ -58,9 +57,9 @@ module Admin
def update_conference def update_conference
authorize! :update, Question.new(conference_id: @conference.id) authorize! :update, Question.new(conference_id: @conference.id)
if @conference.update_attributes(conference_params) if @conference.update_attributes(conference_params)
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Questions for #{@conference.short_title} successfully updated.") redirect_to admin_conference_questions_path(conference_id: @conference.short_title), notice: "Questions for #{@conference.short_title} successfully updated."
else else
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed.") redirect_to admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed."
end end
end end

View file

@ -31,8 +31,8 @@ module Admin
redirect_to admin_conference_registrations_path(@conference.short_title), redirect_to admin_conference_registrations_path(@conference.short_title),
notice: "Deleted registration for #{@user.name}!" notice: "Deleted registration for #{@user.name}!"
else else
redirect_to(admin_conference_registrations_path(@conference.short_title), redirect_to admin_conference_registrations_path(@conference.short_title),
error: 'You must be an admin to delete a registration.') error: 'You must be an admin to delete a registration.'
end end
end end

View file

@ -21,8 +21,8 @@ module Admin
role_name = @role.name role_name = @role.name
if @role.update_attributes(role_params) if @role.update_attributes(role_params)
flash[:notice] = 'Successfully updated role ' + @role.name redirect_to admin_conference_role_path(@conference.short_title, @role.name),
redirect_to admin_conference_role_path(@conference.short_title, @role.name) notice: 'Successfully updated role ' + @role.name
else else
@role.name = role_name @role.name = role_name
flash[:error] = 'Could not update role! ' + @role.errors.full_messages.to_sentence flash[:error] = 'Could not update role! ' + @role.errors.full_messages.to_sentence
@ -35,14 +35,16 @@ module Admin
state = user_params[:state] state = user_params[:state]
unless user unless user
flash[:error] = 'Could not find user. Please provide a valid email!' redirect_to admin_conference_role_path(@conference.short_title, @role.name),
redirect_to(admin_conference_role_path(@conference.short_title, @role.name)) && return error: 'Could not find user. Please provide a valid email!'
return
end end
# The conference must have at least 1 organizer # The conference must have at least 1 organizer
if @role.name == 'organizer' && state == 'false' && @role.users.count == 1 if @role.name == 'organizer' && state == 'false' && @role.users.count == 1
flash[:error] = 'The conference must have at least 1 organizer!' redirect_to admin_conference_role_path(@conference.short_title, @role.name),
redirect_to(admin_conference_role_path(@conference.short_title, @role.name)) && return error: 'The conference must have at least 1 organizer!'
return
end end
# Remove user # Remove user

View file

@ -15,8 +15,8 @@ module Admin
def create def create
@room = @venue.rooms.new(room_params) @room = @venue.rooms.new(room_params)
if @room.save if @room.save
flash[:notice] = 'Room successfully created.' redirect_to admin_conference_venue_rooms_path(conference_id: @conference.short_title),
redirect_to(admin_conference_venue_rooms_path(conference_id: @conference.short_title)) notice: 'Room successfully created.'
else else
flash[:error] = "Creating Room failed: #{@room.errors.full_messages.join('. ')}." flash[:error] = "Creating Room failed: #{@room.errors.full_messages.join('. ')}."
render :new render :new
@ -25,8 +25,8 @@ module Admin
def update def update
if @room.update_attributes(room_params) if @room.update_attributes(room_params)
flash[:notice] = 'Room successfully updated.' redirect_to admin_conference_venue_rooms_path(conference_id: @conference.short_title),
redirect_to(admin_conference_venue_rooms_path(conference_id: @conference.short_title)) notice: 'Room successfully updated.'
else else
flash[:error] = "Update Room failed: #{@room.errors.full_messages.join('. ')}." flash[:error] = "Update Room failed: #{@room.errors.full_messages.join('. ')}."
render :edit render :edit
@ -35,11 +35,11 @@ module Admin
def destroy def destroy
if @room.destroy if @room.destroy
flash[:notice] = 'Room successfully deleted.' redirect_to admin_conference_venue_rooms_path(conference_id: @conference.short_title),
redirect_to(admin_conference_venue_rooms_path(conference_id: @conference.short_title)) notice: 'Room successfully deleted.'
else else
flash[:error] = "Destroying room failed! #{@room.errors.full_messages.join('. ')}." redirect_to admin_conference_venue_rooms_path(conference_id: @conference.short_title),
redirect_to(admin_conference_venue_rooms_path(conference_id: @conference.short_title)) error: "Destroying room failed! #{@room.errors.full_messages.join('. ')}."
end end
end end

View file

@ -35,7 +35,7 @@ module Admin
if @splashpage.destroy if @splashpage.destroy
redirect_to admin_conference_splashpage_path, notice: 'Splashpage was successfully destroyed.' redirect_to admin_conference_splashpage_path, notice: 'Splashpage was successfully destroyed.'
else else
redirect_to admin_conference_splashpage_path, alert: 'An error prohibited this Splashpage from being destroyed: '\ redirect_to admin_conference_splashpage_path, error: 'An error prohibited this Splashpage from being destroyed: '\
"#{@splashpage.errors.full_messages.join('. ')}." "#{@splashpage.errors.full_messages.join('. ')}."
end end
end end

View file

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

View file

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

View file

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

View file

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

View file

@ -20,8 +20,8 @@ module Admin
def create def create
@track = @program.tracks.new(track_params) @track = @program.tracks.new(track_params)
if @track.save if @track.save
flash[:notice] = 'Track successfully created.' redirect_to admin_conference_program_tracks_path(conference_id: @conference.short_title),
redirect_to(admin_conference_program_tracks_path(conference_id: @conference.short_title)) notice: 'Track successfully created.'
else else
flash[:error] = "Creating Track failed: #{@track.errors.full_messages.join('. ')}." flash[:error] = "Creating Track failed: #{@track.errors.full_messages.join('. ')}."
render :new render :new
@ -32,8 +32,8 @@ module Admin
def update def update
if @track.update_attributes(track_params) if @track.update_attributes(track_params)
flash[:notice] = 'Track successfully updated.' redirect_to admin_conference_program_tracks_path(conference_id: @conference.short_title),
redirect_to(admin_conference_program_tracks_path(conference_id: @conference.short_title)) notice: 'Track successfully updated.'
else else
flash[:error] = "Track update failed: #{@track.errors.full_messages.join('. ')}." flash[:error] = "Track update failed: #{@track.errors.full_messages.join('. ')}."
render :edit render :edit
@ -42,11 +42,11 @@ module Admin
def destroy def destroy
if @track.destroy if @track.destroy
flash[:notice] = 'Track successfully deleted.' redirect_to admin_conference_program_tracks_path(conference_id: @conference.short_title),
redirect_to(admin_conference_program_tracks_path(conference_id: @conference.short_title)) notice: 'Track successfully deleted.'
else else
flash[:error] = "Track couldn't be deleted. #{@track.errors.full_messages.join('. ')}." redirect_to admin_conference_program_tracks_path(conference_id: @conference.short_title),
redirect_to(admin_conference_program_tracks_path(conference_id: @conference.short_title)) error: "Track couldn't be deleted. #{@track.errors.full_messages.join('. ')}."
end end
end end

View file

@ -30,7 +30,7 @@ module Admin
if @user.update_attributes(user_params) if @user.update_attributes(user_params)
redirect_to admin_users_path, notice: "Updated #{@user.name} (#{@user.email})!" + message redirect_to admin_users_path, notice: "Updated #{@user.name} (#{@user.email})!" + message
else else
redirect_to admin_users_path, alert: "Could not update #{@user.name} (#{@user.email}). #{@user.errors.full_messages.join('. ')}." redirect_to admin_users_path, error: "Could not update #{@user.name} (#{@user.email}). #{@user.errors.full_messages.join('. ')}."
end end
end end

View file

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

View file

@ -24,9 +24,9 @@ module Admin
def update def update
if @conference.update_attributes(conference_params) if @conference.update_attributes(conference_params)
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: 'Volunteering options were successfully updated.') redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: 'Volunteering options were successfully updated.'
else else
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}") redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id]), error: "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}"
end end
end end

View file

@ -1,5 +1,6 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
include ApplicationHelper include ApplicationHelper
add_flash_types :error
protect_from_forgery with: :exception protect_from_forgery with: :exception
before_filter :get_conferences before_filter :get_conferences
before_filter :store_location before_filter :store_location
@ -52,16 +53,15 @@ class ApplicationController < ActionController::Base
rescue_from IChainRecordNotFound do rescue_from IChainRecordNotFound do
Rails.logger.debug('IChain Record was not Unique!') Rails.logger.debug('IChain Record was not Unique!')
sign_out(current_user) sign_out(current_user)
flash[:error] = 'Your E-Mail adress is already registered at OSEM. Please contact the admin if you want to attach your openSUSE Account to OSEM!' redirect_to root_path,
redirect_to root_path error: 'Your E-Mail adress is already registered at OSEM. Please contact the admin if you want to attach your openSUSE Account to OSEM!'
end end
rescue_from UserDisabled do rescue_from UserDisabled do
Rails.logger.debug('User is disabled!') Rails.logger.debug('User is disabled!')
sign_out(current_user) sign_out(current_user)
mail = User.admin.first ? User.admin.first.email : 'the admin!' mail = User.admin.first ? User.admin.first.email : 'the admin!'
flash[:error] = "This User is disabled. Please contact #{mail}!" redirect_to User.ichain_logout_url, error: "This User is disabled. Please contact #{mail}!"
redirect_to User.ichain_logout_url
end end
def not_found def not_found

View file

@ -11,8 +11,8 @@ class CommercialsController < ApplicationController
redirect_to edit_conference_program_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.' notice: 'Commercial was successfully created.'
else else
flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'),
redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content') error: "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}."
end end
end end
@ -21,8 +21,8 @@ class CommercialsController < ApplicationController
redirect_to edit_conference_program_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.' notice: 'Commercial was successfully updated.'
else else
flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'),
redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content') error: "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}."
end end
end end

View file

@ -21,7 +21,7 @@ class ConferenceRegistrationsController < ApplicationController
end end
if @conference.registration_limit_exceeded? if @conference.registration_limit_exceeded?
redirect_to root_path, alert: "Sorry, registration limit exceeded for #{@conference.title}" redirect_to root_path, error: "Sorry, registration limit exceeded for #{@conference.title}"
return return
end end
@ -60,11 +60,12 @@ class ConferenceRegistrationsController < ApplicationController
sign_in(@registration.user) sign_in(@registration.user)
end end
flash[:notice] = 'You are now registered and will be receiving E-Mail notifications.'
if @conference.tickets.any? && !current_user.supports?(@conference) if @conference.tickets.any? && !current_user.supports?(@conference)
redirect_to conference_tickets_path(@conference.short_title) redirect_to conference_tickets_path(@conference.short_title),
notice: 'You are now registered and will be receiving E-Mail notifications.'
else else
redirect_to conference_conference_registrations_path(@conference.short_title) redirect_to conference_conference_registrations_path(@conference.short_title),
notice: 'You are now registered and will be receiving E-Mail notifications.'
end end
else else
flash[:error] = "Could not create your registration for #{@conference.title}: "\ flash[:error] = "Could not create your registration for #{@conference.title}: "\
@ -100,8 +101,8 @@ class ConferenceRegistrationsController < ApplicationController
def set_registration def set_registration
@registration = Registration.find_by(conference: @conference, user: current_user) @registration = Registration.find_by(conference: @conference, user: current_user)
if !@registration if !@registration
flash[:alert] = "Can't find a registration for #{@conference.title} for you. Please register." redirect_to new_conference_conference_registrations_path(@conference.short_title),
redirect_to new_conference_conference_registrations_path(@conference.short_title) error: "Can't find a registration for #{@conference.title} for you. Please register."
end end
end end

View file

@ -55,8 +55,7 @@ class ProposalController < ApplicationController
ahoy.track 'Event submission', title: 'New submission' ahoy.track 'Event submission', title: 'New submission'
flash[:notice] = 'Proposal was successfully submitted.' redirect_to conference_program_proposal_index_path(@conference.short_title), notice: 'Proposal was successfully submitted.'
redirect_to conference_program_proposal_index_path(@conference.short_title)
end end
def update def update
@ -69,8 +68,8 @@ class ProposalController < ApplicationController
return return
end end
redirect_to(conference_program_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.') notice: 'Proposal was successfully updated.'
end end
def destroy def destroy
@ -80,13 +79,13 @@ class ProposalController < ApplicationController
begin begin
@event.withdraw @event.withdraw
rescue Transitions::InvalidTransition rescue Transitions::InvalidTransition
redirect_to(:back, error: "Event can't be withdrawn") redirect_to :back, error: "Event can't be withdrawn"
return return
end end
@event.save(validate: false) @event.save(validate: false)
redirect_to(conference_program_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.') notice: 'Proposal was successfully withdrawn.'
end end
def confirm def confirm
@ -96,7 +95,7 @@ class ProposalController < ApplicationController
begin begin
@event.confirm! @event.confirm!
rescue Transitions::InvalidTransition rescue Transitions::InvalidTransition
redirect_to(:back, error: "Event can't be confirmed") redirect_to :back, error: "Event can't be confirmed"
return return
end end
@ -107,11 +106,11 @@ class ProposalController < ApplicationController
end end
if @conference.user_registered?(current_user) if @conference.user_registered?(current_user)
redirect_to(conference_program_proposal_index_path(@conference.short_title), redirect_to conference_program_proposal_index_path(@conference.short_title),
notice: 'The proposal was confirmed.') notice: 'The proposal was confirmed.'
else else
redirect_to(new_conference_conference_registrations_path(conference_id: @conference.short_title), redirect_to new_conference_conference_registrations_path(conference_id: @conference.short_title),
alert: 'The proposal was confirmed. Please register to attend the conference.') alert: 'The proposal was confirmed. Please register to attend the conference.'
end end
end end
@ -122,8 +121,8 @@ class ProposalController < ApplicationController
begin begin
@event.restart @event.restart
rescue Transitions::InvalidTransition rescue Transitions::InvalidTransition
redirect_to(conference_program_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.") error: "The proposal can't be re-submitted."
return return
end end
@ -133,8 +132,8 @@ class ProposalController < ApplicationController
return return
end end
redirect_to(conference_program_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.") notice: "The proposal was re-submitted. The #{@conference.short_title} organizers will review it again."
end end
private private

View file

@ -6,22 +6,18 @@ class SubscriptionsController < ApplicationController
def create def create
@subscription = current_user.subscriptions.build(conference_id: @conference.id) @subscription = current_user.subscriptions.build(conference_id: @conference.id)
if @subscription.save! if @subscription.save!
flash[:notice] = "You have been subscribed to receive email notifications for #{@conference.short_title}." redirect_to root_path, notice: "You have been subscribed to receive email notifications for #{@conference.short_title}."
redirect_to root_path
else else
flash[:error] = subscription.errors.full_messages.to_sentence redirect_to root_path, error: subscription.errors.full_messages.to_sentence
redirect_to root_path
end end
end end
def destroy def destroy
@subscription = current_user.subscriptions.find_by(conference_id: @conference.id) @subscription = current_user.subscriptions.find_by(conference_id: @conference.id)
if @subscription.destroy if @subscription.destroy
flash[:notice] = "You have been unsubscribed and now you will not be receiving email notifications for #{@conference.short_title}." redirect_to root_path, notice: "You have been unsubscribed and now you will not be receiving email notifications for #{@conference.short_title}."
redirect_to root_path
else else
flash[:error] = @subscription.errors.full_messages.to_sentence redirect_to root_path, error: @subscription.errors.full_messages.to_sentence
redirect_to root_path
end end
end end
end end

View file

@ -14,7 +14,7 @@ class TicketPurchasesController < ApplicationController
end end
else else
redirect_to conference_conference_registrations_path(@conference.short_title), redirect_to conference_conference_registrations_path(@conference.short_title),
alert: "Oops, something went wrong with your purchase! #{message}" error: "Oops, something went wrong with your purchase! #{message}"
end end
end end
@ -25,7 +25,7 @@ class TicketPurchasesController < ApplicationController
notice: 'Ticket successfully deleted.' notice: 'Ticket successfully deleted.'
else else
redirect_to conference_conference_registrations_path(@conference.short_title), redirect_to conference_conference_registrations_path(@conference.short_title),
alert: 'An error prohibited deleting your purchase! '\ error: 'An error prohibited deleting your purchase! '\
"#{@ticket_purchases.errors.full_messages.join('. ')}." "#{@ticket_purchases.errors.full_messages.join('. ')}."
end end
end end

View file

@ -28,8 +28,8 @@ module Users
openid.save! openid.save!
sign_in user sign_in user
flash[:notice] = "#{user.email} signed in successfully with #{provider}" redirect_to request.env['omniauth.origin'] || root_path,
redirect_to request.env['omniauth.origin'] || root_path notice: "#{user.email} signed in successfully with #{provider}"
rescue => e rescue => e
flash[:error] = e.message flash[:error] = e.message
redirect_back_or_to new_user_registration_path redirect_back_or_to new_user_registration_path

View file

@ -181,9 +181,9 @@ module ApplicationHelper
# Same as redirect_to(:back) if there is a valid HTTP referer, otherwise redirect_to() # Same as redirect_to(:back) if there is a valid HTTP referer, otherwise redirect_to()
def redirect_back_or_to(options = {}, response_status = {}) def redirect_back_or_to(options = {}, response_status = {})
if request.env['HTTP_REFERER'] if request.env['HTTP_REFERER']
redirect_to(:back) redirect_to :back
else else
redirect_to(options, response_status) redirect_to options, response_status
end end
end end

View file

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