Skip to content

Commit

Permalink
Merge pull request #69 from fga-gpp-mds/dev_image
Browse files Browse the repository at this point in the history
Dev image
  • Loading branch information
matheusbsilva authored May 27, 2017
2 parents b8f945c + bd4a947 commit 03c934d
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 85 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ gem 'mini_magick', '~> 4.3'

gem 'rails-i18n', '~> 5.0.0'

gem "paperclip", "~> 3.0"

group :development, :test do

gem 'sqlite3'
Expand Down
117 changes: 63 additions & 54 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.2)
actionpack (= 5.0.2)
actioncable (5.0.3)
actionpack (= 5.0.3)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.2)
actionpack (= 5.0.2)
actionview (= 5.0.2)
activejob (= 5.0.2)
actionmailer (5.0.3)
actionpack (= 5.0.3)
actionview (= 5.0.3)
activejob (= 5.0.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.2)
actionview (= 5.0.2)
activesupport (= 5.0.2)
actionpack (5.0.3)
actionview (= 5.0.3)
activesupport (= 5.0.3)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.2)
activesupport (= 5.0.2)
actionview (5.0.3)
activesupport (= 5.0.3)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.2)
activesupport (= 5.0.2)
activejob (5.0.3)
activesupport (= 5.0.3)
globalid (>= 0.3.6)
activemodel (5.0.2)
activesupport (= 5.0.2)
activerecord (5.0.2)
activemodel (= 5.0.2)
activesupport (= 5.0.2)
activemodel (5.0.3)
activesupport (= 5.0.3)
activerecord (5.0.3)
activemodel (= 5.0.3)
activesupport (= 5.0.3)
arel (~> 7.0)
activesupport (5.0.2)
activesupport (5.0.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
Expand All @@ -43,7 +43,7 @@ GEM
archive-zip (0.7.0)
io-like (~> 0.3.0)
arel (7.1.4)
autoprefixer-rails (7.0.1)
autoprefixer-rails (7.1.1)
execjs
bcrypt (3.1.11)
bindex (0.5.0)
Expand Down Expand Up @@ -71,6 +71,9 @@ GEM
chromedriver-helper (1.1.0)
archive-zip (~> 0.7.0)
nokogiri (~> 1.6)
climate_control (0.2.0)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
coffee-rails (4.2.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.2.x)
Expand All @@ -95,14 +98,14 @@ GEM
multi_test (>= 0.1.2)
cucumber-core (1.5.0)
gherkin (~> 4.0)
cucumber-rails (1.4.5)
cucumber-rails (1.5.0)
capybara (>= 1.1.2, < 3)
cucumber (>= 1.3.8, < 4)
mime-types (>= 1.16, < 4)
mime-types (>= 1.17, < 4)
nokogiri (~> 1.5)
railties (>= 3, < 5.1)
railties (>= 4, < 5.2)
cucumber-wire (0.0.1)
database_cleaner (1.6.0)
database_cleaner (1.6.1)
diff-lcs (1.3)
docile (1.1.5)
erubis (2.7.0)
Expand All @@ -115,9 +118,9 @@ GEM
activesupport (>= 4.2.0)
i18n (0.8.1)
io-like (0.3.0)
jbuilder (2.6.3)
activesupport (>= 3.0.0, < 5.2)
multi_json (~> 1.2)
jbuilder (2.6.4)
activesupport (>= 3.0.0)
multi_json (>= 1.2)
jquery-inputmask-rails (2.5.5)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
Expand All @@ -137,45 +140,50 @@ GEM
mime-types-data (3.2016.0521)
mini_magick (4.7.0)
mini_portile2 (2.1.0)
minitest (5.10.1)
minitest (5.10.2)
multi_json (1.12.1)
multi_test (0.1.2)
nio4r (2.0.0)
nokogiri (1.7.1)
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
paperclip (3.5.4)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.3)
mime-types
pg (0.18.4)
public_suffix (2.0.5)
puma (3.8.2)
rack (2.0.1)
rack (2.0.3)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.2)
actioncable (= 5.0.2)
actionmailer (= 5.0.2)
actionpack (= 5.0.2)
actionview (= 5.0.2)
activejob (= 5.0.2)
activemodel (= 5.0.2)
activerecord (= 5.0.2)
activesupport (= 5.0.2)
rails (5.0.3)
actioncable (= 5.0.3)
actionmailer (= 5.0.3)
actionpack (= 5.0.3)
actionview (= 5.0.3)
activejob (= 5.0.3)
activemodel (= 5.0.3)
activerecord (= 5.0.3)
activesupport (= 5.0.3)
bundler (>= 1.3.0, < 2.0)
railties (= 5.0.2)
railties (= 5.0.3)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.1)
actionpack (~> 5.x)
actionview (~> 5.x)
rails-controller-testing (1.0.2)
actionpack (~> 5.x, >= 5.0.1)
actionview (~> 5.x, >= 5.0.1)
activesupport (~> 5.x)
rails-dom-testing (2.0.2)
activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-i18n (5.0.4)
i18n (~> 0.7)
railties (~> 5.0)
railties (5.0.2)
actionpack (= 5.0.2)
activesupport (= 5.0.2)
railties (5.0.3)
actionpack (= 5.0.3)
activesupport (= 5.0.3)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
Expand All @@ -201,7 +209,7 @@ GEM
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
rubyzip (1.2.1)
sass (3.4.23)
sass (3.4.24)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
Expand All @@ -216,8 +224,8 @@ GEM
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
spring (2.0.1)
simplecov-html (0.10.1)
spring (2.0.2)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
Expand All @@ -235,7 +243,7 @@ GEM
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.7)
tins (1.13.2)
tins (1.14.0)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.3)
Expand All @@ -245,7 +253,7 @@ GEM
execjs (>= 0.3.0, < 3)
validates_cpf_cnpj (0.2.0)
activemodel (>= 3.0.0)
web-console (3.5.0)
web-console (3.5.1)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
Expand Down Expand Up @@ -277,6 +285,7 @@ DEPENDENCIES
jquery-rails
listen (~> 3.0.5)
mini_magick (~> 4.3)
paperclip (~> 3.0)
pg (= 0.18.4)
puma (~> 3.0)
rails (~> 5.0.1)
Expand Down
29 changes: 16 additions & 13 deletions app/controllers/alumns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def create
if ( is_principal? )
@alumn = Alumn.new(alumn_params)
@alumn.parent_id = @@parent.id
@classrooms = Classroom.all.order('name_classroom')
if (@alumn.save)
redirect_to @alumn
else
Expand All @@ -60,6 +61,7 @@ def create
def update
if ( is_principal? )
@alumn = Alumn.find(params[:id])
@classrooms = Classroom.all.order('name_classroom')
if @alumn.update alumn_params
redirect_to @alumn
else
Expand Down Expand Up @@ -95,17 +97,18 @@ def update_password_alumn
end

private
# Strong params to be passed to a alumn
def alumn_params
params.require(:alumn).permit(:registry,
:shift,
:name,
:address,
:phone,
:gender,
:birth_date,
:password,
:parent_id,
:classroom_id)
end
def alumn_params
params.require(:alumn).permit(:registry,
:shift,
:name,
:address,
:phone,
:gender,
:image,
:birth_date,
:password,
:parent_id,
:classroom_id)
end
end

4 changes: 4 additions & 0 deletions app/models/alumn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class Alumn < ApplicationRecord
before_create :initialize_strikes
before_save :validates_password

has_many :suspensions
has_attached_file :image, :styles => { :medium => "250x300>", :thumb => "250x90#" }


def initialize_strikes
self.quantity_strike ||= 0
end
Expand Down
11 changes: 8 additions & 3 deletions app/views/alumns/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render "layouts/navbar" %>
<%= form_for (@alumn) do |f| %>
<%= form_for @alumn, :html => { :multipart => true } do |f| %>
<% if @alumn.errors.any? %>
<div class="container">
<div class="text-danger text-justify">
Expand Down Expand Up @@ -54,7 +54,6 @@
<%= f.text_field :shift, class:"form-control", placeholder:"Ex.: matutino" %>
</div>
</div>

<div class="form-group">
<%= f.label :classroom_id, class:"sr-only", id: "sel1" %>
<div class="input-group">
Expand All @@ -65,7 +64,6 @@
<%= f.select :classroom_id, @classrooms.collect {|classroom| [classroom.name_classroom, classroom.id]},{:include_blank => false}, {:class => "form-control", :id => "sel1"}%>
</div>
</div>

<div class="form-group">
<%= f.label :address, class:"sr-only" %>
<div class="input-group">
Expand Down Expand Up @@ -107,6 +105,13 @@
<%= f.radio_button(:gender,"Masculino") %>
<%= label :gender, "Masculino" %>
</div>
<div class="form-group">
<%= f.label :phone, class:"sr-only" %>
<div class="field">
<p class="text-uppercase"><strong>Imagem</strong></p>
<%= f.file_field :image %>
</div>
</div>
</div>
<%= f.button '<span class="fa fa-check"></span> Salvar'.html_safe, type:"submit", class:'btn btn-lg btn-success' %>
<%= link_to '<span class="fa fa-arrow-left"></span> Voltar'.html_safe, alumns_path, class:'btn btn-lg btn-warning' %>
Expand Down
4 changes: 4 additions & 0 deletions app/views/alumns/_form_edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
<%= f.radio_button(:gender,"Masculino") %>
<%= label :gender, "Masculino" %>
</div>
<div class="field">
<p class="text-uppercase"><strong>Imagem</strong></p>
<%= f.file_field :image %>
</div>
</div>
<%= f.hidden_field :permission, :value => "Alumn"%>
<%= f.button '<span class="fa fa-check"></span> Salvar'.html_safe, type:"submit", class:'btn btn-lg btn-success' %>
Expand Down
6 changes: 5 additions & 1 deletion app/views/alumns/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
<div class="container">
<div class="row item">
<div class="col-sm-12 col-md-4">
<%= image_tag("avatar_250x300.png", alt: "", class: "img-responsive" ) %>
<% if alumn.image_file_name == nil %>
<%= image_tag("avatar_250x300.png", alt: "", class: "img-responsive" ) %>
<% else %>
<%= image_tag(alumn.image.url(:medium), alt: "", class: "img-responsive") %>
<%end%>
</div>
<div class="col-sm-12 col-md-8 text-capitalize descript">
<h2><%= alumn.name %></h2>
Expand Down
Loading

0 comments on commit 03c934d

Please sign in to comment.