diff --git a/.gitignore b/.gitignore
index ca8c327d..c2c807d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -64,4 +64,6 @@
# .idea/misc.xml
# *.ipr
-# End of https://www.gitignore.io/api/ruby,rails,rubymine
\ No newline at end of file
+# End of https://www.gitignore.io/api/ruby,rails,rubymine
+
+/coverage/
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..7f78ee20
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,4 @@
+{
+ "git.ignoreLimitWarning": true,
+ "python.pythonPath": "C:\\Users\\Lucas\\AppData\\Local\\Programs\\Python\\Python39\\python.exe"
+}
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index bfc41880..da6ffa02 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'
@@ -53,6 +52,9 @@ gem 'jquery-rails'
# Uses nokogiri gem
gem 'nokogiri'
+
+ gem 'cycromatic'
+
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
@@ -81,7 +83,7 @@ group :test do
gem 'launchy'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
- gem 'webdrivers'
+ # gem 'webdrivers'
# Adds the RSpec stuff
gem 'rspec-rails' # RSpec
diff --git a/Gemfile.lock b/Gemfile.lock
index c2dba9cb..cafb2ee8 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)
@@ -157,26 +148,28 @@ GEM
cucumber-core (~> 8.0, >= 8.0.1)
cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
cucumber-messages (~> 13.0, >= 13.0.1)
+ cycromatic (0.1.3)
+ parser (~> 2.3)
+ rainbow (~> 2.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)
-
+ ffi (1.15.0-x64-mingw32)
flay (2.12.1)
erubis (~> 2.7.0)
path_expander (~> 1.0)
@@ -189,9 +182,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 +206,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 +227,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,48 +239,45 @@ 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)
+ nokogiri (1.11.4-x64-mingw32)
+ 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 (2.7.2.0)
+ ast (~> 2.4.1)
path_expander (1.1.0)
pg (1.2.3)
+ pg (1.2.3-x64-mingw32)
popper_js (1.16.0)
protobuf-cucumber (3.10.8)
activesupport (>= 3.2)
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 +285,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,31 +307,30 @@ 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)
+ rainbow (2.2.2)
+ rake
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.2)
kwalify (~> 0.7.0)
- parser (~> 3.0.0)
+ parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
psych (~> 3.1)
rainbow (>= 2.0, < 4.0)
regexp_parser (2.1.1)
@@ -383,10 +360,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)
@@ -401,6 +376,8 @@ GEM
tilt (>= 1.1, < 3)
sassc (2.4.0)
ffi (~> 1.9)
+ sassc (2.4.0-x64-mingw32)
+ ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
@@ -410,14 +387,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)
@@ -440,6 +417,8 @@ GEM
turbolinks-source (5.2.0)
tzinfo (1.2.9)
thread_safe (~> 0.1)
+ tzinfo-data (1.2021.1)
+ tzinfo (>= 1.0.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
web-console (3.7.0)
@@ -447,22 +426,19 @@ 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
+ x64-mingw32
DEPENDENCIES
bcrypt (~> 3.1.7)
@@ -473,6 +449,7 @@ DEPENDENCIES
coffee-rails (~> 4.2)
cucumber-rails
cucumber-rails-training-wheels
+ cycromatic
database_cleaner
factory_bot_rails
guard-rspec
@@ -499,12 +476,10 @@ DEPENDENCIES
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
-
webdrivers (~> 4.0)
-
RUBY VERSION
ruby 2.7.2p137
BUNDLED WITH
- 2.2.9
+ 2.1.4
diff --git a/app/controllers/admins_controller.rb b/app/controllers/admins_controller.rb
index dce794e9..e3ccafd0 100644
--- a/app/controllers/admins_controller.rb
+++ b/app/controllers/admins_controller.rb
@@ -1,6 +1,7 @@
class AdminsController < ApplicationController
def index ; end
+
def new ; end
def create
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 9f93d455..05e69632 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -216,10 +216,10 @@ def extrai_campos_turma(node)
def carregar_disciplinas(disciplinas)
disciplinas.each do |d|
- if !Disciplina.find_by_cod_disciplina(d[:cod_disciplina])
+ if !Disciplina.find_by_id_disciplina(d[:id])
criar_disciplina(
- d[:cod_disciplina],
+ d[:id],
d[:nome_disciplina],
d[:creditos]
)
@@ -229,8 +229,9 @@ def carregar_disciplinas(disciplinas)
##
# Método para criar uma disciplina no modelo.
- def criar_disciplina(cod_disciplina, nome, creditos)
+ def criar_disciplina(id_disciplina,cod_disciplina, nome, creditos)
Disciplina.create(
+ :id=> id_disciplina,
:cod_disciplina => cod_disciplina,
:nome => nome,
:c_prat => creditos[:c_prat],
diff --git a/app/controllers/disciplinas_controller.rb b/app/controllers/disciplinas_controller.rb
index 1631d12c..dc38d254 100644
--- a/app/controllers/disciplinas_controller.rb
+++ b/app/controllers/disciplinas_controller.rb
@@ -3,10 +3,24 @@ class DisciplinasController < ApplicationController
before_action :is_admin, only: [:edit, :new, :create, :update, :destroy]
before_action :logged_in
+
+ ##
+ # Método que instancia um novo objeto de disciplina
+ #
+ # Método sem parametros
+ #
+ # Retorna uma nova instancia de disciplina
def new
@disciplina = Disciplina.new
end
+
+ ##
+ # Método que salva uma nova disciplina no banco de dados
+ #
+ # Método sem parametros
+ #
+ # Retorna para a view de dashboard, caso consiga salvar a disciplina. Caso contrário, retorna uma mensagem de erro.
def create
@disciplina = Disciplina.new disciplina_params
@@ -18,16 +32,37 @@ def create
end
end
- def edit; end
+ ##
+ # Método que edita uma disciplina.
+ #
+ def edit
+
+ end
+
+ ##
+ # Método para atualizar uma disciplina.
+ #
+ # Método recebe as informações que devem ser alteradas/mantidas na disciplina.
+ #
+ # Retorna para a view de dashboard de disciplinas se a atualização foi bem sucedida (parâmetros válidos). Caso contrário mostra uma mensagem de erro e renderiza a view de edição de disciplinas.
def update
if @disciplina.update disciplina_params
redirect_to dashboard_disciplinas_path, notice: "Disciplina atualizada!"
else
+ flash[:danger] = "Ocorreu um erro ao atualizar a disciplina."
render 'edit'
end
end
+ ##
+ # Método que exclui uma disciplina do banco de dados.
+ #
+ # O Método procura e apaga a disciplina das turmas e monitorias das quais ela pertence, e depois apaga a disciplina. Funciona como um Cascade.
+ #
+ # Parâmetro: Código da disciplina .
+ #
+ # Redireciona para a view do dashboard de disciplinas após apagar tudo, caso a remoção foi bem sucedida, com uma mensagem de disciplina removida.
def destroy
Turma.find_each do |t|
if t.fk_cod_disciplina == @disciplina.cod_disciplina
@@ -44,24 +79,48 @@ def destroy
end
private
+ ##
+ # Método que especifica e filtra os parâmetros da disciplina.
+ #
+ # O método recebe parâmetros arbitrários e filtra todos os não permitidos
+ #
+ # Retorna quais são os parâmetros permitidos para uma disciplina.
def disciplina_params
- params.require(:disciplina).permit(:nome, :fk_tipo_disciplina_id, :c_prat, :c_teor, :c_est, :c_ext)
+ params.require(:disciplina).permit(:nome, :fk_tipo_disciplina_id, :c_prat, :c_teor, :c_est, :c_ext, :monitoria)
end
+ ##
+ # Método que localiza uma disciplina.
+ #
+ # Método com parâmetros: id.
+ #
+ # Retorna a disciplina com o id especificado.
def find_disciplina
@disciplina = Disciplina.find(params[:id])
end
+ ##
+ # Método que verifica se o usuário está logado.
+ #
+ # Método sem parâmetro.
+ #
+ # Redireciona para a view de login com a mensagem de aviso.
def logged_in
if !logged_in?
- redirect_to new_session_path, notice: "Você precisa estar logado para acessar as Disciplinas"
- end
+ redirect_to new_session_path, notice: "Você precisa estar logado para acessar as Disciplinas"
+ end
end
+ ##
+ # Método que localiza uma disciplina.
+ #
+ # Parâmetro: id.
+ #
+ # Retorna a disciplina com o id especificado.
def is_admin
if !current_user.kind_of?(Admin)
flash[:danger] = "Acesso negado."
redirect_to dashboard_disciplinas_path
end
end
-end
+end
\ No newline at end of file
diff --git a/app/models/disciplina.rb b/app/models/disciplina.rb
index 627e62b4..2aaa58e4 100644
--- a/app/models/disciplina.rb
+++ b/app/models/disciplina.rb
@@ -1,12 +1,33 @@
class Disciplina < ApplicationRecord
+
+ ##
+ # Método estático que retorna os tipos das diciplinas
+ #
+ # Retorna o tipo da disciplina
+ #
def self.all_tipos
return [['Obrigatória', 1], ['Optativa', 2]]
end
+ ##
+ # Método estático para achar todas as disciplinas
+ #
+ # Retorna uma lista de todas as disciplinas, ordenadas por nome
+ #
def self.all_disciplinas
order(:nome).all
end
+ ##
+ # Método estático para achar todas as disciplinas que permitem monitoria
+ #
+ # Retorna uma lista de todas as disciplinas que possuem o campo monitoria como true
+ #
+ def self.com_monitoria
+ return where(monitoria: true)
+
+ end
+
validates_presence_of :nome
validates_presence_of :fk_tipo_disciplina_id
validates_presence_of :c_prat
diff --git a/app/views/dashboard/disciplinas.html.haml b/app/views/dashboard/disciplinas.html.haml
index 0cb05b2b..a01f6f47 100644
--- a/app/views/dashboard/disciplinas.html.haml
+++ b/app/views/dashboard/disciplinas.html.haml
@@ -121,8 +121,8 @@
- if current_user.kind_of?(Admin)
.row
.col-6
- %a.btn.btn-outline-warning.btn-block{href: edit_disciplina_path(d.cod_disciplina)}
+ %a.btn.btn-outline-warning.btn-block{href: edit_disciplina_path(d.id)}
Editar Disciplina
.col-6
- =link_to "Apagar Disciplina", disciplina_path(d.cod_disciplina), method: :delete,
+ =link_to "Apagar Disciplina", disciplina_path(d.id), method: :delete,
class: 'btn btn-outline-danger btn-block'
\ No newline at end of file
diff --git a/app/views/dashboard/monitorias.html.haml b/app/views/dashboard/monitorias.html.haml
index 60280a3e..3742f3c1 100644
--- a/app/views/dashboard/monitorias.html.haml
+++ b/app/views/dashboard/monitorias.html.haml
@@ -125,7 +125,7 @@
- @disciplinas = Disciplina.all_disciplinas
- @disciplinas.each do |disciplina|
- @turmas.each do |turma|
- - if disciplina.cod_disciplina == turma.fk_cod_disciplina
+ - if ((disciplina.cod_disciplina == turma.fk_cod_disciplina) && (disciplina.monitoria == true))
.card
.card-body
%h5
diff --git a/app/views/disciplinas/edit.html.haml b/app/views/disciplinas/edit.html.haml
index c36f64a3..ed0d1eec 100644
--- a/app/views/disciplinas/edit.html.haml
+++ b/app/views/disciplinas/edit.html.haml
@@ -13,10 +13,7 @@
.col
-if flash[:danger]
.alert.alert-danger
- - flash[:danger].each do |msg|
- %ul
- %li
- =msg
+ = flash[:danger]
-if flash[:notice]
.alert.alert-success
= flash[:notice]
@@ -47,11 +44,17 @@
.col-sm-10
= text_field :disciplina, :c_ext, :class => "form-control", :autocomplete => "off"
+
.form-group.row
= label :disciplina, :fk_tipo_disciplina_id, "Tipo", class: "col-sm-2 col-form-label"
.col-sm-10
= select :disciplina, :fk_tipo_disciplina_id, options_for_select(Disciplina.all_tipos)
+ .form-group.row
+ = label :disciplina, :monitoria, "Monitoria", class: "col-sm-2 col-form-label"
+ .col-sm-10
+ = check_box :disciplina, :monitoria, {:class => "form-control", :id => "checkbox"}
+
%br
= submit_tag 'Atualizar', class: "btn btn-outline-primary btn-block"
.col-3
diff --git a/app/views/disciplinas/new.html.haml b/app/views/disciplinas/new.html.haml
index adba25cd..aa2d5764 100644
--- a/app/views/disciplinas/new.html.haml
+++ b/app/views/disciplinas/new.html.haml
@@ -48,6 +48,11 @@
.col-sm-10
= select :disciplina, :fk_tipo_disciplina_id, options_for_select(Disciplina.all_tipos)
+ .form-group.row
+ = label :disciplina, :monitoria, "Monitoria", class: "col-sm-2 col-form-label"
+ .col-sm-10
+ = check_box :disciplina, :monitoria, {:class => "form-control"}
+
%br
= submit_tag 'Cadastrar', class: "btn btn-outline-primary btn-block"
.col-3
diff --git a/config/database.yml b/config/database.yml
index c26fbd59..deaf3275 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -11,22 +11,33 @@ default: &default
timeout: 5000
development:
- <<: *default
- database: monitoriacic_development
+ adapter: postgresql
+ encoding: utf8
+ database: monitoriacic_development
+ username:
+ password:
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test: &test
- <<: *default
- database: monitoriacic_test
+ adapter: postgresql
+ encoding: utf8
+ database: monitoriacic_development
+ username:
+ password:
production:
- <<: *default
- database: monitoriacic_production
+ adapter: postgresql
+ encoding: utf8
+ database: monitoriacic_development
+ username:
+ password:
cucumber:
- <<: *test
+ adapter: postgresql
+ encoding: utf8
+ database: monitoriacic_development
+ username:
+ password:
-cucumber:
- <<: *test
diff --git a/coverage/.last_run.json b/coverage/.last_run.json
index 04ed82cb..dc96f216 100644
--- a/coverage/.last_run.json
+++ b/coverage/.last_run.json
@@ -1,7 +1,5 @@
{
"result": {
-
- "covered_percent": 12.93
-
+ "line": 8.24
}
}
diff --git a/coverage/.resultset.json b/coverage/.resultset.json
index e69de29b..d664e35c 100644
--- a/coverage/.resultset.json
+++ b/coverage/.resultset.json
@@ -0,0 +1,1687 @@
+{
+ "RSpec": {
+ "coverage": {
+ "/home/italo/unb/monitoriaCIC/app/helpers/application_helper.rb": {
+ "lines": [
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/helpers/atendimentos_helper.rb": {
+ "lines": [
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/helpers/atividades_helper.rb": {
+ "lines": [
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/helpers/disciplinas_helper.rb": {
+ "lines": [
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/helpers/historico_helper.rb": {
+ "lines": [
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/helpers/home_helper.rb": {
+ "lines": [
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/helpers/motivos_helper.rb": {
+ "lines": [
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/helpers/reset_senhas_helper.rb": {
+ "lines": [
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/helpers/sessions_helper.rb": {
+ "lines": [
+ 1,
+ 1,
+ 3,
+ null,
+ null,
+ 1,
+ 3,
+ 0,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ 12,
+ null,
+ null,
+ 1,
+ 3,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/helpers/tarefas_helper.rb": {
+ "lines": [
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/admins_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ 3,
+ 3,
+ null,
+ null,
+ 1,
+ 2,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/application_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/atendimentos_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 4,
+ 4,
+ null,
+ 4,
+ 0,
+ null,
+ 4,
+ null,
+ null,
+ 4,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ null,
+ 0,
+ 0,
+ null,
+ 0,
+ null,
+ null,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ null,
+ 0,
+ 0,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ 0,
+ null,
+ null,
+ null,
+ 1,
+ 3,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/atividades_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 4,
+ null,
+ 4,
+ 3,
+ 3,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ 3,
+ 3,
+ null,
+ 3,
+ 2,
+ null,
+ 1,
+ null,
+ null,
+ 3,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 2,
+ 2,
+ null,
+ 2,
+ 2,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ 5,
+ null,
+ null,
+ null,
+ 1,
+ 6,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/dados_bancarios_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ null,
+ 1,
+ null,
+ 1,
+ 5,
+ null,
+ 1,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ 0,
+ null,
+ 0,
+ null,
+ 1,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ 1,
+ 3,
+ 3,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ null,
+ 0,
+ 0,
+ null,
+ 0,
+ null,
+ null,
+ 0,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ null,
+ 0,
+ 0,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ 4,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/dashboard_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ null,
+ 1,
+ null,
+ 1,
+ 3,
+ 1,
+ 2,
+ 1,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ null,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 2,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ 0,
+ null,
+ 0,
+ null,
+ 0,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ 0,
+ 0,
+ null,
+ 0,
+ 0,
+ null,
+ 0,
+ null,
+ null,
+ null,
+ 0,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ null,
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ 2,
+ 2,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ 1,
+ 1,
+ null,
+ 1,
+ null,
+ 1,
+ null,
+ 0,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ 0,
+ null,
+ 0,
+ null,
+ null,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ 0,
+ null,
+ 0,
+ 0,
+ null,
+ 0,
+ null,
+ 0,
+ null,
+ null,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ 0,
+ null,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ 0,
+ null,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 87,
+ null,
+ null,
+ 87,
+ 48,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 87,
+ null,
+ null,
+ null,
+ 1,
+ 48,
+ 48,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 48,
+ 48,
+ null,
+ null,
+ null,
+ 1,
+ 48,
+ null,
+ 0,
+ null,
+ 2,
+ null,
+ 32,
+ null,
+ 9,
+ null,
+ 4,
+ null,
+ null,
+ 0,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/disciplinas_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 4,
+ null,
+ 4,
+ 3,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ 4,
+ 3,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ 0,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ 5,
+ null,
+ null,
+ 1,
+ 6,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/faq_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/home_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/monitorias_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 4,
+ 4,
+ 4,
+ 8,
+ 8,
+ null,
+ null,
+ null,
+ 4,
+ 0,
+ null,
+ 4,
+ 4,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ 1,
+ 3,
+ 3,
+ null,
+ 0,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ 4,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 5,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ null,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/professors_controller.rb": {
+ "lines": [
+ 1,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ 6,
+ null,
+ 6,
+ 2,
+ 2,
+ 2,
+ null,
+ 4,
+ 4,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ 2,
+ null,
+ 2,
+ null,
+ null,
+ 1,
+ 6,
+ 6,
+ null,
+ 6,
+ 4,
+ null,
+ 2,
+ null,
+ null,
+ 6,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ 9,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/reset_senhas_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ 1,
+ null,
+ null,
+ 1,
+ 3,
+ 3,
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ 2,
+ 2,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ null,
+ 0,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ 1,
+ 5,
+ null,
+ null,
+ null,
+ 1,
+ 4,
+ 4,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/sessions_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ null,
+ 1,
+ null,
+ 3,
+ null,
+ null,
+ null,
+ 3,
+ 3,
+ 3,
+ null,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ 1,
+ 6,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/sobre_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/tarefas_controller.rb": {
+ "lines": [
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ 0,
+ null,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ null,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ 0,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/turmas_controller.rb": {
+ "lines": [
+ 1,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 4,
+ null,
+ 4,
+ 3,
+ null,
+ 1,
+ null,
+ null,
+ 4,
+ null,
+ null,
+ 1,
+ 5,
+ 5,
+ null,
+ 5,
+ 4,
+ null,
+ 1,
+ null,
+ null,
+ 5,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ 0,
+ 0,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ 6,
+ null,
+ null,
+ 1,
+ 0,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ 0,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/users_controller.rb": {
+ "lines": [
+ 1,
+ null,
+ 1,
+ null,
+ null,
+ 1,
+ 6,
+ null,
+ 6,
+ 0,
+ 0,
+ 0,
+ null,
+ 6,
+ 6,
+ null,
+ null,
+ null,
+ 1,
+ 6,
+ 6,
+ null,
+ 6,
+ 4,
+ null,
+ 2,
+ null,
+ null,
+ 6,
+ null,
+ null,
+ 1,
+ 1,
+ 12,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/models/atendimento.rb": {
+ "lines": [
+ 1,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/models/application_record.rb": {
+ "lines": [
+ 1,
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/models/atividade.rb": {
+ "lines": [
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/models/dados_bancarios.rb": {
+ "lines": [
+ 1,
+ 1,
+ null,
+ 1,
+ 1,
+ 1,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/models/disciplina.rb": {
+ "lines": [
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 0,
+ null,
+ null,
+ 1,
+ 0,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/models/monitoria.rb": {
+ "lines": [
+ 1,
+ null,
+ 1,
+ 0,
+ 0,
+ 0,
+ null,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/models/professor.rb": {
+ "lines": [
+ 1,
+ 1,
+ null,
+ 1,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/models/tarefa.rb": {
+ "lines": [
+ 1,
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/models/turma.rb": {
+ "lines": [
+ 1,
+ 1,
+ 1,
+ null,
+ 1,
+ 10,
+ 10,
+ 10,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ 1,
+ 0,
+ null,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ 0,
+ null,
+ null,
+ 1,
+ 0,
+ 0,
+ null,
+ 0,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ 0,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ 1,
+ 33,
+ null,
+ 33,
+ 7,
+ 3,
+ null,
+ null,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/models/user.rb": {
+ "lines": [
+ 1,
+ 1,
+ 1,
+ null,
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ null,
+ 1,
+ 1,
+ null,
+ 1,
+ 1,
+ null,
+ 1,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 230,
+ 230,
+ 230,
+ null,
+ 230,
+ 2106,
+ null,
+ 2106,
+ 2106,
+ null,
+ 230,
+ 230,
+ 103,
+ null,
+ null,
+ 230,
+ null,
+ null,
+ 1,
+ 115,
+ 115,
+ 1228,
+ null,
+ null,
+ 115,
+ 115,
+ null,
+ 115,
+ 12,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ 13,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ null,
+ null,
+ 1,
+ 0,
+ null,
+ null,
+ null,
+ 1,
+ 2,
+ 2,
+ 0,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/models/admin.rb": {
+ "lines": [
+ 1,
+ 1,
+ null,
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/models/motivo.rb": {
+ "lines": [
+ 1,
+ null,
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/mailers/professor_mailer.rb": {
+ "lines": [
+ 1,
+ 1,
+ null,
+ null,
+ 1,
+ 2,
+ 2,
+ 2,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/mailers/application_mailer.rb": {
+ "lines": [
+ 1,
+ 1,
+ 1,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/mailers/user_mailer.rb": {
+ "lines": [
+ 1,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1,
+ 2,
+ 2,
+ null,
+ null
+ ]
+ },
+ "/home/italo/unb/monitoriaCIC/app/channels/application_cable/channel.rb": {
+ "lines": [
+ 0,
+ 0,
+ 0,
+ 0
+ ],
+ "branches": {
+ }
+ },
+ "/home/italo/unb/monitoriaCIC/app/channels/application_cable/connection.rb": {
+ "lines": [
+ 0,
+ 0,
+ 0,
+ 0
+ ],
+ "branches": {
+ }
+ },
+ "/home/italo/unb/monitoriaCIC/app/jobs/application_job.rb": {
+ "lines": [
+ 0,
+ 0
+ ],
+ "branches": {
+ }
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/motivos_controller.rb": {
+ "lines": [
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ 0,
+ 0,
+ null,
+ null,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ 0,
+ 0,
+ null,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ null,
+ 0,
+ null,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ 0,
+ 0,
+ 0,
+ 0
+ ],
+ "branches": {
+ }
+ },
+ "/home/italo/unb/monitoriaCIC/app/controllers/historico_controller.rb": {
+ "lines": [
+ 0,
+ null,
+ 0
+ ],
+ "branches": {
+ }
+ }
+ },
+ "timestamp": 1620430844
+ }
+}
diff --git a/coverage/index.html b/coverage/index.html
index e69de29b..a04ec441 100644
--- a/coverage/index.html
+++ b/coverage/index.html
@@ -0,0 +1,19292 @@
+
+
+
+ Code coverage for Monitoriacic
+
+
+
+
+
+
+
+
+
+
+
+
+
Generated
2021-05-07T20:40:44-03:00
+
+
+
+
+
+ All Files
+ (
+
+ 69.95%
+
+
+
+ covered at
+
+
+ 15.13
+
+ hits/line
+ )
+
+
+
+
+
+ 47 files in total.
+
+
+
+ 752 relevant lines,
+ 526 lines covered and
+ 226 lines missed.
+ (
+ 69.95%
+
+)
+
+
+
+
+
+
+
+
+
+
+
+ Controllers
+ (
+
+ 64.19%
+
+
+
+ covered at
+
+
+ 2.29
+
+ hits/line
+ )
+
+
+
+
+
+ 19 files in total.
+
+
+
+ 539 relevant lines,
+ 346 lines covered and
+ 193 lines missed.
+ (
+ 64.19%
+
+)
+
+
+
+
+
+
+
+
+
+
+ Channels
+ (
+
+ 0.0%
+
+
+
+ covered at
+
+
+ 0.0
+
+ hits/line
+ )
+
+
+
+
+
+ 2 files in total.
+
+
+
+ 8 relevant lines,
+ 0 lines covered and
+ 8 lines missed.
+ (
+ 0.0%
+
+)
+
+
+
+
+
+
+
+
+
+
+ Models
+ (
+
+ 87.13%
+
+
+
+ covered at
+
+
+ 59.01
+
+ hits/line
+ )
+
+
+
+
+
+ 12 files in total.
+
+
+
+ 171 relevant lines,
+ 149 lines covered and
+ 22 lines missed.
+ (
+ 87.13%
+
+)
+
+
+
+
+
+
+
+
+
+
+ Mailers
+ (
+
+ 100.0%
+
+
+
+ covered at
+
+
+ 1.38
+
+ hits/line
+ )
+
+
+
+
+
+ 3 files in total.
+
+
+
+ 13 relevant lines,
+ 13 lines covered and
+ 0 lines missed.
+ (
+ 100.0%
+
+)
+
+
+
+
+
+
+
+
+
+
+ Helpers
+ (
+
+ 94.74%
+
+
+
+ covered at
+
+
+ 1.84
+
+ hits/line
+ )
+
+
+
+
+
+ 10 files in total.
+
+
+
+ 19 relevant lines,
+ 18 lines covered and
+ 1 lines missed.
+ (
+ 94.74%
+
+)
+
+
+
+
+
+
+
+
+
+
+ Jobs
+ (
+
+ 0.0%
+
+
+
+ covered at
+
+
+ 0.0
+
+ hits/line
+ )
+
+
+
+
+
+ 1 files in total.
+
+
+
+ 2 relevant lines,
+ 0 lines covered and
+ 2 lines missed.
+ (
+ 0.0%
+
+)
+
+
+
+
+
+
+
+
+ File
+ % covered
+ Lines
+ Relevant Lines
+ Lines covered
+ Lines missed
+ Avg. Hits / Line
+
+
+
+
+
+
+ app/jobs/application_job.rb
+ 0.00 %
+ 2
+ 2
+ 0
+ 2
+ 0.00
+
+
+
+
+
+
+
+
+
+
+
+ Libraries
+ (
+
+ 100.0%
+
+
+
+ covered at
+
+
+ 0.0
+
+ hits/line
+ )
+
+
+
+
+
+ 0 files in total.
+
+
+
+ 0 relevant lines,
+ 0 lines covered and
+ 0 lines missed.
+ (
+ 100.0%
+
+)
+
+
+
+
+
+
+
+
+ File
+ % covered
+ Lines
+ Relevant Lines
+ Lines covered
+ Lines missed
+ Avg. Hits / Line
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ module ApplicationCable
+
+
+
+
+
+
+
+
+
+
+ class Channel < ActionCable::Channel::Base
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ module ApplicationCable
+
+
+
+
+
+
+
+
+
+
+ class Connection < ActionCable::Connection::Base
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class AdminsController < ApplicationController
+
+
+
+
+
+ 1
+
+
+
+
+ def index ; end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def new ; end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def create
+
+
+
+
+
+ 3
+
+
+
+
+ @admin = Admin.create(admin_params)
+
+
+
+
+
+ 3
+
+
+
+
+ redirect_to root_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def admin_params
+
+
+
+
+
+ 2
+
+
+
+
+ params.require(:admin).permit(:id, :name, :email, :password, :password_confirmation)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class ApplicationController < ActionController::Base
+
+
+
+
+
+ 1
+
+
+
+
+ protect_from_forgery
+
+
+
+
+
+ 1
+
+
+
+
+ include SessionsHelper
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class AtendimentosController < ApplicationController
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :set_atendimento, only: [:edit, :update, :destroy]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /atendimentos/new
+
+
+
+
+
+
+
+
+
+
+ ##
+
+
+
+
+
+
+
+
+
+
+ # busca o usuário logado para associá-lo ao novo atendimento.
+
+
+
+
+
+ 1
+
+
+
+
+ def new
+
+
+
+
+
+ 1
+
+
+
+
+ @atendimento = Atendimento.new
+
+
+
+
+
+ 1
+
+
+
+
+ @user = current_user
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /atendimentos/1/edit
+
+
+
+
+
+ 1
+
+
+
+
+ def edit
+
+
+
+
+
+
+
+
+
+
+ @user = current_user
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # POST /atendimentos
+
+
+
+
+
+
+
+
+
+
+ # POST /atendimentos.json
+
+
+
+
+
+
+
+
+
+
+ # Método para criar um atendimento, associando o atendimento ao usuário logado,
+
+
+
+
+
+
+
+
+
+
+ # que será passado pelo atendimento_params
+
+
+
+
+
+
+
+
+
+
+ # Retorna para a pagina dashboard/atendimentos
+
+
+
+
+
+ 1
+
+
+
+
+ def create
+
+
+
+
+
+ 4
+
+
+
+
+ @user = current_user
+
+
+
+
+
+ 4
+
+
+
+
+ @atendimento = Atendimento.create(atendimento_params)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
+
+
+
+
+ if !@atendimento.errors.any?
+
+
+
+
+
+
+
+
+
+
+ flash[:notice] = "Registro de atendimento realizado com sucesso!"
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+ 4
+
+
+
+
+ flash[:danger] = @atendimento.errors.full_messages
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
+
+
+
+
+ redirect_to dashboard_atendimentos_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # PATCH/PUT /atendimentos/1
+
+
+
+
+
+
+
+
+
+
+ # PATCH/PUT /atendimentos/1.json
+
+
+
+
+
+ 1
+
+
+
+
+ def update
+
+
+
+
+
+
+
+
+
+
+ @atendimento = Atendimento.find(params[:id])
+
+
+
+
+
+
+
+
+
+
+ @atendimento.update_attributes(atendimento_params)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ if !@atendimento.errors.any?
+
+
+
+
+
+
+
+
+
+
+ flash[:notice] = 'Atendimento atualizado com sucesso!'
+
+
+
+
+
+
+
+
+
+
+ elsif
+
+
+
+
+
+
+
+
+
+
+ flash[:danger] = @atendimento.errors.first[1]
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_atendimentos_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # DELETE /atendimentos/1
+
+
+
+
+
+
+
+
+
+
+ # DELETE /atendimentos/1.json
+
+
+
+
+
+ 1
+
+
+
+
+ def destroy
+
+
+
+
+
+
+
+
+
+
+ @atendimento = Atendimento.find(params[:id])
+
+
+
+
+
+
+
+
+
+
+ @atendimento.delete
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ flash[:notice] = 'Atendimento apagado com sucesso!'
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_atendimentos_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ private
+
+
+
+
+
+
+
+
+
+
+ # Use callbacks to share common setup or constraints between actions.
+
+
+
+
+
+ 1
+
+
+
+
+ def set_atendimento
+
+
+
+
+
+
+
+
+
+
+ @atendimento = Atendimento.find(params[:id])
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+
+
+
+
+
+ 1
+
+
+
+
+ def atendimento_params
+
+
+
+
+
+ 3
+
+
+
+
+ params.require(:atendimento).permit(:motivo_id, :dia, :descricao, :aluno_atendido, :monitor_id)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class AtividadesController < ApplicationController
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :user_logged
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :set_atividade, only: [:show, :edit, :update, :destroy]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /atividades
+
+
+
+
+
+
+
+
+
+
+ # GET /atividades.json
+
+
+
+
+
+ 1
+
+
+
+
+ def index
+
+
+
+
+
+
+
+
+
+
+ @atividades = Atividade.all
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /atividades/1
+
+
+
+
+
+
+
+
+
+
+ # GET /atividades/1.json
+
+
+
+
+
+ 1
+
+
+
+
+ def show
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /atividades/new
+
+
+
+
+
+
+
+
+
+
+ #Associa o registro de atividade ao usuario logado
+
+
+
+
+
+ 1
+
+
+
+
+ def new
+
+
+
+
+
+ 1
+
+
+
+
+ @atividade = Atividade.new
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /atividades/1/edit
+
+
+
+
+
+ 1
+
+
+
+
+ def edit
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # POST /atividades
+
+
+
+
+
+
+
+
+
+
+ # POST /atividades.json
+
+
+
+
+
+
+
+
+
+
+ # Método para criar o registro de uma atividade, associando a atividade ao usuário logado,
+
+
+
+
+
+
+
+
+
+
+ # que será passado pelo atividade_params
+
+
+
+
+
+
+
+
+
+
+ # Criando ou não, retorna para o dashboard
+
+
+
+
+
+ 1
+
+
+
+
+ def create
+
+
+
+
+
+ 4
+
+
+
+
+ @atividade = Atividade.create(atividade_params)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
+
+
+
+
+ if !@atividade.errors.any?
+
+
+
+
+
+ 3
+
+
+
+
+ flash[:notice] = "Registro de atividade realizado com sucesso!"
+
+
+
+
+
+ 3
+
+
+
+
+ redirect_to dashboard_atividades_path
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+ 1
+
+
+
+
+ flash[:danger] = @atividade.errors.first[1]
+
+
+
+
+
+ 1
+
+
+
+
+ redirect_to dashboard_atividades_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # PATCH/PUT /atividades/1
+
+
+
+
+
+
+
+
+
+
+ # PATCH/PUT /atividades/1.json
+
+
+
+
+
+
+
+
+
+
+ # Método para editar o registro de uma atividade, passando pelo atividade_params a atividade atualizada associada
+
+
+
+
+
+
+
+
+
+
+ # ao usuario que foi capturada por params[:id]
+
+
+
+
+
+ 1
+
+
+
+
+ def update
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 3
+
+
+
+
+ @atividade = Atividade.find(params[:id])
+
+
+
+
+
+ 3
+
+
+
+
+ @atividade.update_attributes(atividade_params)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 3
+
+
+
+
+ if !@atividade.errors.any?
+
+
+
+
+
+ 2
+
+
+
+
+ flash[:notice] = 'Atividade atualizada com sucesso!'
+
+
+
+
+
+
+
+
+
+
+ elsif
+
+
+
+
+
+ 1
+
+
+
+
+ flash[:danger] = @atividade.errors.first[1]
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 3
+
+
+
+
+ redirect_to dashboard_atividades_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # DELETE /atividades/1
+
+
+
+
+
+
+
+
+
+
+ # DELETE /atividades/1.json
+
+
+
+
+
+
+
+
+
+
+ # Metodo utilizado para apagar uma atividade, utilizando seu id como paramentro
+
+
+
+
+
+ 1
+
+
+
+
+ def destroy
+
+
+
+
+
+ 2
+
+
+
+
+ @atividade = Atividade.find(params[:id])
+
+
+
+
+
+ 2
+
+
+
+
+ @atividade.delete
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2
+
+
+
+
+ flash[:notice] = 'Atividade apagada com sucesso!'
+
+
+
+
+
+ 2
+
+
+
+
+ redirect_to dashboard_atividades_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ private
+
+
+
+
+
+
+
+
+
+
+ # verifica se o usuario está logado para poder acessar a pagina de registro
+
+
+
+
+
+ 1
+
+
+
+
+ def user_logged
+
+
+
+
+
+
+
+
+
+
+ if !logged_in?
+
+
+
+
+
+
+
+
+
+
+ redirect_to new_session_path, notice: "Você precisa estar logado para acessar essa página"
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ private
+
+
+
+
+
+
+
+
+
+
+ # Use callbacks to share common setup or constraints between actions.
+
+
+
+
+
+ 1
+
+
+
+
+ def set_atividade
+
+
+
+
+
+ 5
+
+
+
+
+ @atividade = Atividade.find(params[:id])
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+
+
+
+
+
+ 1
+
+
+
+
+ def atividade_params
+
+
+
+
+
+ 6
+
+
+
+
+ params.require(:atividade).permit(:titulo, :mensagem, :matricula_monitor, :data)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class DadosBancariosController < ApplicationController
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :user_logged
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def new; end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def create
+
+
+
+
+
+ 5
+
+
+
+
+ @dados_bancarios = DadosBancarios.create(dados_bancarios_params)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ if !@dados_bancarios.errors.any?
+
+
+
+
+
+
+
+
+
+
+ @user = current_user
+
+
+
+
+
+
+
+
+
+
+ @fk_banco = DadosBancarios.find_by(
+
+
+
+
+
+
+
+
+
+
+ codigo: @dados_bancarios.codigo,
+
+
+
+
+
+
+
+
+
+
+ agencia: @dados_bancarios.agencia,
+
+
+
+
+
+
+
+
+
+
+ conta_corrente: @dados_bancarios.conta_corrente
+
+
+
+
+
+
+
+
+
+
+ )
+
+
+
+
+
+
+
+
+
+
+ @user.update(fk_banco: @fk_banco.id)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ flash[:notice] = 'Dados bancários cadastrados com sucesso!'
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+ 1
+
+
+
+
+ flash[:danger] = @dados_bancarios.errors.full_messages
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ redirect_to dashboard_dados_bancarios_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def edit
+
+
+
+
+
+ 3
+
+
+
+
+ @user = current_user
+
+
+
+
+
+ 3
+
+
+
+
+ @dados_bancarios = DadosBancarios.find(@user.fk_banco)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def update
+
+
+
+
+
+
+
+
+
+
+ @dados_bancarios = DadosBancarios.find(params[:id])
+
+
+
+
+
+
+
+
+
+
+ @dados_bancarios.update_attributes(dados_bancarios_params)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ if !@dados_bancarios.errors.any?
+
+
+
+
+
+
+
+
+
+
+ flash[:notice] = 'Dados atualizados com sucesso!'
+
+
+
+
+
+
+
+
+
+
+ elsif
+
+
+
+
+
+
+
+
+
+
+ flash[:danger] = @dados_bancarios.errors.full_messages
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_dados_bancarios_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def destroy
+
+
+
+
+
+
+
+
+
+
+ @user = current_user
+
+
+
+
+
+
+
+
+
+
+ @dados_bancarios = DadosBancarios.find(params[:id])
+
+
+
+
+
+
+
+
+
+
+ @dados_bancarios.delete
+
+
+
+
+
+
+
+
+
+
+ @user.update(fk_banco: nil)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ flash[:notice] = 'Dados bancários apagados com sucesso!'
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_dados_bancarios_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ private
+
+
+
+
+
+ 1
+
+
+
+
+ def user_logged
+
+
+
+
+
+ 1
+
+
+
+
+ if !logged_in?
+
+
+
+
+
+ 1
+
+
+
+
+ redirect_to new_session_path, notice: "Você precisa estar logado para acessar essa página"
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def dados_bancarios_params
+
+
+
+
+
+ 4
+
+
+
+
+ params.require(:dados_bancarios).permit(:codigo, :agencia, :conta_corrente)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class DashboardController < ApplicationController
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :user_logged
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def index; end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def edit_user
+
+
+
+
+
+ 3
+
+
+
+
+ if current_user.kind_of?(User)
+
+
+
+
+
+ 1
+
+
+
+
+ @user = current_user
+
+
+
+
+
+ 2
+
+
+
+
+ elsif current_user.kind_of?(Professor)
+
+
+
+
+
+ 1
+
+
+
+
+ @professor = current_user
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+ 1
+
+
+
+
+ flash[:danger] = "Apenas alunos e professores podem editar o perfil!"
+
+
+
+
+
+ 1
+
+
+
+
+ redirect_to dashboard_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def dados_bancarios; end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def turmas; end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ##
+
+
+
+
+
+
+
+
+
+
+ # Método chama a view dashboard/atendimentos para renderizar todos os atendimentos
+
+
+
+
+
+ 1
+
+
+
+
+ def atendimentos; end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def atividades; end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def monitorias
+
+
+
+
+
+
+
+
+
+
+ @user = current_user
+
+
+
+
+
+
+
+
+
+
+ @monitorias = Array.new
+
+
+
+
+
+
+
+
+
+
+ Monitoria.find_each do |m|
+
+
+
+
+
+
+
+
+
+
+ if @user.kind_of?(User)
+
+
+
+
+
+
+
+
+
+
+ if m.fk_matricula == @user.matricula
+
+
+
+
+
+
+
+
+
+
+ if m.fk_status_monitoria_id != 4
+
+
+
+
+
+
+
+
+
+
+ @monitorias << m
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def disciplinas
+
+
+
+
+
+ 1
+
+
+
+
+ @disciplinas = Disciplina.find_each
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def apagar_alunos
+
+
+
+
+
+ 2
+
+
+
+
+ @users = User.order(:matricula)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def historico
+
+
+
+
+
+
+
+
+
+
+ @user = current_user
+
+
+
+
+
+
+
+
+
+
+ @mostrar = Array.new
+
+
+
+
+
+
+
+
+
+
+ Monitoria.find_each do |m|
+
+
+
+
+
+
+
+
+
+
+ if (@user.kind_of?(User) && m.fk_matricula == @user.matricula && m.fk_status_monitoria_id == 4)
+
+
+
+
+
+
+
+
+
+
+ @mostrar << m
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def deletar_aluno
+
+
+
+
+
+
+
+
+
+
+ @matricula = params[:user][:matricula]
+
+
+
+
+
+
+
+
+
+
+ if @matricula.length == 0
+
+
+
+
+
+
+
+
+
+
+ @matricula = nil
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ @user = User.find_by_matricula(@matricula)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ if !@user.nil?
+
+
+
+
+
+
+
+
+
+
+ @dados_bancarios = DadosBancarios.where(id: @user.fk_banco)
+
+
+
+
+
+
+
+
+
+
+ if !@dados_bancarios.nil?
+
+
+
+
+
+
+
+
+
+
+ DadosBancarios.delete(@dados_bancarios)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @monitoria = Monitoria.where(fk_matricula: @user.matricula)
+
+
+
+
+
+
+
+
+
+
+ if !@monitoria.nil?
+
+
+
+
+
+
+
+
+
+
+ Monitoria.delete(@monitoria)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @user = User.delete(@user.id)
+
+
+
+
+
+
+
+
+
+
+ flash[:notice] = 'Aluno apagado com sucesso!'
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+
+
+
+
+
+ if !@matricula.nil?
+
+
+
+
+
+
+
+
+
+
+ flash[:danger] = "Aluno de matrícula #{@matricula} não existe."
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+
+
+
+
+
+ flash[:danger] = "Digite uma matrícula para deletar algum aluno."
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_apagar_alunos_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def importar_disciplinas
+
+
+
+
+
+ 1
+
+
+
+
+ @disciplinas = Disciplina.all
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ##
+
+
+
+
+
+
+
+
+
+
+ # Método para raspar as disciplinas do site do MatrículaWeb
+
+
+
+
+
+
+
+
+
+
+ # e carregá-las no modelo.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def raspar_disciplinas
+
+
+
+
+
+ 1
+
+
+
+
+ disciplinas = raspar_matriculaweb_disciplinas
+
+
+
+
+
+ 1
+
+
+
+
+ carregar_disciplinas(disciplinas)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ redirect_to dashboard_importar_disciplinas_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def importar_professores
+
+
+
+
+
+ 1
+
+
+
+
+ @teachers = Professor.all
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def scrape_professores
+
+
+
+
+
+ 1
+
+
+
+
+ web_scraper
+
+
+
+
+
+ 1
+
+
+
+
+ redirect_to dashboard_importar_professores_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ private
+
+
+
+
+
+ 1
+
+
+
+
+ def user_logged
+
+
+
+
+
+ 2
+
+
+
+
+ if !logged_in?
+
+
+
+
+
+ 2
+
+
+
+
+ redirect_to new_session_path, notice: "Você precisa estar logado para acessar essa página"
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ##
+
+
+
+
+
+
+
+
+
+
+ # Método que faz a requisição da página das disciplinas.
+
+
+
+
+
+
+
+
+
+
+ #
+
+
+
+
+
+
+
+
+
+
+ # Retorna uma lista de hashes com os dados das disciplinas.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def raspar_matriculaweb_disciplinas(url = "https://matriculaweb.unb.br/graduacao/oferta_dis.aspx?cod=116")
+
+
+
+
+
+ 1
+
+
+
+
+ require 'open-uri'
+
+
+
+
+
+ 1
+
+
+
+
+ require 'openssl'
+
+
+
+
+
+ 1
+
+
+
+
+ require 'nokogiri'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ pagina = Nokogiri::HTML(open(url))
+
+
+
+
+
+ 1
+
+
+
+
+ tbls_disciplinas = pagina.css('#datatable').css('tr').drop(1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ disciplinas = []
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ tbls_disciplinas.each do |d|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ disciplinas << extrai_campos_disciplina(d)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ disciplinas
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ##
+
+
+
+
+
+
+
+
+
+
+ # Método que realiza as extrações dos dados da disciplina.
+
+
+
+
+
+
+
+
+
+
+ # Retorna um hash com as informações da disciplina.
+
+
+
+
+
+ 1
+
+
+
+
+ def extrai_campos_disciplina(node)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ link_disciplina = node.css('td')[1].css('a')[0][:href]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ info_disciplina = raspar_pagina_disciplina(caminho = link_disciplina)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+
+
+
+
+
+
+
+
+
+
+ :cod_disciplina => node.css('td')[0].text,
+
+
+
+
+
+
+
+
+
+
+ :nome_disciplina => node.css('td')[1].text.titleize,
+
+
+
+
+
+
+
+
+
+
+ :creditos => info_disciplina[:creditos],
+
+
+
+
+
+
+
+
+
+
+ :turmas => info_disciplina[:turmas]
+
+
+
+
+
+
+
+
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ##
+
+
+
+
+
+
+
+
+
+
+ # Método para fazer a requisição da página da oferta de uma disciplina específica.
+
+
+
+
+
+
+
+
+
+
+ # Retorna um hash com as informações de créditos e turmas das disciplinas.
+
+
+
+
+
+ 1
+
+
+
+
+ def raspar_pagina_disciplina(caminho, url_base = "https://matriculaweb.unb.br/graduacao/")
+
+
+
+
+
+
+
+
+
+
+ require 'open-uri'
+
+
+
+
+
+
+
+
+
+
+ require 'openssl'
+
+
+
+
+
+
+
+
+
+
+ require 'nokogiri'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ pagina = Nokogiri::HTML(open(url_base + caminho))
+
+
+
+
+
+
+
+
+
+
+ tabelas = pagina.css('#datatable')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ c_teor, c_prat, c_ext, c_est = tabelas[0]
+
+
+
+
+
+
+
+
+
+
+ .css('tr:nth-child(4) > td')
+
+
+
+
+
+
+
+
+
+
+ .text.split('-').map {|str| str.to_i}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+
+
+
+
+
+
+
+
+
+
+ :creditos => {
+
+
+
+
+
+
+
+
+
+
+ :c_prat => c_prat,
+
+
+
+
+
+
+
+
+
+
+ :c_teor => c_teor,
+
+
+
+
+
+
+
+
+
+
+ :c_est => c_est,
+
+
+
+
+
+
+
+
+
+
+ :c_ext => c_ext
+
+
+
+
+
+
+
+
+
+
+ },
+
+
+
+
+
+
+
+
+
+
+ :turmas => extrai_turmas(tabelas)
+
+
+
+
+
+
+
+
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ##
+
+
+
+
+
+
+
+
+
+
+ # Método para raspagem das turmas da disciplina.
+
+
+
+
+
+
+
+
+
+
+ # Retorna uma lista de hashes das turmas.
+
+
+
+
+
+ 1
+
+
+
+
+ def extrai_turmas(node)
+
+
+
+
+
+
+
+
+
+
+ turmas = []
+
+
+
+
+
+
+
+
+
+
+ node.drop(1).each do |t|
+
+
+
+
+
+
+
+
+
+
+ turmas << extrai_campos_turma(t)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ turmas
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ##
+
+
+
+
+
+
+
+
+
+
+ # Método para extração das informações da turma da página da oferta da
+
+
+
+
+
+
+
+
+
+
+ # disciplina no MatrículoWeb.
+
+
+
+
+
+
+
+
+
+
+ # Retorna um hash com nome da turma e nome do professor.
+
+
+
+
+
+ 1
+
+
+
+
+ def extrai_campos_turma(node)
+
+
+
+
+
+
+
+
+
+
+ {
+
+
+
+
+
+
+
+
+
+
+ :nome_turma => node.css('td.turma').text,
+
+
+
+
+
+
+
+
+
+
+ :nome_professor => node.css('tbody > tr > td:nth-child(5) td').text
+
+
+
+
+
+
+
+
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ##
+
+
+
+
+
+
+
+
+
+
+ # Método para carregar as disciplinas no modelo.
+
+
+
+
+
+ 1
+
+
+
+
+ def carregar_disciplinas(disciplinas)
+
+
+
+
+
+ 1
+
+
+
+
+ disciplinas.each do |d|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ if !Disciplina.find_by_id_disciplina(d[:id])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ criar_disciplina(
+
+
+
+
+
+
+
+
+
+
+ d[:id],
+
+
+
+
+
+
+
+
+
+
+ d[:nome_disciplina],
+
+
+
+
+
+
+
+
+
+
+ d[:creditos]
+
+
+
+
+
+
+
+
+
+
+ )
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ##
+
+
+
+
+
+
+
+
+
+
+ # Método para criar uma disciplina no modelo.
+
+
+
+
+
+ 1
+
+
+
+
+ def criar_disciplina(id_disciplina,cod_disciplina, nome, creditos)
+
+
+
+
+
+
+
+
+
+
+ Disciplina.create(
+
+
+
+
+
+
+
+
+
+
+ :id=> id_disciplina,
+
+
+
+
+
+
+
+
+
+
+ :cod_disciplina => cod_disciplina,
+
+
+
+
+
+
+
+
+
+
+ :nome => nome,
+
+
+
+
+
+
+
+
+
+
+ :c_prat => creditos[:c_prat],
+
+
+
+
+
+
+
+
+
+
+ :c_teor => creditos[:c_teor],
+
+
+
+
+
+
+
+
+
+
+ :c_est => creditos[:c_est],
+
+
+
+
+
+
+
+
+
+
+ :c_ext => creditos[:c_ext]
+
+
+
+
+
+
+
+
+
+
+ )
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Faz um web scrape da página do CIC para adquirir os dados dos professores e cadastrá-los no BD
+
+
+
+
+
+ 1
+
+
+
+
+ def web_scraper
+
+
+
+
+
+
+
+
+
+
+ # Habilitam a abertura de webpages no código
+
+
+
+
+
+ 1
+
+
+
+
+ require 'open-uri'
+
+
+
+
+
+ 1
+
+
+
+
+ require 'openssl'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Cria um node a partir da página do CIC, filtrando pela 'div' em questão os elementos 'li'. Esse node contém todas
+
+
+
+
+
+
+
+
+
+
+ # as informações disponíveis de todos os professores
+
+
+
+
+
+ 1
+
+
+
+
+ teachers_list = Nokogiri::HTML(open('https://cic.unb.br/professores/',
+
+
+
+
+
+
+
+
+
+
+ :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE)).
+
+
+
+
+
+
+
+
+
+
+ css('div#main-content').
+
+
+
+
+
+
+
+
+
+
+ css('li')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ teachers_list.each do |t|
+
+
+
+
+
+ 87
+
+
+
+
+ email = t.css('span.p-email').text.reverse
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Verifica se o e-mail pertence ao domínio da UnB e se o e-mail já está cadastrado no banco de dados
+
+
+
+
+
+ 87
+
+
+
+
+ if valid_email?(email) && !Professor.find_by_email(email)
+
+
+
+
+
+ 48
+
+
+
+
+ create_teacher(t, email)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Verifica se o e-mail pertence ao domínio da UnB (retorna 'true' se sim e 'false', caso contrário)
+
+
+
+
+
+ 1
+
+
+
+
+ def valid_email?(email)
+
+
+
+
+
+ 87
+
+
+
+
+ email =~ /\A[\w+\-.]+@unb\.br\z/i
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Cadastra um professor no banco de dados
+
+
+
+
+
+ 1
+
+
+
+
+ def create_teacher(teacher, email)
+
+
+
+
+
+ 48
+
+
+
+
+ pwd = generate_password
+
+
+
+
+
+ 48
+
+
+
+
+ Professor.create(:name => teacher.css('h4.people-details-h4').text.match(/(\S+\.?\s?)+/),
+
+
+
+
+
+
+
+
+
+
+ :email => email,
+
+
+
+
+
+
+
+
+
+
+ :username => email.match(/[^@]+/),
+
+
+
+
+
+
+
+
+
+
+ :role => match_role(teacher.css('span.people-details.p-people').text),
+
+
+
+
+
+
+
+
+
+
+ :password => pwd,
+
+
+
+
+
+
+
+
+
+
+ :password_confirmation => pwd)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Gera uma string de caracteres aleatórios de tamanho adequado para salvar como senha do professor no BD.
+
+
+
+
+
+
+
+
+
+
+ # Essa senha é apenas um placeholder, durante o cadastro, o professor deverá modifica-la.
+
+
+
+
+
+ 1
+
+
+
+
+ def generate_password
+
+
+
+
+
+ 48
+
+
+
+
+ require 'securerandom'
+
+
+
+
+
+ 48
+
+
+
+
+ SecureRandom.base64(9)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Faz o match da titularidade do professor com o número esperado no BD
+
+
+
+
+
+ 1
+
+
+
+
+ def match_role(role)
+
+
+
+
+
+ 48
+
+
+
+
+ case role
+
+
+
+
+
+
+
+
+
+
+ when /substituto/i
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+
+
+
+
+
+
+ when /colaborador/i
+
+
+
+
+
+ 2
+
+
+
+
+ 3
+
+
+
+
+
+
+
+
+
+
+ when /adjunto/i
+
+
+
+
+
+ 32
+
+
+
+
+ 4
+
+
+
+
+
+
+
+
+
+
+ when /associado/i
+
+
+
+
+
+ 9
+
+
+
+
+ 5
+
+
+
+
+
+
+
+
+
+
+ when /titular/i
+
+
+
+
+
+ 4
+
+
+
+
+ 6
+
+
+
+
+
+
+
+
+
+
+ # Cláusula específica para um erro comum do parser: retornar uma string contendo apenas caracteres de espaço
+
+
+
+
+
+
+
+
+
+
+ when /\A\s/
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+ # Cláusula padrão retorna um valor para cadastrar o professor com o papel de 'professor' no BD
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+ 1
+
+
+
+
+ 2
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class DisciplinasController < ApplicationController
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :find_disciplina, only: [:show, :edit, :update, :destroy]
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :is_admin, only: [:edit, :new, :create, :update, :destroy]
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :logged_in
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def new
+
+
+
+
+
+ 1
+
+
+
+
+ @disciplina = Disciplina.new
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def create
+
+
+
+
+
+ 4
+
+
+
+
+ @disciplina = Disciplina.new disciplina_params
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
+
+
+
+
+ if @disciplina.save
+
+
+
+
+
+ 3
+
+
+
+
+ redirect_to dashboard_disciplinas_path, notice: "Disciplina cadastrada com sucesso!"
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+ 1
+
+
+
+
+ flash[:danger] = "Ocorreu um erro ao cadastrar a disciplina. Nenhuma disciplina cadastrada."
+
+
+
+
+
+ 1
+
+
+
+
+ render 'new'
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def edit; end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def update
+
+
+
+
+
+ 4
+
+
+
+
+ if @disciplina.update disciplina_params
+
+
+
+
+
+ 3
+
+
+
+
+ redirect_to dashboard_disciplinas_path, notice: "Disciplina atualizada!"
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+ 1
+
+
+
+
+ flash[:danger] = "Ocorreu um erro ao atualizar a disciplina."
+
+
+
+
+
+ 1
+
+
+
+
+ render 'edit'
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def destroy
+
+
+
+
+
+ 1
+
+
+
+
+ Turma.find_each do |t|
+
+
+
+
+
+ 1
+
+
+
+
+ if t.fk_cod_disciplina == @disciplina.cod_disciplina
+
+
+
+
+
+ 1
+
+
+
+
+ t.destroy
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+ 1
+
+
+
+
+ Monitoria.find_each do |m|
+
+
+
+
+
+ 1
+
+
+
+
+ if m.fk_cod_disciplina == @disciplina.cod_disciplina
+
+
+
+
+
+
+
+
+
+
+ m.destroy
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+ 1
+
+
+
+
+ @disciplina.destroy
+
+
+
+
+
+ 1
+
+
+
+
+ redirect_to dashboard_disciplinas_path, notice: "Disciplina removida!"
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ private
+
+
+
+
+
+ 1
+
+
+
+
+ def disciplina_params
+
+
+
+
+
+ 5
+
+
+
+
+ params.require(:disciplina).permit(:nome, :fk_tipo_disciplina_id, :c_prat, :c_teor, :c_est, :c_ext, :monitoria)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def find_disciplina
+
+
+
+
+
+ 6
+
+
+
+
+ @disciplina = Disciplina.find(params[:id])
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def logged_in
+
+
+
+
+
+
+
+
+
+
+ if !logged_in?
+
+
+
+
+
+
+
+
+
+
+ redirect_to new_session_path, notice: "Você precisa estar logado para acessar as Disciplinas"
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def is_admin
+
+
+
+
+
+
+
+
+
+
+ if !current_user.kind_of?(Admin)
+
+
+
+
+
+
+
+
+
+
+ flash[:danger] = "Acesso negado."
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_disciplinas_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class FaqController < ApplicationController
+
+
+
+
+
+ 1
+
+
+
+
+ def index ; end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ class HistoricoController < ApplicationController
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class HomeController < ApplicationController
+
+
+
+
+
+ 1
+
+
+
+
+ def index ; end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class MonitoriasController < ApplicationController
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :find_monitor, only: [:show]
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :find_monitoria, only: [:destroy, :edit, :update]
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :logged_in
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def new
+
+
+
+
+
+ 1
+
+
+
+
+ @cod_disciplina = params[:turma]
+
+
+
+
+
+ 1
+
+
+
+
+ @user = current_user
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def create
+
+
+
+
+
+ 4
+
+
+
+
+ @monitoria = Monitoria.new(monitoria_params)
+
+
+
+
+
+ 4
+
+
+
+
+ valid = true
+
+
+
+
+
+ 4
+
+
+
+
+ Monitoria.find_each do |m|
+
+
+
+
+
+ 8
+
+
+
+
+ if m.fk_matricula==@monitoria.fk_matricula and m.fk_turmas_id==@monitoria.fk_turmas_id and m.fk_cod_disciplina==@monitoria.fk_cod_disciplina
+
+
+
+
+
+ 8
+
+
+
+
+ valid = false
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
+
+
+
+
+ if valid and @monitoria.save
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_monitorias_path, notice: "Aplicaçao para monitoria enviada com sucesso!"
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+ 4
+
+
+
+
+ flash[:danger] = "Ocorreu um erro ao cadastrar a monitoria. Nenhuma monitoria cadastrada."
+
+
+
+
+
+ 4
+
+
+
+
+ redirect_to dashboard_monitorias_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def show
+
+
+
+
+
+ 1
+
+
+
+
+ @alunos = User.find_each
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def edit
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def update
+
+
+
+
+
+ 3
+
+
+
+
+ if @monitoria.update monitoria_params
+
+
+
+
+
+ 3
+
+
+
+
+ redirect_to dashboard_monitorias_path, notice: "Situaçao atualizada!"
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+
+
+
+
+
+ render 'edit'
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def destroy
+
+
+
+
+
+ 1
+
+
+
+
+ @monitoria.destroy
+
+
+
+
+
+ 1
+
+
+
+
+ redirect_to dashboard_monitorias_path, notice: "Monitoria removida!"
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ private
+
+
+
+
+
+ 1
+
+
+
+
+ def monitoria_params
+
+
+
+
+
+ 4
+
+
+
+
+ params.require(:monitoria).permit(:remuneracao, :fk_matricula, :fk_cod_disciplina, :fk_turmas_id, :descricao_status, :prioridade, :fk_status_monitoria_id)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def find_monitor
+
+
+
+
+
+ 1
+
+
+
+
+ @monitoria = Monitoria.where(fk_turmas_id: params[:id])
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def find_monitoria
+
+
+
+
+
+ 5
+
+
+
+
+ @monitoria = Monitoria.find(params[:id])
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def logged_in
+
+
+
+
+
+
+
+
+
+
+ if !logged_in?
+
+
+
+
+
+
+
+
+
+
+ redirect_to new_session_path, notice: "Você precisa estar logado para acessar a pagina Monitoria"
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ class MotivosController < ApplicationController
+
+
+
+
+
+
+
+
+
+
+ before_action :set_motivo, only: [:show, :edit, :update, :destroy]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /motivos
+
+
+
+
+
+
+
+
+
+
+ # GET /motivos.json
+
+
+
+
+
+
+
+
+
+
+ def index
+
+
+
+
+
+
+
+
+
+
+ @motivos = Motivo.all
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /motivos/1
+
+
+
+
+
+
+
+
+
+
+ # GET /motivos/1.json
+
+
+
+
+
+
+
+
+
+
+ def show
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /motivos/new
+
+
+
+
+
+
+
+
+
+
+ def new
+
+
+
+
+
+
+
+
+
+
+ @motivo = Motivo.new
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /motivos/1/edit
+
+
+
+
+
+
+
+
+
+
+ def edit
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # POST /motivos
+
+
+
+
+
+
+
+
+
+
+ # POST /motivos.json
+
+
+
+
+
+
+
+
+
+
+ def create
+
+
+
+
+
+
+
+
+
+
+ @motivo = Motivo.new(motivo_params)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ respond_to do |format|
+
+
+
+
+
+
+
+
+
+
+ if @motivo.save
+
+
+
+
+
+
+
+
+
+
+ format.html { redirect_to @motivo, notice: 'Motivo was successfully created.' }
+
+
+
+
+
+
+
+
+
+
+ format.json { render :show, status: :created, location: @motivo }
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+
+
+
+
+
+ format.html { render :new }
+
+
+
+
+
+
+
+
+
+
+ format.json { render json: @motivo.errors, status: :unprocessable_entity }
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # PATCH/PUT /motivos/1
+
+
+
+
+
+
+
+
+
+
+ # PATCH/PUT /motivos/1.json
+
+
+
+
+
+
+
+
+
+
+ def update
+
+
+
+
+
+
+
+
+
+
+ respond_to do |format|
+
+
+
+
+
+
+
+
+
+
+ if @motivo.update(motivo_params)
+
+
+
+
+
+
+
+
+
+
+ format.html { redirect_to @motivo, notice: 'Motivo was successfully updated.' }
+
+
+
+
+
+
+
+
+
+
+ format.json { render :show, status: :ok, location: @motivo }
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+
+
+
+
+
+ format.html { render :edit }
+
+
+
+
+
+
+
+
+
+
+ format.json { render json: @motivo.errors, status: :unprocessable_entity }
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # DELETE /motivos/1
+
+
+
+
+
+
+
+
+
+
+ # DELETE /motivos/1.json
+
+
+
+
+
+
+
+
+
+
+ def destroy
+
+
+
+
+
+
+
+
+
+
+ @motivo.destroy
+
+
+
+
+
+
+
+
+
+
+ respond_to do |format|
+
+
+
+
+
+
+
+
+
+
+ format.html { redirect_to motivos_url, notice: 'Motivo was successfully destroyed.' }
+
+
+
+
+
+
+
+
+
+
+ format.json { head :no_content }
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ private
+
+
+
+
+
+
+
+
+
+
+ # Use callbacks to share common setup or constraints between actions.
+
+
+
+
+
+
+
+
+
+
+ def set_motivo
+
+
+
+
+
+
+
+
+
+
+ @motivo = Motivo.find(params[:id])
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+
+
+
+
+
+
+
+
+
+
+ def motivo_params
+
+
+
+
+
+
+
+
+
+
+ params.require(:motivo).permit(:nome)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class ProfessorsController < ApplicationController
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # usando como pagina de selecao de professores (issue: select de professores)
+
+
+
+
+
+ 1
+
+
+
+
+ def index
+
+
+
+
+
+
+
+
+
+
+ # conteudo do select de professores
+
+
+
+
+
+ 1
+
+
+
+
+ @professor = Professor.all
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def new ; end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def create
+
+
+
+
+
+ 6
+
+
+
+
+ @professor = Professor.create(professor_params)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6
+
+
+
+
+ if !@professor.errors.any?
+
+
+
+
+
+ 2
+
+
+
+
+ flash[:notice] = "Registro realizado com sucesso!"
+
+
+
+
+
+ 2
+
+
+
+
+ log_in(@professor)
+
+
+
+
+
+ 2
+
+
+
+
+ redirect_to dashboard_path
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+ 4
+
+
+
+
+ flash[:danger] = @professor.errors.full_messages
+
+
+
+
+
+ 4
+
+
+
+
+ redirect_to new_professor_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ # usando como pagina de confirmacao dos professores
+
+
+
+
+
+ 1
+
+
+
+
+ def identityconfirmation
+
+
+
+
+
+
+
+
+
+
+ # procura o professor selecionado na lista
+
+
+
+
+
+ 2
+
+
+
+
+ @professor = Professor.where(:name => params[:professor][:name])[0]
+
+
+
+
+
+
+
+
+
+
+ # faz o envio do e-mail de confirmação para o respectivo professor
+
+
+
+
+
+ 2
+
+
+
+
+ ProfessorMailer.with(professor: @professor).key_email.deliver_now
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def update
+
+
+
+
+
+ 6
+
+
+
+
+ @professor = Professor.find_by_email(session[:user_id])
+
+
+
+
+
+ 6
+
+
+
+
+ @professor.update_attributes(professor_params)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6
+
+
+
+
+ if !@professor.errors.any?
+
+
+
+
+
+ 4
+
+
+
+
+ flash[:notice] = "Cadastro atualizado com sucesso!"
+
+
+
+
+
+
+
+
+
+
+ elsif
+
+
+
+
+
+ 2
+
+
+
+
+ flash[:danger] = @professor.errors.full_messages
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6
+
+
+
+
+ redirect_to dashboard_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ protected
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def professor_params
+
+
+
+
+
+ 9
+
+
+
+
+ params.require(:professor).permit(:id, :name, :username, :email, :role, :password, :password_confirmation)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class ResetSenhasController < ApplicationController
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :get_user, only: [:edit, :update]
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :valid_user, only: [:edit, :update]
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :check_expiration, only: [:edit, :update]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def new
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def create
+
+
+
+
+
+ 3
+
+
+
+
+ @user = User.find_by(email: params[:reset_senha][:email].downcase)
+
+
+
+
+
+ 3
+
+
+
+
+ if @user
+
+
+
+
+
+ 1
+
+
+
+
+ @user.create_reset_digest
+
+
+
+
+
+ 1
+
+
+
+
+ @user.send_password_reset_email
+
+
+
+
+
+ 1
+
+
+
+
+ flash[:notice] = "As instruções para resetar sua senha foram enviadas para seu e-mail."
+
+
+
+
+
+ 1
+
+
+
+
+ redirect_to root_url
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+ 2
+
+
+
+
+ flash.now[:danger] = "Seu e-mail não foi encontrado."
+
+
+
+
+
+ 2
+
+
+
+
+ render 'new'
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def edit
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def update
+
+
+
+
+
+
+
+
+
+
+ if params[:user][:password].empty?
+
+
+
+
+
+
+
+
+
+
+ @user.errors.add(:password, "O campo senha deve ser preenchido.")
+
+
+
+
+
+
+
+
+
+
+ render 'edit'
+
+
+
+
+
+
+
+
+
+
+ elsif @user.update_attributes(user_params)
+
+
+
+
+
+
+
+
+
+
+ log_in @user
+
+
+
+
+
+
+
+
+
+
+ flash[:success] = "Sua nova senha foi salva."
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_path
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+
+
+
+
+
+ render 'edit'
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ private
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Instancia o usuário em questão procurando por seu e-mail
+
+
+
+
+
+ 1
+
+
+
+
+ def get_user
+
+
+
+
+
+ 5
+
+
+
+
+ @user = User.find_by(email: params[:email])
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Confirma se o usuário instanciado acima é válido verificando o token que foi passado
+
+
+
+
+
+ 1
+
+
+
+
+ def valid_user
+
+
+
+
+
+ 4
+
+
+
+
+ unless @user && @user.authenticated?(:reset, params[:id])
+
+
+
+
+
+ 4
+
+
+
+
+ redirect_to root_url
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Verifica se o token em questão expirou
+
+
+
+
+
+ 1
+
+
+
+
+ def check_expiration
+
+
+
+
+
+
+
+
+
+
+ if @user.password_reset_expired?
+
+
+
+
+
+
+
+
+
+
+ flash[:danger] = "Password reset has expired."
+
+
+
+
+
+
+
+
+
+
+ redirect_to new_reset_senha_url
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Filtra os parâmetros que serão passados para o BD
+
+
+
+
+
+ 1
+
+
+
+
+ def user_params
+
+
+
+
+
+
+
+
+
+
+ params.require(:user).permit(:password, :password_confirmation)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class SessionsController < ApplicationController
+
+
+
+
+
+ 1
+
+
+
+
+ def new ; end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def create
+
+
+
+
+
+
+
+
+
+
+ ## Busca aluno e professor. Retorna apenas um que for encontrado.
+
+
+
+
+
+ 3
+
+
+
+
+ @login ||= User.find_by_email(login_params[:email]) ||
+
+
+
+
+
+
+
+
+
+
+ Professor.find_by_email(login_params[:email]) ||
+
+
+
+
+
+
+
+
+
+
+ Admin.find_by_email(login_params[:email])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 3
+
+
+
+
+ if @login&.authenticate(login_params[:password])
+
+
+
+
+
+ 3
+
+
+
+
+ log_in(@login)
+
+
+
+
+
+ 3
+
+
+
+
+ redirect_to dashboard_path
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+
+
+
+
+
+ flash[:danger] = "Email ou senha inválidos"
+
+
+
+
+
+
+
+
+
+
+ redirect_to new_session_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def destroy
+
+
+
+
+
+
+
+
+
+
+ session[:user_id] = nil
+
+
+
+
+
+
+
+
+
+
+ redirect_to root_url
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ## Define os parâmetros que serão lidos no formulário de login
+
+
+
+
+
+ 1
+
+
+
+
+ def login_params
+
+
+
+
+
+ 6
+
+
+
+
+ params.require(:user).permit(:email, :password)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class SobreController < ApplicationController
+
+
+
+
+
+ 1
+
+
+
+
+ def index ; end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class TarefasController < ApplicationController
+
+
+
+
+
+ 1
+
+
+
+
+ before_action :set_tarefa, only: [:show, :edit, :update, :destroy]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /tarefas
+
+
+
+
+
+
+
+
+
+
+ # GET /tarefas.json
+
+
+
+
+
+ 1
+
+
+
+
+ def index
+
+
+
+
+
+
+
+
+
+
+ @tarefas = []
+
+
+
+
+
+
+
+
+
+
+ @monitoria_id = params[:monitoria_id].to_i
+
+
+
+
+
+
+
+
+
+
+ @all_tarefas = Tarefa.all
+
+
+
+
+
+
+
+
+
+
+ @all_tarefas.each do |tarefa|
+
+
+
+
+
+
+
+
+
+
+ if tarefa.monitoria_id == @monitoria_id
+
+
+
+
+
+
+
+
+
+
+ @tarefas.push(tarefa)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /tarefas/1
+
+
+
+
+
+
+
+
+
+
+ # GET /tarefas/1.json
+
+
+
+
+
+ 1
+
+
+
+
+ def show
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /tarefas/new
+
+
+
+
+
+ 1
+
+
+
+
+ def new
+
+
+
+
+
+
+
+
+
+
+ @monitoria_id = params[:monitoria_id]
+
+
+
+
+
+
+
+
+
+
+ @tarefa = Tarefa.new(:monitoria_id => @monitoria_id)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # GET /tarefas/1/edit
+
+
+
+
+
+ 1
+
+
+
+
+ def edit
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # POST /tarefas
+
+
+
+
+
+
+
+
+
+
+ # POST /tarefas.json
+
+
+
+
+
+ 1
+
+
+
+
+ def create
+
+
+
+
+
+
+
+
+
+
+ @tarefa = Tarefa.new(tarefa_params)
+
+
+
+
+
+
+
+
+
+
+ if @tarefa.save
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_monitorias_path, notice: "Tarefa atribuida com sucesso!"
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+
+
+
+
+
+ flash[:danger] = "Ocorreu um erro ao atribuir a tarefa."
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_monitorias_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # PATCH/PUT /tarefas/1
+
+
+
+
+
+
+
+
+
+
+ # PATCH/PUT /tarefas/1.json
+
+
+
+
+
+ 1
+
+
+
+
+ def update
+
+
+
+
+
+
+
+
+
+
+ if @tarefa.update(tarefa_params)
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_monitorias_path, notice: "Tarefa atualizada!"
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+
+
+
+
+
+ flash[:danger] = "Ocorreu um erro ao atualizar a tarefa."
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_monitorias_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # DELETE /tarefas/1
+
+
+
+
+
+
+
+
+
+
+ # DELETE /tarefas/1.json
+
+
+
+
+
+ 1
+
+
+
+
+ def destroy
+
+
+
+
+
+
+
+
+
+
+ @tarefa.destroy
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_monitorias_path, notice: "Tarefa removida!"
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ private
+
+
+
+
+
+
+
+
+
+
+ # Use callbacks to share common setup or constraints between actions.
+
+
+
+
+
+ 1
+
+
+
+
+ def set_tarefa
+
+
+
+
+
+
+
+
+
+
+ @tarefa = Tarefa.find(params[:id])
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+
+
+
+
+
+ 1
+
+
+
+
+ def tarefa_params
+
+
+
+
+
+
+
+
+
+
+ params.require(:tarefa).permit(:titulo, :descricao, :nota, :feito, :inicio, :fim, :monitoria_id)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class TurmasController < ApplicationController
+
+
+
+
+
+
+
+
+
+
+ # GET #new
+
+
+
+
+
+ 1
+
+
+
+
+ def new
+
+
+
+
+
+ 1
+
+
+
+
+ @user = current_user
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def edit
+
+
+
+
+
+ 1
+
+
+
+
+ @turma = Turma.find(params[:id])
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def create
+
+
+
+
+
+ 4
+
+
+
+
+ @turma = Turma.create(turma_params)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
+
+
+
+
+ if !@turma.errors.any?
+
+
+
+
+
+ 3
+
+
+
+
+ flash[:notice] = 'Turma cadastrada com sucesso!'
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+ 1
+
+
+
+
+ flash[:danger] = @turma.errors.full_messages
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
+
+
+
+
+ redirect_to dashboard_turmas_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def update
+
+
+
+
+
+ 5
+
+
+
+
+ @turma = Turma.find(params[:id])
+
+
+
+
+
+ 5
+
+
+
+
+ @turma.update_attributes(turma_params)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 5
+
+
+
+
+ if !@turma.errors.any?
+
+
+
+
+
+ 4
+
+
+
+
+ flash[:notice] = 'Turma atualizada com sucesso!'
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+ 1
+
+
+
+
+ flash[:danger] = @turma.errors.full_messages
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 5
+
+
+
+
+ redirect_to dashboard_turmas_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def destroy
+
+
+
+
+
+ 1
+
+
+
+
+ @turma = Turma.find(params[:id])
+
+
+
+
+
+ 1
+
+
+
+
+ Monitoria.find_each do |m|
+
+
+
+
+
+
+
+
+
+
+ if m.fk_turmas_id == @turma.id
+
+
+
+
+
+
+
+
+
+
+ m.destroy
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+ 1
+
+
+
+
+ @turma.destroy
+
+
+
+
+
+ 1
+
+
+
+
+ flash[:notice] = 'Turma apagada com sucesso!'
+
+
+
+
+
+ 1
+
+
+
+
+ redirect_to dashboard_turmas_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ private
+
+
+
+
+
+ 1
+
+
+
+
+ def turma_params
+
+
+
+
+
+ 6
+
+
+
+
+ params.require(:turma).permit(:id, :turma, :professor, :fk_cod_disciplina, :qnt_bolsas, :fk_vagas_id)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def find_turma
+
+
+
+
+
+
+
+
+
+
+ @turma = Turma.find(params[:id])
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def self.get_turmas(professor)
+
+
+
+
+
+
+
+
+
+
+ @turmas = Array.new
+
+
+
+
+
+
+
+
+
+
+ @turmas_buscadas = Turma.find_each do |turma|
+
+
+
+
+
+
+
+
+
+
+ if turma.professor == professor.name
+
+
+
+
+
+
+
+
+
+
+ @turmas << turma
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ @turmas
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class UsersController < ApplicationController
+
+
+
+
+
+
+
+
+
+
+ ## GET /users/new
+
+
+
+
+
+ 1
+
+
+
+
+ def new ; end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ## POST /users/sign_up
+
+
+
+
+
+ 1
+
+
+
+
+ def create
+
+
+
+
+
+ 6
+
+
+
+
+ @user = User.create(user_params)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6
+
+
+
+
+ if !@user.errors.any?
+
+
+
+
+
+
+
+
+
+
+ log_in(@user)
+
+
+
+
+
+
+
+
+
+
+ flash[:notice] = "Registro realizado com sucesso!"
+
+
+
+
+
+
+
+
+
+
+ redirect_to dashboard_path
+
+
+
+
+
+
+
+
+
+
+ else
+
+
+
+
+
+ 6
+
+
+
+
+ flash[:danger] = @user.errors.full_messages
+
+
+
+
+
+ 6
+
+
+
+
+ redirect_to new_user_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def update
+
+
+
+
+
+ 6
+
+
+
+
+ @user = User.find_by_email(session[:user_id])
+
+
+
+
+
+ 6
+
+
+
+
+ @user.update_attributes(user_params)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6
+
+
+
+
+ if !@user.errors.any?
+
+
+
+
+
+ 4
+
+
+
+
+ flash[:notice] = "Cadastro atualizado com sucesso!"
+
+
+
+
+
+
+
+
+
+
+ elsif
+
+
+
+
+
+ 2
+
+
+
+
+ flash[:danger] = @user.errors.full_messages
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6
+
+
+
+
+ redirect_to dashboard_path
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ private
+
+
+
+
+
+ 1
+
+
+
+
+ def user_params
+
+
+
+
+
+ 12
+
+
+
+
+ params.require(:user).permit(:id, :name, :matricula, :email, :cpf, :rg, :password, :password_confirmation)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ module ApplicationHelper
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ module AtendimentosHelper
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ module AtividadesHelper
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ module DisciplinasHelper
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ module HistoricoHelper
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ module HomeHelper
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ module MotivosHelper
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ module ResetSenhasHelper
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ module SessionsHelper
+
+
+
+
+
+ 1
+
+
+
+
+ def log_in(user)
+
+
+
+
+
+ 3
+
+
+
+
+ session[:user_id] = user.email
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def logged_user
+
+
+
+
+
+ 3
+
+
+
+
+ if !current_user.nil?
+
+
+
+
+
+
+
+
+
+
+ current_user
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def current_user
+
+
+
+
+
+
+
+
+
+
+ ## Determina se o usuário logado é um aluno ou professor
+
+
+
+
+
+ 12
+
+
+
+
+ @current_user ||= User.find_by(email: session[:user_id]) || Professor.find_by(email: session[:user_id]) || Admin.find_by(email: session[:user_id])
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def logged_in?
+
+
+
+
+
+ 3
+
+
+
+
+ !logged_user.nil?
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ module TarefasHelper
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ class ApplicationJob < ActiveJob::Base
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class ApplicationMailer < ActionMailer::Base
+
+
+
+
+
+ 1
+
+
+
+
+ default from: 'noreply@example.com' # TODO: mudar esse campo após definir o domínio utilizado pela plataforma
+
+
+
+
+
+ 1
+
+
+
+
+ layout 'mailer'
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class ProfessorMailer < ApplicationMailer
+
+
+
+
+
+ 1
+
+
+
+
+ default from: 'notifications@example.com'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # as configuracoes de envio de email de confirmacao para professores eh feita aqui
+
+
+
+
+
+ 1
+
+
+
+
+ def key_email
+
+
+
+
+
+ 2
+
+
+
+
+ @professor = params[:professor]
+
+
+
+
+
+ 2
+
+
+
+
+ @url = 'http://localhost:3000/sessions/new'
+
+
+
+
+
+ 2
+
+
+
+
+ mail(to: @professor.email, subject: 'Saudações querido(a) professor(a)!')
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class UserMailer < ApplicationMailer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Subject can be set in your I18n file at config/locales/en.yml
+
+
+
+
+
+
+
+
+
+
+ # with the following lookup:
+
+
+
+
+
+
+
+
+
+
+ #
+
+
+
+
+
+
+
+
+
+
+ # en.user_mailer.reset_senha.subject
+
+
+
+
+
+
+
+
+
+
+ #
+
+
+
+
+
+ 1
+
+
+
+
+ def reset_senha(user)
+
+
+
+
+
+ 2
+
+
+
+
+ @user = user
+
+
+
+
+
+ 2
+
+
+
+
+ mail to: user.email, subject: "Recuperação de senha"
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class Admin < ActiveRecord::Base
+
+
+
+
+
+ 1
+
+
+
+
+ has_secure_password
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ self.primary_key = :id
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class ApplicationRecord < ActiveRecord::Base
+
+
+
+
+
+ 1
+
+
+
+
+ self.abstract_class = true
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class Atendimento < ApplicationRecord
+
+
+
+
+
+
+
+
+
+
+ ##
+
+
+
+
+
+
+
+
+
+
+ # Cada atendimento está associado à um monitor
+
+
+
+
+
+ 1
+
+
+
+
+ belongs_to :motivo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ##
+
+
+
+
+
+
+
+
+
+
+ # atendimento possui os campos obrigatórios monitor_id, motivo_id e dia
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :monitor_id
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :motivo_id
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :dia
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class Atividade < ApplicationRecord
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ## Verifica se o formulário foi preenchido de acordo com a especificação
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :titulo, message: "Campo obrigatório 'Título' não preenchido! Registro não realizado."
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :mensagem, message: "Campo obrigatório 'Descrição' não preenchido! Registro não realizado."
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :data, message: "Campo obrigatório 'Data' não preenchido! Registro não realizado."
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :matricula_monitor, message: "Campo obrigatório 'Matrícula' não preenchido! Registro não realizado."
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class DadosBancarios < ActiveRecord::Base
+
+
+
+
+
+ 1
+
+
+
+
+ self.primary_key = :id
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :codigo
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :agencia
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :conta_corrente
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ validates :codigo, length: { in: 6..25 }, format: {
+
+
+
+
+
+
+
+
+
+
+ without: /[\d]+|['"!¹@²#³$£%¢¨¬&\*\(\)\-_\+=§`´\[\]{}\^~ªº°\?\/:;>.<,\|\\]+/,
+
+
+
+
+
+
+
+
+
+
+ message: 'only letters and spaces'
+
+
+
+
+
+
+
+
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ validates :agencia, format: { with: /\A[\d]+\z/, message: "only numbers" }
+
+
+
+
+
+ 1
+
+
+
+
+ validates :conta_corrente, format: { with: /\A[\d]+\z/, message: "only numbers" }
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class Disciplina < ApplicationRecord
+
+
+
+
+
+ 1
+
+
+
+
+ def self.all_tipos
+
+
+
+
+
+ 1
+
+
+
+
+ return [['Obrigatória', 1], ['Optativa', 2]]
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def self.all_disciplinas
+
+
+
+
+
+
+
+
+
+
+ order(:nome).all
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def self.com_monitoria
+
+
+
+
+
+
+
+
+
+
+ return where(monitoria: true)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :nome
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :fk_tipo_disciplina_id
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :c_prat
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :c_teor
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :c_est
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :c_ext
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ validates :nome, format: { without: /[\d]+|['"!¹@²#³$£%¢¨¬&\*\(\)\-_\+=§`´\[\]{}\^~ªº°\?\/:;>.<,\|\\]+/, message: 'apenas letras e espaços'}
+
+
+
+
+
+ 1
+
+
+
+
+ validates :c_prat, format: { with: /\A[\d]+\z/, message: "apenas numeros" }
+
+
+
+
+
+ 1
+
+
+
+
+ validates :c_teor, format: { with: /\A[\d]+\z/, message: "apenas numeros" }
+
+
+
+
+
+ 1
+
+
+
+
+ validates :c_est, format: { with: /\A[\d]+\z/, message: "apenas numeros" }
+
+
+
+
+
+ 1
+
+
+
+
+ validates :c_ext, format: { with: /\A[\d]+\z/, message: "apenas numeros" }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class Monitoria < ApplicationRecord
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def self.all_disciplinas
+
+
+
+
+
+
+
+
+
+
+ @disciplinas = Array.new
+
+
+
+
+
+
+
+
+
+
+ Disciplina.find_each do |d|
+
+
+
+
+
+
+
+
+
+
+ @disciplinas << [d.nome, d.cod_disciplina]
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ @disciplinas
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # def self.all_turmas
+
+
+
+
+
+
+
+
+
+
+ # @turmas = Array.new
+
+
+
+
+
+
+
+
+
+
+ # Turma.find_each do |t|
+
+
+
+
+
+
+
+
+
+
+ # @turmas << [t.turma, t.id]
+
+
+
+
+
+
+
+
+
+
+ # end
+
+
+
+
+
+
+
+
+
+
+ # @turmas
+
+
+
+
+
+
+
+
+
+
+ # end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def self.all_status
+
+
+
+
+
+ 1
+
+
+
+
+ return [['Pendente', 1], ['Recusado', 2], ['Aceito', 3], ['Encerrado', 4]]
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :remuneracao
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :fk_matricula
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :fk_cod_disciplina
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :fk_turmas_id
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :fk_status_monitoria_id
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class Motivo < ApplicationRecord
+
+
+
+
+
+
+
+
+
+
+ #belongs_to:organization,:class_name=>'User',:foreign_key=>'user_id'
+
+
+
+
+
+ 1
+
+
+
+
+ CLASS_LIST=["Duvida","Pergunta","Falar com o coordenador"]
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class Professor < ActiveRecord::Base
+
+
+
+
+
+ 1
+
+
+
+
+ has_secure_password
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ self.primary_key = :id
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def self.all_roles
+
+
+
+
+
+ 1
+
+
+
+
+ return [['Professor(a) substituto(a)', 1], ['Professor(a)', 2], ['Professor(a) Colaborador(a)', 3],
+
+
+
+
+
+
+
+
+
+
+ ['Professor(a) Adjunto(a)', 4], ['Professor(a) Associado(a)', 5], ['Professor(a) Titular', 6]]
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :name
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :username
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :email
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ validates_uniqueness_of :username
+
+
+
+
+
+ 1
+
+
+
+
+ validates_uniqueness_of :email
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Verificação do nome
+
+
+
+
+
+ 1
+
+
+
+
+ validates :name, length: { in: 3..50 }, format: { without: /[\d]+|[!@#$%*\(\)\|\\;\:\/?\]\[=\+\-_",\.]+/,
+
+
+
+
+
+
+
+
+
+
+ message: "only letters and spaces" }
+
+
+
+
+
+
+
+
+
+
+ # Verificação do username
+
+
+
+
+
+ 1
+
+
+
+
+ validates :username, length: { in: 3..15 }, format: {
+
+
+
+
+
+
+
+
+
+
+ with: /\A[\w+]+\z/, message: "only word characters (letter, numbers, underscore...)" }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Verificação do email
+
+
+
+
+
+ 1
+
+
+
+
+ VALID_EMAIL_REGEX = /\A[\w+\-.]+@unb\.br\z/i
+
+
+
+
+
+ 1
+
+
+
+
+ validates :email, format: { with: VALID_EMAIL_REGEX, message: "not a UnB email" }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Verificação da senha e confirmação de senha
+
+
+
+
+
+ 1
+
+
+
+
+ validates :password, length: { in: 6..12, message: "must be between 6 and 12 characters" }, on: :create
+
+
+
+
+
+ 1
+
+
+
+
+ validates :password_confirmation, length: { in: 6..12, message: "must be between 6 and 12 characters" }, on: :create
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class Tarefa < ApplicationRecord
+
+
+
+
+
+ 1
+
+
+
+
+ belongs_to :monitoria
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class Turma < ActiveRecord::Base
+
+
+
+
+
+ 1
+
+
+
+
+ def self.qnt_bolsas
+
+
+
+
+
+ 1
+
+
+
+
+ @qnt_bolsas = []
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ for i in 1..10
+
+
+
+
+
+ 10
+
+
+
+
+ @vaga = []
+
+
+
+
+
+ 10
+
+
+
+
+ @vaga = [i.to_s, i]
+
+
+
+
+
+ 10
+
+
+
+
+ @qnt_bolsas.insert(-1, @vaga)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ return @qnt_bolsas
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def self.sel_disciplinas
+
+
+
+
+
+
+
+
+
+
+ @disciplinas = Disciplina.select('cod_disciplina', 'nome')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @select = []
+
+
+
+
+
+
+
+
+
+
+ @disciplinas.each do |disciplina|
+
+
+
+
+
+
+
+
+
+
+ @atual = []
+
+
+
+
+
+
+
+
+
+
+ @atual = [disciplina.nome, disciplina.cod_disciplina]
+
+
+
+
+
+
+
+
+
+
+ @select.insert(-1, @atual)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ return @select
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def self.show_disciplinas
+
+
+
+
+
+
+
+
+
+
+ @disciplinas = Disciplina.select('nome')
+
+
+
+
+
+
+
+
+
+
+ @show = []
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @disciplinas.each do |disciplina|
+
+
+
+
+
+
+
+
+
+
+ @atual = String.new
+
+
+
+
+
+
+
+
+
+
+ @atual = disciplina.nome
+
+
+
+
+
+
+
+
+
+
+ @show.insert(-1, @atual)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ return @show
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def self.sel_turmas
+
+
+
+
+
+
+
+
+
+
+ [
+
+
+
+
+
+ 1
+
+
+
+
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
+
+
+
+
+
+
+
+
+
+
+ 'AA', 'BB', 'CC', 'DD', 'EE', 'FF', 'GG', 'HH'
+
+
+
+
+
+
+
+
+
+
+ ]
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def self.all_turmas
+
+
+
+
+
+ 1
+
+
+
+
+ find_each()
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :turma
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :professor
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :fk_cod_disciplina
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :qnt_bolsas
+
+
+
+
+
+ 1
+
+
+
+
+ validate :turma_unica
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def turma_unica
+
+
+
+
+
+ 33
+
+
+
+
+ @turmas = Turma.where(fk_cod_disciplina: fk_cod_disciplina)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 33
+
+
+
+
+ @turmas.each do |t|
+
+
+
+
+
+ 7
+
+
+
+
+ if t.turma == turma
+
+
+
+
+
+ 3
+
+
+
+
+ errors.add(:turma, "#{turma} não é a única para a disciplina #{Disciplina.find(fk_cod_disciplina).nome}")
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ class User < ActiveRecord::Base
+
+
+
+
+
+ 1
+
+
+
+
+ attr_accessor :remember_token, :reset_token
+
+
+
+
+
+ 1
+
+
+
+
+ has_secure_password
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ self.primary_key = :id
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ## Verifica se o formulário foi preenchido de acordo com a especificação
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :name
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :email
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :cpf
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :rg
+
+
+
+
+
+ 1
+
+
+
+
+ validates_presence_of :matricula
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ## Verifica se as informações não se repetem no Banco de Dados
+
+
+
+
+
+ 1
+
+
+
+
+ validates_uniqueness_of :email
+
+
+
+
+
+ 1
+
+
+
+
+ validates_uniqueness_of :cpf
+
+
+
+
+
+ 1
+
+
+
+
+ validates_uniqueness_of :rg
+
+
+
+
+
+ 1
+
+
+
+
+ validates_uniqueness_of :matricula
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ## Verifica se os campos tem o tamanho correto
+
+
+
+
+
+
+
+
+
+
+ # Verificação do nome
+
+
+
+
+
+ 1
+
+
+
+
+ validates :name, length: { in: 3..50 }, format: {
+
+
+
+
+
+
+
+
+
+
+ without: /[\d]+|['"!¹@²#³$£%¢¨¬&\*\(\)\-_\+=§`´\[\]{}\^~ªº°\?\/:;>.<,\|\\]+/,
+
+
+
+
+
+
+
+
+
+
+ message: 'only letters and spaces'
+
+
+
+
+
+
+
+
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+ # Verificação da matrícula
+
+
+
+
+
+ 1
+
+
+
+
+ validates :matricula, length: { is: 9 }, format: { with: /\A[\d]+\z/, message: "only numbers" }
+
+
+
+
+
+
+
+
+
+
+ # Verificação do email
+
+
+
+
+
+ 1
+
+
+
+
+ VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(?:\.[a-z\d\-]+)*\.[a-z]+\z/i
+
+
+
+
+
+ 1
+
+
+
+
+ validates :email, format: { with: VALID_EMAIL_REGEX, message: "invalid email format" }
+
+
+
+
+
+
+
+
+
+
+ # Verificação do CPF
+
+
+
+
+
+ 1
+
+
+
+
+ validates :cpf, length: { is: 11 }, format: { with: /\A[\d]+\z/, message: "only numbers" }
+
+
+
+
+
+ 1
+
+
+
+
+ validate :valid_cpf
+
+
+
+
+
+
+
+
+
+
+ # Verificação do RG
+
+
+
+
+
+ 1
+
+
+
+
+ validates :rg, length: { minimum: 7 }, format: { with: /\A[\d]+\z/, message: "only numbers" }
+
+
+
+
+
+
+
+
+
+
+ # Verificação da senha e confirmação de senha
+
+
+
+
+
+ 1
+
+
+
+
+ validates :password, length: { in: 6...12, message: "must be between 6 and 12 characters" }, on: :create
+
+
+
+
+
+ 1
+
+
+
+
+ validates :password_confirmation, length: { in: 6...12, message: "must be between 6 and 12 characters" }, on: :create
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Cálculo de validação dp CPF
+
+
+
+
+
+ 1
+
+
+
+
+ def nth_validation_digit(cpf_array, digit)
+
+
+
+
+
+ 230
+
+
+
+
+ @somatorio = 0
+
+
+
+
+
+ 230
+
+
+
+
+ @aux = 0
+
+
+
+
+
+ 230
+
+
+
+
+ @peso = 12-digit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 230
+
+
+
+
+ cpf_array.each do |value|
+
+
+
+
+
+ 2106
+
+
+
+
+ @somatorio += value*(@peso-(@aux))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2106
+
+
+
+
+ @aux += 1
+
+
+
+
+
+ 2106
+
+
+
+
+ break if @aux == (11-digit)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+ 230
+
+
+
+
+ @validation_digit = 11-(@somatorio%11)
+
+
+
+
+
+ 230
+
+
+
+
+ if @validation_digit > 9
+
+
+
+
+
+ 103
+
+
+
+
+ @validation_digit = 0
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 230
+
+
+
+
+ return @validation_digit
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ def valid_cpf
+
+
+
+
+
+ 115
+
+
+
+
+ @cpf_array = Array.new
+
+
+
+
+
+ 115
+
+
+
+
+ for x in 0...(cpf.length)
+
+
+
+
+
+ 1228
+
+
+
+
+ @cpf_array[x] = cpf[x].to_i
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 115
+
+
+
+
+ @first = nth_validation_digit(@cpf_array, 2) # Calcula o @first com base nos 9 digitos
+
+
+
+
+
+ 115
+
+
+
+
+ @second = nth_validation_digit(@cpf_array, 1) # Calcula o @second com base nos 9 digitos + 1o validação
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 115
+
+
+
+
+ if (cpf[9].to_i) != @first || (cpf[10].to_i) != @second
+
+
+
+
+
+ 12
+
+
+
+
+ errors.add(:cpf, "is invalid")
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Retorna o digest de um hash de uma string passada para o método
+
+
+
+
+
+ 1
+
+
+
+
+ def User.digest(string)
+
+
+
+
+
+ 1
+
+
+
+
+ cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST :
+
+
+
+
+
+
+
+
+
+
+ BCrypt::Engine.cost
+
+
+
+
+
+ 1
+
+
+
+
+ BCrypt::Password.create(string, cost: cost)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Retorna um token aleatório
+
+
+
+
+
+ 1
+
+
+
+
+ def User.new_token
+
+
+
+
+
+ 13
+
+
+
+
+ SecureRandom.urlsafe_base64
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Define os atributos para resetar a senha
+
+
+
+
+
+ 1
+
+
+
+
+ def create_reset_digest
+
+
+
+
+
+ 1
+
+
+
+
+ self.reset_token = User.new_token
+
+
+
+
+
+ 1
+
+
+
+
+ update_attribute(:reset_digest, User.digest(reset_token))
+
+
+
+
+
+ 1
+
+
+
+
+ update_attribute(:reset_sent_at, Time.zone.now)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Envia o e-mail para resetar a senha
+
+
+
+
+
+ 1
+
+
+
+
+ def send_password_reset_email
+
+
+
+
+
+ 1
+
+
+
+
+ UserMailer.reset_senha(self).deliver_now
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Retorna true se o parâmetro password reset expirou
+
+
+
+
+
+ 1
+
+
+
+
+ def password_reset_expired?
+
+
+
+
+
+
+
+
+
+
+ reset_sent_at < 2.hours.ago
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # Retorna true se o token passado é o mesmo que o digest armazenado no banco
+
+
+
+
+
+ 1
+
+
+
+
+ def authenticated?(attribute, token)
+
+
+
+
+
+ 2
+
+
+
+
+ digest = send("#{attribute}_digest")
+
+
+
+
+
+ 2
+
+
+
+
+ return false if digest.nil?
+
+
+
+
+
+
+
+
+
+
+ BCrypt::Password.new(digest).is_password?(token)
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cyclomatic_disciplina.txt b/cyclomatic_disciplina.txt
new file mode 100644
index 00000000..e0f04ea9
Binary files /dev/null and b/cyclomatic_disciplina.txt differ
diff --git a/cyclomatic_result.txt b/cyclomatic_result.txt
new file mode 100644
index 00000000..8f410d66
Binary files /dev/null and b/cyclomatic_result.txt differ
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/migrate/20210505021717_add_monitoria_to_disciplinas.rb b/db/migrate/20210505021717_add_monitoria_to_disciplinas.rb
new file mode 100644
index 00000000..d0d183fe
--- /dev/null
+++ b/db/migrate/20210505021717_add_monitoria_to_disciplinas.rb
@@ -0,0 +1,5 @@
+class AddMonitoriaToDisciplinas < ActiveRecord::Migration[5.2]
+ def change
+ add_column :disciplinas, :monitoria, :boolean, default: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b3b197b1..5cce6952 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,9 +11,12 @@
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2019_12_10_130811) do
+ActiveRecord::Schema.define(version: 2021_05_05_021717) 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
t.string "email", null: false
@@ -25,13 +28,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
@@ -68,6 +71,7 @@
t.integer "c_est", default: 0, null: false
t.integer "c_ext", default: 0, null: false
t.integer "cod_disciplina", default: 0, null: false
+ t.boolean "monitoria", default: false
t.index ["cod_disciplina"], name: "disciplinas_cod_disciplina_index"
t.index ["fk_tipo_disciplina_id"], name: "fk_disciplinas_tipo_disciplina1_idx"
end
@@ -142,7 +146,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 +197,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..b80f2fcf 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -13,33 +13,37 @@
Disciplina.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([{nome: "APC",
fk_tipo_disciplina_id: 1, c_prat: 2, c_teor: 4,
- cod_disciplina: 1}])
+ cod_disciplina: 1, monitoria: true}])
+
-Disciplina.create([{id:2, nome: "ED",
+Disciplina.create([{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")
+ # cpf: "03638481182", rg: "2645178", matricula: "140080279")
+
# 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([{turma: "A", professor: "Carla", fk_cod_disciplina: 1}])
######################
diff --git a/doc/3_1_7.html b/doc/3_1_7.html
index 85d1e9d1..894b52fc 100644
--- a/doc/3_1_7.html
+++ b/doc/3_1_7.html
@@ -21,8 +21,6 @@
-
-