Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
This commit is contained in:
commit
7f302305ff
|
@ -850,6 +850,8 @@ class CoursesController < ApplicationController
|
|||
# render_403
|
||||
# return
|
||||
# end
|
||||
# 统计访问量
|
||||
@course.update_attribute(: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)
|
||||
|
|
|
@ -107,32 +107,18 @@ class NewsController < ApplicationController
|
|||
|
||||
def show
|
||||
# 更新news对应的forge_messages的消息viewed字段
|
||||
ids = @news.comments.map { |comment| comment.id }.join(",") unless @news.comments.nil?
|
||||
if @project
|
||||
query_message_news = @news.forge_messages
|
||||
# 更新新闻
|
||||
query_message_news = ForgeMessage.where("forge_message_id =? and user_id =? and viewed =?", @news.id, User.current.id, 0).first
|
||||
# 更新新闻的时候一并更新回复
|
||||
ForgeMessage.where("forge_message_id in (#{ids}) and forge_message_type = 'Comment' and user_id = #{User.current.id}").update_all(:viewed => true) unless ids.blank?
|
||||
else
|
||||
query_message_news = @news.course_messages
|
||||
query_message_news = CourseMessage.where("course_message_id =? and user_id =? and viewed =?", @news.id, User.current.id, 0).first
|
||||
CourseMessage.where("course_message_id in (#{ids}) and course_message_type = 'Comment' and user_id = #{User.current.id}").update_all(:viewed => true) unless ids.blank?
|
||||
end
|
||||
query_message_news.each do |query|
|
||||
if User.current.id == query.user_id
|
||||
query.update_attributes(:viewed => true)
|
||||
end
|
||||
end
|
||||
# 更新项目新闻的评阅的消息viewed字段
|
||||
current_message_comments = @news.comments
|
||||
current_message_comments.each do |current_message_comment|
|
||||
if @project
|
||||
query_message_comment = current_message_comment.forge_messages
|
||||
else
|
||||
query_message_comment = current_message_comment.course_messages
|
||||
end
|
||||
query_message_comment.each do |query|
|
||||
if User.current.id == query.user_id
|
||||
query.update_attributes(:viewed => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
# end
|
||||
|
||||
query_message_news.update_attribute(:viewed, true) unless query_message_news.nil?
|
||||
# over
|
||||
cs = CoursesService.new
|
||||
result = cs.show_course_news params,User.current
|
||||
@news = result[:news]
|
||||
|
|
|
@ -69,6 +69,8 @@ class OrganizationsController < ApplicationController
|
|||
def show
|
||||
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
|
||||
@organization = Organization.find(params[:id])
|
||||
# 统计访问量
|
||||
@organization.update_attribute(:visits, @organization.visits.to_i + 1)
|
||||
if params[:org_subfield_id]
|
||||
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
|
||||
|
|
|
@ -298,6 +298,8 @@ class ProjectsController < ApplicationController
|
|||
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
|
||||
return
|
||||
end
|
||||
# 统计访问量
|
||||
@project.update_attribute(:visits, @project.visits.to_i + 1)
|
||||
=begin
|
||||
cond = @project.project_condition(Setting.display_subprojects_issues?)
|
||||
has = {
|
||||
|
|
|
@ -1182,6 +1182,10 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
# 统计访问量
|
||||
unless User.current == @user
|
||||
@user.update_attribute(:visits, @user.visits.to_i + 1)
|
||||
end
|
||||
#更新用户申请成为课程老师或教辅消息的状态
|
||||
if params[:course_id] != nil
|
||||
join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?",
|
||||
|
|
|
@ -250,7 +250,7 @@
|
|||
</div><!--项目标签 end-->
|
||||
<!--课程推荐-->
|
||||
<%= render :partial => 'courses/recommendation', :locals => {:course => @course} %>
|
||||
<div class="fontGrey5 mt10 ml10 mb10">访问计数 100</div>
|
||||
<div class="fontGrey5 mt10 ml10 mb10">访问计数 <%= @course.visits.to_i %></div>
|
||||
</div><!--LSide end-->
|
||||
|
||||
<div id="RSide" class="fl">
|
||||
|
|
|
@ -132,7 +132,7 @@
|
|||
<div class="homepageLeftMenuContainer" id="sub_field_left_lists">
|
||||
<%= render :partial => "organizations/org_left_subfield_list", :locals => {:organization => @organization} %>
|
||||
</div>
|
||||
<div class="fontGrey5 mt10 ml20">访问计数 100</div>
|
||||
<div class="fontGrey5 mt10 ml20">访问计数 <%= @organization.visits.to_i %></div>
|
||||
</div>
|
||||
<div class="homepageRight" style="margin-top:<%= (params[:show_homepage].nil? && User.current.logged?) ? '10px':'0px' %>;">
|
||||
<%= render_flash_messages %>
|
||||
|
|
|
@ -159,7 +159,7 @@
|
|||
<div class="cl"></div>
|
||||
</div><!--项目标签 end-->
|
||||
|
||||
<div class="fontGrey5 mt10 ml10 mb10">访问计数 100</div>
|
||||
<div class="fontGrey5 mt10 ml10 mb10">访问计数 <%= @project.visits.to_i %></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@
|
|||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fontGrey5 mt10 ml20">访问计数 100</div>
|
||||
<div class="fontGrey5 mt10 ml20">访问计数 <%= @user.visits.to_i %></div>
|
||||
</div>
|
||||
<div class="homepageRight">
|
||||
<%= yield %>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddVisitsToUser < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :visits, :integer, :default => 0
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddVisitsToProject < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :projects, :visits, :integer, :default => 0
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddVisitsToCourse < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :courses, :visits, :integer, :default => 0
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddVisitsToOrganization < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :organizations, :visits, :integer, :default => 0
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160310033019) do
|
||||
ActiveRecord::Schema.define(:version => 20160311072819) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -508,6 +508,7 @@ ActiveRecord::Schema.define(:version => 20160310033019) do
|
|||
t.integer "is_excellent", :default => 0
|
||||
t.integer "excellent_option", :default => 0
|
||||
t.integer "is_copy", :default => 0
|
||||
t.integer "visits", :default => 0
|
||||
end
|
||||
|
||||
create_table "custom_fields", :force => true do |t|
|
||||
|
@ -1284,6 +1285,7 @@ ActiveRecord::Schema.define(:version => 20160310033019) do
|
|||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.boolean "allow_guest_download", :default => true
|
||||
t.integer "visits", :default => 0
|
||||
end
|
||||
|
||||
create_table "phone_app_versions", :force => true do |t|
|
||||
|
@ -1443,6 +1445,7 @@ ActiveRecord::Schema.define(:version => 20160310033019) do
|
|||
t.integer "acts_count", :default => 0
|
||||
t.integer "journals_count", :default => 0
|
||||
t.integer "boards_reply_count", :default => 0
|
||||
t.integer "visits", :default => 0
|
||||
end
|
||||
|
||||
add_index "projects", ["lft"], :name => "index_projects_on_lft"
|
||||
|
@ -1902,6 +1905,7 @@ ActiveRecord::Schema.define(:version => 20160310033019) do
|
|||
t.string "mail_notification", :default => "", :null => false
|
||||
t.string "salt", :limit => 64
|
||||
t.integer "gid"
|
||||
t.integer "visits", :default => 0
|
||||
end
|
||||
|
||||
add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"
|
||||
|
|
Loading…
Reference in New Issue