Permalink
Browse files

Merge branch 'bek' into develop

  • Loading branch information...
2 parents 50677a2 + 79a6917 commit a1fb89fd471d255ca1f6cb1865f52f85f90def55 @bek0nik bek0nik committed Mar 29, 2012
View
1 app/controllers/sessions_controller.rb
@@ -55,6 +55,7 @@ def create
def destroy
#session[:user_id] = nil
+ current_user.last_log_out
cookies.delete(:auth_token)
redirect_to sign_in_path
flash[:notice] = "Вы вышли из системы"
View
8 app/models/user.rb
@@ -4,7 +4,7 @@ class User < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation,
:password_reset_token, :password_reset_sent_at,
:role, :lastname, :firstname, :phonehome, :phonemobile,
- :area_code, :phonemobile1, :phonemobile2, :fired, :last_sign_in_at
+ :area_code, :phonemobile1, :phonemobile2, :fired, :last_sign_in_at, :last_log_out_at
#encript password before save
before_save :encrypt_password
@@ -129,6 +129,12 @@ def last_sign
save!
end
+ # last logout
+ def last_log_out
+ self.last_log_out_at = Time.current
+ save!
+ end
+
end
# == Schema Information
#
View
12 app/views/users/index.html.erb
@@ -4,6 +4,9 @@
<thead>
<th>Фамилия Имя</th>
<th>Последний визит</th>
+ <% if current_user.role? %>
+ <th>Вышел из системы</th>
+ <% end %>
<th>Действия</th>
<th>Статус</th>
</thead>
@@ -19,6 +22,15 @@
<% end %>
</td>
+ <% if current_user.role? %>
+ <td>
+ <% if isset_last_sign_in(u.last_log_out_at) %>
+ -
+ <% else %>
+ <%= to_datetime(u.last_log_out_at) %>
+ <% end %>
+ </td>
+ <% end %>
<td class="actions-buttons">
<%= link_to eye_icon, user_path(u) %>
<% if can? :update, @users %>
View
5 db/migrate/20120329074113_add_last_log_out_to_users.rb
@@ -0,0 +1,5 @@
+class AddLastLogOutToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :last_log_out_at, :datetime
+ end
+end
View
17 db/schema.rb
@@ -1,4 +1,4 @@
-# -*- encoding : utf-8 -*-
+# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120328092814) do
+ActiveRecord::Schema.define(:version => 20120329074113) do
create_table "cities", :force => true do |t|
t.string "name"
@@ -37,7 +37,9 @@
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "potentials", :default => false
+ t.integer "type_customer_id"
t.integer "social_status_id"
+ t.string "permalink"
t.integer "typetransaction_id"
t.datetime "lastcall"
t.integer "user_id"
@@ -69,10 +71,12 @@
end
create_table "properties", :force => true do |t|
- t.string "condition"
- t.string "value"
- t.integer "subject_id"
- t.string "typefield"
+ t.string "condition"
+ t.string "value"
+ t.integer "subject_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.string "typefield"
end
create_table "residents", :force => true do |t|
@@ -170,6 +174,7 @@
t.string "phonehome"
t.boolean "fired", :default => false
t.datetime "last_sign_in_at"
+ t.datetime "last_log_out_at"
end
create_table "value_fields", :force => true do |t|

0 comments on commit a1fb89f

Please sign in to comment.