Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
This commit is contained in:
commit
a1fbe8b886
|
@ -103,6 +103,9 @@ class AttachmentsController < ApplicationController
|
|||
direct_download_history
|
||||
end
|
||||
else
|
||||
# 记录用户行为
|
||||
record_user_actions(params[:id])
|
||||
# 直接下载历史版本
|
||||
direct_download_history
|
||||
end
|
||||
end
|
||||
|
@ -113,6 +116,14 @@ class AttachmentsController < ApplicationController
|
|||
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
|
||||
end
|
||||
|
||||
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) unless id.nil?
|
||||
end
|
||||
end
|
||||
|
||||
def download
|
||||
# modify by nwb
|
||||
# 下载添加权限设置
|
||||
|
@ -135,6 +146,8 @@ class AttachmentsController < ApplicationController
|
|||
direct_download
|
||||
end
|
||||
else
|
||||
# 记录用户行为
|
||||
record_user_actions(params[:id])
|
||||
direct_download
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,7 @@ class CoursesController < ApplicationController
|
|||
helper :members
|
||||
helper :words
|
||||
helper :attachments
|
||||
helper :files
|
||||
helper :activity_notifys
|
||||
|
||||
before_filter :auth_login1, :only => [:show, :course_activity, :feedback]
|
||||
|
|
|
@ -207,8 +207,7 @@ class FilesController < ApplicationController
|
|||
sort = "created_on DESC"
|
||||
end
|
||||
if keywords != "%%"
|
||||
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").
|
||||
reorder(sort)
|
||||
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
|
||||
else
|
||||
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' "). reorder(sort)
|
||||
end
|
||||
|
|
|
@ -2533,6 +2533,8 @@ class UsersController < ApplicationController
|
|||
render_403
|
||||
return
|
||||
end
|
||||
@resource_id = params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id]
|
||||
@resource_type = params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project"
|
||||
@user = User.find(params[:id])
|
||||
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
||||
|
@ -2561,6 +2563,8 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def import_resources_search
|
||||
@resource_id = params[:mul_id]
|
||||
@resource_type = params[:mul_type]
|
||||
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
||||
@user = User.current
|
||||
|
@ -2571,6 +2575,7 @@ class UsersController < ApplicationController
|
|||
render_403
|
||||
return
|
||||
end
|
||||
@resource_id = params[:mul_id]
|
||||
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
||||
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
||||
user_course_ids = User.current.courses.map { |c| c.id}
|
||||
|
|
|
@ -865,7 +865,7 @@ module CoursesHelper
|
|||
# 学生按作业总分排序,取前8个
|
||||
def hero_homework_score(course, score_sort_by)
|
||||
sql_select = "SELECT members.*,(
|
||||
SELECT SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty))
|
||||
SELECT SUM(IF(student_works.final_score is null,null,IF(student_works.final_score = 0, 0, student_works.final_score - student_works.absence_penalty - student_works.late_penalty)))
|
||||
FROM student_works,homework_commons
|
||||
WHERE student_works.homework_common_id = homework_commons.id
|
||||
AND homework_commons.course_id = #{course.id}
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -66,8 +66,8 @@ class CourseActivity < ActiveRecord::Base
|
|||
|
||||
# 发布新课导语
|
||||
# 导语要放置在课程创建信息之后
|
||||
# 导语
|
||||
def add_course_lead
|
||||
# 避免空数据迁移报错问题
|
||||
if self.course_act_type == "Course" and Message.where("id=12440").any?
|
||||
lead_message = Message.find(12440)
|
||||
name = lead_message.subject
|
||||
|
@ -75,7 +75,7 @@ class CourseActivity < ActiveRecord::Base
|
|||
# message的status状态为0为正常,为1表示创建课程时发送的message
|
||||
# author_id 默认为课程使者创建
|
||||
message = Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => 1 , :sticky => true, :status => true )
|
||||
# 更新的目的是为了排序,因为该条动态的时间可能与课程创建的动态创建时间一直
|
||||
# 更新的目的是为了排序,因为该条动态的时间可能与课程创建的动态创建时间一致
|
||||
message.course_acts.first.update_attribute(:updated_at, message.course_acts.first.updated_at + 1) if message.course_acts.first
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
class UserActions < ActiveRecord::Base
|
||||
attr_accessible :action_id, :action_type, :user_id
|
||||
has_many :users
|
||||
end
|
|
@ -8,11 +8,11 @@
|
|||
<div class="fl">
|
||||
<p class="f12 mb5"><%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %><div class="cl"></div> </p>
|
||||
<p class="f12">
|
||||
<% if e_course.attachments.count > 0 %>
|
||||
<span class="fl mr15 fontGrey4"><%= l(:project_module_attachments) %>(<%= link_to e_course.attachments.count, course_files_path(e_course), :class => "linkBlue2" %>)</span>
|
||||
<% if visable_attachemnts(e_course.attachments).count > 0 %>
|
||||
<span class="fl mr15 fontGrey4"><%= l(:project_module_attachments) %>(<%= link_to visable_attachemnts(e_course.attachments).count, course_files_path(e_course), :class => "linkBlue2" %>)</span>
|
||||
<% end %>
|
||||
<% if e_course.homework_commons.count > 0 %>
|
||||
<span class="fl fontGrey4"><%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)</span>
|
||||
<% if e_course.homework_commons.where("publish_time <= '#{Date.today}'").count > 0 %>
|
||||
<span class="fl fontGrey4"><%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.where("publish_time <= '#{Date.today}'").count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)</span>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</p>
|
||||
|
|
|
@ -108,23 +108,15 @@
|
|||
<div class="cl"></div>
|
||||
<div class="re_con_top">
|
||||
<p class="f_l fontBlue f_b f_14">共有 <span id="attachment_count"><%= @all_attachments.count%></span> 个资源</p>
|
||||
<p class="f_r" style="color: #808080">
|
||||
<% if @order == "asc" %>
|
||||
按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
|
||||
<%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
|
||||
<%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序
|
||||
<% else %>
|
||||
按 <%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
|
||||
<%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
|
||||
<%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序
|
||||
<% end %>
|
||||
<p class="f_r" style="color: #808080" id="course_filter_order">
|
||||
<%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div id="course_list">
|
||||
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
|
||||
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
|
||||
</div>
|
||||
</div>
|
||||
<%# html_title(l(:label_attachment_plural)) -%>
|
|
@ -0,0 +1,15 @@
|
|||
<% if @order == "asc" %>
|
||||
按 <%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:desc", :tag_name => @tag_name.nil? ? " " : @tag_name, :q => @q.nil? ? " " : @q), :class => "f_b c_grey", :remote => true %>
|
||||
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
|
||||
<%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:desc", :tag_name => @tag_name.nil? ? " " : @tag_name, :q => @q.nil? ? " " : @q), :class => "f_b c_grey",:remote => true %>
|
||||
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
|
||||
<%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort => "quotes:desc", :tag_name => @tag_name.nil? ? " " : @tag_name, :q => @q.nil? ? " " : @q), :class => "f_b c_grey", :remote => true %>
|
||||
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序
|
||||
<% else %>
|
||||
按 <%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:asc", :tag_name => @tag_name.nil? ? ' ' : @tag_name, :q => @q.nil? ? ' ' : @q), :class => "f_b c_grey" , :remote => true %>
|
||||
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
|
||||
<%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:asc", :tag_name => @tag_name.nil? ? ' ' : @tag_name, :q => @q.nil? ? ' ' : @q), :class => "f_b c_grey", :remote => true %>
|
||||
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
|
||||
<%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort =>"quotes:asc", :tag_name => @tag_name.nil? ? ' ' : @tag_name, :q => @q.nil? ? ' ' : @q),:class => "f_b c_grey", :remote => true %>
|
||||
<%= render partial:'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序
|
||||
<% end %>
|
|
@ -1,5 +1,6 @@
|
|||
<% if @course %>
|
||||
$("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
|
||||
$("#course_filter_order").html("<%= escape_javascript(render :partial => 'course_file_filter_order', :locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach, tag_name: @tag_name, q: @q})%>");
|
||||
$("#attachment_count").html("<%= @result.count%>")
|
||||
<% else %>
|
||||
$("#course_list").html("<%= escape_javascript(render :partial => 'project_list',:locals => {project:@project, all_attachments:@result_search_project, sort:@sort, order:@order, project_attachments:@searched_attach}) %>");
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
$(function(){
|
||||
$("#RSide").removeAttr("id");
|
||||
$("#Container").css("width","1000px");
|
||||
if(<%= @is_edit %>) {
|
||||
if(true == <%= @is_edit %>) {
|
||||
issueEditShow();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -41,14 +41,6 @@
|
|||
<% content = activity.parent.content%>
|
||||
<% end %>
|
||||
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
|
||||
<% if activity.status == 1 %>
|
||||
<span style="font-family:Calibri;font-size:10.5000pt;"><%= activity.created_on.year %></span>
|
||||
<span style="font-size:10.5000pt;">年</span>
|
||||
<span style="font-family:Calibri;font-size:10.5000pt;"><%= activity.created_on.month %></span>
|
||||
<span style="font-size:10.5000pt;">月</span>
|
||||
<span style="font-family:Calibri;font-size:10.5000pt;"><%= activity.created_on.day %></span>
|
||||
<span style="font-size:10.5000pt;">日</span>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
<div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
|
||||
<div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<a href="<%= import_resources_user_path(User.current, :type => '1', :subfield_file_id => params[:subfield_file_id]) %>" id="my_resources_choose" class="subject-choose fl" data-remote="true">我的资源</a>
|
||||
<% end %>
|
||||
<div id="user_import_resource_search">
|
||||
<%=render :partial=>'users/user_import_resource_search', :locals => {:type => @type, :search => ''} %>
|
||||
<%=render :partial=>'users/user_import_resource_search', :locals => {:type => @type, :search => '', :mul_id => @resource_id, :mul_type => @resource_type} %>
|
||||
</div>
|
||||
<!--<%#= form_tag( url_for(:controller => 'users', :action => 'import_resources_search', :id => User.current.id), :remote => true , :method => 'get', :id => 'resource_search_form') do %>-->
|
||||
<!--<input type="text" name="search" placeholder="输入资源关键词进行搜索" class="subjectSearch fr" />-->
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%= form_tag( url_for({:controller => 'users', :action => 'import_into_container',
|
||||
:mul_id => project_id.nil? ? (course_id.nil? ? subfield_file_id : course_id) : project_id,
|
||||
:mul_type => project_id.nil? ? (course_id.nil? ? "SubfieldFile" : "Course") : "Project"}),
|
||||
:mul_id => @resource_id,
|
||||
:mul_type => @resource_type}),
|
||||
:method => 'post', :id => 'resource_import_container_form') do %>
|
||||
<% @attachments.each do |attach| %>
|
||||
<ul class="subjectRow">
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
}
|
||||
lastSearchCondition = $(e.target).val().trim();
|
||||
$.ajax({
|
||||
url: '<%= url_for(:controller => 'users', :action => 'import_resources_search', :id => User.current.id) %>'+'?name='+ e.target.value+'&type=<%=type %>',
|
||||
url: '<%= url_for({:controller => 'users', :action => 'import_resources_search', :id => User.current.id}) %>'+'?name='+ e.target.value+'&type=<%=type %>'+'&mul_id=<%=@resource_id %>'+'&mul_type=<%=@resource_type %>',
|
||||
type:'get'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<% if params[:project_id] %>
|
||||
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :project_id => params[:project_id]} ) %>');
|
||||
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :project_id => params[:project_id], :mul_id => @resource_id, :mul_type => @resource_type}) %>');
|
||||
<% elsif params[:course_id] %>
|
||||
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :course_id => params[:course_id]} ) %>');
|
||||
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :course_id => params[:course_id], :mul_id => @resource_id, :mul_type => @resource_type}) %>');
|
||||
<% elsif params[:subfield_file_id] %>
|
||||
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :subfield_file_id => params[:subfield_file_id]} ) %>');
|
||||
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :subfield_file_id => params[:subfield_file_id], :mul_id => @resource_id, :mul_type => @resource_type}) %>');
|
||||
<% end %>
|
||||
showModal('ajax-modal', '615px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
$("#import_resource_info_list").html('<%= escape_javascript( render :partial => 'user_import_resource_list',
|
||||
:locals => {:user => @user, :type => @type, :project_id => params[:project_id], :subfield_file_id => params[:subfield_file_id], :course_id => params[:course_id]} ) %>');
|
||||
:locals => {:user => @user, :type => @type,
|
||||
:mul_id => @resource_id,
|
||||
:mul_type => @resource_type}) %>');
|
||||
$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
||||
|
|
|
@ -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
|
10
db/schema.rb
10
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"
|
||||
|
|
|
@ -247,11 +247,11 @@ function regexTopicDescription()
|
|||
|
||||
function submit_topic()
|
||||
{
|
||||
if(regexTopicSubject() && regexTopicDescription())
|
||||
{
|
||||
// if(regexTopicSubject() && regexTopicDescription())
|
||||
// {
|
||||
message_content_editor.sync();
|
||||
$("#message-form").submit();
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
function reset_topic(){
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
*/
|
||||
function submit_topic()
|
||||
{
|
||||
if(regexTopicSubject() && regexTopicDescription())
|
||||
{
|
||||
// if(regexTopicSubject() && regexTopicDescription())
|
||||
// {
|
||||
message_content_editor.sync();
|
||||
$("#message-form").submit();
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
function regexTopicSubject() {
|
||||
|
|
|
@ -618,11 +618,11 @@ function regexTopicDescription()
|
|||
}
|
||||
function submit_topic_project()
|
||||
{
|
||||
if(regexTopicSubject() && regexTopicDescription())
|
||||
{
|
||||
// if(regexTopicSubject() && regexTopicDescription())
|
||||
// {
|
||||
message_content_editor.sync();
|
||||
$("#message-form-project").submit();
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
function reset_topic(){
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
FactoryGirl.define do
|
||||
factory :user_action, :class => 'UserActions' do
|
||||
user_id 1
|
||||
action_type "MyString"
|
||||
action_id 1
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UserActions, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue