Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusbsilva committed Jun 4, 2017
2 parents d7fa6e2 + 8ba9303 commit 426b324
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
24 changes: 12 additions & 12 deletions app/controllers/classrooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@
# Class name: ClassroomsController
# Description: Controller used to communicate with the proprietary view of classrooms
class ClassroomsController < ApplicationController
include SessionsHelper
include SessionsHelper

def index
if ( is_principal? )
if ( is_principal? or is_secretary? )
@classrooms = Classroom.all.order('name_classroom')
else
redirect_to "/errors/error_500"
redirect_to "/errors/error_500"
end
end

def new
if ( is_principal? )
@classroom = Classroom.new
else
redirect_to "/errors/error_500"
redirect_to "/errors/error_500"
end
end

def show
if ( is_principal? )
if ( is_principal? or is_secretary?)
@classroom = Classroom.find(params[:id])
else
redirect_to "/errors/error_500"
redirect_to "/errors/error_500"
end
end

Expand All @@ -37,7 +37,7 @@ def create
render 'classrooms/new'
end
else
redirect_to "/errors/error_500"
redirect_to "/errors/error_500"
end
end

Expand All @@ -47,15 +47,15 @@ def destroy
@classroom.destroy
redirect_to users_path
else
redirect_to "/errors/error_500"
redirect_to "/errors/error_500"
end
end

def edit
if ( is_principal? )
@classroom = Classroom.find(params[:id])
else
redirect_to "/errors/error_500"
redirect_to "/errors/error_500"
end
end

Expand All @@ -68,7 +68,7 @@ def update
render "classrooms/edit"
end
else
redirect_to "/errors/error_500"
redirect_to "/errors/error_500"
end
end

Expand All @@ -77,7 +77,7 @@ def add_alumns
@classroom = Classroom.find(params[:id])
@alumns = @classroom.alumns
else
redirect_to "/errors/error_500"
redirect_to "/errors/error_500"
end
end

Expand All @@ -98,7 +98,7 @@ def add_alumn
end
end
else
redirect_to "/errors/error_500"
redirect_to "/errors/error_500"
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/views/classrooms/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<div class="container">
<div class="pull-right">
<%= link_to '<span class="fa fa-arrow-left"></span> Voltar'.html_safe, :back, class:'btn btn-sm btn-info' %>
<%if @current_user.is_a?(Employee) %>
<%if @current_user.permission=="Principal" %>
<%if is_employee? %>
<%if is_principal? %>
<%= link_to '<span class="fa fa-edit"></span> Editar'.html_safe, edit_classroom_path(classroom), class:"btn btn-sm btn-default" %>
<%= link_to '<span class="fa fa-times"></span> Excluir'.html_safe, "", method: :delete, class:'btn btn-sm btn-danger', data: { confirm: 'Tem certeza? Essa alteração não pode ser desfeita.' } %>
<%= link_to '<span class="fa fa-user-plus"></span> Adicionar Alunos'.html_safe, add_alumns_path(classroom), class:"btn btn-sm btn-success" %>
<%= link_to '<span class="fa fa-address-card"></span> Matérias'.html_safe, classroom_subjects_path(classroom), class:'btn btn-sm btn-warning' %>
<% end %>
<%= link_to '<span class="fa fa-address-card"></span> Matérias'.html_safe, classroom_subjects_path(classroom), class:'btn btn-sm btn-warning' %>
<% end %>
</div>
<div class="row item">
Expand Down
15 changes: 6 additions & 9 deletions app/views/layouts/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
</div>
<div class="collapse navbar-collapse" id="coll-nav">
<ul class="nav navbar-nav pull-right">
<%if is_secretary? %>
<li><%=link_to '<span class="fa fa-sticky-note-o"></span> Notas'.html_safe, grades_path %></li>
<%end%>
<% if is_principal? or is_secretary?%>
<li><%=link_to '<span class="fa fa-book"></span> Matéria'.html_safe, subjects_path %></li>
<%end%>
<% if is_teacher? %>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-hospopup="true" aria-expanded="false">
Expand Down Expand Up @@ -49,13 +43,16 @@
</ul>
</li>
<% end %>
<%if is_principal? %>
<%if is_principal? or is_secretary? %>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-hospopup="true" aria-expanded="false">
<span class="fa fa-search"></span> Visualizar
</a>
<ul class="dropdown-menu">
<li><%= link_to '<span class="fa fa-user-circle-o"></span> Secretários'.html_safe, secretaries_path %></li>
<% if is_principal? %>
<li><%= link_to '<span class="fa fa-user-circle-o"></span> Secretários'.html_safe, secretaries_path %></li>
<li><%=link_to '<span class="fa fa-book"></span> Matéria'.html_safe, subjects_path %></li>
<% end %>
<li><%= link_to '<span class="fa fa-users"></span> Turmas'.html_safe, classrooms_path %></li>
<li><%= link_to '<span class="fa fa-search"></span> Alunos'.html_safe, alumns_path %></li>
</ul>
Expand All @@ -66,4 +63,4 @@
</ul>
</div>
</div>
</nav>
</nav>
14 changes: 7 additions & 7 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@
end

create_table "grades", force: :cascade do |t|
t.float "grade_01"
t.float "grade_02"
t.float "grade_03"
t.float "grade_04"
t.float "grade_final"
t.float "grade_01", default: 0.0
t.float "grade_02", default: 0.0
t.float "grade_03", default: 0.0
t.float "grade_04", default: 0.0
t.float "grade_final", default: 0.0
t.integer "alumn_id"
t.integer "subject_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "classroom_id"
t.index ["alumn_id"], name: "index_grades_on_alumn_id"
t.index ["classroom_id"], name: "index_grades_on_classroom_id"
Expand Down

0 comments on commit 426b324

Please sign in to comment.