Skip to content

Commit

Permalink
basic process controller working
Browse files Browse the repository at this point in the history
Signed-off-by: Manoel <[email protected]>
  • Loading branch information
vieirin committed Nov 23, 2020
1 parent 7050e31 commit 3fdfeaf
Show file tree
Hide file tree
Showing 23 changed files with 402 additions and 183 deletions.
206 changes: 103 additions & 103 deletions .idea/secretaria_ppgi.iml

Large diffs are not rendered by default.

217 changes: 143 additions & 74 deletions .idea/workspace.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ group :test do
gem 'shoulda-matchers'
end

gem "font-awesome-rails"
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ GEM
erubi (1.9.0)
execjs (2.7.0)
ffi (1.11.1)
font-awesome-rails (4.7.0.5)
railties (>= 3.2, < 6.1)
gherkin (5.1.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
Expand Down Expand Up @@ -191,8 +193,6 @@ GEM
rspec-mocks (~> 3.9.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.0)
ruby-debug-ide (0.7.2)
rake (>= 0.8.1)
ruby_dep (1.5.0)
rubyzip (2.0.0)
sass (3.7.4)
Expand Down Expand Up @@ -260,13 +260,13 @@ DEPENDENCIES
cucumber-rails
database_cleaner
devise
font-awesome-rails
jbuilder (~> 2.5)
listen (>= 3.0.5, < 3.2)
pg (>= 0.18, < 2.0)
puma (~> 3.12)
rails (~> 5.2.3)
rspec-rails
ruby-debug-ide
sass-rails (~> 5.0)
selenium-webdriver
shoulda-matchers
Expand All @@ -282,4 +282,4 @@ RUBY VERSION
ruby 2.6.3p62

BUNDLED WITH
1.17.2
1.17.3
3 changes: 3 additions & 0 deletions app/assets/javascripts/process.coffee
Original file line number Diff line number Diff line change
@@ -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/
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
*
*= require_tree .
*= require_self
*= require font-awesome
*/
11 changes: 11 additions & 0 deletions app/assets/stylesheets/process.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Place all the styles related to the process controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

#creation_form {
max-width: 60%;
}

.delete_link {
color: grey;
}
1 change: 0 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?

protected

def configure_permitted_parameters
Expand Down
1 change: 1 addition & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class HomeController < ApplicationController
def index

end
end
38 changes: 38 additions & 0 deletions app/controllers/process_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
class ProcessController < ApplicationController
def reload_processes(user)
@processes = []
processes_query = user.processos
unless processes_query.nil?
processes_query.each do |process|
puts(process.attributes)
@processes.append(process.attributes)
end
end
@processes
end

def index
if user_signed_in?
@user = current_user
reload_processes(@user)
end
end

def create
if user_signed_in?
user = current_user
permitted_params = params.require(:processo).permit(:sei_process_code, :process_status_id, :documents)
process = user.processos.create(permitted_params)
reload_processes(user)
end
end

def delete
if user_signed_in?
user = current_user
permitted_params = params.permit(:id)
user.processos.destroy(permitted_params[:id])
reload_processes(user)
end
end
end
1 change: 1 addition & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
module ApplicationHelper
include FontAwesome::Rails::IconHelper
end
2 changes: 2 additions & 0 deletions app/helpers/process_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ProcessHelper
end
1 change: 1 addition & 0 deletions app/models/processo.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class Processo < ApplicationRecord
belongs_to :user
end
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ class User < ApplicationRecord
has_many :information
has_many :user_notifications
has_many :requests
has_many :processos
end
44 changes: 44 additions & 0 deletions app/views/process/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<%= stylesheet_link_tag "process" %>
<h1>Lista de Processos</h1>
<h2>Criar um novo processo</h2>
<%= form_for :processo, url: process_creation_path ,html: {id: "creation_form", :multipart => true} do |f| %>
<div>
<%= f.label "Número do processo SEI" %>
<%= f.text_field :sei_process_code %>
</div>
<div>
<%= label_tag(:status_id, "Status do processo") %>
<%= f.select(:process_status_id, options_for_select([['Status 1', 1], ['Status 2', 2], ['Status 3', 3]], 1)) %>
</div>
<div>
<%= f.file_field :documents, multiple: true, name: "doc_[document]" %>
</div>
<div>

</div>
<div>
<%= submit_tag("Enviar") %>
</div>
<% end %>
<table>
<thead>
<tr>
<th>Número SEI</th>
<th>Status do processo</th>
<th>Deletar</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @processes.each do |process| %>
<tr>
<td><%= process['sei_process_code'] %></td>
<td align="right"><%= process['process_status_id'] %></td>
<td align="center">
<%= link_to fa_icon('trash').html_safe, "#{process['id']}", :method => :delete, :action => "delete", :id => process['id'], class: "delete_link" %>
<% end %>
</td>
</tr>
</tbody>
</table>

1 change: 1 addition & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ default: &default

development:
<<: *default
host: localhost
database: secretaria_ppgi_development

# The specified database role being used to connect to postgres.
Expand Down
1 change: 1 addition & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Rails.application.config.assets.precompile += %w( process.scss )
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# frozen_string_literal: true

Rails.application.routes.draw do
get 'process/index'
post 'process', to: 'process#create', as: 'process_creation'
delete 'process/:id', to: 'process#delete', as: 'process_delete'
get 'home/index'
devise_for :users
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"name": "secretaria_ppgi",
"private": true,
"dependencies": {}
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.1"
}
}
12 changes: 12 additions & 0 deletions spec/controllers/process_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'rails_helper'

RSpec.describe ProcessController, type: :controller do

describe "GET #index" do
it "returns http success" do
get :index
expect(response).to have_http_status(:success)
end
end

end
15 changes: 15 additions & 0 deletions spec/helpers/process_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'rails_helper'

# Specs in this file have access to a helper object that includes
# the ProcessHelper. For example:
#
# describe ProcessHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe ProcessHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
5 changes: 5 additions & 0 deletions spec/views/process/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

RSpec.describe "process/index.html.erb", type: :view do
pending "add some examples to (or delete) #{__FILE__}"
end
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@fortawesome/fontawesome-free@^5.15.1":
version "5.15.1"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.1.tgz#ccfef6ddbe59f8fe8f694783e1d3eb88902dc5eb"
integrity sha512-OEdH7SyC1suTdhBGW91/zBfR6qaIhThbcN8PUXtXilY4GYnSBbVqOntdHbC1vXwsDnX0Qix2m2+DSU1J51ybOQ==

0 comments on commit 3fdfeaf

Please sign in to comment.