Files
grecia/app/controllers/management/base_controller.rb
Javi Martín db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00

65 lines
1.4 KiB
Ruby

class Management::BaseController < ActionController::Base
include GlobalizeFallbacks
layout "management"
default_form_builder ConsulFormBuilder
before_action :verify_manager
before_action :set_locale
helper_method :managed_user
helper_method :current_user
helper_method :manager_logged_in
private
def verify_manager
raise ActionController::RoutingError.new("Not Found") if current_manager.blank?
end
def current_manager
session[:manager]
end
def current_user
managed_user
end
def managed_user
@managed_user ||= Verification::Management::ManagedUser.find(
session[:document_type],
session[:document_number]
)
end
def check_verified_user(alert_msg)
unless managed_user.level_two_or_three_verified?
redirect_to management_document_verifications_path, alert: alert_msg
end
end
def set_locale
if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym)
session[:locale] = params[:locale]
end
session[:locale] ||= I18n.default_locale
I18n.locale = session[:locale]
Globalize.locale = I18n.locale
end
def current_budget
Budget.current
end
def clear_password
session[:new_password] = nil
end
def manager_logged_in
if current_manager
@manager_logged_in = User.find_by_manager_login(session[:manager]["login"])
end
end
end