Flash uniformity done in a bunch of files
This commit is contained in:
parent
1e9f4b514c
commit
598606547e
9 changed files with 37 additions and 39 deletions
|
|
@ -4,6 +4,8 @@ class ApplicationController < ActionController::Base
|
|||
before_filter :get_conferences
|
||||
before_filter :store_location
|
||||
helper_method :date_string
|
||||
add_flash_types :error
|
||||
add_flash_types :alert
|
||||
# Ensure every controller authorizes resource or skips authorization (skip_authorization_check)
|
||||
check_authorization unless: :devise_controller?
|
||||
|
||||
|
|
@ -52,16 +54,14 @@ class ApplicationController < ActionController::Base
|
|||
rescue_from IChainRecordNotFound do
|
||||
Rails.logger.debug('IChain Record was not Unique!')
|
||||
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(@ user), 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
|
||||
|
||||
rescue_from UserDisabled do
|
||||
Rails.logger.debug('User is disabled!')
|
||||
sign_out(current_user)
|
||||
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
|
||||
redirect_to User.ichain_logout_url(@ user), error: "This User is disabled. Please contact #{mail}!"
|
||||
end
|
||||
|
||||
def not_found
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ class CommercialsController < ApplicationController
|
|||
load_resource :conference, find_by: :short_title
|
||||
before_action :set_event
|
||||
load_and_authorize_resource through: :event
|
||||
add_flash_types :error
|
||||
add_flash_types :alert
|
||||
|
||||
def create
|
||||
@commercial = @event.commercials.build(commercial_params)
|
||||
|
|
@ -11,8 +13,7 @@ class CommercialsController < ApplicationController
|
|||
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('. ')}."
|
||||
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
|
||||
|
||||
|
|
@ -21,8 +22,7 @@ class CommercialsController < ApplicationController
|
|||
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('. ')}."
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ class ConferenceRegistrationsController < ApplicationController
|
|||
load_resource :conference, find_by: :short_title
|
||||
authorize_resource :conference_registrations, class: Registration
|
||||
before_action :set_registration, only: [:edit, :update, :destroy, :show]
|
||||
add_flash_types :error
|
||||
add_flash_types :alert
|
||||
|
||||
def new
|
||||
# Redirect to registration edit when user is already registered
|
||||
|
|
@ -60,16 +62,14 @@ class ConferenceRegistrationsController < ApplicationController
|
|||
sign_in(@registration.user)
|
||||
end
|
||||
|
||||
flash[:notice] = 'You are now registered and will be receiving E-Mail notifications.'
|
||||
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
|
||||
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
|
||||
else
|
||||
flash[:error] = "Could not create your registration for #{@conference.title}: "\
|
||||
render :new, error: "Could not create your registration for #{@conference.title}: "\
|
||||
"#{@registration.errors.full_messages.join('. ')}."
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -78,9 +78,8 @@ class ConferenceRegistrationsController < ApplicationController
|
|||
redirect_to conference_conference_registrations_path(@conference.short_title),
|
||||
notice: 'Registration was successfully updated.'
|
||||
else
|
||||
flash[:error] = "Could not update your registration for #{@conference.title}: "\
|
||||
render :edit, error: "Could not update your registration for #{@conference.title}: "\
|
||||
"#{@registration.errors.full_messages.join('. ')}."
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -100,8 +99,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."
|
||||
redirect_to new_conference_conference_registrations_path(@conference.short_title)
|
||||
redirect_to new_conference_conference_registrations_path(@conference.short_title), alert: "Can't find a registration for #{@conference.title} for you. Please register."
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ class ProposalController < ApplicationController
|
|||
load_resource :conference, find_by: :short_title
|
||||
load_resource :program, through: :conference, singleton: true
|
||||
load_and_authorize_resource :event, parent: false, through: :program
|
||||
add_flash_types :error
|
||||
add_flash_types :alert
|
||||
|
||||
def index
|
||||
@events = current_user.proposals(@conference)
|
||||
|
|
@ -31,8 +33,7 @@ class ProposalController < ApplicationController
|
|||
if @user.save
|
||||
sign_in(@user)
|
||||
else
|
||||
flash[:error] = "Could not save user: #{@user.errors.full_messages.join(', ')}"
|
||||
render action: 'new'
|
||||
render action: 'new', error: "Could not save user: #{@user.errors.full_messages.join(', ')}"
|
||||
return
|
||||
end
|
||||
end
|
||||
|
|
@ -48,15 +49,13 @@ class ProposalController < ApplicationController
|
|||
event_role: 'speaker')
|
||||
|
||||
unless @event.save
|
||||
flash[:error] = "Could not submit proposal: #{@event.errors.full_messages.join(', ')}"
|
||||
render action: 'new'
|
||||
render action: 'new', error: "Could not submit proposal: #{@event.errors.full_messages.join(', ')}"
|
||||
return
|
||||
end
|
||||
|
||||
ahoy.track 'Event submission', title: 'New submission'
|
||||
|
||||
flash[:notice] = 'Proposal was successfully submitted.'
|
||||
redirect_to conference_program_proposal_index_path(@conference.short_title)
|
||||
redirect_to conference_program_proposal_index_path(@conference.short_title), notice: 'Proposal was successfully submitted.'
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
@ -64,8 +63,7 @@ class ProposalController < ApplicationController
|
|||
@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(', ')}"
|
||||
render action: 'new'
|
||||
render action: 'new', error: "Could not update proposal: #{@event.errors.full_messages.join(', ')}"
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -101,8 +99,7 @@ class ProposalController < ApplicationController
|
|||
end
|
||||
|
||||
if !@event.save
|
||||
flash[:error] = "Could not confirm proposal: #{@event.errors.full_messages.join(', ')}"
|
||||
render action: 'new'
|
||||
render action: 'new', error: "Could not confirm proposal: #{@event.errors.full_messages.join(', ')}"
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -128,8 +125,7 @@ class ProposalController < ApplicationController
|
|||
end
|
||||
|
||||
if !@event.save
|
||||
flash[:error] = "Could not re-submit proposal: #{@event.errors.full_messages.join(', ')}"
|
||||
render action: 'new'
|
||||
render action: 'new', error: "Could not re-submit proposal: #{@event.errors.full_messages.join(', ')}"
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
class RegistrationsController < Devise::RegistrationsController
|
||||
before_action :configure_permitted_parameters, if: :devise_controller?
|
||||
|
||||
|
||||
def edit
|
||||
@openids = Openid.where(user_id: current_user.id).order(:provider)
|
||||
super
|
||||
|
|
|
|||
|
|
@ -2,26 +2,24 @@ class SubscriptionsController < ApplicationController
|
|||
before_filter :authenticate_user!
|
||||
load_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource only: [:create, :destroy], through: :conference
|
||||
add_flash_types :error
|
||||
add_flash_types :alert
|
||||
|
||||
def create
|
||||
@subscription = current_user.subscriptions.build(conference_id: @conference.id)
|
||||
if @subscription.save!
|
||||
flash[:notice] = "You have been subscribed to receive email notifications for #{@conference.short_title}."
|
||||
redirect_to root_path
|
||||
redirect_to root_path, notice: "You have been subscribed to receive email notifications for #{@conference.short_title}."
|
||||
else
|
||||
flash[:error] = subscription.errors.full_messages.to_sentence
|
||||
redirect_to root_path
|
||||
redirect_to root_path, error: subscription.errors.full_messages.to_sentence
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@subscription = current_user.subscriptions.find_by(conference_id: @conference.id)
|
||||
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
|
||||
redirect_to root_path, notice: "You have been unsubscribed and now you will not be receiving email notifications for #{@conference.short_title}."
|
||||
else
|
||||
flash[:error] = @subscription.errors.full_messages.to_sentence
|
||||
redirect_to root_path
|
||||
redirect_to root_path, error: @subscription.errors.full_messages.to_sentence
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ class TicketPurchasesController < ApplicationController
|
|||
before_filter :authenticate_user!
|
||||
load_resource :conference, find_by: :short_title
|
||||
authorize_resource :conference_registrations, class: Registration
|
||||
add_flash_types :error
|
||||
add_flash_types :alert
|
||||
|
||||
def create
|
||||
message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0])
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ class TicketsController < ApplicationController
|
|||
load_resource :ticket, through: :conference
|
||||
authorize_resource :conference_registrations, class: Registration
|
||||
before_filter :check_load_resource, only: :index
|
||||
add_flash_types :error
|
||||
add_flash_types :alert
|
||||
|
||||
def index; end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
class UsersController < ApplicationController
|
||||
load_and_authorize_resource
|
||||
add_flash_types :error
|
||||
add_flash_types :alert
|
||||
|
||||
# GET /users/1
|
||||
def show
|
||||
|
|
@ -15,8 +17,7 @@ class UsersController < ApplicationController
|
|||
if @user.update(user_params)
|
||||
redirect_to @user, notice: 'User was successfully updated.'
|
||||
else
|
||||
flash[:error] = "An error prohibited your Profile from being saved: #{@user.errors.full_messages.join('. ')}."
|
||||
render :edit
|
||||
render :edit, error: "An error prohibited your Profile from being saved: #{@user.errors.full_messages.join('. ')}."
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue