diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..3bbd03ac Binary files /dev/null and b/.DS_Store differ diff --git a/.rake_tasks~ b/.rake_tasks~ new file mode 100644 index 00000000..c00fc44b --- /dev/null +++ b/.rake_tasks~ @@ -0,0 +1,55 @@ +about +active_storage:install +app:template +app:update +assets:clean[keep] +assets:clobber +assets:environment +assets:precompile +cache_digests:dependencies +cache_digests:nested_dependencies +cucumber +cucumber:all +cucumber:ok +cucumber:rerun +cucumber:wip +db:create +db:drop +db:environment:set +db:fixtures:load +db:migrate +db:migrate:status +db:rollback +db:schema:cache:clear +db:schema:cache:dump +db:schema:dump +db:schema:load +db:seed +db:setup +db:structure:dump +db:structure:load +db:version +dev:cache +initializers +log:clear +middleware +notes +notes:custom +restart +routes +secret +spec +spec:controllers +spec:helpers +spec:models +spec:requests +spec:routing +spec:views +stats +test +test:db +test:system +time:zones[country_or_offset] +tmp:clear +tmp:create +yarn:install diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..7f44804c --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 2.6.3 diff --git a/Gemfile b/Gemfile index 54be0f4e..0c45aad4 100644 --- a/Gemfile +++ b/Gemfile @@ -42,7 +42,6 @@ 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] gem 'rspec-rails' - end group :development do @@ -56,15 +55,23 @@ end group :test do # Adds support for Capybara system testing and selenium driver - gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome gem 'webdrivers' gem 'cucumber-rails', require: false + gem 'cucumber-rails-training-wheels' # some pre-fabbed step definitions # database_cleaner is not required, but highly recommended gem 'database_cleaner' + gem 'capybara', '>= 2.15' + gem 'launchy' # a useful debugging aid for user stories gem 'shoulda-matchers' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +# Rails 5.2 and Rails 6 +gem 'active_storage_validations' + +# Optional, to use :dimension validator or :aspect_ratio validator +gem 'mini_magick', '>= 4.9.5' diff --git a/Gemfile.lock b/Gemfile.lock index 0a9e4f86..0e242db3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,43 +1,45 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.3) - actionpack (= 5.2.3) + actioncable (5.2.4.4) + actionpack (= 5.2.4.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.3) - actionpack (= 5.2.3) - actionview (= 5.2.3) - activejob (= 5.2.3) + actionmailer (5.2.4.4) + actionpack (= 5.2.4.4) + actionview (= 5.2.4.4) + activejob (= 5.2.4.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.3) - actionview (= 5.2.3) - activesupport (= 5.2.3) - rack (~> 2.0) + actionpack (5.2.4.4) + actionview (= 5.2.4.4) + activesupport (= 5.2.4.4) + 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.3) - activesupport (= 5.2.3) + actionview (5.2.4.4) + activesupport (= 5.2.4.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.3) - activesupport (= 5.2.3) + active_storage_validations (0.9.0) + rails (>= 5.2.0) + activejob (5.2.4.4) + activesupport (= 5.2.4.4) globalid (>= 0.3.6) - activemodel (5.2.3) - activesupport (= 5.2.3) - activerecord (5.2.3) - activemodel (= 5.2.3) - activesupport (= 5.2.3) + activemodel (5.2.4.4) + activesupport (= 5.2.4.4) + activerecord (5.2.4.4) + activemodel (= 5.2.4.4) + activesupport (= 5.2.4.4) arel (>= 9.0) - activestorage (5.2.3) - actionpack (= 5.2.3) - activerecord (= 5.2.3) + activestorage (5.2.4.4) + actionpack (= 5.2.4.4) + activerecord (= 5.2.4.4) marcel (~> 0.3.1) - activesupport (5.2.3) + activesupport (5.2.4.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -45,14 +47,13 @@ GEM addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) arel (9.0.0) - backports (3.15.0) - bcrypt (3.1.13) + bcrypt (3.1.16) bindex (0.8.1) - bootsnap (1.4.5) + bootsnap (1.5.1) msgpack (~> 1.0) - builder (3.2.3) - byebug (11.0.1) - capybara (3.29.0) + builder (3.2.4) + byebug (11.1.3) + capybara (3.33.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -68,131 +69,160 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.5) - crass (1.0.5) - cucumber (3.1.2) - builder (>= 2.1.2) - cucumber-core (~> 3.2.0) - cucumber-expressions (~> 6.0.1) - cucumber-wire (~> 0.0.1) - diff-lcs (~> 1.3) - gherkin (~> 5.1.0) - multi_json (>= 1.7.5, < 2.0) - multi_test (>= 0.1.2) - cucumber-core (3.2.1) - backports (>= 3.8.0) - cucumber-tag_expressions (~> 1.1.0) - gherkin (~> 5.0) - cucumber-expressions (6.0.1) - cucumber-rails (2.0.0) - capybara (>= 2.12, < 4) - cucumber (>= 3.0.2, < 4) - mime-types (>= 2.0, < 4) + concurrent-ruby (1.1.7) + crass (1.0.6) + cucumber (5.2.0) + builder (~> 3.2, >= 3.2.4) + cucumber-core (~> 8.0, >= 8.0.1) + cucumber-create-meta (~> 2.0, >= 2.0.2) + cucumber-cucumber-expressions (~> 10.3, >= 10.3.0) + cucumber-gherkin (~> 15.0, >= 15.0.2) + cucumber-html-formatter (~> 9.0, >= 9.0.0) + cucumber-messages (~> 13.1, >= 13.1.0) + cucumber-wire (~> 4.0, >= 4.0.1) + diff-lcs (~> 1.4, >= 1.4.4) + multi_test (~> 0.1, >= 0.1.2) + sys-uname (~> 1.2, >= 1.2.1) + cucumber-core (8.0.1) + cucumber-gherkin (~> 15.0, >= 15.0.2) + cucumber-messages (~> 13.0, >= 13.0.1) + cucumber-tag-expressions (~> 2.0, >= 2.0.4) + cucumber-create-meta (2.0.4) + cucumber-messages (~> 13.1, >= 13.1.0) + sys-uname (~> 1.2, >= 1.2.1) + cucumber-cucumber-expressions (10.3.0) + cucumber-gherkin (15.0.2) + cucumber-messages (~> 13.0, >= 13.0.1) + cucumber-html-formatter (9.0.0) + cucumber-messages (~> 13.0, >= 13.0.1) + cucumber-messages (13.2.0) + protobuf-cucumber (~> 3.10, >= 3.10.8) + cucumber-rails (2.2.0) + capybara (>= 2.18, < 4) + cucumber (>= 3.0.2, < 6) + mime-types (~> 3.2) nokogiri (~> 1.8) - railties (>= 4.2, < 7) - cucumber-tag_expressions (1.1.1) - cucumber-wire (0.0.1) - database_cleaner (1.7.0) - devise (4.7.1) + rails (>= 5.0, < 7) + cucumber-rails-training-wheels (1.0.0) + cucumber-rails (>= 1.1.1) + cucumber-tag-expressions (2.0.4) + cucumber-wire (4.0.1) + cucumber-core (~> 8.0, >= 8.0.1) + cucumber-cucumber-expressions (~> 10.3, >= 10.3.0) + cucumber-messages (~> 13.0, >= 13.0.1) + database_cleaner (1.8.5) + devise (4.7.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - diff-lcs (1.3) - erubi (1.9.0) + diff-lcs (1.4.4) + erubi (1.10.0) execjs (2.7.0) - ffi (1.11.1) - gherkin (5.1.0) + ffi (1.13.1) + ffi (1.13.1-x64-mingw32) globalid (0.4.2) activesupport (>= 4.2.0) - i18n (1.7.0) + i18n (1.8.5) concurrent-ruby (~> 1.0) - jbuilder (2.9.1) - activesupport (>= 4.2.0) + jbuilder (2.10.1) + activesupport (>= 5.0.0) + launchy (2.5.0) + addressable (~> 2.7) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) - loofah (2.3.1) + loofah (2.7.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) marcel (0.3.3) mimemagic (~> 0.3.2) - method_source (0.9.2) - mime-types (3.3) + method_source (1.0.0) + middleware (0.1.0) + mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2019.1009) - mimemagic (0.3.3) + mime-types-data (3.2020.1104) + mimemagic (0.3.5) + mini_magick (4.11.0) mini_mime (1.0.2) mini_portile2 (2.4.0) - minitest (5.12.2) - msgpack (1.3.1) - multi_json (1.14.1) + minitest (5.14.2) + msgpack (1.3.3) + msgpack (1.3.3-x64-mingw32) multi_test (0.1.2) - nio4r (2.5.2) - nokogiri (1.10.8) + nio4r (2.5.4) + nokogiri (1.10.10) + mini_portile2 (~> 2.4.0) + nokogiri (1.10.10-x64-mingw32) mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) - pg (1.1.4) - public_suffix (4.0.1) + pg (1.2.3) + pg (1.2.3-x64-mingw32) + protobuf-cucumber (3.10.8) + activesupport (>= 3.2) + middleware + thor + thread_safe + public_suffix (4.0.6) puma (3.12.6) rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.3) - actioncable (= 5.2.3) - actionmailer (= 5.2.3) - actionpack (= 5.2.3) - actionview (= 5.2.3) - activejob (= 5.2.3) - activemodel (= 5.2.3) - activerecord (= 5.2.3) - activestorage (= 5.2.3) - activesupport (= 5.2.3) + rails (5.2.4.4) + actioncable (= 5.2.4.4) + actionmailer (= 5.2.4.4) + actionpack (= 5.2.4.4) + actionview (= 5.2.4.4) + activejob (= 5.2.4.4) + activemodel (= 5.2.4.4) + activerecord (= 5.2.4.4) + activestorage (= 5.2.4.4) + activesupport (= 5.2.4.4) bundler (>= 1.3.0) - railties (= 5.2.3) + railties (= 5.2.4.4) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - railties (5.2.3) - actionpack (= 5.2.3) - activesupport (= 5.2.3) + railties (5.2.4.4) + actionpack (= 5.2.4.4) + activesupport (= 5.2.4.4) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) - rake (13.0.0) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (1.6.0) - responders (3.0.0) + regexp_parser (1.8.2) + responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) - rspec-core (3.9.0) - rspec-support (~> 3.9.0) - rspec-expectations (3.9.0) + rspec-core (3.10.0) + rspec-support (~> 3.10.0) + rspec-expectations (3.10.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-mocks (3.9.0) + rspec-support (~> 3.10.0) + rspec-mocks (3.10.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-rails (3.9.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-support (~> 3.9.0) - rspec-support (3.9.0) + rspec-support (~> 3.10.0) + rspec-rails (4.0.1) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.9) + rspec-expectations (~> 3.9) + rspec-mocks (~> 3.9) + rspec-support (~> 3.9) + rspec-support (3.10.0) ruby_dep (1.5.0) - rubyzip (2.0.0) + rubyzip (2.3.0) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -204,44 +234,48 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - selenium-webdriver (3.142.6) + selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - shoulda-matchers (4.1.2) + shoulda-matchers (4.4.1) activesupport (>= 4.2.0) - spring (2.1.0) + spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) + sprockets-rails (3.2.2) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - thor (0.20.3) + sys-uname (1.2.2) + ffi (~> 1.1) + thor (1.0.1) thread_safe (0.3.6) tilt (2.0.10) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) - tzinfo (1.2.5) + tzinfo (1.2.8) thread_safe (~> 0.1) + tzinfo-data (1.2020.4) + tzinfo (>= 1.0.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - warden (1.2.8) - rack (>= 2.0.6) + warden (1.2.9) + rack (>= 2.0.9) web-console (3.7.0) actionview (>= 5.0) activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) - webdrivers (4.1.3) + webdrivers (4.4.1) 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) @@ -249,17 +283,22 @@ GEM PLATFORMS ruby + x64-mingw32 DEPENDENCIES + active_storage_validations bootsnap (>= 1.1.0) byebug capybara (>= 2.15) coffee-rails (~> 4.2) cucumber-rails + cucumber-rails-training-wheels database_cleaner devise jbuilder (~> 2.5) + launchy listen (>= 3.0.5, < 3.2) + mini_magick (>= 4.9.5) pg (>= 0.18, < 2.0) puma (~> 3.12) rails (~> 5.2.3) diff --git a/app/assets/javascripts/accreditations.coffee b/app/assets/javascripts/accreditations.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/accreditations.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/requirements.coffee b/app/assets/javascripts/requirements.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/requirements.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/sei_processes.coffee b/app/assets/javascripts/sei_processes.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/sei_processes.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/accreditations.scss b/app/assets/stylesheets/accreditations.scss new file mode 100644 index 00000000..5c7ed1fa --- /dev/null +++ b/app/assets/stylesheets/accreditations.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Accreditations controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/requirements.scss b/app/assets/stylesheets/requirements.scss new file mode 100644 index 00000000..911f2332 --- /dev/null +++ b/app/assets/stylesheets/requirements.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Requirements controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/scaffolds.scss b/app/assets/stylesheets/scaffolds.scss new file mode 100644 index 00000000..60451880 --- /dev/null +++ b/app/assets/stylesheets/scaffolds.scss @@ -0,0 +1,84 @@ +body { + background-color: #fff; + color: #333; + margin: 33px; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + + &:visited { + color: #666; + } + + &:hover { + color: #fff; + background-color: #000; + } +} + +th { + padding-bottom: 5px; +} + +td { + padding: 0 5px 7px; +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px 7px 0; + margin-bottom: 20px; + background-color: #f0f0f0; + + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px -7px 0; + background-color: #c00; + color: #fff; + } + + ul li { + font-size: 12px; + list-style: square; + } +} + +label { + display: block; +} diff --git a/app/assets/stylesheets/sei_processes.scss b/app/assets/stylesheets/sei_processes.scss new file mode 100644 index 00000000..d0b190c0 --- /dev/null +++ b/app/assets/stylesheets/sei_processes.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the SeiProcesses controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/accreditations_controller.rb b/app/controllers/accreditations_controller.rb new file mode 100644 index 00000000..54e31ebc --- /dev/null +++ b/app/controllers/accreditations_controller.rb @@ -0,0 +1,73 @@ +class AccreditationsController < ApplicationController + before_action :set_accreditation, only: [:show, :edit, :update, :destroy] + + # GET /accreditations + # GET /accreditations.json + def index + @accreditations = Accreditation.all + end + + # GET /accreditations/1 + # GET /accreditations/1.json + def show + end + + # GET /accreditations/new + def new + end + + # GET /accreditations/1/edit + def edit + end + + # POST /accreditations + # POST /accreditations.json + def create + @accreditation = Accreditation.new(accreditation_params) + + respond_to do |format| + if @accreditation.save + format.html { redirect_to accreditations_url, notice: 'Accreditation was successfully created.' } + format.json { render :show, status: :created, location: @accreditation } + else + format.html { render :new } + format.json { render json: @accreditation.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /accreditations/1 + # PATCH/PUT /accreditations/1.json + def update + respond_to do |format| + if @accreditation.update(accreditation_params) + format.html { redirect_to accreditations_url, notice: 'Credenciamento atualizado com sucesso!' } + format.json { render :show, status: :ok, location: @accreditation } + else + format.html { render :edit } + format.json { render json: @accreditation.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /accreditations/1 + # DELETE /accreditations/1.json + def destroy + @accreditation.destroy + respond_to do |format| + format.html { redirect_to accreditations_url, notice: 'Accreditation was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_accreditation + @accreditation = Accreditation.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def accreditation_params + params.require(:accreditation).permit(:user_id, :start_date, :end_date, :sei_proccess_id) + end +end diff --git a/app/controllers/requirements_controller.rb b/app/controllers/requirements_controller.rb new file mode 100644 index 00000000..fbe65d66 --- /dev/null +++ b/app/controllers/requirements_controller.rb @@ -0,0 +1,81 @@ +class RequirementsController < ApplicationController + before_action :set_requirement, only: [:show, :edit, :update, :destroy] + + # GET /requirements + # GET /requirements.json + def index + @requirements = Requirement.all + end + + # GET /requirements/1 + # GET /requirements/1.json + def show + end + + # GET /requirements/new + def new + @requirement = Requirement.new + end + + # GET /requirements/1/edit + def edit + end + + # POST /requirements + # POST /requirements.json + def create + @requirement = Requirement.new(requirement_params) + + respond_to do |format| + if @requirement.save + format.html { redirect_to @requirement, notice: 'Requisitos criados com sucesso!' } + format.json { render :show, status: :created, location: @requirement } + else + format.html { render :new } + format.json { render json: @requirement.errors, status: :unprocessable_entity } + end + end + end + + def delete_document_attachment + @document = ActiveStorage::Attachment.find_by(id: params[:id]) + @requirement_id = params[:requirement_id] + @document&.purge + redirect_to edit_requirement_path(@requirement_id) + end + + # PATCH/PUT /requirements/1 + # PATCH/PUT /requirements/1.json + def update + respond_to do |format| + if @requirement.update(requirement_params) + format.html { redirect_to @requirement, notice: 'Requisitos atualizados com sucesso!' } + format.json { render :show, status: :ok, location: @requirement } + else + format.html { render :edit } + format.json { render json: @requirement.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /requirements/1 + # DELETE /requirements/1.json + def destroy + @requirement.destroy + respond_to do |format| + format.html { redirect_to requirements_url, notice: 'Requisitos excluídos com sucesso!' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_requirement + @requirement = Requirement.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def requirement_params + params.require(:requirement).permit(:title, :content, documents: []) + end +end diff --git a/app/controllers/sei_processes_controller.rb b/app/controllers/sei_processes_controller.rb new file mode 100644 index 00000000..3accd0e4 --- /dev/null +++ b/app/controllers/sei_processes_controller.rb @@ -0,0 +1,89 @@ +class SeiProcessesController < ApplicationController + before_action :set_sei_process, only: [:show, :edit, :update, :destroy] + + # GET /sei_processes + # GET /sei_processes.json + def index + @all_statuses = %w[Espera Aprovado Rejeitado] + + session[:statuses] = params[:statuses] || session[:statuses] || @all_statuses.zip([]).to_h + @status_filter = session[:statuses].keys + + if current_user.role == "administrator" + @sei_processes = SeiProcess.where(status: @status_filter) + else + @my_processes = SeiProcess.where(user_id: current_user.id, status: @status_filter) + end + end + + # GET /sei_processes/1 + # GET /sei_processes/1.json + def show + end + + # GET /sei_processes/new + def new + @requirements = Requirement.find_by(title: 'Requisitos de Credenciamento') + @sei_process = SeiProcess.new(user_id: current_user.id, status: 'Espera', code: '0') + end + + # GET /sei_processes/1/edit + def edit + end + + # POST /sei_processes + # POST /sei_processes.json + def create + @sei_process = SeiProcess.new(sei_process_params) + + respond_to do |format| + if @sei_process.save + format.html { redirect_to sei_processes_url, notice: 'Processo aberto com sucesso!' } + format.json { render :index, status: :created, location: @sei_process } + else + format.html { render :new } + format.json { render json: @sei_process.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /sei_processes/1 + # PATCH/PUT /sei_processes/1.json + def update + respond_to do |format| + if @sei_process.update(sei_process_params) + format.html { redirect_to sei_processes_url, notice: 'Processo atualizado com sucesso!' } + format.json { render :index, status: :ok, location: @sei_process } + + if (@sei_process.status == 'Aprovado') && @sei_process.documents.attached? + Accreditation.create!(user_id: @sei_process.user_id, sei_process_id: @sei_process.id) + end + + else + format.html { render :edit } + format.json { render json: @sei_process.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /sei_processes/1 + # DELETE /sei_processes/1.json + def destroy + @sei_process.destroy + respond_to do |format| + format.html { redirect_to sei_processes_url, notice: 'Processo excluído com sucesso!' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_sei_process + @sei_process = SeiProcess.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def sei_process_params + params.require(:sei_process).permit(:user_id, :status, :code, documents: []) + end +end diff --git a/app/helpers/accreditations_helper.rb b/app/helpers/accreditations_helper.rb new file mode 100644 index 00000000..ad946900 --- /dev/null +++ b/app/helpers/accreditations_helper.rb @@ -0,0 +1,2 @@ +module AccreditationsHelper +end diff --git a/app/helpers/requirements_helper.rb b/app/helpers/requirements_helper.rb new file mode 100644 index 00000000..377e5e33 --- /dev/null +++ b/app/helpers/requirements_helper.rb @@ -0,0 +1,2 @@ +module RequirementsHelper +end diff --git a/app/helpers/sei_processes_helper.rb b/app/helpers/sei_processes_helper.rb new file mode 100644 index 00000000..c74ddc6e --- /dev/null +++ b/app/helpers/sei_processes_helper.rb @@ -0,0 +1,2 @@ +module SeiProcessesHelper +end diff --git a/app/models/accreditation.rb b/app/models/accreditation.rb new file mode 100644 index 00000000..df0d1da3 --- /dev/null +++ b/app/models/accreditation.rb @@ -0,0 +1,13 @@ +class Accreditation < ApplicationRecord + belongs_to :user + belongs_to :sei_process + + validate :check_date, on: :update + def check_date + if (end_date == nil) || (end_date < start_date) + self.errors.add(:end_date, 'Data inválida') + return false + end + true + end +end diff --git a/app/models/requirement.rb b/app/models/requirement.rb new file mode 100644 index 00000000..98106d97 --- /dev/null +++ b/app/models/requirement.rb @@ -0,0 +1,4 @@ +class Requirement < ApplicationRecord + validates :title, presence: true, uniqueness: true + has_many_attached :documents +end diff --git a/app/models/sei_process.rb b/app/models/sei_process.rb new file mode 100644 index 00000000..ec8776c8 --- /dev/null +++ b/app/models/sei_process.rb @@ -0,0 +1,11 @@ +class SeiProcess < ApplicationRecord + belongs_to :user + has_many_attached :documents + validates :documents, attached: true + + enum status: { + Espera: 0, + Aprovado: 1, + Rejeitado: 2 + } +end diff --git a/app/views/accreditations/_accreditation.json.jbuilder b/app/views/accreditations/_accreditation.json.jbuilder new file mode 100644 index 00000000..3e22c1cd --- /dev/null +++ b/app/views/accreditations/_accreditation.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! accreditation, :id, :user_id, :start_date, :end_date, :sei_process_id, :created_at, :updated_at +json.url accreditation_url(accreditation, format: :json) diff --git a/app/views/accreditations/_form_edit.html.erb b/app/views/accreditations/_form_edit.html.erb new file mode 100644 index 00000000..aa1b6c0f --- /dev/null +++ b/app/views/accreditations/_form_edit.html.erb @@ -0,0 +1,27 @@ +<%= form_with(model: accreditation, local: true) do |form| %> + <% if accreditation.errors.any? %> +
+ Código do Processo SEI: + <%= @accreditation.sei_process_id %> +
++ Nome: + <%= @accreditation.user.full_name %> +
++ Matrícula: + <%= @accreditation.user.registration %> +
+ +<% if @accreditation.sei_process.documents.attached? %> ++ Documentos anexados: + <% @accreditation.sei_process.documents.each do | document | %> +
| Nome | +Matrícula | +Código SEI | +Data de Início | +Data de Fim | ++ | |
|---|---|---|---|---|---|---|
| <%= accreditation.user.full_name %> | +<%= accreditation.user.registration %> | +<%= accreditation.sei_process_id %> | +<%= accreditation.start_date %> | +<%= accreditation.end_date %> | + <% if accreditation.start_date != nil && accreditation.end_date != nil %> +<%= link_to 'Mostrar', accreditation %> | + <% else %> +<%= link_to 'Definir Prazo', edit_accreditation_path(accreditation) %> | + <% end %> +
+ Código do Processo SEI: + <%= @accreditation.sei_process_id %> +
++ Nome: + <%= @accreditation.user.full_name %> +
++ Matrícula: + <%= @accreditation.user.registration %> +
++ Data de Início: + <%= @accreditation.start_date %> +
++ Data de Fim: + <%= @accreditation.end_date %> +
+ +<% if @accreditation.sei_process.documents.attached? %> ++ Documentos anexados: + <% @accreditation.sei_process.documents.each do | document | %> +
Find me in app/views/home/index.html.erb
+Nome: <%= current_user.full_name %>
Email: <%= current_user.email %>
Cargo: <%= current_user.role %>
- <%= link_to "Sair", destroy_user_session_path, method: :delete %> + + <% if current_user.role == "administrator" %> + <%= link_to "Lista de Requisitos", requirements_path %> + <%= link_to "Lista de Processos", sei_processes_path %> + <%= link_to "Lista de Credenciamentos", accreditations_path %> + + <% else %> + <%= link_to "Meus Processos Abertos", sei_processes_path %> + <% end %> + +Você também pode se registrar ou pegar uma conta no arquivo db/seeds.rb
diff --git a/app/views/requirements/_form_edit.html.erb b/app/views/requirements/_form_edit.html.erb new file mode 100644 index 00000000..95a4d603 --- /dev/null +++ b/app/views/requirements/_form_edit.html.erb @@ -0,0 +1,46 @@ +<%= form_with(model: requirement, local: true) do |form| %> + <% if requirement.errors.any? %> +| Tipo de Requisito | ++ | ||
|---|---|---|---|
| <%= requirement.title %> | +<%= link_to 'Mostrar', requirement %> | +<%= link_to 'Editar', edit_requirement_path(requirement) %> | +<%= link_to 'Excluir', requirement, method: :delete, data: { confirm: 'Tem certeza que deseja excluir essa Informação?' } %> | +
+ Tipo dos Requisitos: + <%= @requirement.title %> +
+ ++ Conteúdo: + <%= @requirement.content %> +
+ +<% if @requirement.documents.attached? %> ++ Documentos anexados + <% @requirement.documents.each do |document| %> +
+ Nome: + <%= @sei_process.user.full_name %> +
++ Matrícula: + <%= @sei_process.user.registration %> +
+ +<% if @sei_process.documents.attached? %> ++ Documentos anexados: + <% @sei_process.documents.each do | document | %> +
| Nome | +Matrícula | +Código do Processo | +Status | ++ | |
|---|---|---|---|---|---|
| <%= sei_process.user.full_name %> | +<%= sei_process.user.registration %> | +<%= sei_process.id %> | +<%= sei_process.status %> | + <% if sei_process.status != 'Espera' %> +<%= link_to 'Mostrar', sei_process_path(sei_process) %> | + <% else %> +<%= link_to 'Avaliar', edit_sei_process_path(sei_process) %> | + <% end %> +
| Código do Processo | +Status | ++ | ||
|---|---|---|---|---|
| <%= sei_process.id %> | +<%= sei_process.status %> | +|||
+ Documentos Necessários: + <% @requirements.documents.each do | document | %> +
+ Nome: + <%= @sei_process.user.full_name %> +
++ Matrícula: + <%= @sei_process.user.registration %> +
+ +<% if @sei_process.documents.attached? %> ++ Documentos anexados: + <% @sei_process.documents.each do | document | %> +
+ Status: + <%= @sei_process.status %> +
+ +<%= link_to 'Voltar', sei_processes_path %> diff --git a/app/views/sei_processes/show.json.jbuilder b/app/views/sei_processes/show.json.jbuilder new file mode 100644 index 00000000..7a81fbf8 --- /dev/null +++ b/app/views/sei_processes/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "sei_processes/sei_process", sei_process: @sei_process diff --git a/config/database.yml b/config/database.yml index bbc24623..9930ddf5 100644 --- a/config/database.yml +++ b/config/database.yml @@ -82,4 +82,4 @@ production: <<: *default database: secretaria_ppgi_production username: secretaria_ppgi - password: <%= ENV['SECRETARIA_PPGI_DATABASE_PASSWORD'] %> + password: <%= ENV['SECRETARIA_PPGI_DATABASE_PASSWORD'] %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f33f7f68..e0f4a3df 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,15 @@ # frozen_string_literal: true Rails.application.routes.draw do + resources :accreditations + resources :sei_processes + + resources :requirements do + member do + delete :delete_document_attachment + end + end + get 'home/index' devise_for :users # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html diff --git a/cucumber.yaml b/cucumber.yaml new file mode 100644 index 00000000..2a5fdc5d --- /dev/null +++ b/cucumber.yaml @@ -0,0 +1,6 @@ +--- +default: -p html -p bdd -p json +html: --format html --out=features.html +dot: --format progress +bdd: --format pretty +json: --format json -o "report.json" diff --git a/db/migrate/20201113221041_create_requirements.rb b/db/migrate/20201113221041_create_requirements.rb new file mode 100644 index 00000000..bb94ff67 --- /dev/null +++ b/db/migrate/20201113221041_create_requirements.rb @@ -0,0 +1,10 @@ +class CreateRequirements < ActiveRecord::Migration[5.2] + def change + create_table :requirements do |t| + t.string :title + t.text :content + + t.timestamps + end + end +end diff --git a/db/migrate/20201113222004_create_sei_processes.rb b/db/migrate/20201113222004_create_sei_processes.rb new file mode 100644 index 00000000..35886acf --- /dev/null +++ b/db/migrate/20201113222004_create_sei_processes.rb @@ -0,0 +1,11 @@ +class CreateSeiProcesses < ActiveRecord::Migration[5.2] + def change + create_table :sei_processes do |t| + t.belongs_to :user, foreign_key: true + t.integer :status + t.string :code + + t.timestamps + end + end +end diff --git a/db/migrate/20201113222556_create_active_storage_tables.active_storage.rb b/db/migrate/20201113222556_create_active_storage_tables.active_storage.rb new file mode 100644 index 00000000..0b2ce257 --- /dev/null +++ b/db/migrate/20201113222556_create_active_storage_tables.active_storage.rb @@ -0,0 +1,27 @@ +# This migration comes from active_storage (originally 20170806125915) +class CreateActiveStorageTables < ActiveRecord::Migration[5.2] + def change + create_table :active_storage_blobs do |t| + t.string :key, null: false + t.string :filename, null: false + t.string :content_type + t.text :metadata + t.bigint :byte_size, null: false + t.string :checksum, null: false + t.datetime :created_at, null: false + + t.index [ :key ], unique: true + end + + create_table :active_storage_attachments do |t| + t.string :name, null: false + t.references :record, null: false, polymorphic: true, index: false + t.references :blob, null: false + + t.datetime :created_at, null: false + + t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end +end diff --git a/db/migrate/20201114202425_create_accreditations.rb b/db/migrate/20201114202425_create_accreditations.rb new file mode 100644 index 00000000..7de196f9 --- /dev/null +++ b/db/migrate/20201114202425_create_accreditations.rb @@ -0,0 +1,12 @@ +class CreateAccreditations < ActiveRecord::Migration[5.2] + def change + create_table :accreditations do |t| + t.belongs_to :user, foreign_key: true + t.date :start_date + t.date :end_date + t.references :sei_process, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 96d61d72..f4d4f7ca 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,11 +10,59 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_11_14_163205) do +ActiveRecord::Schema.define(version: 2020_11_14_202425) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "accreditations", force: :cascade do |t| + t.bigint "user_id" + t.date "start_date" + t.date "end_date" + t.bigint "sei_process_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["sei_process_id"], name: "index_accreditations_on_sei_process_id" + t.index ["user_id"], name: "index_accreditations_on_user_id" + end + + create_table "active_storage_attachments", force: :cascade do |t| + t.string "name", null: false + t.string "record_type", null: false + t.bigint "record_id", null: false + t.bigint "blob_id", null: false + t.datetime "created_at", null: false + t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" + t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true + end + + create_table "active_storage_blobs", force: :cascade do |t| + t.string "key", null: false + t.string "filename", null: false + t.string "content_type" + t.text "metadata" + t.bigint "byte_size", null: false + t.string "checksum", null: false + t.datetime "created_at", null: false + t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true + end + + create_table "requirements", force: :cascade do |t| + t.string "title" + t.text "content" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "sei_processes", force: :cascade do |t| + t.bigint "user_id" + t.integer "status" + t.string "code" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["user_id"], name: "index_sei_processes_on_user_id" + end + create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false @@ -30,4 +78,8 @@ t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end + add_foreign_key "accreditations", "sei_processes" + add_foreign_key "accreditations", "users" + add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" + add_foreign_key "sei_processes", "users" end diff --git a/db/seeds.rb b/db/seeds.rb index a5ddd2f6..8cccea57 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -11,4 +11,8 @@ User.create(full_name: "Administrador", email: "admin@admin.com", password: "admin123", role: "administrator", registration: "000000000") User.create(full_name: "Secretário", email: "secretary@secretary.com", password: "admin123", role: "secretary", registration: "000000000") User.create(full_name: "Professor", email: "professor@professor.com", password: "admin123", role: "professor", registration: "000000000") -User.create(full_name: "Aluno", email: "student@student.com", password: "admin123", role: "student", registration: "000000000") \ No newline at end of file +User.create(full_name: "Aluno", email: "student@student.com", password: "admin123", role: "student", registration: "000000000") + +Accreditation.destroy_all +Requirement.destroy_all +SeiProcess.destroy_all diff --git a/features.html b/features.html new file mode 100644 index 00000000..cf25f8dd --- /dev/null +++ b/features.html @@ -0,0 +1,763 @@ + + + +