From 4999b47b44eacc0c9d224beaa55a77243ff0c08d Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 16:46:26 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8E=BB=E6=8E=89ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/users_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index bdd34d80d..44b919121 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -62,7 +62,7 @@ module UsersHelper when 'Course' result = current_time_and_term_resource content when 'Project' - result = content.name + "(" + content.id.to_s + ")" + result = content.name when 'Issue' result = content.subject when 'Message' From 79767f4baec04d63fa3276b3255d62e2da785cd3 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 17:22:07 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=A1=8C=E4=B8=BA?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 6 ++++++ app/models/user_actions.rb | 4 ++++ db/migrate/20160317090350_create_user_actions.rb | 11 +++++++++++ db/schema.rb | 10 +++++++++- spec/factories/user_actions.rb | 8 ++++++++ spec/models/user_actions_spec.rb | 5 +++++ 6 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 app/models/user_actions.rb create mode 100644 db/migrate/20160317090350_create_user_actions.rb create mode 100644 spec/factories/user_actions.rb create mode 100644 spec/models/user_actions_spec.rb diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index e974f26b4..155e75976 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -104,6 +104,8 @@ class AttachmentsController < ApplicationController end else direct_download_history + # 记录用户行为 + record_user_actions end end else @@ -113,6 +115,10 @@ class AttachmentsController < ApplicationController redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html" end + def record_user_actions + UserActions.create(:action_id => id, :action_type => "AttachmentHistory", :user_id => User.current.id) + end + def download # modify by nwb # 下载添加权限设置 diff --git a/app/models/user_actions.rb b/app/models/user_actions.rb new file mode 100644 index 000000000..de2388911 --- /dev/null +++ b/app/models/user_actions.rb @@ -0,0 +1,4 @@ +class UserActions < ActiveRecord::Base + attr_accessible :action_id, :action_type, :user_id + has_many :users +end diff --git a/db/migrate/20160317090350_create_user_actions.rb b/db/migrate/20160317090350_create_user_actions.rb new file mode 100644 index 000000000..d7893fcad --- /dev/null +++ b/db/migrate/20160317090350_create_user_actions.rb @@ -0,0 +1,11 @@ +class CreateUserActions < ActiveRecord::Migration + def change + create_table :user_actions do |t| + t.integer :user_id + t.string :action_type + t.integer :action_id + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 33bf42b5b..2c55aad61 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160316055201) do +ActiveRecord::Schema.define(:version => 20160317090350) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1782,6 +1782,14 @@ ActiveRecord::Schema.define(:version => 20160316055201) do t.integer "fields_bits", :default => 0 end + create_table "user_actions", :force => true do |t| + t.integer "user_id" + t.string "action_type" + t.integer "action_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "user_activities", :force => true do |t| t.string "act_type" t.integer "act_id" diff --git a/spec/factories/user_actions.rb b/spec/factories/user_actions.rb new file mode 100644 index 000000000..38dbed67e --- /dev/null +++ b/spec/factories/user_actions.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :user_action, :class => 'UserActions' do + user_id 1 +action_type "MyString" +action_id 1 + end + +end diff --git a/spec/models/user_actions_spec.rb b/spec/models/user_actions_spec.rb new file mode 100644 index 000000000..afe799fb9 --- /dev/null +++ b/spec/models/user_actions_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe UserActions, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 6f5a4d429d702f8fe3253552f9d80c25b256c0b7 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Thu, 17 Mar 2016 21:17:30 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=8Aissue=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2=E6=A0=B7=E5=BC=8F=E4=B9=B1=E4=BA=86?= =?UTF-8?q?=E3=80=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index 4b82f8665..cf771a700 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -9,7 +9,7 @@ $(function(){ $("#RSide").removeAttr("id"); $("#Container").css("width","1000px"); - if(<%= @is_edit %>) { + if(true == <%= @is_edit %>) { issueEditShow(); } }); From b262e1b4325943b53b006c4d6108ed0628ea51ce Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 18 Mar 2016 09:58:47 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 155e75976..9d5b3cc5a 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -103,9 +103,10 @@ class AttachmentsController < ApplicationController direct_download_history end else - direct_download_history # 记录用户行为 - record_user_actions + record_user_actions(params[:id]) + # 直接下载历史版本 + direct_download_history end end else @@ -115,8 +116,12 @@ class AttachmentsController < ApplicationController redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html" end - def record_user_actions - UserActions.create(:action_id => id, :action_type => "AttachmentHistory", :user_id => User.current.id) + def record_user_actions id + if params[:action] == "download_history" + UserActions.create(:action_id => id, :action_type => "AttachmentHistory", :user_id => User.current.id) unless id.nil? + elsif params[:action] == "download" + UserActions.create(:action_id => id, :action_type => "Attachment", :user_id => User.current.id) + end end def download @@ -141,6 +146,8 @@ class AttachmentsController < ApplicationController direct_download end else + # 记录用户行为 + record_user_actions(params[:id]) direct_download end end From 4766abab7fb7c7378e5b12e79bbaed4b92354316 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 18 Mar 2016 09:59:39 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E8=A1=8C=E4=B8=BA?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0ID=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 9d5b3cc5a..9853b4dc1 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -120,7 +120,7 @@ class AttachmentsController < ApplicationController if params[:action] == "download_history" UserActions.create(:action_id => id, :action_type => "AttachmentHistory", :user_id => User.current.id) unless id.nil? elsif params[:action] == "download" - UserActions.create(:action_id => id, :action_type => "Attachment", :user_id => User.current.id) + UserActions.create(:action_id => id, :action_type => "Attachment", :user_id => User.current.id) unless id.nil? end end From 1eafad6468e336424a29069ca60f6e34523f1b10 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 18 Mar 2016 10:05:31 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E9=BC=A0=E6=A0=87=E7=BB=8F=E8=BF=87?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=A4=B4=E5=83=8F=E6=98=BE=E7=A4=BA=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF=E5=90=8E=EF=BC=8C=E6=8C=81=E7=BB=AD?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E5=8D=8A?= =?UTF-8?q?=E7=A7=92=E9=92=9F=EF=BC=8C=E4=BB=A5=E4=BE=BF=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=8F=8A=E6=97=B6=E6=93=8D=E4=BD=9C=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_course_activity.html.erb | 13 ++++++++++++- app/views/layouts/new_base_user.html.erb | 13 ++++++++++++- app/views/org_subfields/_show_details.html.erb | 13 +------------ app/views/organizations/_org_activities.html.erb | 12 ------------ .../organizations/_org_left_subfield_list.html.erb | 13 ++++++++++++- app/views/projects/_project_activities.html.erb | 13 ++++++++++++- app/views/users/_user_activities.html.erb | 13 ------------- 7 files changed, 49 insertions(+), 41 deletions(-) diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb index d65c0b3ab..bdbcabff0 100644 --- a/app/views/courses/_course_activity.html.erb +++ b/app/views/courses/_course_activity.html.erb @@ -2,6 +2,8 @@ <%= import_ke(enable_at: true, prettify: false, init_activity: true) %> <% end %>