Merge branch 'hjq_new_course' of https://git.trustie.net/jacknudt/trustieforge into hjq_new_course
This commit is contained in:
commit
49026f0438
|
@ -852,7 +852,7 @@ class CoursesController < ApplicationController
|
|||
# return
|
||||
# end
|
||||
# 统计访问量
|
||||
@course.update_attribute(:visits, @course.visits.to_i + 1)
|
||||
@course.update_column(:visits, @course.visits.to_i + 1)
|
||||
#更新创建课程消息状态
|
||||
create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0)
|
||||
create_course_messages.update_all(:viewed => true)
|
||||
|
|
|
@ -458,10 +458,16 @@ class FilesController < ApplicationController
|
|||
if params[:in_project_toolbar]
|
||||
@in_project_toolbar = params[:in_project_toolbar]
|
||||
end
|
||||
# 发送邮件
|
||||
attachments = Attachment.attach_filesex(@project, params[:attachments], params[:attachment_type])
|
||||
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
||||
# 发送邮件
|
||||
Mailer.run.attachments_added(attachments[:files])
|
||||
# 生成动态
|
||||
attachments[:files].each do |file|
|
||||
ForgeActivity.create(:user_id => User.current.id, :project_id => @project.id, :forge_act_id => file.id, :forge_act_type => "Attachment")
|
||||
end
|
||||
# 更新资源总数, 根据上传的附件数累加
|
||||
@project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count) unless @project.project_score.nil?
|
||||
end
|
||||
# end
|
||||
if params[:project_attachment_type] && params[:project_attachment_type].is_a?(Array)
|
||||
|
@ -485,11 +491,6 @@ class FilesController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
# 更新资源总数, 根据上传的附件数累加
|
||||
unless @project.project_score.nil?
|
||||
@project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count)
|
||||
end
|
||||
# end
|
||||
# TODO: 临时用 nyan
|
||||
sort_init 'created_on', 'desc'
|
||||
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||
|
|
|
@ -295,11 +295,13 @@ class ProjectsController < ApplicationController
|
|||
def show
|
||||
# 更新消息为已读
|
||||
update_message_status(User.current, @project)
|
||||
# over
|
||||
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
|
||||
return
|
||||
end
|
||||
# 统计访问量
|
||||
@project.update_attribute(:visits, @project.visits.to_i + 1)
|
||||
@project.update_column(:visits, @project.visits + 1)
|
||||
# over
|
||||
@author = params[:user_id].blank? ? nil : User.active.find(params[:user_id])
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
# 根据私密性,取出符合条件的所有数据
|
||||
|
@ -321,8 +323,6 @@ class ProjectsController < ApplicationController
|
|||
= ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc")
|
||||
.page(params['page'|| 1]).per(10);
|
||||
end
|
||||
boards = @project.boards.includes(:last_message => :author).all
|
||||
@topic_count = @project.boards.count
|
||||
# 根据对应的请求,返回对应的数据
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
@ -560,18 +560,9 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def update_message_status(user, project)
|
||||
project_invite_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =?", user, project, "ProjectInvite")
|
||||
project_invite_messages.each do |project_invite_message|
|
||||
project_invite_message.update_attribute(:viewed, true)
|
||||
end
|
||||
#更新被加入项目消息的viewed字段
|
||||
join_project_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?", user, project, "JoinProject")
|
||||
join_project_messages.each do |join_project|
|
||||
join_project.update_attribute(:viewed, true)
|
||||
end
|
||||
#更新被移出项目消息的viewed字段
|
||||
remove_project_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?", user, project, "RemoveFromProject")
|
||||
remove_project_messages.update_all(:viewed => true)
|
||||
# 更新加入项目消息
|
||||
project__messages = ForgeMessage.where("forge_message_type in ('ProjectInvite', 'JoinProject', 'RemoveFromProject') and user_id =? and project_id =? ", user, project)
|
||||
project__messages.update_all(:viewed => true) unless project__messages.blank?
|
||||
end
|
||||
|
||||
def message_invite(message_id, key)
|
||||
|
|
|
@ -90,7 +90,7 @@ class Attachment < ActiveRecord::Base
|
|||
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
|
||||
|
||||
before_save :files_to_final_location
|
||||
after_save :act_as_course_activity,:act_as_forge_activity
|
||||
after_save :act_as_course_activity
|
||||
after_create :office_conver, :be_user_score,:create_attachment_ealasticsearch_index
|
||||
after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index
|
||||
after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count, :down_course_score
|
||||
|
|
Loading…
Reference in New Issue