diff --git a/Gemfile b/Gemfile index bfc41880..a2ba1fe7 100644 --- a/Gemfile +++ b/Gemfile @@ -27,7 +27,6 @@ gem 'jbuilder', '~> 2.5' # Use ActiveModel has_secure_password gem 'bcrypt', '~> 3.1.7' -gem 'webdrivers', '~> 4.0' # Uses HAML templates gem 'haml' @@ -89,7 +88,8 @@ group :test do gem 'rails-controller-testing' gem 'factory_bot_rails' gem 'simplecov' - + gem 'metric_fu-Saikuro','~> 1.1', '>= 1.1.3' + # Used for metrics gem 'metric_fu', git: 'https://github.com/metricfu/metric_fu.git' end diff --git a/Gemfile.lock b/Gemfile.lock index c2dba9cb..77049953 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -20,48 +20,43 @@ GIT GEM remote: https://rubygems.org/ specs: - - abstract_type (0.0.7) - actioncable (5.2.4) - actionpack (= 5.2.4) + actioncable (5.2.6) + actionpack (= 5.2.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.4) - actionpack (= 5.2.4) - actionview (= 5.2.4) - activejob (= 5.2.4) + actionmailer (5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.4) - actionview (= 5.2.4) - activesupport (= 5.2.4) - rack (~> 2.0) + actionpack (5.2.6) + actionview (= 5.2.6) + activesupport (= 5.2.6) + rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.4) - activesupport (= 5.2.4) - + actionview (5.2.6) + activesupport (= 5.2.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - - activejob (5.2.4) - activesupport (= 5.2.4) + activejob (5.2.6) + activesupport (= 5.2.6) globalid (>= 0.3.6) - activemodel (5.2.4) - activesupport (= 5.2.4) - activerecord (5.2.4) - activemodel (= 5.2.4) - activesupport (= 5.2.4) + activemodel (5.2.6) + activesupport (= 5.2.6) + activerecord (5.2.6) + activemodel (= 5.2.6) + activesupport (= 5.2.6) arel (>= 9.0) - activestorage (5.2.4) - actionpack (= 5.2.4) - activerecord (= 5.2.4) - marcel (~> 0.3.1) - activesupport (5.2.4) - + activestorage (5.2.6) + actionpack (= 5.2.6) + activerecord (= 5.2.6) + marcel (~> 1.0.0) + activesupport (5.2.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -70,14 +65,12 @@ GEM public_suffix (>= 2.0.2, < 5.0) arel (9.0.0) arrayfields (4.9.2) - ast (2.4.2) - autoprefixer-rails (10.2.4.0) - - execjs + autoprefixer-rails (10.2.5.0) + execjs (< 2.8.0) bcrypt (3.1.16) bindex (0.8.1) - bootsnap (1.7.3) + bootsnap (1.7.5) msgpack (~> 1.0) bootstrap (4.3.1) autoprefixer-rails (>= 9.1.0) @@ -114,7 +107,6 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.8) crass (1.0.6) cucumber (5.3.0) @@ -143,13 +135,12 @@ GEM cucumber-messages (~> 13.0, >= 13.0.1) cucumber-messages (13.2.1) protobuf-cucumber (~> 3.10, >= 3.10.8) - cucumber-rails (2.2.0) + cucumber-rails (2.3.0) capybara (>= 2.18, < 4) cucumber (>= 3.0.2, < 6) mime-types (~> 3.2) - nokogiri (~> 1.8) - rails (>= 5.0, < 7) + railties (>= 5.0, < 7) cucumber-rails-training-wheels (1.0.0) cucumber-rails (>= 1.1.1) cucumber-tag-expressions (2.0.4) @@ -159,24 +150,22 @@ GEM cucumber-messages (~> 13.0, >= 13.0.1) database_cleaner (2.0.1) database_cleaner-active_record (~> 2.0.0) - database_cleaner-active_record (2.0.0) + database_cleaner-active_record (2.0.1) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) diff-lcs (1.4.4) - docile (1.3.5) + docile (1.4.0) erubi (1.10.0) erubis (2.7.0) execjs (2.7.0) - factory_bot (6.1.0) + factory_bot (6.2.0) activesupport (>= 5.0.0) - factory_bot_rails (6.1.0) - factory_bot (~> 6.1.0) + factory_bot_rails (6.2.0) + factory_bot (~> 6.2.0) railties (>= 5.0.0) fattr (2.4.0) - ffi (1.15.0) - flay (2.12.1) erubis (~> 2.7.0) path_expander (~> 1.0) @@ -189,9 +178,7 @@ GEM formatador (0.2.5) globalid (0.4.2) activesupport (>= 4.2.0) - - guard (2.16.2) - + guard (2.17.0) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) lumberjack (>= 1.0.12, < 2.0) @@ -215,22 +202,16 @@ GEM html2haml (>= 1.0.1) railties (>= 5.1) hirb (0.7.3) - html2haml (2.2.0) erubis (~> 2.7.0) haml (>= 4.0, < 6) nokogiri (>= 1.6.0) ruby_parser (~> 3.5) - http-accept (1.7.0) - http-cookie (1.0.3) - domain_name (~> 0.5) - i18n (1.7.0) + i18n (1.8.10) concurrent-ruby (~> 1.0) - ice_nine (0.11.2) - jbuilder (2.9.1) - activesupport (>= 4.2.0) - jquery-rails (4.3.5) - + jbuilder (2.11.2) + activesupport (>= 5.0.0) + jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) @@ -242,9 +223,7 @@ GEM rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) - - loofah (2.9.0) - + loofah (2.9.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) lumberjack (1.2.8) @@ -256,36 +235,30 @@ GEM fattr (~> 2.2, >= 2.2.0) map (~> 6.1, >= 6.1.0) map (6.6.0) - marcel (0.3.3) - mimemagic (~> 0.3.2) + marcel (1.0.1) method_source (1.0.0) metric_fu-Saikuro (1.1.3) middleware (0.1.0) mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2021.0225) - mimemagic (0.3.6) - mini_mime (1.0.2) - - - mini_portile2 (2.4.0) - minitest (5.13.0) - msgpack (1.3.1) - multi_json (1.14.1) - + mini_mime (1.1.0) + mini_portile2 (2.5.1) + minitest (5.14.4) + msgpack (1.4.2) + multi_json (1.15.0) multi_test (0.1.2) nenv (0.3.0) - netrc (0.11.0) - nio4r (2.5.2) - nokogiri (1.10.7) - mini_portile2 (~> 2.4.0) + nio4r (2.5.7) + nokogiri (1.11.4) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - parallel (1.19.1) - parser (2.5.3.0) - ast (~> 2.4.0) - + parallel (1.20.1) + parser (3.0.1.1) + ast (~> 2.4.1) path_expander (1.1.0) pg (1.2.3) popper_js (1.16.0) @@ -294,10 +267,10 @@ GEM middleware thor thread_safe - pry (0.14.0) + pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) - psych (3.3.1) + psych (3.3.2) public_suffix (4.0.6) puma (3.12.6) racc (1.5.2) @@ -305,20 +278,18 @@ GEM rack-test (1.1.0) rack (>= 1.0, < 3) railroady (1.5.3) - - rails (5.2.4.5) - actioncable (= 5.2.4.5) - actionmailer (= 5.2.4.5) - actionpack (= 5.2.4.5) - actionview (= 5.2.4.5) - activejob (= 5.2.4.5) - activemodel (= 5.2.4.5) - activerecord (= 5.2.4.5) - activestorage (= 5.2.4.5) - activesupport (= 5.2.4.5) + rails (5.2.6) + actioncable (= 5.2.6) + actionmailer (= 5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) + activemodel (= 5.2.6) + activerecord (= 5.2.6) + activestorage (= 5.2.6) + activesupport (= 5.2.6) bundler (>= 1.3.0) - railties (= 5.2.4.5) - + railties (= 5.2.6) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -329,29 +300,27 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - rails_best_practices (1.20.0) + rails_best_practices (1.20.1) activesupport - code_analyzer (>= 0.5.1) + code_analyzer (>= 0.5.2) erubis i18n json require_all (~> 3.0) ruby-progressbar - - railties (5.2.4.5) - actionpack (= 5.2.4.5) - activesupport (= 5.2.4.5) + railties (5.2.6) + actionpack (= 5.2.6) + activesupport (= 5.2.6) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) rainbow (3.0.0) rake (13.0.3) - rb-fsevent (0.10.4) + rb-fsevent (0.11.0) rb-inotify (0.10.1) - ffi (~> 1.0) redcard (1.1.0) - reek (6.0.3) + reek (6.0.4) kwalify (~> 0.7.0) parser (~> 3.0.0) psych (~> 3.1) @@ -383,10 +352,8 @@ GEM rspec-support (3.10.2) ruby-progressbar (1.11.0) ruby_dep (1.5.0) - - ruby_parser (3.15.1) - - sexp_processor (~> 4.9) + ruby_parser (3.16.0) + sexp_processor (~> 4.15, >= 4.15.1) rubyzip (2.3.0) sass (3.7.4) sass-listen (~> 4.0.0) @@ -410,14 +377,14 @@ GEM selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - sexp_processor (4.15.2) + sexp_processor (4.15.3) shellany (0.0.1) simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) - simplecov_json_formatter (0.1.2) + simplecov_json_formatter (0.1.3) spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) @@ -447,22 +414,18 @@ GEM activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) - - - webdrivers (4.1.3) + webdrivers (4.6.0) nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (>= 3.0, < 4.0) - websocket-driver (0.7.1) - - + websocket-driver (0.7.3) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) PLATFORMS - x86_64-linux + ruby DEPENDENCIES bcrypt (~> 3.1.7) @@ -483,6 +446,7 @@ DEPENDENCIES launchy listen (>= 3.0.5, < 3.2) metric_fu! + metric_fu-Saikuro (~> 1.1, >= 1.1.3) nokogiri pg puma (~> 3.11) @@ -499,12 +463,10 @@ DEPENDENCIES tzinfo-data uglifier (>= 1.3.0) web-console (>= 3.3.0) - - webdrivers (~> 4.0) - + webdrivers RUBY VERSION ruby 2.7.2p137 BUNDLED WITH - 2.2.9 + 2.1.4 diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 9f93d455..2170ce24 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -111,6 +111,73 @@ def scrape_professores redirect_to dashboard_importar_professores_path end + ## + # Método recebe as informações do banco de dados das turmas + # e conta o número de monitorias pendentes para usar na view. + # + + def vagas_monitoria + @turmas = Turma.all_turmas + @monitorias = Monitoria.where(fk_status_monitoria_id: 1, remuneracao: "Remunerado") + @pendentes = @monitorias.size + + end + + ## + # Método recebe as informações do banco de dados das turmas, + # uma lista de monitores aceitos e dos usuarios e disponibiliza. + # para serem usadas na view. + # + + def monitoria_remunerada + @turmas = Turma.all_turmas + @monitores = Monitoria.where(fk_status_monitoria_id: 3, remuneracao: "Remunerado") + @users = User.all + end + + ## + # Método para alocação de bolsas remunerada. Método recebe do banco de dados uma lista de monitores + # remunerados em status de pendência e as informações das turmas existentes. + # Retorna flashes de sucesso ou fracasso ao checar se existem monitores a serem alocados. + # Verifica se o monitor pode ser alocado na turma, atualiza o banco e redireciona para a página de vagas de monitoria. + # + + def alocar_bolsa + @monitorias = Monitoria.where(fk_status_monitoria_id: 1, remuneracao: "Remunerado") + @turmas = Turma.all_turmas + tamanho = @monitorias.size + + case tamanho + when 0 + flash[:danger] = "Não existe monitorias a serem alocadas, ou as monitorias já foram alocadas!" + else + flash[:notice] = "Alunos alocados com sucesso!" + end + + @turmas.each_with_index do |turma, idx| + vagas = turma.qnt_bolsas + turma_id = turma.id + + @monitorias.each do |monitoria| + monitoria_turma_id = monitoria.fk_turmas_id + + if(monitoria_turma_id == turma_id) + case vagas + when 0 + monitoria.update!(fk_status_monitoria_id: 2) + else + vagas = vagas-1 + monitoria.update!(fk_status_monitoria_id: 3) + end + end + end + turma.update!(qnt_bolsas: vagas) + end + + redirect_to dashboard_vagas_monitoria_path + + end + private def user_logged if !logged_in? diff --git a/app/controllers/monitorias_remunerada_controller.rb b/app/controllers/monitorias_remunerada_controller.rb new file mode 100644 index 00000000..7abb4f63 --- /dev/null +++ b/app/controllers/monitorias_remunerada_controller.rb @@ -0,0 +1,57 @@ +class MonitoriasRemuneradaController < ApplicationController + before_action :find_monitor, only: [:show] + before_action :find_monitoria, only: [:destroy, :edit, :update] + + def show + @alunos = User.find_each + end + + ## + # Método para dar update nas vagas de monitoria, ao atualizar a situação + # da monitoria, atualiza a quantidade de bolsas de cada turma. + # Por fim redireciona a página para a aba de monitoria remunerada. + + def update + @turmas = Turma.all + status = @monitoria.fk_status_monitoria_id + turma_id = @monitoria.fk_turmas_id + + case status + when 1 || 2 + situacao = 1 + else + situacao = 2 + end + + @turmas.each do |turma| + if turma.id == turma_id + bolsas = turma.qnt_bolsas + case situacao + when 1 + turma.update!(qnt_bolsas: bolsas + 1) + else + if(bolsas > 0) + turma.update!(qnt_bolsas: bolsas - 1) + end + end + end + end + + if @monitoria.update monitoria_params + redirect_to dashboard_monitoria_remunerada_path, notice: "Situaçao atualizada!" + end + end + + private + def monitoria_params + params.require(:monitoria).permit(:remuneracao, :fk_matricula, :fk_cod_disciplina, :fk_turmas_id, :descricao_status, :prioridade, :fk_status_monitoria_id) + end + + def find_monitor + @monitoria = Monitoria.where(fk_turmas_id: params[:id]) + end + + def find_monitoria + @monitoria = Monitoria.find(params[:id]) + end +end diff --git a/app/models/turma.rb b/app/models/turma.rb index eba73ce3..c87efbe1 100644 --- a/app/models/turma.rb +++ b/app/models/turma.rb @@ -48,19 +48,19 @@ def self.all_turmas find_each() end - validates_presence_of :turma + # validates_presence_of :turma validates_presence_of :professor validates_presence_of :fk_cod_disciplina validates_presence_of :qnt_bolsas - validate :turma_unica + validates :turma, presence: true, uniqueness: true - def turma_unica - @turmas = Turma.where(fk_cod_disciplina: fk_cod_disciplina) + # def turma_unica + # @turmas = Turma.where(fk_cod_disciplina: fk_cod_disciplina) - @turmas.each do |t| - if t.turma == turma - errors.add(:turma, "#{turma} não é a única para a disciplina #{Disciplina.find(fk_cod_disciplina).nome}") - end - end - end -end \ No newline at end of file + # @turmas.each do |t| + # if t.turma == turma + # errors.add(:turma, "#{turma} não é a única para a disciplina #{Disciplina.find(fk_cod_disciplina).nome}") + # end + # end + # end +end diff --git a/app/views/dashboard/index.html.haml b/app/views/dashboard/index.html.haml index 151842fa..27771d1d 100644 --- a/app/views/dashboard/index.html.haml +++ b/app/views/dashboard/index.html.haml @@ -91,6 +91,13 @@ %span{'data-feather': "file-text"} Minhas Atividades + -if current_user.kind_of?(Admin) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_vagas_monitoria_path} + %span{'data-feather': "check"} + Vagas de monitoria + %main.col-md-9.ml-sm-auto.col-lg-10.px-4{role: "main"} .row - if flash[:notice] diff --git a/app/views/dashboard/monitoria_remunerada.html.haml b/app/views/dashboard/monitoria_remunerada.html.haml new file mode 100644 index 00000000..1794139e --- /dev/null +++ b/app/views/dashboard/monitoria_remunerada.html.haml @@ -0,0 +1,123 @@ +%br +%br +.container-fluid + .row + %nav.col-md-2.d-none.d-md-block.bg-light.sidebar{style: 'margin-top: 40px'} + .sidebar-sticky + %ul.nav.flex-column + %li.nav-item + %a.nav-link{href: dashboard_path} + %span{'data-feather': "home"} + Dashboard + %span.sr-only (current) + + -if current_user.kind_of?(Admin) + %li.nav-item + %a.nav-link{href: dashboard_disciplinas_path} + %span{'data-feather': "file"} + Disciplinas + + - if current_user.kind_of?(User) || current_user.kind_of?(Professor) + %li.nav-item + %a.nav-link{href: dashboard_monitorias_path} + %span{'data-feather': "github"} + Monitoria + + -if current_user.kind_of?(Professor) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_turmas_path} + %span{'data-feather': "edit"} + Turmas + + -if current_user.kind_of?(Admin) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_apagar_alunos_path} + %span{'data-feather': "trash"} + Apagar alunos + + -if current_user.kind_of?(Admin) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_importar_professores_path} + %span{'data-feather': "users"} + Importar lista de professores + + -if current_user.kind_of?(Admin) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link.active{href: dashboard_vagas_monitoria_path} + %span{'data-feather': "check"} + Vagas de monitoria + + -unless current_user.kind_of?(Admin) + %h6.sidebar-heading.d-flex.justify-content-between.align-items-center.px-3.mt-4.mb-1.text-muted + Menu + %span do usuário + %a.d-flex.align-items-center.text-muted{href: "#"} + %span{'data-feather': "plus-circle"} + + -if current_user.kind_of?(User) || current_user.kind_of?(Professor) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_edit_user_path} + %span{'data-feather': "settings"} + Editar Perfil + + -if current_user.kind_of?(User) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_dados_bancarios_path} + %span{'data-feather': "dollar-sign"} + Dados Bancários + + %main.col-md-9.ml-sm-auto.col-lg-10.px-4{role: "main"} + -if flash[:danger] + .alert.alert-danger + - flash[:danger] + -if flash[:notice] + .alert.alert-success + = flash[:notice] + .row + .col + %h1 Monitoria Remunerada + %br + %table.table + %thead + %tr + %td Disciplina + %td Turma + %td Bolsas Restantes + %td Monitores + %tbody + - @turmas.each do |a| + %tr + %td + = Disciplina.find_by_cod_disciplina(a.fk_cod_disciplina).nome + %td + = a.turma + %td + = a.qnt_bolsas + %td + - @monitores.each_with_index do |monitor, i| + - if monitor.fk_turmas_id == a.id + = "#{User.find_by_matricula(monitor.fk_matricula).name}. " + .row + .col + .ul.list-group + - @turmas.each do |turma| + - @disciplina = Disciplina.find(turma.fk_cod_disciplina) + %li.list-group-item + Disciplina: + %b + = @disciplina.nome + %br + Turma: + %b + = turma.turma + %br + %br + - cod = @disciplina.cod_disciplina + - m = Monitoria.find_by(fk_cod_disciplina: cod, fk_turmas_id: turma.id) + = link_to "Ver lista de monitores", dashboard_monitorias_remunerada_candidatos_path(id: turma.id), class: 'btn btn-outline-primary unb-blue' \ No newline at end of file diff --git a/app/views/dashboard/vagas_monitoria.html.haml b/app/views/dashboard/vagas_monitoria.html.haml new file mode 100644 index 00000000..fdd56ab3 --- /dev/null +++ b/app/views/dashboard/vagas_monitoria.html.haml @@ -0,0 +1,99 @@ +%br +%br +.container-fluid + .row + %nav.col-md-2.d-none.d-md-block.bg-light.sidebar{style: 'margin-top: 40px'} + .sidebar-sticky + %ul.nav.flex-column + %li.nav-item + %a.nav-link{href: dashboard_path} + %span{'data-feather': "home"} + Dashboard + %span.sr-only (current) + + -if current_user.kind_of?(Admin) + %li.nav-item + %a.nav-link{href: dashboard_disciplinas_path} + %span{'data-feather': "file"} + Disciplinas + + - if current_user.kind_of?(User) || current_user.kind_of?(Professor) + %li.nav-item + %a.nav-link{href: dashboard_monitorias_path} + %span{'data-feather': "github"} + Monitoria + + -if current_user.kind_of?(Professor) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_turmas_path} + %span{'data-feather': "edit"} + Turmas + + -if current_user.kind_of?(Admin) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_apagar_alunos_path} + %span{'data-feather': "trash"} + Apagar alunos + + -if current_user.kind_of?(Admin) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_importar_professores_path} + %span{'data-feather': "users"} + Importar lista de professores + + -if current_user.kind_of?(Admin) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link.active{href: dashboard_vagas_monitoria_path} + %span{'data-feather': "check"} + Vagas de monitoria + + -unless current_user.kind_of?(Admin) + %h6.sidebar-heading.d-flex.justify-content-between.align-items-center.px-3.mt-4.mb-1.text-muted + Menu + %span do usuário + %a.d-flex.align-items-center.text-muted{href: "#"} + %span{'data-feather': "plus-circle"} + + -if current_user.kind_of?(User) || current_user.kind_of?(Professor) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_edit_user_path} + %span{'data-feather': "settings"} + Editar Perfil + + -if current_user.kind_of?(User) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_dados_bancarios_path} + %span{'data-feather': "dollar-sign"} + Dados Bancários + + %main.col-md-9.ml-sm-auto.col-lg-10.px-4{role: "main"} + - if flash[:notice] + .alert.alert-success + =flash[:notice] + - if flash[:danger] + %div{class: "alert alert-danger"} + =flash[:danger] + .row + .col + %h1 Vagas de Monitoria + .col-4 + %br + .row + .col-16 + Quantidade de monitorias pendentes. + %h1 #{@pendentes} + = form_tag dashboard_alocar_bolsa_path, method: :get do + = submit_tag 'Alocar', class: 'btn btn-outline-success unb-green btn-block' + %br + Revisão de vagas para monitoria Remunerada. + %br + .row + .col-3 + = link_to "Monitoria Remunerada", dashboard_monitoria_remunerada_path, class: 'btn btn-outline-primary unb-blue' + %br \ No newline at end of file diff --git a/app/views/monitorias_remunerada/edit.html.haml b/app/views/monitorias_remunerada/edit.html.haml new file mode 100644 index 00000000..b12ef837 --- /dev/null +++ b/app/views/monitorias_remunerada/edit.html.haml @@ -0,0 +1,52 @@ +%br +%main.container{role: "main"} + .row + .col-3 + .col.text-center + %h1 Aplicar Para Monitor + %hr + %p.text-justify + Altere a situação do candidato a monitoria para: Pendente, Recusado ou Aceito. + .col-3 + + .row + .col-3 + .col + -if flash[:danger] + .alert.alert-danger + = flash[:danger] + -if flash[:notice] + .alert.alert-success + = flash[:notice] + + = form_tag monitorias_remunerada_path, method: :put do + - @aluno = User.find_by(matricula: @monitoria.fk_matricula) + .form-group.row + = label_tag :aluno, "Aluno", class: "col-sm-3 col-form-label" + .col-sm-9 + %p.form-control-plaintext + =@aluno.name + .form-group.row + = label_tag :matricula, 'Matrícula', class: 'col-sm-3 col-form-label' + .col-sm-9 + %p.form-control-plaintext + =@aluno.matricula + .form-group.row + = label_tag :remuneracao, 'Remuneração', class: 'col-sm-3 col-form-label' + .col-sm-9 + %p.form-control-plaintext + =@monitoria.remuneracao + .form-group.row + = label_tag :descricao_status, 'Descrição', class: 'col-sm-3 col-form-label' + .col-sm-9 + %p.form-control-plaintext + =@monitoria.descricao_status + + .form-group.row + = label :monitoria, :fk_status_monitoria_id, "Situaçao", class: "col-sm-3 col-form-label" + .col-sm-9 + = select :monitoria, :fk_status_monitoria_id, options_for_select(Monitoria.all_status), {}, class: 'custom-select' + + %br + = submit_tag 'Atualizar', class: "btn btn-outline-primary btn-block" + .col-3 \ No newline at end of file diff --git a/app/views/monitorias_remunerada/show.html.haml b/app/views/monitorias_remunerada/show.html.haml new file mode 100644 index 00000000..260b20ed --- /dev/null +++ b/app/views/monitorias_remunerada/show.html.haml @@ -0,0 +1,118 @@ +%br +%br +.container-fluid + .row + %nav.col-md-2.d-none.d-md-block.bg-light.sidebar{style: 'margin-top: 40px'} + .sidebar-sticky + %ul.nav.flex-column + %li.nav-item + %a.nav-link{href: dashboard_path} + %span{'data-feather': "home"} + Dashboard + %span.sr-only (current) + + -if current_user.kind_of?(Admin) + %li.nav-item + %a.nav-link{href: dashboard_disciplinas_path} + %span{'data-feather': "file"} + Disciplinas + + - if current_user.kind_of?(User) || current_user.kind_of?(Professor) + %li.nav-item + %a.nav-link{href: dashboard_monitorias_path} + %span{'data-feather': "github"} + Monitoria + + -if current_user.kind_of?(Professor) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_turmas_path} + %span{'data-feather': "edit"} + Turmas + + -if current_user.kind_of?(Admin) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_apagar_alunos_path} + %span{'data-feather': "trash"} + Apagar alunos + + -if current_user.kind_of?(Admin) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_importar_professores_path} + %span{'data-feather': "users"} + Importar lista de professores + + -if current_user.kind_of?(Admin) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link.active{href: dashboard_vagas_monitoria_path} + %span{'data-feather': "check"} + Vagas de monitoria + + -unless current_user.kind_of?(Admin) + %h6.sidebar-heading.d-flex.justify-content-between.align-items-center.px-3.mt-4.mb-1.text-muted + Menu + %span do usuário + %a.d-flex.align-items-center.text-muted{href: "#"} + %span{'data-feather': "plus-circle"} + + -if current_user.kind_of?(User) || current_user.kind_of?(Professor) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_edit_user_path} + %span{'data-feather': "settings"} + Editar Perfil + + -if current_user.kind_of?(User) + %ul.nav.flex-column.mb-2 + %li.nav-item + %a.nav-link{href: dashboard_dados_bancarios_path} + %span{'data-feather': "dollar-sign"} + Dados Bancários + + %main.col-md-9.ml-sm-auto.col-lg-10.px-4{role: "main"} + .col-1 + .col + -if flash[:danger] + .alert.alert-danger + - flash[:danger] + -if flash[:notice] + .alert.alert-success + = flash[:notice] + - d = Disciplina.find(Turma.find(params[:id]).fk_cod_disciplina) + %h2 Candidatos a monitor + %h4 Disciplina: #{d.nome} + %h5 + Turma: #{Turma.find(params[:id]).turma} + %br + .row + - @alunos.each do |a| + - @monitoria.each do |monitor| + - if monitor.fk_matricula == a.matricula and monitor.remuneracao == 'Remunerado' + .col-3 + .card + .card-body + %h5.card-title + Aluno: #{a.name} + Matrícula: #{a.matricula} + %br + Remuneração: #{monitor.remuneracao} + %br + Descrição: #{monitor.descricao_status} + %br + Status: + %b + - if monitor.fk_status_monitoria_id == 1 + Pendente + - elsif monitor.fk_status_monitoria_id == 2 + Rejeitado + - elsif monitor.fk_status_monitoria_id == 3 + Aceito + - else + Encerrado + + %hr + =link_to "Alterar Situaçao", edit_monitorias_remunerada_path(monitor.id), class: 'btn btn-outline-primary unb-blue btn-block' + .col-1 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 5c0e1204..7fb15df7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,6 +19,7 @@ get 'new_from_disciplina' end end + resources :monitorias_remunerada resources :reset_senhas, only: [:new, :create, :edit, :update] match "/dashboard", to: "dashboard#index", via: 'get' @@ -35,6 +36,12 @@ match "/dashboard/raspar_disciplinas", to: "dashboard#raspar_disciplinas", via: 'get' match "/dashboard/importar_professores", to: "dashboard#importar_professores", via: 'get' match "/dashboard/scrape_professores", to: "dashboard#scrape_professores", via: 'get' + match "/dashboard/vagas_monitoria", to: "dashboard#vagas_monitoria", via: 'get' + match "/dashboard/monitoria_remunerada", to: "dashboard#monitoria_remunerada", via: 'get' + match "/dashboard/alocar_bolsa", to: "dashboard#alocar_bolsa", :via => 'get' + match "/dashboard/monitorias_remunerada/candidatos", to: "monitorias_remunerada#show", via: 'get' + get 'monitorias_remunerada/edit' + get 'monitorias_remunerada/show' match "/dashboard/atendimentos", to: "dashboard#atendimentos", via: [:get, :post] match "/dashboard/registrar_atividade", to: "dashboard#registrar_atividade", via: 'get' diff --git a/db/migrate/20191121154635_add_monitor_to_atendimentos.rb b/db/migrate/20191121154635_add_monitor_to_atendimentos.rb index 190fa11f..2431b02f 100644 --- a/db/migrate/20191121154635_add_monitor_to_atendimentos.rb +++ b/db/migrate/20191121154635_add_monitor_to_atendimentos.rb @@ -1,5 +1,5 @@ class AddMonitorToAtendimentos < ActiveRecord::Migration[5.2] def change - add_reference :atendimentos, :monitor, foreign_key: true + add_reference :atendimentos, :monitor, foreign_key: {to_table: :users} end end diff --git a/db/schema.rb b/db/schema.rb index b3b197b1..d0aa8b15 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,9 +10,10 @@ # # It's strongly recommended that you check this file into your version control system. - ActiveRecord::Schema.define(version: 2019_12_10_130811) do + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" create_table "admins", force: :cascade do |t| t.string "name", null: false @@ -25,13 +26,13 @@ end create_table "atendimentos", force: :cascade do |t| - t.integer "motivo_id" + t.bigint "motivo_id" t.date "dia" t.string "descricao" t.string "aluno_atendido" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.integer "monitor_id" + t.bigint "monitor_id" t.index ["monitor_id"], name: "index_atendimentos_on_monitor_id" t.index ["motivo_id"], name: "index_atendimentos_on_motivo_id" end @@ -142,7 +143,7 @@ t.boolean "feito" t.datetime "inicio" t.datetime "fim" - t.integer "monitoria_id" + t.bigint "monitoria_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["monitoria_id"], name: "index_tarefas_on_monitoria_id" @@ -193,4 +194,7 @@ t.integer "c_restantes", default: 0, null: false end + add_foreign_key "atendimentos", "motivos" + add_foreign_key "atendimentos", "users", column: "monitor_id" + add_foreign_key "tarefas", "monitoria", column: "monitoria_id" end diff --git a/db/seeds.rb b/db/seeds.rb index 54463dc5..04022dc5 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -11,35 +11,69 @@ User.destroy_all Turma.destroy_all Disciplina.destroy_all +Monitoria.destroy_all ###################### -#Admin.create(id: 1, name: "Admin UnB", email: "secretaria@cic.unb.br", password: "123456", -# remember_token: nil, created_at: '2018-06-04 18:12:09.050792', updated_at: '2018-06-04 18:12:09.050792') +Admin.create(id: 1, name: "Admin UnB", email: "secretaria@cic.unb.br", password: "123456", + remember_token: nil, created_at: '2018-06-04 18:12:09.050792', updated_at: '2018-06-04 18:12:09.050792') ###################### -Disciplina.create([{id:1, nome: "APC", +Disciplina.create!([{id:1, nome: "APC", fk_tipo_disciplina_id: 1, c_prat: 2, c_teor: 4, cod_disciplina: 1}]) -Disciplina.create([{id:2, nome: "ED", +Disciplina.create!([{id:2, nome: "ED", fk_tipo_disciplina_id: 1, c_prat: 2, c_teor: 2, cod_disciplina: 2}]) ###################### -# User.create(id: 1, name: "Aluno1", email: "aluno1@gmail.com", password: "123456", -# cpf: "03638481182", rg: "2645178", matricula: "140080279") +User.create!(id: 1, name: "Aluno", email: "aluno1@gmail.com", password: "123456", password_confirmation: '123456', + cpf: "03638481182", rg: "2645178", matricula: "140080279") +User.create!(id: 2, name: "Aluno A", email: "aluno2@gmail.com", password: "123456", password_confirmation: '123456', + cpf: "58385203028", rg: "2435178", matricula: "150060279") + +User.create!(id: 3, name: "Aluno B", email: "aluno3@gmail.com", password: "123456", password_confirmation: '123456', + cpf: "19215272003", rg: "5245378", matricula: "160088333") + +User.create!(id: 4, name: "Aluno C", email: "aluno4@gmail.com", password: "123456", password_confirmation: '123456', + cpf: "26389963009", rg: "3345179", matricula: "130099979") + +User.create!(id: 5, name: "Aluno D", email: "aluno5@gmail.com", password: "123456", password_confirmation: '123456', + cpf: "80906055083", rg: "6205279", matricula: "180080279") + +###################### +Monitoria.create!(id: 1, remuneracao: 'Remunerado', fk_matricula: '140080279' , fk_cod_disciplina: 1, fk_turmas_id: 1, prioridade: 1, + fk_status_monitoria_id: 1); + +Monitoria.create!(id: 2, remuneracao: 'Remunerado', fk_matricula: '150060279' , fk_cod_disciplina: 1, fk_turmas_id: 2, prioridade: 1, + fk_status_monitoria_id: 1); + +Monitoria.create!(id: 3, remuneracao: 'Remunerado',fk_matricula: '160088333' , fk_cod_disciplina: 1, fk_turmas_id: 1, prioridade: 1, + fk_status_monitoria_id: 1); + +Monitoria.create!(id: 4, remuneracao: 'Remunerado',fk_matricula: '130099979', fk_cod_disciplina: 2, fk_turmas_id: 4, prioridade: 1, + fk_status_monitoria_id: 1); + +Monitoria.create!(id: 5, remuneracao: 'Remunerado',fk_matricula: '180080279', fk_cod_disciplina: 1, fk_turmas_id: 4, prioridade: 1, + fk_status_monitoria_id: 1); +###################### + # User.create(id: 2, name: "Aluno2", email: "aluno2@gmail.com", password: "123456", # cpf: "03638481111", rg: "2645111", matricula: "140080211", # fk_banco: nil, remember_token: nil, created_at: '2018-06-04 19:02:24.831795', # updated_at: '2018-06-04 19:02:24.831795') -#Professor.create(id: 1, name: "Carla", email: "carla@unb.br", username: "carla", password: "123456", role: 1) +Professor.create!(id: 1, name: "Genaina", email: "genaina@unb.br", username: "genaina", password: "123456", password_confirmation: '123456', role: 1) +Professor.create!(id: 2, name: "Carla", email: "carla@unb.br", username: "carla", password: "123456", password_confirmation: '123456', role: 1) ###################### ###################### -# Turma.create([{id:1, turma: "A", professor: "Carla", fk_cod_disciplina: 1}]) +Turma.create!(id:1, turma: "A", professor: "Carla", fk_cod_disciplina: 1 , qnt_bolsas: 1, fk_vagas_id: 1) +Turma.create!(id:2, turma: "B", professor: "Genaina", fk_cod_disciplina: 1, qnt_bolsas: 1, fk_vagas_id: 1) +Turma.create!(id:3, turma: "C", professor: "Genaina", fk_cod_disciplina: 2, qnt_bolsas: 1, fk_vagas_id: 1) +Turma.create!(id:4, turma: "D", professor: "Carla", fk_cod_disciplina: 2, qnt_bolsas: 4, fk_vagas_id: 1) ###################### diff --git a/doc/3_1_7.html b/doc/3_1_7.html index 85d1e9d1..a404eb1b 100644 --- a/doc/3_1_7.html +++ b/doc/3_1_7.html @@ -21,8 +21,6 @@ - -