2017-06-21 16:14:41 +02:00
|
|
|
module ApplicationHelper
|
2018-01-11 18:09:01 +01:00
|
|
|
include SanitizeUrl
|
|
|
|
|
|
|
|
def sanitize_url(url)
|
2018-01-18 17:24:21 +01:00
|
|
|
if !url.nil?
|
|
|
|
super(url, schemes: ['http', 'https'], replace_evil_with: root_url)
|
|
|
|
end
|
2018-01-11 18:09:01 +01:00
|
|
|
end
|
|
|
|
|
2017-06-21 16:14:41 +02:00
|
|
|
def flash_class(level)
|
|
|
|
case level
|
|
|
|
when "notice" then "alert-success"
|
|
|
|
when "alert" then "alert-danger"
|
|
|
|
end
|
|
|
|
end
|
2017-06-22 16:45:57 +02:00
|
|
|
|
|
|
|
def current_email
|
2018-05-30 18:45:46 +02:00
|
|
|
current_user&.email ||
|
|
|
|
current_gestionnaire&.email ||
|
|
|
|
current_administrateur&.email
|
2017-06-22 16:45:57 +02:00
|
|
|
end
|
2018-03-08 13:54:26 +01:00
|
|
|
|
|
|
|
def root_path_for_profile(nav_bar_profile)
|
|
|
|
case nav_bar_profile
|
|
|
|
when :gestionnaire
|
|
|
|
gestionnaire_procedures_path
|
|
|
|
when :user
|
2018-06-27 14:47:02 +02:00
|
|
|
dossiers_path
|
2018-03-08 13:54:26 +01:00
|
|
|
else
|
|
|
|
root_path
|
|
|
|
end
|
|
|
|
end
|
2018-04-03 18:05:29 +02:00
|
|
|
|
|
|
|
def ensure_safe_json(json)
|
|
|
|
JSON.parse(json).to_json
|
|
|
|
rescue Exception => e
|
|
|
|
Raven.capture_exception(e)
|
|
|
|
{}
|
|
|
|
end
|
2017-06-21 16:14:41 +02:00
|
|
|
end
|