user action
This commit is contained in:
		
							parent
							
								
									3d0a1cef56
								
							
						
					
					
						commit
						37aa950028
					
				|  | @ -0,0 +1,6 @@ | ||||||
|  | class Admin::UserActionsController < OrbitBackendController | ||||||
|  | 
 | ||||||
|  |   def index | ||||||
|  |     @user_actions = UserAction.all | ||||||
|  |   end | ||||||
|  | end | ||||||
|  | @ -29,6 +29,7 @@ class ApplicationController < ActionController::Base | ||||||
| 
 | 
 | ||||||
|   def set_current_user |   def set_current_user | ||||||
|     User.current = current_or_guest_user |     User.current = current_or_guest_user | ||||||
|  |     UserActionRecoder.perform(current_or_guest_user,params) | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def front_end_available(module_app_title='') |   def front_end_available(module_app_title='') | ||||||
|  |  | ||||||
|  | @ -0,0 +1,8 @@ | ||||||
|  | class UserActionRecoder | ||||||
|  |  @queue = :low | ||||||
|  |  def self.perform(user,params)   | ||||||
|  |    UserAction.create!(:user=>user,:params=>params,:page=>"#{params['controller']}##{params['action']}") | ||||||
|  |     true | ||||||
|  |  end | ||||||
|  | 
 | ||||||
|  | end | ||||||
|  | @ -31,6 +31,8 @@ class User | ||||||
|   # has_many :papers, :autosave => true, :dependent => :destroy |   # has_many :papers, :autosave => true, :dependent => :destroy | ||||||
|   has_and_belongs_to_many :sub_role_tags |   has_and_belongs_to_many :sub_role_tags | ||||||
| 
 | 
 | ||||||
|  |   has_many :user_actions, :dependent => :destroy | ||||||
|  | 
 | ||||||
| #  has_and_belongs_to_many :statuses | #  has_and_belongs_to_many :statuses | ||||||
|   has_and_belongs_to_many :roles |   has_and_belongs_to_many :roles | ||||||
|   has_and_belongs_to_many :sub_roles |   has_and_belongs_to_many :sub_roles | ||||||
|  |  | ||||||
|  | @ -0,0 +1,10 @@ | ||||||
|  | class UserAction | ||||||
|  |   include Mongoid::Document | ||||||
|  |   include Mongoid::Timestamps | ||||||
|  | 
 | ||||||
|  |   belongs_to :user | ||||||
|  |   field :params,:type => Hash | ||||||
|  | 
 | ||||||
|  |   field :page | ||||||
|  | 
 | ||||||
|  | end | ||||||
|  | @ -0,0 +1,16 @@ | ||||||
|  | <table class="table"> | ||||||
|  |   <tr> | ||||||
|  |     <th>時間</th> | ||||||
|  |     <th>使用帳號</th> | ||||||
|  |     <th>頁面</th> | ||||||
|  |   </tr> | ||||||
|  | 
 | ||||||
|  |   <%  @user_actions.each do |user_action| %> | ||||||
|  |     <tr> | ||||||
|  |       <td><%= user_action.created_at %></td> | ||||||
|  |       <td><%= user_action.user.name %></td> | ||||||
|  |       <td><%= user_action.page %></td> | ||||||
|  |     </tr>  | ||||||
|  |   <% end %> | ||||||
|  | </table> | ||||||
|  | 
 | ||||||
|  | @ -1,6 +1,8 @@ | ||||||
| Orbit::Application.routes.draw do | Orbit::Application.routes.draw do | ||||||
|   # get "robots.txt" => 'robots#index' |   # get "robots.txt" => 'robots#index' | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|   devise_for :users do |   devise_for :users do | ||||||
|     match "/users_passwd" => "desktop/registrations#update", :as => :users_passwd, :via => :put |     match "/users_passwd" => "desktop/registrations#update", :as => :users_passwd, :via => :put | ||||||
|   end |   end | ||||||
|  | @ -18,6 +20,7 @@ Orbit::Application.routes.draw do | ||||||
| 
 | 
 | ||||||
|   # routes for admin |   # routes for admin | ||||||
|   namespace :admin do |   namespace :admin do | ||||||
|  |     match 'user_actions' => 'user_actions#index' | ||||||
|     match 'system_preference' => "sites#show_system_preference",:as=>"system_preference" |     match 'system_preference' => "sites#show_system_preference",:as=>"system_preference" | ||||||
|     mount Resque::Server.new, :at => "/resque" |     mount Resque::Server.new, :at => "/resque" | ||||||
|     resources :assets do    |     resources :assets do    | ||||||
|  |  | ||||||
		Reference in New Issue