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 :get_conferences
|
||||||
before_filter :store_location
|
before_filter :store_location
|
||||||
helper_method :date_string
|
helper_method :date_string
|
||||||
|
add_flash_types :error
|
||||||
|
add_flash_types :alert
|
||||||
# Ensure every controller authorizes resource or skips authorization (skip_authorization_check)
|
# Ensure every controller authorizes resource or skips authorization (skip_authorization_check)
|
||||||
check_authorization unless: :devise_controller?
|
check_authorization unless: :devise_controller?
|
||||||
|
|
||||||
|
|
@ -52,16 +54,14 @@ 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(@ 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!"
|
||||||
redirect_to root_path
|
|
||||||
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(@ user), error: "This User is disabled. Please contact #{mail}!"
|
||||||
redirect_to User.ichain_logout_url
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def not_found
|
def not_found
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ class CommercialsController < ApplicationController
|
||||||
load_resource :conference, find_by: :short_title
|
load_resource :conference, find_by: :short_title
|
||||||
before_action :set_event
|
before_action :set_event
|
||||||
load_and_authorize_resource through: :event
|
load_and_authorize_resource through: :event
|
||||||
|
add_flash_types :error
|
||||||
|
add_flash_types :alert
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@commercial = @event.commercials.build(commercial_params)
|
@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'),
|
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'), 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')
|
|
||||||
end
|
end
|
||||||
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'),
|
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'), 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')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ class ConferenceRegistrationsController < ApplicationController
|
||||||
load_resource :conference, find_by: :short_title
|
load_resource :conference, find_by: :short_title
|
||||||
authorize_resource :conference_registrations, class: Registration
|
authorize_resource :conference_registrations, class: Registration
|
||||||
before_action :set_registration, only: [:edit, :update, :destroy, :show]
|
before_action :set_registration, only: [:edit, :update, :destroy, :show]
|
||||||
|
add_flash_types :error
|
||||||
|
add_flash_types :alert
|
||||||
|
|
||||||
def new
|
def new
|
||||||
# Redirect to registration edit when user is already registered
|
# Redirect to registration edit when user is already registered
|
||||||
|
|
@ -60,16 +62,14 @@ 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}: "\
|
render :new, error: "Could not create your registration for #{@conference.title}: "\
|
||||||
"#{@registration.errors.full_messages.join('. ')}."
|
"#{@registration.errors.full_messages.join('. ')}."
|
||||||
render :new
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -78,9 +78,8 @@ class ConferenceRegistrationsController < ApplicationController
|
||||||
redirect_to conference_conference_registrations_path(@conference.short_title),
|
redirect_to conference_conference_registrations_path(@conference.short_title),
|
||||||
notice: 'Registration was successfully updated.'
|
notice: 'Registration was successfully updated.'
|
||||||
else
|
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('. ')}."
|
"#{@registration.errors.full_messages.join('. ')}."
|
||||||
render :edit
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -100,8 +99,7 @@ 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), alert: "Can't find a registration for #{@conference.title} for you. Please register."
|
||||||
redirect_to new_conference_conference_registrations_path(@conference.short_title)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ class ProposalController < ApplicationController
|
||||||
load_resource :conference, find_by: :short_title
|
load_resource :conference, find_by: :short_title
|
||||||
load_resource :program, through: :conference, singleton: true
|
load_resource :program, through: :conference, singleton: true
|
||||||
load_and_authorize_resource :event, parent: false, through: :program
|
load_and_authorize_resource :event, parent: false, through: :program
|
||||||
|
add_flash_types :error
|
||||||
|
add_flash_types :alert
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@events = current_user.proposals(@conference)
|
@events = current_user.proposals(@conference)
|
||||||
|
|
@ -31,8 +33,7 @@ class ProposalController < ApplicationController
|
||||||
if @user.save
|
if @user.save
|
||||||
sign_in(@user)
|
sign_in(@user)
|
||||||
else
|
else
|
||||||
flash[:error] = "Could not save user: #{@user.errors.full_messages.join(', ')}"
|
render action: 'new', error: "Could not save user: #{@user.errors.full_messages.join(', ')}"
|
||||||
render action: 'new'
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -48,15 +49,13 @@ class ProposalController < ApplicationController
|
||||||
event_role: 'speaker')
|
event_role: 'speaker')
|
||||||
|
|
||||||
unless @event.save
|
unless @event.save
|
||||||
flash[:error] = "Could not submit proposal: #{@event.errors.full_messages.join(', ')}"
|
render action: 'new', error: "Could not submit proposal: #{@event.errors.full_messages.join(', ')}"
|
||||||
render action: 'new'
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -64,8 +63,7 @@ class ProposalController < ApplicationController
|
||||||
@url = conference_program_proposal_path(@conference.short_title, params[:id])
|
@url = conference_program_proposal_path(@conference.short_title, params[:id])
|
||||||
|
|
||||||
if !@event.update(event_params)
|
if !@event.update(event_params)
|
||||||
flash[:error] = "Could not update proposal: #{@event.errors.full_messages.join(', ')}"
|
render action: 'new', error: "Could not update proposal: #{@event.errors.full_messages.join(', ')}"
|
||||||
render action: 'new'
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -101,8 +99,7 @@ class ProposalController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if !@event.save
|
if !@event.save
|
||||||
flash[:error] = "Could not confirm proposal: #{@event.errors.full_messages.join(', ')}"
|
render action: 'new', error: "Could not confirm proposal: #{@event.errors.full_messages.join(', ')}"
|
||||||
render action: 'new'
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -128,8 +125,7 @@ class ProposalController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if !@event.save
|
if !@event.save
|
||||||
flash[:error] = "Could not re-submit proposal: #{@event.errors.full_messages.join(', ')}"
|
render action: 'new', error: "Could not re-submit proposal: #{@event.errors.full_messages.join(', ')}"
|
||||||
render action: 'new'
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
class RegistrationsController < Devise::RegistrationsController
|
class RegistrationsController < Devise::RegistrationsController
|
||||||
before_action :configure_permitted_parameters, if: :devise_controller?
|
before_action :configure_permitted_parameters, if: :devise_controller?
|
||||||
|
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@openids = Openid.where(user_id: current_user.id).order(:provider)
|
@openids = Openid.where(user_id: current_user.id).order(:provider)
|
||||||
|
|
|
||||||
|
|
@ -2,26 +2,24 @@ class SubscriptionsController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
load_resource :conference, find_by: :short_title
|
load_resource :conference, find_by: :short_title
|
||||||
load_and_authorize_resource only: [:create, :destroy], through: :conference
|
load_and_authorize_resource only: [:create, :destroy], through: :conference
|
||||||
|
add_flash_types :error
|
||||||
|
add_flash_types :alert
|
||||||
|
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ class TicketPurchasesController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
load_resource :conference, find_by: :short_title
|
load_resource :conference, find_by: :short_title
|
||||||
authorize_resource :conference_registrations, class: Registration
|
authorize_resource :conference_registrations, class: Registration
|
||||||
|
add_flash_types :error
|
||||||
|
add_flash_types :alert
|
||||||
|
|
||||||
def create
|
def create
|
||||||
message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0])
|
message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0])
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ class TicketsController < ApplicationController
|
||||||
load_resource :ticket, through: :conference
|
load_resource :ticket, through: :conference
|
||||||
authorize_resource :conference_registrations, class: Registration
|
authorize_resource :conference_registrations, class: Registration
|
||||||
before_filter :check_load_resource, only: :index
|
before_filter :check_load_resource, only: :index
|
||||||
|
add_flash_types :error
|
||||||
|
add_flash_types :alert
|
||||||
|
|
||||||
def index; end
|
def index; end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
add_flash_types :error
|
||||||
|
add_flash_types :alert
|
||||||
|
|
||||||
# GET /users/1
|
# GET /users/1
|
||||||
def show
|
def show
|
||||||
|
|
@ -15,8 +17,7 @@ class UsersController < ApplicationController
|
||||||
if @user.update(user_params)
|
if @user.update(user_params)
|
||||||
redirect_to @user, notice: 'User was successfully updated.'
|
redirect_to @user, notice: 'User was successfully updated.'
|
||||||
else
|
else
|
||||||
flash[:error] = "An error prohibited your Profile from being saved: #{@user.errors.full_messages.join('. ')}."
|
render :edit, error: "An error prohibited your Profile from being saved: #{@user.errors.full_messages.join('. ')}."
|
||||||
render :edit
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue