Skip to content

Commit

Permalink
Merge pull request #62 from fga-gpp-mds/dev_misses_pt2
Browse files Browse the repository at this point in the history
Dev misses pt2
  • Loading branch information
Mattioli authored May 19, 2017
2 parents de89b08 + d663e19 commit 0721266
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 193 deletions.
10 changes: 10 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ body {
background-color: #9768D1;
}

.btn-shades{
background-color: #aaa;
color: white;
}

.btn-shades:hover{
background-color: #555;
color: white;
}

@import "bootswatch/flatly/bootswatch";
25 changes: 14 additions & 11 deletions app/controllers/school_misses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ def index
end
end

def show
#if ( logged_in? )
# @school_miss = SchoolMiss.find(params[:id])
#end
end
# def show
# #if ( logged_in? )
# # @school_miss = SchoolMiss.find(params[:id])
# #end
# end

def new
if ( is_employee? )
Expand All @@ -33,19 +33,23 @@ def create
end

def edit
#if ( is_employee? )
# @school_miss = SchoolMiss.find(params[:id])
#end
if ( is_employee? )
@school_miss = SchoolMiss.find(params[:id])
# @alumn = Alumn.find_by_id(@school_miss.alumn_id)
end
end

def update
if ( is_employee? )
# alumns/idalumn/school_misses/idmiss
# @school_miss.alumn_id = Alumn.current.id
#alumn = Alumn.find(params[:id])
#@school_miss = alumn.school_misses.find(params[:id])
@school_miss = SchoolMiss.find(params[:id])
@school_miss.alumn_id = Alumn.current.id
if ( @school_miss.update(school_miss_params) )
redirect_to alumn_path(@school_miss.alumn_id)
else
#render edit_school_miss_path
# render edit_school_miss_path
end
end
end
Expand All @@ -54,7 +58,6 @@ def destroy
if ( is_principal? )
@school_miss = SchoolMiss.find(params[:id])
@school_miss.destroy

redirect_to alumn_path(@school_miss.alumn_id)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/school_miss.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class SchoolMiss < ApplicationRecord
belongs_to :alumn, dependent: :destroy
belongs_to :alumn

validates :date, presence: { message:"Não pode estar e branco." }

Expand Down
19 changes: 2 additions & 17 deletions app/views/alumns/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<h4>Sexo: <%= @alumn.gender %></h4>
<h4>Endereço: <%= @alumn.address %></h4>
<h4>Data de Nascimento: <%= @alumn.birth_date %></h4>
<h4>Turma: <%= @alumn.classroom.name_classroom %></h4>
<h4>Turma: <%= %></h4>
<h4><%=link_to "Responsável: #{@alumn.parent.name}",parent_path(@alumn.parent), class: "btn btn-default" %></h4>
</div>
</div>
Expand All @@ -44,22 +44,7 @@
<div>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="faltas">
<% if (@current_user.is_a?(Employee)) %>
<%= link_to '<span class="fa fa-user-times"></span> Adicionar uma nova falta'.html_safe, new_alumn_school_miss_path(@alumn), class:"btn btn-success btn-sm" %>
<% end %>
<ul>
<% @alumn.school_misses.all.reverse.each do |miss| %>
<% if (@current_user.is_a?(Principal)) %>
<br>
<li class="text-danger"><%= miss.date.day %>/<%= miss.date.month %>/<%= miss.date.year %>
<%= link_to '<span class="fa fa-edit"></span> Editar'.html_safe, edit_alumn_school_miss_path(miss), class:"btn btn-sm btn-default" %>
</li>
<% else %>
<br>
<li class="text-danger"><%= miss.date.day %>/<%= miss.date.month %>/<%= miss.date.year %></li>
<% end %>
<% end %>
</ul>
<%= render "school_misses/index" %>
</div>
<div role="tabpanel" class="tab-pane" id="boletim">
<!-- <%# TODO: %> -->
Expand Down
24 changes: 12 additions & 12 deletions app/views/layouts/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
<ul class="nav navbar-nav pull-right">
<% if is_principal? or is_secretary? or is_teacher? %>
<li><%=link_to '<span class="fa fa-book"></span> Matéria'.html_safe, subjects_path %></li>
<li><%=link_to '<span class="fa fa-sticky-note-o"></span> Avisos'.html_safe, notifications_path %></li>
<!-- <li><%=link_to '<span class="fa fa-sticky-note-o"></span> Avisos'.html_safe, notifications_path %></li> -->
<%end%>
<%if is_principal? %>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-hospopup="true" aria-expanded="false">
<span class="fa fa-plus"></span> Criar
</a>
<ul class="dropdown-menu">
<li><%= link_to '<span class="fa fa-user-plus"></span> Criar Responsável e Aluno'.html_safe, new_parent_path %></li>
<li><%= link_to '<span class="fa fa-user-circle-o"></span> Criar Secretário'.html_safe, new_secretary_path %></li>
<li><%= link_to '<span class="fa fa-user-plus"></span> Criar Professor'.html_safe, new_teacher_path %></li>
<li><%= link_to '<span class="fa fa-users"></span> Criar Turma'.html_safe, new_classroom_path %></li>
<li><%= link_to '<span class="fa fa-paper-plane-o"></span> Criar Notificação'.html_safe, new_notification_path %></li>
<% end %>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-hospopup="true" aria-expanded="false">
<span class="fa fa-plus"></span> Criar
</a>
<ul class="dropdown-menu">
<li><%= link_to '<span class="fa fa-user-plus"></span> Criar Responsável e Aluno'.html_safe, new_parent_path %></li>
<li><%= link_to '<span class="fa fa-user-circle-o"></span> Criar Secretário'.html_safe, new_secretary_path %></li>
<li><%= link_to '<span class="fa fa-user-plus"></span> Criar Professor'.html_safe, new_teacher_path %></li>
<li><%= link_to '<span class="fa fa-users"></span> Criar Turma'.html_safe, new_classroom_path %></li>
<li><%= link_to '<span class="fa fa-paper-plane-o"></span> Criar Notificação'.html_safe, new_notification_path %></li>
</ul>
</li>
<% end %>
<%if is_principal? %>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-hospopup="true" aria-expanded="false">
Expand Down
19 changes: 19 additions & 0 deletions app/views/school_misses/_index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<% if (@current_user.is_a?(Employee)) %>
<%= link_to '<span class="fa fa-user-times"></span> Adicionar uma nova falta'.html_safe, new_alumn_school_miss_path(@alumn), class:"btn btn-success btn-sm" %>
<% end %>
<ul>
<br>
<% @alumn.school_misses.all.reverse.each do |miss| %>
<% if (@current_user.is_a?(Principal)) %>
<!-- <br> -->
<li class="text-danger inline">
<%= miss.date.day %>/<%= miss.date.month %>/<%= miss.date.year %>
</li>
<%= link_to '<span class="fa fa-edit"></span> Editar'.html_safe, edit_alumn_school_miss_path(@alumn, miss), class:"btn btn-xs btn-shades" %>
<%= link_to '<span class="fa fa-times"></span> Deletar'.html_safe, [@alumn, miss], :method => :delete, class:"btn btn-xs btn-default" %>
<% else %>
<br>
<li class="text-danger"><%= miss.date.day %>/<%= miss.date.month %>/<%= miss.date.year %></li>
<% end %>
<% end %>
</ul>
Empty file.
2 changes: 1 addition & 1 deletion coverage/.last_run.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"result": {
"covered_percent": 93.36
"covered_percent": 93.38
}
}
Loading

0 comments on commit 0721266

Please sign in to comment.