Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Devise now displays a message after sign up. Many other changes.

  • Loading branch information...
commit 2c786f1092b7ff6a717315cce7944a38b737c2b7 1 parent 69452ec
Nicholas Pufal authored May 13, 2012
7  app/controllers/admin/students_reports_controller.rb
... ...
@@ -1,5 +1,10 @@
1 1
 class Admin::StudentsReportsController < Admin::ReportsController
2 2
   def index
3  
-    
  3
+    @students = Student.all
  4
+  end
  5
+  
  6
+  def show
  7
+    @student = Student.find(params[:id])
  8
+    @groups = @student.groups
4 9
   end
5 10
 end
7  app/controllers/application_controller.rb
@@ -4,11 +4,4 @@ class ApplicationController < ActionController::Base
4 4
   before_filter :authenticate_user!
5 5
   
6 6
   respond_to :html
7  
-  
8  
-  protected
9  
-  
10  
-  def after_sign_in_path_for(resource)
11  
-    resource.admin? ? admin_root_path : root_path
12  
-  end
13  
-  
14 7
 end
14  app/controllers/registrations_controller.rb
... ...
@@ -0,0 +1,14 @@
  1
+#encoding: utf-8
  2
+
  3
+class RegistrationsController < Devise::RegistrationsController
  4
+  
  5
+  protected
  6
+  
  7
+  def after_sign_in_path_for(resource)
  8
+    resource.admin? ? admin_root_path : root_path
  9
+  end
  10
+  
  11
+  def after_sign_up_path_for(resource)
  12
+    new_user_session_path
  13
+  end
  14
+end
1  app/models/group.rb
@@ -3,4 +3,5 @@ class Group < ActiveRecord::Base
3 3
   has_and_belongs_to_many :exams
4 4
   
5 5
   validates_presence_of :name
  6
+  
6 7
 end
1  app/models/student.rb
... ...
@@ -1,5 +1,4 @@
1 1
 class Student < User
2  
-  # has_many :exams, :through => :results
3 2
   has_many :assessments
4 3
   has_and_belongs_to_many :groups
5 4
   has_many :exams, :through => :groups
4  app/presenters/group_report_presenter.rb
@@ -16,7 +16,9 @@ def exam_title(exam)
16 16
   end
17 17
   
18 18
   def student_name(student)
19  
-    handle_presence student.name
  19
+    handle_presence student.name do
  20
+      h.link_to student.name, h.admin_student_report_path(student), :target => "_blank"
  21
+    end
20 22
   end
21 23
   
22 24
   def result(student, exam)
28  app/presenters/student_report_presenter.rb
... ...
@@ -0,0 +1,28 @@
  1
+#encoding: utf-8
  2
+
  3
+class StudentReportPresenter < BasePresenter 
  4
+  presents :student
  5
+  
  6
+  def name
  7
+    handle_presence student.name do
  8
+      h.link_to(student.name, h.admin_student_report_path(student))
  9
+    end
  10
+  end
  11
+  
  12
+  def name_show
  13
+    handle_presence student.name
  14
+  end
  15
+  
  16
+  def group_name(group)
  17
+    handle_presence group.name
  18
+  end
  19
+  
  20
+  def exam_title(exam)
  21
+    handle_presence exam.title 
  22
+  end
  23
+  
  24
+  def result(student, exam)
  25
+    Assessment.find_result(student, exam) ? Assessment.find_result(student, exam).grade : 0.0
  26
+  end
  27
+  
  28
+end
10  app/views/admin/groups_reports/show.html.erb
@@ -7,7 +7,7 @@
7 7
 
8 8
 	<!-- filtering form -->
9 9
 	<%= form_tag admin_group_report_path(@group), :method => :get, :class => "well form-inline" do %>
10  
-		<span>Filtrar alunos por nota:</span>
  10
+		<span>Filtrar  por nota:</span>
11 11
 		
12 12
 		<%= select_tag "filter", 
13 13
 				options_for_select((1..10).collect{|n| ["#{n}", n] }, params[:filter]), 
@@ -30,19 +30,17 @@
30 30
 			</tr>
31 31
 		</thead>
32 32
 		<tbody>
  33
+			<% @group.students.each do |student| %>
33 34
 			<tr>
34  
-				<% @group.students.each do |student| %>
35  
-				
36 35
 					<td><%= group_report_presenter.student_name(student) %></td>
37 36
 										
38 37
 					<% @exams.each do |exam| %>
39 38
 						<td class="<%= group_report_presenter.result_class(student, exam) %>">
40 39
 							<%= group_report_presenter.result(student, exam) %>
41 40
 						</td>
42  
-					<% end %>	
43  
-					
44  
-				<% end %>
  41
+					<% end %>						
45 42
 			</tr>
  43
+			<% end %>
46 44
 		</tbody>		
47 45
 	</table>
48 46
 <% end %>
14  app/views/admin/students_reports/_table.html.erb
... ...
@@ -0,0 +1,14 @@
  1
+<table class="table table-bordered table-condensed table-striped reports_table">
  2
+	<tbody>
  3
+		<% group.exams.each do |exam| %>
  4
+		<tr>
  5
+			<td>
  6
+				<%= student_report_presenter.exam_title(exam) %>
  7
+			</td>
  8
+			<td>
  9
+				<%= student_report_presenter.result(@student, exam) %>
  10
+			</td>
  11
+		</tr>
  12
+		<% end %>	
  13
+	</tbody>		
  14
+</table>
29  app/views/admin/students_reports/index.html.erb
... ...
@@ -1 +1,28 @@
1  
-teste estudantes
  1
+<div class="page-header">
  2
+  <h1>Relatórios por aluno</h1>
  3
+</div>
  4
+
  5
+<% if @students.present? %>
  6
+	<table class="table table-striped">
  7
+		<thead>
  8
+			<tr>
  9
+				<th>Selecione um aluno</th>
  10
+			</tr>
  11
+		</thead>
  12
+
  13
+		<tbody>
  14
+			<% @students.each do |student| %>
  15
+				<% presenter student, StudentReportPresenter do |student_report_presenter| %>
  16
+				<tr>
  17
+					<td><%= student_report_presenter.name %></td>
  18
+				</tr>
  19
+				<% end %>
  20
+			<% end %>
  21
+		</tbody>		
  22
+	</table>
  23
+<% else %>
  24
+	<div class="alert alert-block">
  25
+		<a class="close" data-dismiss="alert">×</a>
  26
+		<p>Não existem alunos cadastrados.</p>
  27
+	</div>
  28
+<% end %>
25  app/views/admin/students_reports/show.html.erb
... ...
@@ -0,0 +1,25 @@
  1
+<%= go_back_button "Ver outro aluno", admin_students_reports_path %>
  2
+
  3
+<% presenter @student, StudentReportPresenter do |student_report_presenter| %>
  4
+	<div class="page-header">
  5
+	  <h2>Relatórios por aluno <small>(<%= student_report_presenter.name_show %>)</small></h2>
  6
+	</div>
  7
+
  8
+	<div class="tabbable">
  9
+	  <ul class="nav nav-tabs">
  10
+			<% @groups.each_with_index do |group, index| %>
  11
+				<li class="<%= "active" if index == 0 %>"><a href="#group<%= index %>" data-toggle="tab"><%= student_report_presenter.group_name(group) %></a></li>
  12
+			<% end %>
  13
+	  </ul>
  14
+
  15
+
  16
+	  <div class="tab-content">
  17
+			<% @groups.each_with_index do |group, index| %>
  18
+				<div class="tab-pane <%= "active" if index == 0 %>" id="group<%= index %>">
  19
+		      <%= render "table", :group => group, :student_report_presenter => student_report_presenter %>
  20
+		    </div>
  21
+			<% end %>
  22
+	  </div>
  23
+	</div>
  24
+	
  25
+<% end %>
25  app/views/registrations/edit.html.erb
... ...
@@ -0,0 +1,25 @@
  1
+<h2>Edit <%= resource_name.to_s.humanize %></h2>
  2
+
  3
+<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
  4
+  <%= devise_error_messages! %>
  5
+
  6
+  <div><%= f.label :email %><br />
  7
+  <%= f.email_field :email %></div>
  8
+
  9
+  <div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
  10
+  <%= f.password_field :password %></div>
  11
+
  12
+  <div><%= f.label :password_confirmation %><br />
  13
+  <%= f.password_field :password_confirmation %></div>
  14
+
  15
+  <div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
  16
+  <%= f.password_field :current_password %></div>
  17
+
  18
+  <div><%= f.submit "Update" %></div>
  19
+<% end %>
  20
+
  21
+<h3>Cancel my account</h3>
  22
+
  23
+<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
  24
+
  25
+<%= link_to "Back", :back %>
48  app/views/registrations/new.html.erb
... ...
@@ -0,0 +1,48 @@
  1
+<div class="page-header">
  2
+	<h2>Cadastro</h2>
  3
+</div>
  4
+
  5
+<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => "form-horizontal"}) do |f| %>
  6
+
  7
+  <%= devise_error_messages! %>
  8
+
  9
+	<div class="control-group">
  10
+		<%= f.label :name, "Nome completo", :class => "control-label" %>
  11
+		<div class="controls">
  12
+			<%= f.text_field :name, :class => "input-xlarge" %>
  13
+		</div>
  14
+	</div>
  15
+	
  16
+	<div class="control-group">
  17
+		<%= f.label :email, "E-mail", :class => "control-label" %>
  18
+		<div class="controls">
  19
+			<%= f.email_field :email, :class => "input-xlarge" %>
  20
+		</div>
  21
+	</div>
  22
+	
  23
+	<div class="control-group">
  24
+		<%= f.label :password, "Senha", :class => "control-label" %>
  25
+		<div class="controls">
  26
+			<%= f.password_field :password, :class => "input-xlarge" %>
  27
+		</div>
  28
+	</div>
  29
+	
  30
+	<div class="control-group">
  31
+		<%= f.label :password_confirmation, "Confirmação de senha", :class => "control-label" %>
  32
+		<div class="controls">
  33
+			<%= f.password_field :password_confirmation, :class => "input-xlarge" %>
  34
+		</div>
  35
+	</div>
  36
+	
  37
+	<div class="control-group">
  38
+		<div class="controls">
  39
+	  	<%= f.submit "Cadastrar", :class => "btn" %>
  40
+		</div>
  41
+	</div>
  42
+<% end %>
  43
+
  44
+<%= render :partial => "devise/shared/links" %>
  45
+
  46
+
  47
+
  48
+
2  config/locales/devise.pt-BR.yml
@@ -34,7 +34,7 @@
34 34
       send_paranoid_instructions: 'Se o seu endereço de e-mail estiver cadastrado, você receberá uma mensagem com instruções para confirmação da sua conta.'
35 35
       confirmed: 'Sua conta foi confirmada com sucesso. Você está logado.'
36 36
     registrations:
37  
-      signed_up: 'Login efetuado com sucesso. Se não foi autorizado, a confirmação será enviada por e-mail.'
  37
+      signed_up: 'Cadastro efetuado com sucesso. Aguarde a liberação do professor para efetuar login.'
38 38
       signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
39 39
       signed_up_but_inactive: 'Você foi cadastrado com sucesso. No entanto, não foi possível efetuar login, pois sua conta não foi ativada.'
40 40
       signed_up_but_locked: 'Você foi cadastrado com sucesso. No entanto, não foi possível efetuar login, pois sua conta está bloqueada.'
5  config/routes.rb
... ...
@@ -1,9 +1,8 @@
1 1
 AlternativaTcc::Application.routes.draw do
2  
-  devise_for :students
  2
+  devise_for :students, :controllers => { :registrations => "registrations" }
3 3
   
4  
-  devise_for :users, :skip => [:registrations]
  4
+  devise_for :users, :controllers => { :registrations => "registrations" }, :skip => [:registrations]
5 5
 
6  
-  
7 6
   root :to => "assessments#index"  
8 7
   
9 8
   resources :exams, :only => [:show] do

0 notes on commit 2c786f1

Please sign in to comment.
Something went wrong with that request. Please try again.