Skip to content

Commit

Permalink
Notify exception. Only show admission page to committee professors
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoFelipe committed Jan 4, 2024
1 parent 2f1f999 commit e6662d0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
7 changes: 5 additions & 2 deletions app/controllers/admissions/admission_processes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ def consolidate_phase
@message += ". #{I18n.t("#{i18n_prefix}.not_approved", count: @not_approved.count)}"
end
end

rescue => err
ExceptionNotifier.notify_exception(err)
@exception = "Erro ao consolidar fase: #{err}"
ensure
params.each_key do |key|
if !["authenticity_token", "controller", "action"].include? key
Expand All @@ -224,7 +226,8 @@ def calculate_ranking
@ranking = @admission_process.rankings.where(id: params[:admission_process_ranking_id]).first
@candidates = @ranking.generate_ranking
rescue => exception
@errors = exception
ExceptionNotifier.notify_exception(exception)
@errors = "Erro ao calcular ranking: #{exception}"
end

params.each_key do |key|
Expand Down
1 change: 1 addition & 0 deletions app/models/admissions/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def initialize_admissions(user, roles)
can :override, Admissions::AdmissionApplication
can :cancel, Admissions::AdmissionApplication
can :configuration, Admissions::AdmissionApplication
can :read_all, Admissions::AdmissionApplication
end
if roles[Role::ROLE_ADMINISTRADOR] || roles[Role::ROLE_COORDENACAO]
can :manage, ADMISSION_MODELS
Expand Down
16 changes: 14 additions & 2 deletions config/navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,18 @@ def can_read?(*args)
Admissions::RankingMachine,
Admissions::AdmissionApplication,
]
mainhelper.listitem :admissions, admission_models do |submenu|
check_admission_application = -> {
return true if can?(:read_all, Admissions::AdmissionApplication)
return false if !can?(:read, Admissions::AdmissionApplication)
applications = Admissions::AdmissionApplication.includes(:pendencies)
.where(pendencies: { user_id: current_user.id })
applications.size > 0
}
admissions_if = -> { can_read?(
admission_models - [Admissions::AdmissionApplication]
).call || check_admission_application.call }

mainhelper.listitem :admissions, admission_models, if: admissions_if do |submenu|
submenu.modelitem Admissions::AdmissionProcess
submenu.modelitem Admissions::FormTemplate
submenu.item(:consolidation_template, consolidation_templates_path,
Expand All @@ -214,7 +225,8 @@ def can_read?(*args)
submenu.modelitem Admissions::AdmissionPhase
submenu.modelitem Admissions::RankingConfig
submenu.modelitem Admissions::RankingMachine
submenu.modelitem Admissions::AdmissionApplication
submenu.modelitem(Admissions::AdmissionApplication,
if: check_admission_application)
end

config_models = [
Expand Down

0 comments on commit e6662d0

Please sign in to comment.