Merge branch 'dev_zanle' into szzh
Conflicts: app/views/projects/show.html.erb db/schema.rb
This commit is contained in:
commit
1f2b5eedb8
|
@ -186,6 +186,10 @@ class AttachmentsController < ApplicationController
|
|||
|
||||
@attachment = Attachment.new(:file => request.raw_post)
|
||||
@attachment.author = User.current
|
||||
if !params[:project].nil?
|
||||
@attachment.container_type = 'Project'
|
||||
@attachment.container_id = params[:project].split("?")[0]
|
||||
end
|
||||
@attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16)
|
||||
saved = @attachment.save
|
||||
|
||||
|
|
|
@ -153,6 +153,8 @@ class IssuesController < ApplicationController
|
|||
def create
|
||||
call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
|
||||
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
|
||||
# 给该issue在它所在的项目中所有的issues中所在的位置给一个序号
|
||||
@issue.project_issues_index = @issue.project.issues.last.project_issues_index + 1
|
||||
if @issue.save
|
||||
call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
|
||||
respond_to do |format|
|
||||
|
|
|
@ -249,6 +249,7 @@ class ProjectsController < ApplicationController
|
|||
# Author lizanle
|
||||
# Description 项目动态展示方法,删除了不必要的代码
|
||||
def show
|
||||
=begin
|
||||
# 试图跳转到请求的按钮
|
||||
if params[:login]
|
||||
login = params[:login]
|
||||
|
@ -283,30 +284,37 @@ class ProjectsController < ApplicationController
|
|||
# 时间跨度不能太大,不然很慢,所以删掉了-1.years
|
||||
@date_from = @date_to - @days
|
||||
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
|
||||
=end
|
||||
|
||||
@author = params[:user_id].blank? ? nil : User.active.find(params[:user_id])
|
||||
# 决定显示所用用户或单个用户活动
|
||||
=begin
|
||||
@activity = Redmine::Activity::Fetcher.new(User.current,
|
||||
:project => @project,
|
||||
:with_subprojects => @with_subprojects,
|
||||
:author => @author)
|
||||
@activity.scope_select {|t| !has["show_#{t}"].nil?}
|
||||
=end
|
||||
|
||||
# 根据私密性,取出符合条件的所有数据
|
||||
if User.current.member_of?(@project) || User.current.admin?
|
||||
events = @activity.events(@date_from, @date_to)
|
||||
@events_pages = ForgeActivity.where("project_id = ?",@project).order("created_at desc").page(params['page'|| 1]).per(20);
|
||||
#events = @activity.events(@date_from, @date_to)
|
||||
else
|
||||
events = @activity.events(@date_from, @date_to, :is_public => 1)
|
||||
@events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public
|
||||
= ?",@project,1).order("created_at desc")
|
||||
.page(params['page'|| 1]).per(10);
|
||||
# @events = @activity.events(@date_from, @date_to, :is_public => 1)
|
||||
end
|
||||
|
||||
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@events_count = events.count
|
||||
@events_pages = Paginator.new @events_count, @limit, params['page']
|
||||
@offset ||= @events_pages.offset
|
||||
=begin
|
||||
@events_pages = Paginator.new events.count, 10, params['page']
|
||||
# 总的数据中取出某一页
|
||||
events = events.slice(@offset,@limit)
|
||||
events = events.slice(@events_pages.offset,10)
|
||||
# 按天分组
|
||||
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
||||
=end
|
||||
|
||||
# 根据对应的请求,返回对应的数据
|
||||
respond_to do |format|
|
||||
|
|
|
@ -408,6 +408,9 @@ class UsersController < ApplicationController
|
|||
|
||||
def show
|
||||
pre_count = 10 #limit
|
||||
# Time 2015-02-04 11:46:34
|
||||
# Author lizanle
|
||||
# Description type 1 :所有动态包括我关注的人 type 2:我的动态 type 3:关于我的回复
|
||||
case params[:type]
|
||||
when "1"
|
||||
if @user == User.current
|
||||
|
@ -429,6 +432,9 @@ class UsersController < ApplicationController
|
|||
@message = messages[@info_pages.offset, @info_pages.per_page]
|
||||
@state = 2
|
||||
else
|
||||
# Time 2015-02-04 10:50:49
|
||||
# Author lizanle
|
||||
# Description 所有动态
|
||||
where_condition = nil;
|
||||
# where_condition = "act_type <> 'JournalsForMessage'"
|
||||
if @user == User.current
|
||||
|
@ -438,16 +444,14 @@ class UsersController < ApplicationController
|
|||
else
|
||||
activity = Activity.where(where_condition).where('user_id = ?', @user.id).order('id desc')
|
||||
end
|
||||
|
||||
@activity_count = activity.count
|
||||
@activity_pages = Paginator.new @activity_count, pre_count, params['page']
|
||||
activity_page = activity.slice(@activity_pages.offset,@activity_pages.per_page * 2)
|
||||
activity_page = activity_page.reject { |e|
|
||||
@activity = activity.slice(@activity_pages.offset,@activity_pages.per_page )
|
||||
@activity = @activity.reject { |e|
|
||||
((e.act_type=="Issue") && ( !e.act.visible?(User.current))) ||
|
||||
((e.act_type == "Journal") && (!e.act.project.visible?(User.current))) ||
|
||||
((e.act_type == "Bid") && ((!User.current.member_of_course?(e.act.courses.first) || !User.current.admin?)))
|
||||
}
|
||||
@activity = activity.slice(0,@activity_pages.per_page)
|
||||
@state = 0
|
||||
end
|
||||
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
module ExpireHelper
|
||||
#index.html 中 “projects”塊 緩存過期
|
||||
def expire_project_cache
|
||||
ActionController::Base.new.expire_fragment('projects')
|
||||
end
|
||||
|
||||
#index.html 中 “activities”塊 緩存過期
|
||||
def expire_activitie_cache
|
||||
ActionController::Base.new.expire_fragment('activities')
|
||||
end
|
||||
|
||||
#welcome/index.html 中 “forums”塊 緩存過期
|
||||
def expire_forum_cache
|
||||
ActionController::Base.new.expire_fragment('forums')
|
||||
end
|
||||
end
|
|
@ -25,7 +25,9 @@ class Attachment < ActiveRecord::Base
|
|||
belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'"
|
||||
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
||||
belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
|
||||
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# end
|
||||
include UserScoreHelper
|
||||
|
||||
validates :filename, presence: true, length: {maximum: 254}
|
||||
|
@ -70,7 +72,7 @@ class Attachment < ActiveRecord::Base
|
|||
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
|
||||
|
||||
before_save :files_to_final_location
|
||||
after_create :be_user_score # user_score
|
||||
after_create :be_user_score ,:act_as_forge_activity# user_score
|
||||
after_update :be_user_score
|
||||
after_destroy :delete_from_disk,:down_user_score
|
||||
|
||||
|
@ -529,4 +531,14 @@ class Attachment < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# Time 2015-03-02 17:42:48
|
||||
# Author lizanle
|
||||
# Description 上传该项目的文档资料也要保存一份在公共表中
|
||||
def act_as_forge_activity
|
||||
if self.container_type == 'Project'
|
||||
self.forge_acts << ForgeActivity.new(:user_id => self.author_id,
|
||||
:project_id => self.container_id)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -17,7 +17,6 @@ class Bid < ActiveRecord::Base
|
|||
HomeworkProject = 2
|
||||
attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type, :password
|
||||
include Redmine::SafeAttributes
|
||||
include ExpireHelper
|
||||
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => :author_id
|
||||
belongs_to :course
|
||||
|
@ -33,12 +32,6 @@ class Bid < ActiveRecord::Base
|
|||
has_many :join_in_contests, :dependent => :destroy
|
||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||
# has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}"
|
||||
|
||||
|
||||
after_create :expire_activitie_cache
|
||||
after_update :expire_activitie_cache
|
||||
before_destroy :expire_activitie_cache
|
||||
|
||||
acts_as_attachable
|
||||
|
||||
NAME_LENGTH_LIMIT = 60
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class Changeset < ActiveRecord::Base
|
||||
include ExpireHelper
|
||||
belongs_to :repository
|
||||
belongs_to :user
|
||||
include UserScoreHelper
|
||||
|
@ -65,9 +64,8 @@ class Changeset < ActiveRecord::Base
|
|||
includes(:repository => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args))
|
||||
}
|
||||
|
||||
after_create :scan_for_issues,:refresh_changests,:expire_activitie_cache#:be_user_score # user_score
|
||||
after_update :be_user_score,:expire_activitie_cache
|
||||
before_destroy :expire_activitie_cache
|
||||
after_create :scan_for_issues,:refresh_changests#:be_user_score # user_score
|
||||
after_update :be_user_score
|
||||
after_destroy :down_user_score
|
||||
before_create :before_create_cs
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
class ContestNotification < ActiveRecord::Base
|
||||
include ExpireHelper
|
||||
attr_accessible :content, :title
|
||||
validates :title, length: {maximum: 30}
|
||||
after_create :expire_forum_cache
|
||||
after_update :expire_forum_cache
|
||||
before_destroy :expire_forum_cache
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -17,18 +17,16 @@
|
|||
|
||||
class Document < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include ExpireHelper
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
|
||||
include UserScoreHelper
|
||||
after_save :be_user_score # user_score
|
||||
after_destroy :down_user_score
|
||||
after_create :expire_activitie_cache
|
||||
after_update :expire_activitie_cache
|
||||
before_destroy :expire_activitie_cache
|
||||
acts_as_attachable :delete_permission => :delete_documents
|
||||
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# end
|
||||
acts_as_searchable :columns => ['title', "#{table_name}.description"], :include => :project
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"},
|
||||
#:author => Proc.new {|o| o.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author) },
|
||||
|
@ -39,7 +37,7 @@ class Document < ActiveRecord::Base
|
|||
|
||||
validates_presence_of :project, :title, :category
|
||||
validates_length_of :title, :maximum => 60
|
||||
|
||||
after_create :act_as_forge_activity
|
||||
scope :visible, lambda {|*args|
|
||||
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args))
|
||||
}
|
||||
|
@ -81,5 +79,12 @@ class Document < ActiveRecord::Base
|
|||
update_document(self.user,2,self.project)
|
||||
end
|
||||
|
||||
# Time 2015-03-02 10:51:16
|
||||
# Author lizanle
|
||||
# Description 新创建的document要在公共表ForgeActivity中记录
|
||||
def act_as_forge_activity
|
||||
self.forge_acts << ForgeActivity.new(:user_id => self.user_id,
|
||||
:project_id => self.project_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# Time 2015-02-06 10:42:34
|
||||
# Author lizanle
|
||||
# Description 这是保存Project相关的动态的公共表
|
||||
class ForgeActivity < ActiveRecord::Base
|
||||
# 公共表中活动类型,命名规则:TYPE_OF_{类名}_ACT
|
||||
TYPE_OF_ISSUE_ACT = "Issue"
|
||||
TYPE_OF_MESSAGE_ACT = "Message"
|
||||
TYPE_OF_ATTACHMENT_ACT = "Attachment"
|
||||
TYPE_OF_DOCUMENT_ACT = "Document"
|
||||
TYPE_OF_JOURNAL_ACT = "Journal"
|
||||
TYPE_OF_WIKI_ACT = "Wiki"
|
||||
TYPE_OF_NEWS_ACT = "News"
|
||||
attr_accessible :forge_act_id, :forge_act_type,:project_id,:user_id,:org_id
|
||||
# 虚拟关联
|
||||
belongs_to :forge_act ,:polymorphic => true
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
validates :user_id,presence: true
|
||||
validates :project_id,presence: true
|
||||
validates :forge_act_id,presence: true
|
||||
validates :forge_act_type, presence: true
|
||||
end
|
|
@ -1,13 +1,8 @@
|
|||
class Forum < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include ExpireHelper
|
||||
has_many :topics, :class_name => 'Memo', :conditions => "#{Memo.table_name}.parent_id IS NULL", :order => "#{Memo.table_name}.created_at DESC", :dependent => :destroy
|
||||
has_many :memos, :dependent => :destroy, conditions: "parent_id IS NULL"
|
||||
belongs_to :creator, :class_name => "User", :foreign_key => 'creator_id'
|
||||
|
||||
after_create :expire_forum_cache
|
||||
after_update :expire_forum_cache
|
||||
before_destroy :expire_forum_cache
|
||||
safe_attributes 'name',
|
||||
'description',
|
||||
'topic_count',
|
||||
|
|
|
@ -19,7 +19,6 @@ class Issue < ActiveRecord::Base
|
|||
include Redmine::SafeAttributes
|
||||
include Redmine::Utils::DateCalculation
|
||||
include UserScoreHelper
|
||||
include ExpireHelper
|
||||
belongs_to :project
|
||||
belongs_to :tracker
|
||||
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
|
||||
|
@ -46,6 +45,8 @@ class Issue < ActiveRecord::Base
|
|||
|
||||
# added by fq
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# end
|
||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||
|
||||
|
@ -64,7 +65,9 @@ class Issue < ActiveRecord::Base
|
|||
},
|
||||
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o}},
|
||||
:type => Proc.new {|o| 'issue' + (o.closed? ? ' closed' : '') }
|
||||
|
||||
# Time 2015-01-31 13:52:53
|
||||
# Author lizanle
|
||||
# Description 将hash传进去
|
||||
acts_as_activity_provider :find_options => {:include => [:project, :author, :tracker]},
|
||||
:author_key => :author_id
|
||||
|
||||
|
@ -77,12 +80,9 @@ class Issue < ActiveRecord::Base
|
|||
attr_reader :current_journal
|
||||
|
||||
# fq
|
||||
after_create :act_as_activity,:be_user_score_new_issue
|
||||
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity
|
||||
after_update :be_user_score
|
||||
after_destroy :down_user_score
|
||||
after_create :expire_activitie_cache
|
||||
after_update :expire_activitie_cache
|
||||
before_destroy :expire_activitie_cache
|
||||
# after_create :be_user_score
|
||||
# end
|
||||
|
||||
|
@ -130,6 +130,14 @@ class Issue < ActiveRecord::Base
|
|||
end
|
||||
# end
|
||||
|
||||
# Time 2015-02-26 10:51:16
|
||||
# Author lizanle
|
||||
# Description 新创建的issue要在公共表ForgeActivity中记录
|
||||
def act_as_forge_activity
|
||||
self.forge_acts << ForgeActivity.new(:user_id => self.author_id,
|
||||
:project_id => self.project_id)
|
||||
end
|
||||
# end
|
||||
|
||||
|
||||
# Returns a SQL conditions string used to find all issues visible by the specified user
|
||||
|
@ -1168,13 +1176,13 @@ class Issue < ActiveRecord::Base
|
|||
|
||||
# back string obj which is belong to project.
|
||||
def source_from
|
||||
"" << self.project.name.to_s <<
|
||||
"#" << project_index
|
||||
"" << self.project.name.to_s
|
||||
end
|
||||
|
||||
def project_index
|
||||
if self.project.issues.include?(self)
|
||||
(self.project.issues.index(self).to_i + 1).to_s
|
||||
|
||||
else
|
||||
issue_index = 1
|
||||
self.project.issues.each do |issue|
|
||||
|
@ -1185,8 +1193,10 @@ class Issue < ActiveRecord::Base
|
|||
issue_index = issue_index+1
|
||||
end
|
||||
end
|
||||
|
||||
issue_index.to_s
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -27,6 +27,8 @@ class Journal < ActiveRecord::Base
|
|||
# added by fq
|
||||
has_one :journal_reply
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# end
|
||||
attr_accessor :indice
|
||||
|
||||
|
@ -46,7 +48,7 @@ class Journal < ActiveRecord::Base
|
|||
before_create :split_private_notes
|
||||
|
||||
# fq
|
||||
after_save :act_as_activity,:be_user_score
|
||||
after_save :act_as_activity,:be_user_score,:act_as_forge_activity
|
||||
# end
|
||||
#after_destroy :down_user_score
|
||||
#before_save :be_user_score
|
||||
|
@ -156,6 +158,15 @@ class Journal < ActiveRecord::Base
|
|||
end
|
||||
# end
|
||||
|
||||
# Time 2015-02-27 13:30:19
|
||||
# Author lizanle
|
||||
# Description 公共表中需要保存一份该记录
|
||||
def act_as_forge_activity
|
||||
self.forge_acts << ForgeActivity.new(:user_id => self.user_id,
|
||||
:project_id => self.issue.project.id)
|
||||
|
||||
end
|
||||
|
||||
# 更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#新建了缺陷留言且留言不为空,不为空白
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
class JournalsForMessage < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include UserScoreHelper
|
||||
include ExpireHelper
|
||||
safe_attributes "jour_type", # 留言所属类型
|
||||
"jour_id", # 留言所属类型的id
|
||||
"notes", # 留言内容
|
||||
|
@ -55,9 +54,7 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
|
||||
validates :notes, presence: true
|
||||
after_create :act_as_activity ,:expire_activitie_cache#huang
|
||||
after_update :expire_activitie_cache
|
||||
before_destroy :expire_activitie_cache
|
||||
after_create :act_as_activity #huang
|
||||
after_create :reset_counters!
|
||||
after_destroy :reset_counters!
|
||||
after_save :be_user_score
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
class Memo < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include UserScoreHelper
|
||||
include ExpireHelper
|
||||
belongs_to :forum
|
||||
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
|
||||
|
||||
after_create :expire_cache
|
||||
after_update :expire_cache
|
||||
before_destroy :expire_cache
|
||||
validates_presence_of :author_id, :forum_id, :subject,:content
|
||||
# 若是主题帖,则内容可以是空
|
||||
#validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? }
|
||||
|
@ -174,8 +169,5 @@ class Memo < ActiveRecord::Base
|
|||
update_memo_number(User.current,1)
|
||||
update_replay_for_memo(User.current,1)
|
||||
end
|
||||
def expire_cache
|
||||
expire_forum_cache
|
||||
expire_activitie_cache
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
class Message < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include UserScoreHelper
|
||||
include ExpireHelper
|
||||
belongs_to :board
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||
|
@ -29,6 +28,8 @@ class Message < ActiveRecord::Base
|
|||
|
||||
# added by fq
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# end
|
||||
|
||||
acts_as_searchable :columns => ['subject', 'content'],
|
||||
|
@ -59,13 +60,12 @@ class Message < ActiveRecord::Base
|
|||
validates_length_of :subject, :maximum => 255
|
||||
validate :cannot_reply_to_locked_topic, :on => :create
|
||||
|
||||
after_create :add_author_as_watcher, :reset_counters!,:expire_activitie_cache
|
||||
after_update :update_messages_board,:expire_activitie_cache
|
||||
before_destroy :expire_activitie_cache
|
||||
after_create :add_author_as_watcher, :reset_counters!
|
||||
after_update :update_messages_board
|
||||
after_destroy :reset_counters!,:down_user_score
|
||||
|
||||
# fq
|
||||
after_create :act_as_activity,:be_user_score
|
||||
after_create :act_as_activity,:be_user_score,:act_as_forge_activity
|
||||
#before_save :be_user_score
|
||||
# end
|
||||
|
||||
|
@ -160,6 +160,14 @@ class Message < ActiveRecord::Base
|
|||
end
|
||||
# end
|
||||
|
||||
# Time 2015-02-27 14:32:25
|
||||
# Author lizanle
|
||||
# Description
|
||||
def act_as_forge_activity
|
||||
self.forge_acts << ForgeActivity.new(:user_id => self.author_id,
|
||||
:project_id => self.board.project.id)
|
||||
end
|
||||
|
||||
#更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#新建message且无parent的为发帖
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
class News < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include ExpireHelper
|
||||
belongs_to :project
|
||||
#added by nwb
|
||||
belongs_to :course
|
||||
|
@ -25,7 +24,9 @@ class News < ActiveRecord::Base
|
|||
has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
|
||||
# fq
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
#end
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# end
|
||||
|
||||
validates_presence_of :title, :description
|
||||
validates_length_of :title, :maximum => 60
|
||||
|
@ -46,11 +47,8 @@ class News < ActiveRecord::Base
|
|||
|
||||
after_create :add_author_as_watcher
|
||||
# fq
|
||||
after_create :act_as_activity
|
||||
after_create :act_as_activity,:act_as_forge_activity
|
||||
# end
|
||||
after_create :expire_activitie_cache
|
||||
after_update :expire_activitie_cache
|
||||
before_destroy :expire_activitie_cache
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
|
||||
|
@ -96,5 +94,12 @@ class News < ActiveRecord::Base
|
|||
self.acts << Activity.new(:user_id => self.author_id)
|
||||
end
|
||||
|
||||
# Time 2015-02-27 15:48:17
|
||||
# Author lizanle
|
||||
# Description 公用表中也要记录
|
||||
def act_as_forge_activity
|
||||
self.forge_acts << ForgeActivity.new(:user_id => self.author_id,
|
||||
:project_id => self.project.id)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
class Project < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include ExpireHelper
|
||||
ProjectType_project = 0
|
||||
ProjectType_course = 1
|
||||
|
||||
|
@ -132,9 +131,8 @@ class Project < ActiveRecord::Base
|
|||
#ActiveModel::Dirty 这里有一个changed方法。对任何对象都可以用
|
||||
after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?}
|
||||
# 创建project之后默认创建一个board,之后的board去掉了board的概念
|
||||
after_create :create_board_sync,:expire_project_cache
|
||||
after_update :expire_project_cache
|
||||
before_destroy :delete_all_members,:expire_project_cache
|
||||
after_create :create_board_sync
|
||||
before_destroy :delete_all_members
|
||||
def remove_references_before_destroy
|
||||
return if self.id.nil?
|
||||
Watcher.delete_all ['watchable_id = ?', id]
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class Tracker < ActiveRecord::Base
|
||||
|
||||
# Time 2015-02-6 09:34:44
|
||||
# Author lizanle
|
||||
# Description freeze方法让字符串不可变
|
||||
CORE_FIELDS_UNDISABLABLE = %w(project_id tracker_id subject description priority_id is_private).freeze
|
||||
# Fields that can be disabled
|
||||
# Other (future) fields should be appended, not inserted!
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
// file.click();
|
||||
// }
|
||||
</script>
|
||||
<% project = project %>
|
||||
<span class="add_attachment" style="font-weight:normal;">
|
||||
<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
|
||||
<!--%= link_to image_tag(),"javascript:void(0)", :onclick => "_file.click()"%-->
|
||||
|
@ -41,7 +42,7 @@
|
|||
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
|
||||
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
||||
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
||||
:upload_path => uploads_path(:format => 'js'),
|
||||
:upload_path => uploads_path(:format => 'js',:project =>project),
|
||||
:description_placeholder => l(:label_optional_description)
|
||||
} %>
|
||||
<span id="upload_file_count">
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
</p>
|
||||
|
||||
<p><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
|
||||
<p><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form', locals: {project: project} %></p>
|
||||
</div>
|
||||
<%= submit_tag l(:button_add) %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<%# html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %>
|
||||
|
||||
<% html_title "#{@issue.tracker.name} #{@issue.source_from}: #{@issue.subject}" %>
|
||||
<% html_title "#{@issue.tracker.name} #{@issue.source_from}'#'#{@issue.project_index}: #{@issue.subject}" %>
|
||||
|
||||
<%= render :partial => 'action_menu' %>
|
||||
|
||||
|
@ -87,7 +86,7 @@ end %>
|
|||
<%= render_custom_fields_rows(@issue) %>
|
||||
<%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
|
||||
</table>
|
||||
|
||||
woca
|
||||
<% if @issue.description? || @issue.attachments.any? -%>
|
||||
<hr />
|
||||
<% if @issue.description? %>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
paginator: the paginator that renders the pagination tags inside
|
||||
-%>
|
||||
<%= paginator.render do -%>
|
||||
<div class="pagination">
|
||||
<div id="paginator" class="pagination">
|
||||
<%= first_page_tag unless current_page.first? %>
|
||||
<%= prev_page_tag unless current_page.first? %>
|
||||
<% each_page do |page| -%>
|
||||
|
|
|
@ -40,18 +40,15 @@
|
|||
</div>
|
||||
<div class="debug">
|
||||
<%= debug(params) if Rails.env.development? %>
|
||||
<div class="hidden">
|
||||
<script>
|
||||
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-46523987-1', 'trustie.net');
|
||||
ga('send', 'pageview');
|
||||
|
||||
var _hmt = _hmt || [];
|
||||
(function() {
|
||||
var hm = document.createElement("script");
|
||||
hm.src = "//hm.baidu.com/hm.js?67e9738474be83f55f1233001a6ac34e";
|
||||
var s = document.getElementsByTagName("script")[0];
|
||||
s.parentNode.insertBefore(hm, s);
|
||||
})();
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,121 +1,177 @@
|
|||
<% if @events_by_day.size >0 %>
|
||||
<div class="content-title-top-avtive">
|
||||
<p class="subtitle">
|
||||
<!-- # 暂时隐藏时间的显示% -->
|
||||
<%#= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %>
|
||||
</p>
|
||||
|
||||
<% @events_by_day.keys.sort.reverse.each do |day| %>
|
||||
<% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
|
||||
<%= javascript_include_tag "jquery.infinitescroll.js" %>
|
||||
<script>
|
||||
/* $(document).ready(function (){ //别忘了加这句,除非你没学Jquery
|
||||
$("#container").infinitescroll({
|
||||
navSelector: "#paginator", //页面分页元素--成功后自动隐藏
|
||||
nextSelector: "#paginator a[rel='next']", //下一页的按钮,但是貌似这个选不中
|
||||
itemSelector: ".scroll " ,
|
||||
path: function(current){ var page = parseInt(current)+1;
|
||||
var project_id = <%= @project.id %>;
|
||||
return "/projects/"+project_id+"?page="+page
|
||||
}, //下一页的路径
|
||||
animate: true,
|
||||
maxPage: 500
|
||||
});
|
||||
});*/
|
||||
</script>
|
||||
<div id="container">
|
||||
<div class="scroll">
|
||||
<% unless @events_pages.empty? %>
|
||||
<% @events_pages.each do |e| -%>
|
||||
<% act = e.forge_act %>
|
||||
<% if e.forge_act_type == "Issue" %>
|
||||
<div class="activity-item underline-evreycontent" style="font-size: 14px;line-height:1.5em;width: 100%;word-wrap: break-word;word-break: break-all;">
|
||||
<div class="activity-avatar" style="float: left; margin:3px; height: 100%;">
|
||||
<%= image_tag(url_to_avatar(e.event_author), :class => "avatar") %>
|
||||
<%= image_tag(url_to_avatar(act.author), :class => "avatar") %>
|
||||
</div>
|
||||
|
||||
<div class="activity-content" style="padding:5px 5px 5px 70px;">
|
||||
<strong>
|
||||
<%= h(e.project) if @project.nil? || @project.id != e.project.id %>
|
||||
</strong>
|
||||
<strong> <%= h(e.project) if @project.nil? || @project.id != e.project_id %></strong>
|
||||
<span class="activity-title font_lighter">
|
||||
<% if @canShowRealName %>
|
||||
<%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>
|
||||
(<%= link_to_user(e.event_author, @canShowRealName) if e.respond_to?(:event_author) %>)
|
||||
<% else %>
|
||||
<%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>
|
||||
<% end %>
|
||||
<%= link_to_user(act.author) %>
|
||||
<%= l(:label_new_activity) %>
|
||||
</span>
|
||||
<%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Project)) ? project_files_path(e.container) : e.event_url %>
|
||||
|
||||
<%= link_to format_activity_title("#{act.source_from}##{act.project_issues_index} (#{act.status}): #{act.tracker.name} #{act.subject}"),
|
||||
{:controller => 'issues',
|
||||
:action => 'show',
|
||||
:id => act.id} %>
|
||||
<div class="activity_description info-break" style="font-size: 13px;width: 100%;word-break: break-all;word-wrap: break-word;">
|
||||
<%= textAreailizable e,:event_description %>
|
||||
<%#= h(truncate(strip_tags(e.event_description).gsub(/ /, ' '), length: 30, omission: '...')) %>
|
||||
<%= textAreailizable act,:description %>
|
||||
</div>
|
||||
<div class="activity_status" style="position:relative; padding-top: 3px;">
|
||||
<span class="font_lighter"> <%= l :label_activity_time %>
|
||||
:
|
||||
<%= format_activity_day(day) %>
|
||||
<%= format_time(e.event_datetime, false) %>
|
||||
: <%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %></span>
|
||||
<div class="" style="display:inline-block;position:absolute; right:2%;">
|
||||
<span> <%= link_to l(:label_find_all_comments), issue_path(act.id) %> </span><span class="font_lighter"><%= l(:label_comments_count, :count => act.journals.count) %></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% elsif e.forge_act_type == "Journal" %>
|
||||
<div class="activity-item underline-evreycontent" style="font-size: 14px;line-height:1.5em;width: 100%;word-wrap: break-word;word-break: break-all;">
|
||||
<div class="activity-avatar" style="float: left; margin:3px; height: 100%;">
|
||||
<%= image_tag(url_to_avatar(e.user), :class => "avatar") %>
|
||||
</div>
|
||||
|
||||
<div class="activity-content" style="padding:5px 5px 5px 70px;">
|
||||
<strong> <%= h(e.project) if @project.nil? || @project.id != e.project_id %></strong>
|
||||
<span class="activity-title font_lighter">
|
||||
<%= link_to(h(e.user), user_path(e.user_id)) %>
|
||||
<%= l(:label_new_activity) %>
|
||||
</span>
|
||||
<% if e.event_type == "issue" %>
|
||||
<%= link_to(l(:label_activity_project)+act.issue.project.name, project_path(act.issue.project.id)) %>
|
||||
<%= link_to format_activity_title("#{act.issue.tracker} ##{act.issue.project_issues_index}: #{act.issue.subject}"),
|
||||
{:controller => 'issues', :action => 'show', :id => act.issue.id, :anchor => "change-#{act.id}"} %>
|
||||
<div class="activity_description info-break" style="font-size: 13px;width: 100%;word-break: break-all;word-wrap: break-word;">
|
||||
<%= textAreailizable act,:notes %>
|
||||
</div>
|
||||
<div class="activity_status" style="position:relative; padding-top: 3px;">
|
||||
<span class="font_lighter"> <%= l :label_activity_time %>
|
||||
: <%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% elsif e.forge_act_type == "Message" %>
|
||||
<div class="activity-item underline-evreycontent" style="font-size: 14px;line-height:1.5em;width: 100%;word-wrap: break-word;word-break: break-all;">
|
||||
<div class="activity-avatar" style="float: left; margin:3px; height: 100%;">
|
||||
<%= image_tag(url_to_avatar(e.user), :class => "avatar") %>
|
||||
</div>
|
||||
<div class="activity-content" style="padding:5px 5px 5px 70px;">
|
||||
<strong> <%= h(e.project) if @project.nil? || @project.id != e.project_id %></strong>
|
||||
<span class="activity-title font_lighter">
|
||||
<%= link_to(h(e.user), user_path(e.user_id)) %>
|
||||
<%= l(:label_new_activity) %>
|
||||
</span>
|
||||
<%= link_to format_activity_title("#{act.board.name}: #{act.subject}"),
|
||||
{:controller => 'messages',
|
||||
:action => 'show',
|
||||
:board_id => act.board_id}.merge(act.parent_id.nil? ? {:id => act.id} : {:id => act.parent_id, :r => act.id, :anchor => "message-#{act.id}"}) %>
|
||||
<div class="activity_description info-break" style="font-size: 13px;width: 100%;word-break: break-all;word-wrap: break-word;">
|
||||
<%= textAreailizable act,:content %>
|
||||
</div>
|
||||
<div class="activity_status" style="position:relative; padding-top: 3px;">
|
||||
<span class="font_lighter"> <%= l :label_activity_time %>
|
||||
: <%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% elsif e.forge_act_type == "News" %>
|
||||
<div class="activity-item underline-evreycontent" style="font-size: 14px;line-height:1.5em;width: 100%;word-wrap: break-word;word-break: break-all;">
|
||||
<div class="activity-avatar" style="float: left; margin:3px; height: 100%;">
|
||||
<%= image_tag(url_to_avatar(e.user), :class => "avatar") %>
|
||||
</div>
|
||||
<div class="activity-content" style="padding:5px 5px 5px 70px;">
|
||||
<strong> <%= h(e.project) if @project.nil? || @project.id != e.project_id %></strong>
|
||||
<span class="activity-title font_lighter">
|
||||
<%= link_to(h(e.user), user_path(e.user_id)) %>
|
||||
<%= l(:label_new_activity) %>
|
||||
</span>
|
||||
<%= link_to format_activity_title("#{l(:label_news)}: #{act.title}"), {:controller => 'news', :action => 'show', :id => act.id} %>
|
||||
<div class="activity_description info-break" style="font-size: 13px;width: 100%;word-break: break-all;word-wrap: break-word;">
|
||||
<%= textAreailizable act,:description %>
|
||||
</div>
|
||||
<div class="activity_status" style="position:relative; padding-top: 3px;">
|
||||
<span class="font_lighter"> <%= l :label_activity_time %>
|
||||
: <%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %></span>
|
||||
<div class="" style="display:inline-block;position:absolute; right:2%;">
|
||||
<span>
|
||||
<%= link_to l(:label_find_all_comments), issue_path(e) %>
|
||||
<%= link_to l(:label_find_all_comments), {:controller => 'news', :action => 'show', :id => act.id} %>
|
||||
</span>
|
||||
<span class="font_lighter">
|
||||
<%= l(:label_comments_count, :count => e.journals.count) %>
|
||||
<%= l(:label_comments_count, :count => act.comments_count) %>
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
<% end -%>
|
||||
<% if (@events_pages.page == @events_pages.last_page) %>
|
||||
<div class="activity-item underline-evreycontent" style="font-size: 14px;line-height:1.5em;">
|
||||
<% elsif e.forge_act_type == "Document" %>
|
||||
<div class="activity-item underline-evreycontent" style="font-size: 14px;line-height:1.5em;width: 100%;word-wrap: break-word;word-break: break-all;">
|
||||
<div class="activity-avatar" style="float: left; margin:3px; height: 100%;">
|
||||
<%= image_tag(url_to_avatar(@user), :class => "avatar") %>
|
||||
<%= image_tag(url_to_avatar(e.user), :class => "avatar") %>
|
||||
</div>
|
||||
<div class="activity-content" style="padding:5px 5px 5px 70px;">
|
||||
<strong> <%= h(e.project) if @project.nil? || @project.id != e.project_id %></strong>
|
||||
<span class="activity-title font_lighter">
|
||||
<% if @canShowRealName %>
|
||||
(<%= link_to_user(@user, @canShowRealName) %>)
|
||||
<% else %>
|
||||
<%= link_to_user(@user) %>
|
||||
<% end %>
|
||||
<%#= l(:label_new_activity) %>
|
||||
<%= link_to(h(e.user), user_path(e.user_id)) %>
|
||||
<%= l(:label_new_activity) %>
|
||||
</span>
|
||||
<%= l(:label_user_create_project) %>
|
||||
<%= link_to @project.name %>
|
||||
<strong> !</strong>
|
||||
<div class="activity_description info-break" style="font-size: 13px;">
|
||||
<%= link_to format_activity_title("#{l(:label_document)}: #{act.title}"), {:controller => 'documents', :action => 'show', :id => act.id} %>
|
||||
<div class="activity_description info-break" style="font-size: 13px;width: 100%;word-break: break-all;word-wrap: break-word;">
|
||||
<%= textAreailizable act,:description %>
|
||||
</div>
|
||||
<div class="activity_status" style="position:relative; padding-top: 3px;">
|
||||
<span class="font_lighter">
|
||||
<%= l :label_activity_time %>:
|
||||
<%= format_time(@project.created_on) %>
|
||||
</span>
|
||||
<span class="font_lighter"> <%= l :label_activity_time %>
|
||||
: <%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="activity-item underline-evreycontent" style="font-size: 14px;line-height:1.5em;">
|
||||
<% elsif e.forge_act_type == "Attachment" %>
|
||||
<div class="activity-item underline-evreycontent" style="font-size: 14px;line-height:1.5em;width: 100%;word-wrap: break-word;word-break: break-all;">
|
||||
<div class="activity-avatar" style="float: left; margin:3px; height: 100%;">
|
||||
<%= image_tag(url_to_avatar(@user), :class => "avatar") %>
|
||||
<%= image_tag(url_to_avatar(e.user), :class => "avatar") %>
|
||||
</div>
|
||||
<div class="activity-content" style="padding:5px 5px 5px 70px;">
|
||||
<strong> <%= h(e.project) if @project.nil? || @project.id != e.project_id %></strong>
|
||||
<span class="activity-title font_lighter">
|
||||
<% if @canShowRealName %>
|
||||
(<%= link_to_user(@user, @canShowRealName) %>)
|
||||
<% else %>
|
||||
<%= link_to_user(@user) %>
|
||||
<% end %>
|
||||
<%#= l(:label_new_activity) %>
|
||||
<%= link_to(h(e.user), user_path(e.user_id)) %>
|
||||
<%= l(:label_new_activity) %>
|
||||
</span>
|
||||
<%= @user.to_s %>
|
||||
<%= l(:label_user_create_project) %>
|
||||
<%= link_to @project.name %>
|
||||
<strong> !</strong>
|
||||
<div class="activity_description info-break" style="font-size: 13px;">
|
||||
<%= link_to format_activity_title("#{l(:label_attachment)}: #{act.filename}"), {:controller => 'attachments', :action => 'show', :id => act.id} %>
|
||||
<div class="activity_description info-break" style="font-size: 13px;width: 100%;word-break: break-all;word-wrap: break-word;">
|
||||
<%= textAreailizable act,:description %>
|
||||
</div>
|
||||
<div class="activity_status" style="position:relative; padding-top: 3px;">
|
||||
<span class="font_lighter">
|
||||
<%= l :label_activity_time %>:
|
||||
<%= format_time(@project.created_on) %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<span class="font_lighter"> <%= l :label_activity_time %>
|
||||
: <%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %></span>
|
||||
|
||||
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full @events_pages %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% html_title(l(:label_overview)) -%>
|
||||
|
||||
<%= paginate @events_pages %>
|
|
@ -114,10 +114,8 @@
|
|||
</strong>
|
||||
</h3>
|
||||
<div class="user-message-box-list" style="margin-top: 10px;">
|
||||
<% cache("activities") do %>
|
||||
<%activities = find_all_activities%>
|
||||
<% activities.each do |event| %>
|
||||
<% cache event do %>
|
||||
<li style="display: block;height:60px; padding-bottom: 4px;">
|
||||
<div class="inner-right" style="float: left; height: 100%; ">
|
||||
<%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %>
|
||||
|
@ -141,8 +139,6 @@
|
|||
</p>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</ul>
|
||||
|
@ -150,17 +146,14 @@
|
|||
|
||||
<div class="right" style="float: right; width: 48%; ">
|
||||
<ul class="welcome-message-list">
|
||||
<!--<%# cache 'forum_links' do %> -->
|
||||
<div class="forum-topic" style="height: 25px; width: 98%; margin-left: 2px;">
|
||||
<h3 style="color: rgb(21, 188, 207);"><strong> <%= l(:lable_bar_active)%> </strong> <%= link_to l(:label_my_question) , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
|
||||
<%= link_to l(:label_my_feedback) , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> </h3>
|
||||
<span style="margin-top: -30px;float: right; display: block;"> <%= link_to l(:label_more), forums_path %> </span>
|
||||
</div>
|
||||
<div class="welcome-box-list-new memo_activity">
|
||||
<% cache("forums") do %>
|
||||
<% topics = find_new_forum_topics(6) %>
|
||||
<% topics.includes(:forum, :last_reply, :author).each do |topic|%>
|
||||
<% cache topic do %>
|
||||
<li class="message-brief-intro" style="line-height:1.4em;">
|
||||
<div class='memo_title text_nowrap'>
|
||||
<%= link_to '['+topic.forum.name + ']',forum_path(topic.forum),:class => 'memo_Bar_title' %>
|
||||
|
@ -189,9 +182,6 @@
|
|||
</div>
|
||||
</li>
|
||||
<%end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
class CreateForgeActivities < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :forge_activities do |t|
|
||||
t.integer :user_id
|
||||
t.integer :project_id
|
||||
t.references :forge_act, polymorphic: true, index: true
|
||||
t.integer :org_id
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :forge_activities ,:forge_act_id
|
||||
end
|
||||
end
|
|
@ -0,0 +1,46 @@
|
|||
# Time 2015-02-37 15:03:42
|
||||
# Author lizanle
|
||||
# Description 将Issue中的数据导入forge_activities表
|
||||
class ImportIssueDataToForgeActivities < ActiveRecord::Migration
|
||||
def up
|
||||
issue_arr = select_all("SELECT\n" +
|
||||
" `issues`.`id` AS id,\n" +
|
||||
" `issues`.`project_id` AS project_id,\n" +
|
||||
" `issues`.`author_id` AS author_id,\n" +
|
||||
" `issues`.`created_on` AS created_on,\n" +
|
||||
" `issues`.`updated_on` AS updated_on\n" +
|
||||
"FROM\n" +
|
||||
" `issues`\n" +
|
||||
"LEFT OUTER JOIN `projects` ON `projects`.`id` = `issues`.`project_id`\n" +
|
||||
"LEFT OUTER JOIN `users` ON `users`.`id` = `issues`.`author_id`\n" +
|
||||
"AND `users`.`type` IN ('User', 'AnonymousUser')\n" +
|
||||
"LEFT OUTER JOIN `trackers` ON `trackers`.`id` = `issues`.`tracker_id`\n" +
|
||||
"WHERE\n" +
|
||||
" (\n" +
|
||||
" projects. STATUS <> 9\n" +
|
||||
" AND projects.id IN (\n" +
|
||||
" SELECT\n" +
|
||||
" em.project_id\n" +
|
||||
" FROM\n" +
|
||||
" enabled_modules em\n" +
|
||||
" WHERE\n" +
|
||||
" em. NAME = 'issue_tracking'\n" +
|
||||
" )\n" +
|
||||
" )");
|
||||
issue_arr.each do |e|
|
||||
ForgeActivity.connection.execute("insert into forge_activities(forge_act_id,
|
||||
forge_act_type,
|
||||
project_id,
|
||||
user_id,
|
||||
created_at,
|
||||
updated_at)
|
||||
values(#{e["id"]},'#{Issue.to_s}',#{e["project_id"]},#{e["author_id"]},
|
||||
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}',
|
||||
'#{e["updated_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}')")
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
ForgeActivity.delete_all([" forge_act_type = ?",ForgeActivity::TYPE_OF_ISSUE_ACT])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,51 @@
|
|||
class AddJournalDataToForgeActivities < ActiveRecord::Migration
|
||||
def up
|
||||
journal_arr = select_all("SELECT\n" +
|
||||
" `journals`.`id` AS id,\n" +
|
||||
" `journals`.`created_on` AS created_on,\n" +
|
||||
" `projects`.`id` AS project_id,\n" +
|
||||
" `issues`.`updated_on` AS updated_on,\n" +
|
||||
" `users`.`id` AS author_id\n" +
|
||||
"FROM\n" +
|
||||
" `journals`\n" +
|
||||
"LEFT OUTER JOIN `issues` ON `issues`.`id` = `journals`.`journalized_id`\n" +
|
||||
"LEFT OUTER JOIN `projects` ON `projects`.`id` = `issues`.`project_id`\n" +
|
||||
"LEFT OUTER JOIN `journal_details` ON `journal_details`.`journal_id` = `journals`.`id`\n" +
|
||||
"LEFT OUTER JOIN `users` ON `users`.`id` = `journals`.`user_id`\n" +
|
||||
"AND `users`.`type` IN ('User', 'AnonymousUser')\n" +
|
||||
"WHERE\n" +
|
||||
" (\n" +
|
||||
" projects. STATUS <> 9\n" +
|
||||
" AND projects.id IN (\n" +
|
||||
" SELECT\n" +
|
||||
" em.project_id\n" +
|
||||
" FROM\n" +
|
||||
" enabled_modules em\n" +
|
||||
" WHERE\n" +
|
||||
" em. NAME = 'issue_tracking'\n" +
|
||||
" )\n" +
|
||||
" )\n" +
|
||||
" AND (\n" +
|
||||
" journals.journalized_type = 'Issue'\n" +
|
||||
" AND (\n" +
|
||||
" journal_details.prop_key = 'status_id'\n" +
|
||||
" OR journals.notes <> ''\n" +
|
||||
" )\n" +
|
||||
" )");
|
||||
journal_arr.each do |e|
|
||||
ForgeActivity.connection.execute("insert into forge_activities(forge_act_id,
|
||||
forge_act_type,
|
||||
project_id,
|
||||
user_id,
|
||||
created_at,
|
||||
updated_at)
|
||||
values(#{e["id"]},'#{Journal.to_s}',#{e["project_id"]},#{e["author_id"]},
|
||||
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}',
|
||||
'#{e["updated_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}')")
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
ForgeActivity.delete_all([" forge_act_type = ?",ForgeActivity::TYPE_OF_JOURNAL_ACT])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,41 @@
|
|||
class ImportMessageDataToForgeActivities < ActiveRecord::Migration
|
||||
def up
|
||||
issue_arr = select_all("SELECT\n" +
|
||||
" `messages`.`id` AS id,\n" +
|
||||
" `messages`.`author_id` AS author_id,\n" +
|
||||
" `projects`.`id` AS project_id,\n" +
|
||||
" `messages`.`created_on` AS created_on,\n" +
|
||||
" `messages`.`updated_on` AS updated_on\n" +
|
||||
"FROM\n" +
|
||||
" `messages`\n" +
|
||||
"LEFT OUTER JOIN `boards` ON `boards`.`id` = `messages`.`board_id`\n" +
|
||||
"LEFT OUTER JOIN `projects` ON `projects`.`id` = `boards`.`project_id`\n" +
|
||||
"LEFT OUTER JOIN `users` ON `users`.`id` = `messages`.`author_id`\n" +
|
||||
"AND `users`.`type` IN ('User', 'AnonymousUser')\n" +
|
||||
"WHERE\n" +
|
||||
" projects. STATUS <> 9\n" +
|
||||
" AND projects.id IN (\n" +
|
||||
" SELECT\n" +
|
||||
" em.project_id\n" +
|
||||
" FROM\n" +
|
||||
" enabled_modules em\n" +
|
||||
" WHERE\n" +
|
||||
" em. NAME = 'boards'\n" +
|
||||
")");
|
||||
issue_arr.each do |e|
|
||||
ForgeActivity.connection.execute("insert into forge_activities(forge_act_id,
|
||||
forge_act_type,
|
||||
project_id,
|
||||
user_id,
|
||||
created_at,
|
||||
updated_at)
|
||||
values(#{e["id"]},'#{Message.to_s}',#{e["project_id"]},#{e["author_id"]},
|
||||
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}',
|
||||
'#{e["updated_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}')")
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
ForgeActivity.delete_all([" forge_act_type = ?",ForgeActivity::TYPE_OF_MESSAGE_ACT])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,41 @@
|
|||
class ImportNewsDataToForgeActivities < ActiveRecord::Migration
|
||||
def up
|
||||
issue_arr = select_all("SELECT\n" +
|
||||
" `messages`.`id` AS id,\n" +
|
||||
" `messages`.`author_id` AS author_id,\n" +
|
||||
" `projects`.`id` AS project_id,\n" +
|
||||
" `messages`.`created_on` AS created_on,\n" +
|
||||
" `messages`.`updated_on` AS updated_on\n" +
|
||||
"FROM\n" +
|
||||
" `messages`\n" +
|
||||
"LEFT OUTER JOIN `boards` ON `boards`.`id` = `messages`.`board_id`\n" +
|
||||
"LEFT OUTER JOIN `projects` ON `projects`.`id` = `boards`.`project_id`\n" +
|
||||
"LEFT OUTER JOIN `users` ON `users`.`id` = `messages`.`author_id`\n" +
|
||||
"AND `users`.`type` IN ('User', 'AnonymousUser')\n" +
|
||||
"WHERE\n" +
|
||||
" projects. STATUS <> 9\n" +
|
||||
" AND projects.id IN (\n" +
|
||||
" SELECT\n" +
|
||||
" em.project_id\n" +
|
||||
" FROM\n" +
|
||||
" enabled_modules em\n" +
|
||||
" WHERE\n" +
|
||||
" em. NAME = 'boards'\n" +
|
||||
")");
|
||||
issue_arr.each do |e|
|
||||
ForgeActivity.connection.execute("insert into forge_activities(forge_act_id,
|
||||
forge_act_type,
|
||||
project_id,
|
||||
user_id,
|
||||
created_at,
|
||||
updated_at)
|
||||
values(#{e["id"]},'#{News.to_s}',#{e["project_id"]},#{e["author_id"]},
|
||||
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}',
|
||||
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}')")
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
ForgeActivity.delete_all([" forge_act_type = ?",ForgeActivity::TYPE_OF_NEWS_ACT])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
class AddColumnProjectIssueIndexToIssues < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :issues, :project_issues_index, :integer
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
class AddDataToProjectIssuesIndexsInIssue < ActiveRecord::Migration
|
||||
def change
|
||||
for i in 1 ... 1000 do i
|
||||
Issue.page(i).per(10).each do |e|
|
||||
index = e.project.issues.index(e).to_i + 1
|
||||
execute("update issues set project_issues_index = #{index} where id = #{e.id}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,37 @@
|
|||
class ImportDocumentDataToForgeActivities < ActiveRecord::Migration
|
||||
def up
|
||||
doc_arr = select_all("SELECT\n" +
|
||||
" `documents`.`id` AS id,\n" +
|
||||
" `documents`.`project_id` AS project_id,\n" +
|
||||
" `documents`.`created_on` AS created_on,\n" +
|
||||
" `documents`.`user_id` AS author_id\n" +
|
||||
"FROM\n" +
|
||||
" `documents`\n" +
|
||||
"LEFT OUTER JOIN `projects` ON `projects`.`id` = `documents`.`project_id`\n" +
|
||||
"WHERE\n" +
|
||||
" projects. STATUS <> 9\n" +
|
||||
" AND projects.id IN (\n" +
|
||||
" SELECT\n" +
|
||||
" em.project_id\n" +
|
||||
" FROM\n" +
|
||||
" enabled_modules em\n" +
|
||||
" WHERE\n" +
|
||||
" em. NAME = 'documents'\n" +
|
||||
")");
|
||||
doc_arr.each do |e|
|
||||
ForgeActivity.connection.execute("insert into forge_activities(forge_act_id,
|
||||
forge_act_type,
|
||||
project_id,
|
||||
user_id,
|
||||
created_at,
|
||||
updated_at)
|
||||
values(#{e["id"]},'#{Document.to_s}',#{e["project_id"]},#{e["author_id"]},
|
||||
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}',
|
||||
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}')")
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
ForgeActivity.delete_all([" forge_act_type = ?",ForgeActivity::TYPE_OF_DOCUMENT_ACT])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,43 @@
|
|||
class ImportAttachmentsDataToForgeActivities < ActiveRecord::Migration
|
||||
def up
|
||||
attach_arr = select_all("SELECT\n" +
|
||||
" attachments.author_id as author_id,\n" +
|
||||
" attachments.created_on as created_on,\n" +
|
||||
" attachments.id as id,\n" +
|
||||
" projects.id as project_id\n" +
|
||||
"FROM\n" +
|
||||
" `attachments`\n" +
|
||||
"LEFT JOIN versions ON attachments.container_type = 'Version'\n" +
|
||||
"AND versions.id = attachments.container_id\n" +
|
||||
"LEFT JOIN projects ON versions.project_id = projects.id\n" +
|
||||
"OR (\n" +
|
||||
" attachments.container_type = 'Project'\n" +
|
||||
" AND attachments.container_id = projects.id\n" +
|
||||
")\n" +
|
||||
"WHERE\n" +
|
||||
" projects. STATUS <> 9\n" +
|
||||
" AND projects.id IN (\n" +
|
||||
" SELECT\n" +
|
||||
" em.project_id\n" +
|
||||
" FROM\n" +
|
||||
" enabled_modules em\n" +
|
||||
" WHERE\n" +
|
||||
" em. NAME = 'files'\n" +
|
||||
" )");
|
||||
attach_arr.each do |e|
|
||||
ForgeActivity.connection.execute("insert into forge_activities(forge_act_id,
|
||||
forge_act_type,
|
||||
project_id,
|
||||
user_id,
|
||||
created_at,
|
||||
updated_at)
|
||||
values(#{e["id"]},'#{Attachment.to_s}',#{e["project_id"]},#{e["author_id"]},
|
||||
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}',
|
||||
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}')")
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
ForgeActivity.delete_all([" forge_act_type = ?",ForgeActivity::TYPE_OF_ATTACHMENT_ACT])
|
||||
end
|
||||
end
|
43
db/schema.rb
43
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20150305011359) do
|
||||
ActiveRecord::Schema.define(:version => 20150302091345) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -472,6 +472,18 @@ ActiveRecord::Schema.define(:version => 20150305011359) do
|
|||
t.integer "show_contest", :default => 1
|
||||
end
|
||||
|
||||
create_table "forge_activities", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "project_id"
|
||||
t.integer "forge_act_id"
|
||||
t.string "forge_act_type"
|
||||
t.integer "org_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id"
|
||||
|
||||
create_table "forums", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
t.text "description"
|
||||
|
@ -581,6 +593,7 @@ ActiveRecord::Schema.define(:version => 20150305011359) do
|
|||
t.integer "rgt"
|
||||
t.boolean "is_private", :default => false, :null => false
|
||||
t.datetime "closed_on"
|
||||
t.integer "project_issues_index"
|
||||
end
|
||||
|
||||
add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id"
|
||||
|
@ -618,6 +631,16 @@ ActiveRecord::Schema.define(:version => 20150305011359) do
|
|||
|
||||
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
|
||||
|
||||
create_table "journal_details_copy", :force => true do |t|
|
||||
t.integer "journal_id", :default => 0, :null => false
|
||||
t.string "property", :limit => 30, :default => "", :null => false
|
||||
t.string "prop_key", :limit => 30, :default => "", :null => false
|
||||
t.text "old_value"
|
||||
t.text "value"
|
||||
end
|
||||
|
||||
add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
|
||||
|
||||
create_table "journal_replies", :id => false, :force => true do |t|
|
||||
t.integer "journal_id"
|
||||
t.integer "user_id"
|
||||
|
@ -802,13 +825,6 @@ ActiveRecord::Schema.define(:version => 20150305011359) do
|
|||
t.integer "project_id"
|
||||
end
|
||||
|
||||
create_table "organizations", :force => true do |t|
|
||||
t.string "name"
|
||||
t.string "logo_link"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "poll_answers", :force => true do |t|
|
||||
t.integer "poll_question_id"
|
||||
t.text "answer_text"
|
||||
|
@ -933,7 +949,6 @@ ActiveRecord::Schema.define(:version => 20150305011359) do
|
|||
t.integer "user_id"
|
||||
t.integer "dts_test", :default => 0
|
||||
t.string "enterprise_name"
|
||||
t.integer "organization_id"
|
||||
end
|
||||
|
||||
add_index "projects", ["lft"], :name => "index_projects_on_lft"
|
||||
|
@ -1021,12 +1036,12 @@ ActiveRecord::Schema.define(:version => 20150305011359) do
|
|||
end
|
||||
|
||||
create_table "roles", :force => true do |t|
|
||||
t.string "name", :limit => 30, :default => "", :null => false
|
||||
t.integer "position", :default => 1
|
||||
t.boolean "assignable", :default => true
|
||||
t.integer "builtin", :default => 0, :null => false
|
||||
t.string "name", :limit => 90
|
||||
t.integer "position"
|
||||
t.boolean "assignable"
|
||||
t.integer "builtin"
|
||||
t.text "permissions"
|
||||
t.string "issues_visibility", :limit => 30, :default => "default", :null => false
|
||||
t.string "issues_visibility", :limit => 90
|
||||
end
|
||||
|
||||
create_table "schools", :force => true do |t|
|
||||
|
|
|
@ -24,6 +24,10 @@ module Redmine
|
|||
|
||||
module ClassMethods
|
||||
def acts_as_activity_provider(options = {})
|
||||
# Time 2015-01-31 13:54:34
|
||||
# Author lizanle
|
||||
# Description mod.included_modules -> array
|
||||
# 返回mod包含的 modules数组
|
||||
unless self.included_modules.include?(Redmine::Acts::ActivityProvider::InstanceMethods)
|
||||
cattr_accessor :activity_provider_options
|
||||
send :include, Redmine::Acts::ActivityProvider::InstanceMethods
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
//= require_directory ./rateable
|
||||
//= require jquery.min
|
||||
//= require jquery.infinitescroll
|
||||
|
||||
/* Redmine - project management software
|
||||
Copyright (C) 2006-2013 Jean-Philippe Lang */
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe ForgeActivity do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue