Conflicts:
	app/controllers/account_controller.rb
This commit is contained in:
linchun 2014-06-23 15:06:37 +08:00
commit 9c5066b81c
420 changed files with 56947 additions and 775 deletions

18
Gemfile
View File

@ -42,6 +42,24 @@ group :ldap do
gem "net-ldap", "~> 0.3.1"
end
group :test do
# shoulda的版本做了改动
#gem "shoulda", "~> 3.3.2"
gem "shoulda", "> 3.3.2"
gem "mocha", "~> 0.13.3"
gem 'capybara', '~> 2.0.0'
gem 'nokogiri', '< 1.6.0'
end
platforms :mri, :mingw do
group :rmagick do
# RMagick 2 supports ruby 1.9
# RMagick 1 would be fine for ruby 1.8 but Bundler does not support
# different requirements for the same gem on different platforms
gem "rmagick", ">= 2.0.0"
end
end
# Optional gem for OpenID authentication
group :openid do
gem "ruby-openid", "~> 2.1.4", :require => "openid"

View File

@ -52,6 +52,15 @@ GEM
rails (>= 3, < 5)
arel (3.0.2)
builder (3.0.0)
capybara (2.0.3)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 1.0.0)
childprocess (0.5.3)
ffi (~> 1.0, >= 1.0.11)
coderay (1.0.9)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
@ -64,6 +73,7 @@ GEM
execjs (1.4.0)
multi_json (~> 1.0)
fastercsv (1.5.0)
ffi (1.9.3-x86-mingw32)
hike (1.2.3)
i18n (0.6.1)
journey (1.0.4)
@ -74,10 +84,14 @@ GEM
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.4)
mime-types (1.23)
mocha (0.13.3)
metaclass (~> 0.0.1)
multi_json (1.7.6)
mysql2 (0.3.11-x86-mingw32)
net-ldap (0.3.1)
nokogiri (1.5.11-x86-mingw32)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
@ -104,15 +118,28 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.4)
rake (10.3.2)
rdoc (3.12.2)
json (~> 1.4)
rmagick (2.13.2)
ruby-openid (2.1.8)
rubyzip (1.1.4)
sass (3.2.7)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
selenium-webdriver (2.42.0)
childprocess (>= 0.5.0)
multi_json (~> 1.0)
rubyzip (~> 1.0)
websocket (~> 1.0.4)
shoulda (3.5.0)
shoulda-context (~> 1.0, >= 1.0.1)
shoulda-matchers (>= 1.4.1, < 3.0)
shoulda-context (1.2.1)
shoulda-matchers (2.6.1)
activesupport (>= 3.0.0)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
@ -127,6 +154,9 @@ GEM
uglifier (1.0.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
websocket (1.0.7)
xpath (1.0.0)
nokogiri (~> 1.3)
PLATFORMS
x86-mingw32
@ -137,17 +167,22 @@ DEPENDENCIES
acts-as-taggable-on (= 2.4.1)
better_errors!
builder (= 3.0.0)
capybara (~> 2.0.0)
coderay (~> 1.0.6)
coffee-rails (~> 3.2.1)
fastercsv (~> 1.5.0)
i18n (~> 0.6.0)
jquery-rails (~> 2.0.2)
mocha (~> 0.13.3)
mysql2 (~> 0.3.11)
net-ldap (~> 0.3.1)
nokogiri (< 1.6.0)
rack-mini-profiler!
rack-openid
rails (= 3.2.13)
rmagick (>= 2.0.0)
ruby-openid (~> 2.1.4)
sass-rails (~> 3.2.3)
seems_rateable!
shoulda (> 3.3.2)
uglifier (>= 1.0.3)

View File

@ -143,16 +143,17 @@ class AccountController < ApplicationController
end
#added by bai
unless @user.id.nil?
ue = @user.extensions
ue.identity = params[:identity]
if @user.id != nil
ue = @user.user_extensions ||= UserExtensions.new
#ue = UserExtensions.create(:identity => params[:identity].to_i,:technical_title => params[:technical_title], :gender => params[:gender].to_i, :user_id => @user.id, :student_id => )
ue.identity = params[:identity].to_i
ue.technical_title = params[:technical_title]
ue.gender = params[:gender]
ue.gender = params[:gender].to_i
ue.user_id = @user.id
ue.student_id = params[:no]
ue.location = params[:province]
ue.location_city = params[:city]
@user.save
ue.location = params[:province] if params[:province] != nil
ue.location_city = params[:city] if params[:city] != nil
ue.save
end
end

View File

@ -59,6 +59,8 @@ class AttachmentsController < ApplicationController
:type => detect_content_type(@attachment),
:disposition => (@attachment.image? ? 'inline' : 'attachment')
end
rescue => e
redirect_to "http://forge.trustie.net/file_not_found.html"
end
#更新资源文件类型

View File

@ -1,4 +1,5 @@
class HomeworkAttachController < ApplicationController
include CoursesHelper
###############################
#判断当前角色权限时需先找到当前操作的project
before_filter :find_project_by_bid_id, :only => [:new]
@ -77,6 +78,15 @@ class HomeworkAttachController < ApplicationController
if bid.homeworks.where("user_id = ?",User.current).count == 0
user_id = params[:user_id]
bid_id = params[:bid_id]
if params[:homework_attach]
if params[:homework_attach][:project_id]
project_id = params[:homework_attach][:project_id]
else
project_id = 0
end
else
project_id = 0
end
sta = 0
name = params[:new_form][:name]
description = params[:new_form][:description]
@ -85,7 +95,8 @@ class HomeworkAttachController < ApplicationController
:state => sta,
:name => name,
:description => description,
:bid_id => bid_id
:bid_id => bid_id,
:project_id => project_id
}
@ -177,8 +188,18 @@ class HomeworkAttachController < ApplicationController
if User.current.admin? || User.current.member_of?(course)
name = params[:homework_name]
description = params[:homework_description]
if params[:homework_attach]
if params[:homework_attach][:project_id]
project_id = params[:homework_attach][:project_id]
else
project_id = 0
end
else
project_id = 0
end
@homework.name = name
@homework.description = description
@homework.project_id = project_id
if params[:attachments]
@homework.save_attachments(params[:attachments])
end
@ -196,7 +217,7 @@ class HomeworkAttachController < ApplicationController
def destroy
#@homework = HomeworkAttach.find(params[:id])
if User.current.admin? || User.current == @homework
if User.current.admin? || User.current == @homework.user
if @homework.destroy
respond_to do |format|
format.html { redirect_to project_for_bid_path @homework.bid }
@ -237,6 +258,9 @@ class HomeworkAttachController < ApplicationController
@offset ||= @feedback_pages.offset
@jour = @jours[@offset, @limit]
@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC")
@totle_score = score_for_homework @homework
@teaher_score = teacher_score_for_homework @homework
else
render_403 :message => :notice_not_authorized
end
@ -268,6 +292,9 @@ class HomeworkAttachController < ApplicationController
@offset ||= @feedback_pages.offset
@jour = @jours[@offset, @limit]
@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC")
@totle_score = score_for_homework @homework
@teaher_score = teacher_score_for_homework @homework
respond_to do |format|
format.js
end

View File

@ -9,10 +9,13 @@ class PraiseTreadController < ApplicationController
if request.get?
@obj_id = params[:obj_id]
@obj_type = params[:obj_type]
@horizontal = params[:horizontal]
@horizontal = params[:horizontal].downcase == "false" ? false:true
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
unless @obj.author_id == User.current.id
praise_tread_plus(@obj_type,@obj_id,1)
end
end
end
def praise_minus
@ -45,10 +48,13 @@ class PraiseTreadController < ApplicationController
if request.get?
@obj_id = params[:obj_id]
@obj_type = params[:obj_type]
@horizontal = params[:horizontal]
@horizontal = params[:horizontal].downcase == "false" ? false:true
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
unless @obj.author_id == User.current.id
praise_tread_plus(@obj_type,@obj_id,0)
end
end
end
def tread_minus

View File

@ -32,12 +32,14 @@ class UsersController < ApplicationController
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info,
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index]
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score]
#edit has been deleted by huang, 2013-9-23
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
:watch_bids, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index]
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index]
before_filter :auth_user_extension, only: :show
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx
@ -94,6 +96,10 @@ class UsersController < ApplicationController
def show_score
end
def show_new_score
end
# end
##added by fq
@ -767,6 +773,29 @@ class UsersController < ApplicationController
end
# end
def topic_new_score_index
end
def project_new_score_index
end
def activity_new_score_index
end
def influence_new_score_index
end
def score_new_index
end
def update_score
@user = User.find(params[:id])
end
private

View File

@ -27,7 +27,7 @@ class ZipdownController < ApplicationController
else
logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!"
end
send_file zipfile, :filename => obj.name, :type => detect_content_type(zipfile) if zipfile
send_file zipfile, :filename => obj.name+".zip", :type => detect_content_type(zipfile) if zipfile
#rescue NameError, ActiveRecord::RecordNotFound => e
#logger.error "[ZipDown] ===> #{e}"
@ -39,7 +39,7 @@ class ZipdownController < ApplicationController
homework = HomeworkAttach.find params[:homework]
if homework != nil && (User.current.admin? || User.current.member_of?(homework.bid.courses.first))
zipfile = zip_homework_by_user homework
send_file zipfile, :filename => homework.name, :type => detect_content_type(zipfile) if zipfile
send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if zipfile
else
render_403 :message => :notice_not_authorized
end
@ -88,7 +88,7 @@ class ZipdownController < ApplicationController
#length = attach.storage_path.length
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
end
zipping "#{homeattach.user.name.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true
zipping "#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true
#user_attaches_paths
end

View File

@ -182,4 +182,71 @@ module CoursesHelper
def users_for_homework homework
homework.nil? ? [] : (homework.users + [homework.user])
end
#获取指定作业的最终评分
#最终评分 = 学生评分的平均分 * 0.4 +教师评分 * 0.6
def score_for_homework homework
if homework.bid.is_evaluation == 1 || homework.bid.is_evaluation == nil
return format("%.2f",(teacher_score_for_homework(homework).to_f * 0.6 + student_score_for_homework(homework).to_f * 0.4))
else
return teacher_score_for_homework homework
end
end
#获取作业的互评得分
def student_score_for_homework homework
member = searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars")
student_stars_count = 0
student_stars.each do |star|
student_stars_count = student_stars_count + star.stars
end
return format("%.2f",student_stars_count / (student_stars.count == 0 ? 1 : student_stars.count))
end
#获取作业的教师评分
def teacher_score_for_homework homework
member = searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
teacher_stars = homework.rates(:quality).where("rater_id = #{member.user_id}").select("stars").first
return format("%.2f",teacher_stars == nil ? 0 : teacher_stars.stars)
end
#获取指定作业的得分
def project_score project
issue_count = project.issues.count
issue_journal_count = project.issue_changes.count
issue_score = issue_count * 0.2
issue_journal_score = issue_journal_count * 0.1
finall_issue_score = issue_score + issue_journal_score
new_count = project.news.count
new_score = new_count * 0.1
finall_new_score = new_score
document_count = project.documents.count
file_score = document_count * 0.1
finall_file_score = file_score
changeset_count = project.changesets.count
code_submit_score = changeset_count * 0.3
finall_code_submit_score = code_submit_score
board_message_count = 0
project.boards.each do |board|
board_message_count += board.messages_count
end
topic_score = board_message_count * 0.1
#finall_topic_score = topic_score
finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score
format("%.2f",finall_project_score)
end
#获取指定作业的参与人员
#返回结果:张三、李四、王五
def homework_user_of_homework homework,is_teacher
homework_users = ""
homework.users.each do |user|
homework_users = homework_users + (is_teacher ? user.realname : user.name)
if user != homework.users.last
homework_users = homework_users + ""
end
end
return homework_users
end
end

View File

@ -54,4 +54,24 @@ module HomeworkAttachHelper
raise RuntimeError, 'unknow type, Please input you type into this helper.'
end
end
def user_projects_option
cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
memberships = User.current.memberships.all(:conditions => cond)
projects = memberships.map(&:project)
not_have_project = []
not_have_project << "<<NULL>>"
not_have_project << 0
type = []
type << not_have_project
projects.each do |project|
if project != nil
option = []
option << project.name
option << project.id
type << option
end
end
type
end
end

View File

@ -70,7 +70,7 @@ module JournalsHelper
content << textilizable(journal, :notes)
css_classes = "wiki"
css_classes << " editable" if editable
content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes)
content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes ,:style => "width:580px")
end
def link_to_in_place_notes_editor(text, field_id, url, options={})

View File

@ -370,7 +370,7 @@ class Attachment < ActiveRecord::Base
type = self.container_type
types = %w|Document News Version Project Issue Message WikiPage|
if types.include?(type)
UserScore.project(:push_file, User.current, { attachment_id: self.id })
UserScore.project(:push_file, User.current,self, { attachment_id: self.id })
end
end
end

View File

@ -19,7 +19,7 @@ class Changeset < ActiveRecord::Base
belongs_to :repository
belongs_to :user
after_save :be_user_score # user_score
#after_save :be_user_score # user_score
has_many :filechanges, :class_name => 'Change', :dependent => :delete_all
# fq
@ -63,7 +63,7 @@ class Changeset < ActiveRecord::Base
includes(:repository => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args))
}
after_create :scan_for_issues
after_create :scan_for_issues,:be_user_score # user_score
before_create :before_create_cs
# fq
@ -300,11 +300,9 @@ class Changeset < ActiveRecord::Base
# update user score
def be_user_score
if self.new_record?
UserScore.project(:push_code, self.user, { changeset_id: self.id })
UserScore.project(:push_code, self.user,self, { changeset_id: self.id })
#更新用户等级
self.user.update_user_level
end
UserLevels.update_user_level(self.user)
end
end

View File

@ -21,7 +21,7 @@ class Document < ActiveRecord::Base
belongs_to :user
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
before_save :be_user_score # user_score
after_create :be_user_score # user_score
acts_as_attachable :delete_permission => :delete_documents
@ -62,8 +62,6 @@ class Document < ActiveRecord::Base
# update user score
def be_user_score
if self.new_record?
UserScore.project(:push_document, self.user, { document_id: self.id })
end
UserScore.project(:push_document, self.user,self,{ document_id: self.id })
end
end

View File

@ -9,6 +9,7 @@ class HomeworkAttach < ActiveRecord::Base
has_many :homework_users, :dependent => :destroy
has_many :users, :through => :homework_users
seems_rateable :allow_update => true, :dimensions => :quality
belongs_to :project
safe_attributes "bid_id",
"user_id"
@ -30,7 +31,7 @@ class HomeworkAttach < ActiveRecord::Base
result
end
def project
def project_for_homework
work = HomeworkForCourse.find_by_bid_id(self.bid_id)
if work
work.project

View File

@ -76,8 +76,8 @@ class Issue < ActiveRecord::Base
attr_reader :current_journal
# fq
after_create :act_as_activity
before_save :be_user_score
after_create :act_as_activity,:be_user_score_new_issue
after_update :be_user_score
# after_create :be_user_score
# end
@ -1489,14 +1489,19 @@ class Issue < ActiveRecord::Base
# update user score
def be_user_score
if self.new_record?
UserScore.project(:post_issue, User.current, { issue_id: self.id })
elsif self.done_ratio_changed?
UserScore.project(:update_issue_ratio, User.current, { issue_id: self.id })
#缺陷状态更改
elsif self.status_id_changed?
#协同得分
UserScore.joint(:change_issue_status, User.current,nil, {issue_id: self.id})
#缺陷完成度更新
if self.done_ratio_changed?
UserScore.project(:update_issue_ratio, User.current,self,{ issue_id: self.id })
end
#缺陷状态更改
if self.status_id_changed?
#协同得分
UserScore.joint(:change_issue_status, User.current,nil,self, {issue_id: self.id})
end
end
#发布缺陷
def be_user_score_new_issue
UserScore.project(:post_issue, User.current,self, { issue_id: self.id })
end
end

View File

@ -45,10 +45,10 @@ class Journal < ActiveRecord::Base
before_create :split_private_notes
# fq
after_create :act_as_activity
after_create :act_as_activity,:be_user_score
# end
before_save :be_user_score
#before_save :be_user_score
#before_destroy :down_user_score
scope :visible, lambda {|*args|
@ -158,9 +158,9 @@ class Journal < ActiveRecord::Base
# 更新用户分数 -by zjc
def be_user_score
#新建了缺陷留言且留言不为空,不为空白
if self.new_record? && !self.notes.nil? && self.notes.gsub(' ','') != ''
if !self.notes.nil? && self.notes.gsub(' ','') != ''
#协同得分加分
UserScore.joint(:post_issue, User.current,self.issue.author, { message_id: self.id })
UserScore.joint(:post_issue_message, User.current,self.issue.author,self, { message_id: self.id })
end
end
# 减少用户分数 -by zjc
@ -168,7 +168,7 @@ class Journal < ActiveRecord::Base
#删除有效缺陷留言
if !self.notes.nil? && self.notes.gsub(' ','') != ''
#协同得分减分
UserScore.joint(:delete_issue, User.current,self.issue.author, { message_id: self.id })
UserScore.joint(:delete_issue_message, User.current,self.issue.author, { message_id: self.id })
end
end
end

View File

@ -40,9 +40,9 @@ class JournalsForMessage < ActiveRecord::Base
validates :notes, presence: true
after_create :act_as_activity #huang
after_create :reset_counters!
after_create :reset_counters!,:be_user_score
after_destroy :reset_counters!
before_save :be_user_score
#before_save :be_user_score
#before_destroy :down_user_score
# default_scope { where('m_parent_id IS NULL') }
@ -105,9 +105,9 @@ class JournalsForMessage < ActiveRecord::Base
# 更新用户分数 -by zjc
def be_user_score
#新建了留言回复
if self.new_record? && self.reply_id != 0
if self.reply_id != 0
#协同得分加分
UserScore.joint(:reply_message, User.current,User.find(self.reply_id), { journals_for_messages_id: self.id })
UserScore.joint(:reply_message, User.current,User.find(self.reply_id),self, { journals_for_messages_id: self.id })
end
end
# 更新用户分数 -by zjc

View File

@ -75,6 +75,11 @@ class Mailer < ActionMailer::Base
return -1
end
mail :to => journals_for_message.jour.author.mail, :subject => @title
elsif journals_for_message.jour.class.to_s.to_sym == :Contest
if !journals_for_message.jour.author.notify_about? journals_for_message
return -1
end
mail :to => journals_for_message.jour.author.mail, :subject => @title
else
mail :to => @mail.mail, :subject => @title
end

View File

@ -12,6 +12,7 @@ class Memo < ActiveRecord::Base
acts_as_tree :counter_cache => :replies_count, :order => "#{Memo.table_name}.created_at ASC"
acts_as_attachable
has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj
belongs_to :last_reply, :class_name => 'Memo', :foreign_key => 'last_reply_id'
# acts_as_searchable :column => ['subject', 'content'],
# #:include => { :forum => :p}
@ -40,13 +41,13 @@ class Memo < ActiveRecord::Base
"parent_id",
"replies_count"
after_create :add_author_as_watcher, :reset_counters!
after_create :add_author_as_watcher, :reset_counters!,:be_user_score
# after_update :update_memos_forum
after_destroy :reset_counters!
# after_create :send_notification
# after_save :plusParentAndForum
# after_destroy :minusParentAndForum
before_save :be_user_score
#before_save :be_user_score
# scope :visible, lambda { |*args|
# includes(:forum => ).where()
# }
@ -145,11 +146,11 @@ class Memo < ActiveRecord::Base
#更新用户分数 -by zjc
def be_user_score
#新建memo且无parent的为发帖
if self.new_record? && self.parent_id.nil?
UserScore.joint(:post_message, User.current,nil, { memo_id: self.id })
if self.parent_id.nil?
UserScore.joint(:post_message, User.current,nil,self ,{ memo_id: self.id })
#新建memo且有parent的为回帖
elsif self.new_record? && !self.parent_id.nil?
UserScore.joint(:reply_posting, User.current,self.parent.author, { memo_id: self.id })
elsif !self.parent_id.nil?
UserScore.joint(:reply_posting, User.current,self.parent.author,self, { memo_id: self.id })
end
end

View File

@ -53,8 +53,8 @@ class Message < ActiveRecord::Base
after_destroy :reset_counters!
# fq
after_create :act_as_activity
before_save :be_user_score
after_create :act_as_activity,:be_user_score
#before_save :be_user_score
#before_destroy :down_user_score
# end
@ -127,11 +127,11 @@ class Message < ActiveRecord::Base
#更新用户分数 -by zjc
def be_user_score
#新建message且无parent的为发帖
if self.new_record? && self.parent_id.nil?
UserScore.joint(:post_message, User.current,nil, { message_id: self.id })
if self.parent_id.nil?
UserScore.joint(:post_message, User.current,nil,self, { message_id: self.id })
#新建message且有parent的为回帖
elsif self.new_record? && !self.parent_id.nil?
UserScore.joint(:reply_posting, User.current,self.parent.author, { message_id: self.id })
elsif !self.parent_id.nil?
UserScore.joint(:reply_posting, User.current,self.parent.author,self, { message_id: self.id })
end
end
#减少用户分数

View File

@ -2,7 +2,7 @@ class PraiseTread < ActiveRecord::Base
attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread
belongs_to :user
belongs_to :praise_tread_object, polymorphic: true
before_save :be_user_score
after_create :be_user_score
def self.find_object_by_type_and_id(type,id)
@obj = nil
@ -28,17 +28,17 @@ class PraiseTread < ActiveRecord::Base
#更新用户分数 - by zjc
def be_user_score
#踩贴吧或讨论区帖子
if self.new_record? && self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message')
if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
UserScore.skill(:treaded_by_user, User.current,target_user, { praise_tread_id: self.id })
UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id })
#顶贴吧或讨论区帖子
elsif self.new_record? && self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message')
elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
UserScore.skill(:praised_by_user, User.current,target_user,{ praise_tread_id: self.id })
UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id })
#更新用户等级
target_user.update_user_level
UserLevels.update_user_level(target_user)
end
end
end

View File

@ -30,6 +30,7 @@ class Project < ActiveRecord::Base
# Specific overidden Activities
belongs_to :homework_attach
has_many :time_entry_activities
has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}"
has_many :memberships, :class_name => 'Member'

View File

@ -17,6 +17,6 @@ class ProjectInfo < ActiveRecord::Base
#更新用户等级
def update_user_level
self.user.update_user_level
UserLevels.update_user_level(self.user)
end
end

View File

@ -885,63 +885,6 @@ class User < Principal
end
end
#获取user的等级 -by zjc
def get_level
if self.level.nil?
update_user_level
end
self.level.level
end
#更新用户等级 - by zjc
def update_user_level
user_level = self.level.nil? ? UserLevels.new : self.level
user_level.user = self
#判断user的等级
pis = self.project_infos #ProjectInfo.find_all_by_user_id(self.id)
isManager = false;
pis.each do |pi|
#判断是否为项目管理员
if self.allowed_to?({:controller => "projects", :action => "edit"}, pi.project)
isManager = true;
end
end
has_effective_praise_count = false;
self.messages.each do |message|
if message.parent_id.nil?
ptcs = PraiseTreadCache.find_all_by_object_id(message.id)
ptcs.each do |ptc|
if ptc.object_type == 'Message' && ptc.praise_num.to_i > 5
has_effective_praise_count = true
end
end
end
end
if !has_effective_praise_count
self.memos do |memo|
if memo.parent_id.nil?
ptcs = PraiseTreadCache.find_all_by_object_id(memo.id)
ptcs.each do |ptc|
if ptc.object_type == 'Memo' && ptc.praise_num > 5
has_effective_praise_count = true
end
end
end
end
end
if isManager || self.changesets.count > 100
user_level.level = 3
elsif (self.changesets.count > 1 && self.changesets.count <= 100) || has_effective_praise_count
user_level.level = 2
else
user_level.level = 1
end
user_level.save
self.reload
end
protected
def validate_password_length

View File

@ -2,4 +2,67 @@
class UserLevels < ActiveRecord::Base
attr_accessible :user_id, :level
belongs_to :user
#获取user的等级 -by zjc
def get_level(user)
unless user.nil?
if user.level.nil?
UserLevels.update_user_level(user)
end
user.level.level
end
end
#更新用户的等级 -by zjc
def self.update_user_level(user)
unless user.nil?
user_level = user.level.nil? ? UserLevels.new : user.level
user_level.user = user
#判断user的等级
pis = user.project_infos #ProjectInfo.find_all_by_user_id(self.id)
isManager = false;
pis.each do |pi|
#判断是否为项目管理员
if user.allowed_to?({:controller => "projects", :action => "edit"}, pi.project)
isManager = true;
end
end
has_effective_praise_count = false;
user.messages.each do |message|
if message.parent_id.nil?
ptcs = PraiseTreadCache.find_all_by_object_id(message.id)
ptcs.each do |ptc|
if ptc.object_type == 'Message' && ptc.praise_num.to_i > 5
has_effective_praise_count = true
end
end
end
end
if !has_effective_praise_count
user.memos do |memo|
if memo.parent_id.nil?
ptcs = PraiseTreadCache.find_all_by_object_id(memo.id)
ptcs.each do |ptc|
if ptc.object_type == 'Memo' && ptc.praise_num > 5
has_effective_praise_count = true
end
end
end
end
end
if isManager || user.changesets.count > 100
user_level.level = 3
elsif (user.changesets.count > 1 && user.changesets.count <= 100) || has_effective_praise_count
user_level.level = 2
else
user_level.level = 1
end
user_level.save
user.reload
end
end
end

View File

@ -48,46 +48,51 @@ class UserScore < ActiveRecord::Base
# # => true #当前用户发帖计分操作成功
#
# Returns boolean. 返回积分保存结果
def self.joint(operate, current_user, target_user, options={})
def self.joint(operate, current_user, target_user,obj, options={})
current_user, target_user = get_users(current_user, target_user)
user_score = current_user.user_score_attr
case operate
when :post_message # current_user 发帖了 Add Message
user_score.collaboration = user_score.collaboration.to_i + 2
user_score.save
create_score_changed_details({:current_user_id => current_user.id ,:score_type => "collaboration",:score_action => "post_message",:user_id => current_user.id,:old_score => user_score.collaboration - 2,:new_score => user_score.collaboration,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a message. options => (#{options.to_s})"
when :delete_message # current_user 发帖了 Delete Message
user_score.collaboration = user_score.collaboration.to_i - 2
user_score.save
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a message. options => (#{options.to_s})"
when :post_issue # current_user 对 target_user 的缺陷留言了 Add Journal
#when :delete_message # current_user 删帖了 Delete Message
# user_score.collaboration = user_score.collaboration.to_i - 2
# user_score.save
# Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a message. options => (#{options.to_s})"
when :post_issue_message # current_user 对 target_user 的缺陷留言了 Add Journal
user_score.collaboration = user_score.collaboration.to_i + 1
user_score.save
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "post_issue_message",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a issue. options => (#{options.to_s})"
when :delete_issue # current_user 删除了 对 target_user 的缺陷留言了 Delete Journal
user_score.collaboration = user_score.collaboration.to_i - 1
user_score.save
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue. options => (#{options.to_s})"
#when :delete_issue_message # current_user 删除了 对 target_user 的缺陷留言了 Delete Journal
# user_score.collaboration = user_score.collaboration.to_i - 1
# user_score.save
# Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue. options => (#{options.to_s})"
when :change_issue_status # current_user 更改了缺陷的状态 Changed Issue
user_score.collaboration = user_score.collaboration.to_i + 1
user_score.save
create_score_changed_details({:current_user_id => current_user.id , :score_type => "collaboration",:score_action => "change_issue_status",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} change issue status. options => (#{options.to_s})"
when :reply_message # current_user 对 target_user 留言的回复 Add Journals_for_messages
user_score.collaboration = user_score.collaboration.to_i + 1
user_score.save
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "reply_message",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply message. options => (#{options.to_s})"
when :reply_message_delete # current_user 删除了对 target_user 留言的回复 delete Journals_for_messages
user_score.collaboration = user_score.collaboration.to_i - 1
user_score.save
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} delete reply message. options => (#{options.to_s})"
#when :reply_message_delete # current_user 删除了对 target_user 留言的回复 delete Journals_for_messages
# user_score.collaboration = user_score.collaboration.to_i - 1
# user_score.save
# Rails.logger.info "[UserScore#joint] ===> User: #{current_user} delete reply message. options => (#{options.to_s})"
when :reply_posting # current_user 对 target_user 帖子的回复 Add Message
user_score.collaboration = user_score.collaboration.to_i + 1
user_score.save
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "reply_posting",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply posting. options => (#{options.to_s})"
when :reply_deleting # current_user 删除了 对 target_user 帖子的回复 Delete Message
user_score.collaboration = user_score.collaboration.to_i - 1
user_score.save
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply deleting. options => (#{options.to_s})"
#when :reply_deleting # current_user 删除了 对 target_user 帖子的回复 Delete Message
# user_score.collaboration = user_score.collaboration.to_i - 1
# user_score.save
# Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply deleting. options => (#{options.to_s})"
else
Rails.logger.error "[UserScore#joint] ===> #{operate} is not define."
return false
@ -106,17 +111,19 @@ class UserScore < ActiveRecord::Base
# # => true #当前被关注用户记分成功
#
# Returns boolean. 返回积分保存结果
def self.influence(operate, current_user, target_user, options={})
def self.influence(operate, current_user, target_user,obj, options={})
current_user, target_user = get_users(current_user, target_user)
user_score = target_user.user_score_attr
case operate
when :followed_by # current_user 关注了target_user Add watcher
user_score.influence = user_score.influence.to_i + 2
user_score.save
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "influence",:score_action => "followed_by",:user_id => target_user.id,:old_score => user_score.influence - 2,:new_score => user_score.influence,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#influence] ===> User: #{current_user} be followed. options => (#{options.to_s})"
when :cancel_followed # current_uer 取消了对 target_user的关注 delete watcher
user_score.influence = user_score.influence.to_i - 2
user_score.save
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "influence",:score_action => "cancel_followed",:user_id => target_user.id,:old_score => user_score.influence + 2,:new_score => user_score.influence,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#influence] ===> User: #{current_user} canceled followed. options => (#{options.to_s})"
else
Rails.logger.error "[UserScore#influence] ===> #{operate} is not define."
@ -136,7 +143,7 @@ class UserScore < ActiveRecord::Base
# # => true #当前current_user对target_user用户帖子的记分成功
#
# Returns boolean. 返回积分保存结果
def self.skill(operate, current_user, target_user, options={})
def self.skill(operate, current_user, target_user,obj, options={})
current_user, target_user = get_users(current_user, target_user)
current_user_score = current_user.user_score_attr
target_user_score = target_user.user_score_attr
@ -146,6 +153,7 @@ class UserScore < ActiveRecord::Base
when :treaded_by_user # current_user 踩了 target_user 的帖子
current_user_score.skill = current_user_score.skill.to_i - 2 #踩别人的帖子减2分 add praise_tread
current_user_score.save
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "treaded_by_user",:user_id => current_user.id,:old_score => current_user_score.skill + 2,:new_score => current_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
if current_user.id == target_user.id
target_user.reload
target_user_score = target_user.user_score_attr
@ -154,12 +162,15 @@ class UserScore < ActiveRecord::Base
if level == 1
target_user_score.skill = target_user_score.skill.to_i - 2 #帖子被一级会员踩-2分 add praise_tread
target_user_score.save
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "treaded_by_user",:user_id => target_user.id,:old_score => target_user_score.skill + 2,:new_score => target_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
elsif level == 2
target_user_score.skill = target_user_score.skill.to_i - 4 #帖子被二级会员踩-4分 add praise_tread
target_user_score.save
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "treaded_by_user",:user_id => target_user.id,:old_score => target_user_score.skill + 4,:new_score => target_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
elsif level == 3
target_user_score.skill = target_user_score.skill.to_i - 6 #帖子被三级会员踩-6分 add praise_tread
target_user_score.save
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "treaded_by_user",:user_id => target_user.id,:old_score => target_user_score.skill + 6,:new_score => target_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
end
Rails.logger.info "[UserScore#skill] ===> User: #{current_user} treaded_by #{target_user}. options => (#{options.to_s})"
@ -168,14 +179,16 @@ class UserScore < ActiveRecord::Base
if level == 1
target_user_score.skill = target_user_score.skill.to_i + 4 #帖子被一级会员顶+4分 add praise_tread
target_user_score.save
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "praised_by_user",:user_id => target_user.id,:old_score => target_user_score.skill - 4,:new_score => target_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
elsif level == 2
target_user_score.skill = target_user_score.skill.to_i + 6 #帖子被二级会员顶+6分 add praise_tread
target_user_score.save
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "praised_by_user",:user_id => target_user.id,:old_score => target_user_score.skill - 6,:new_score => target_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
elsif level == 3
target_user_score.skill = target_user_score.skill.to_i + 8 #帖子被三级会员顶+8分 add praise_tread
target_user_score.save
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "praised_by_user",:user_id => target_user.id,:old_score => target_user_score.skill - 8,:new_score => target_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
end
Rails.logger.info "[UserScore#skill] ===> User: #{current_user} praised_by #{target_user}. options => (#{options.to_s})"
else
Rails.logger.error "[UserScore#skill] ===> #{operate} is not define."
@ -195,7 +208,7 @@ class UserScore < ActiveRecord::Base
# # => true #当前current_user对项目贡献积分成功
#
# Returns boolean. 返回积分保存结果
def self.project(operate, current_user, options={})
def self.project(operate, current_user,obj, options={})
current_user, target_user = get_users(current_user, nil)
user_score = current_user.try(:user_score_attr)
return false if current_user.nil?
@ -203,22 +216,27 @@ class UserScore < ActiveRecord::Base
when :push_code # current_user 提交了代码 changeset
user_score = user_score.active.to_i + 4
user_score.save
create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "push_code",:user_id => current_user.id,:old_score => user_score.active - 4,:new_score => user_score.active,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed code one time. options => (#{options.to_s})"
when :push_document # current_user
when :push_document # current_user 提交了文档 document
user_score.active = user_score.active.to_i + 4
user_score.save
create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "push_document",:user_id => current_user.id,:old_score => user_score.active - 4,:new_score => user_score.active,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed a document. options => (#{options.to_s})"
when :push_file # current_user
when :push_file # current_user 提交了附件 attachment
user_score.active = user_score.active.to_i + 4
user_score.save
create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "push_file",:user_id => current_user.id,:old_score => user_score.active - 4,:new_score => user_score.active,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed a file. options => (#{options.to_s})"
when :update_issue_ratio # current_user
when :update_issue_ratio # current_user 更新了缺陷完成度 issue
user_score.active = user_score.active.to_i + 2
user_score.save
create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "update_issue_ratio",:user_id => current_user.id,:old_score => user_score.active - 2,:new_score => user_score.active,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] updated issue ratio. options => (#{options.to_s})"
when :post_issue # current_user
when :post_issue # current_user 发布了缺陷 issue
user_score.active = user_score.active.to_i + 4
user_score.save
create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "post_issue",:user_id => current_user.id,:old_score => user_score.active - 4,:new_score => user_score.active,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] posting issue. options => (#{options.to_s})"
else
Rails.logger.error "[UserScore#project] ===> #{operate} is not define."
@ -228,6 +246,44 @@ class UserScore < ActiveRecord::Base
Rails.logger.error "[UserScore#project] ===> Exception: #{e}."
end
#获取用户的user_score
def self.score(user)
if user.user_score.nil?
us = UserScore.new
us.user_id = user.id
us.save
us
else
user.user_score
end
end
#计算总得分
def total_score
score = self.influence.to_i + self.skill.to_i + self.collaboration.to_i + self.active.to_i
score
end
#创建分数改变记录 -by zjc
def self.create_score_changed_details(attributes)
if attributes.is_a? Hash
usd = UserScoreDetails.new
usd.current_user_id =attributes[:current_user_id]
usd.target_user_id = attributes[:target_user_id]
usd.score_type = attributes[:score_type]
usd.score_action = attributes[:score_action]
usd.user_id = attributes[:user_id]
usd.old_score = attributes[:old_score]
usd.new_score = attributes[:new_score]
usd.current_user_level = attributes[:current_user_level]
usd.target_user_level = attributes[:target_user_level]
#usd.score_changeable_obj = attributes[:score_changeable_obj]
usd.score_changeable_obj_id = attributes[:score_changeable_obj_id]
usd.score_changeable_obj_type = attributes[:score_changeable_obj_type]
usd.save
end
end
private
def self.get_users(current_user, target_user)

View File

@ -0,0 +1,4 @@
class UserScoreDetails < ActiveRecord::Base
attr_accessible :current_user_id, :current_user_level, :new_score, :old_score, :score_action, :score_changeable_obj_id, :score_changeable_obj_type, :score_type, :target_user_id, :target_user_level, :user_id
belongs_to :score_changeable_obj,:polymorphic => true
end

View File

@ -22,7 +22,7 @@ class Watcher < ActiveRecord::Base
has_one :project_status
has_one :users_status
#end
before_save :be_user_score
after_create :be_user_score
before_destroy :down_user_score
validates_presence_of :user
@ -76,9 +76,9 @@ class Watcher < ActiveRecord::Base
# 更新用户分数 -by zjc
def be_user_score
#添加了关注
if self.new_record? && self.watchable_type == 'Principal'
if self.watchable_type == 'Principal'
#影响力得分
UserScore.influence(:followed_by, self.user,self.watchable, { watcher_id: self.id })
UserScore.influence(:followed_by, self.user,self.watchable,self, { watcher_id: self.id })
end
end
@ -86,7 +86,7 @@ class Watcher < ActiveRecord::Base
def down_user_score
#取消关注
if self.watchable_type == 'Principal'
UserScore.influence(:cancel_followed, self.user,self.watchable, { watcher_id: self.id })
UserScore.influence(:cancel_followed, self.user,self.watchable,self, { watcher_id: self.id })
end
end

View File

@ -24,7 +24,8 @@
<% end %>
<% end %>
<% if options[:author] %>
<span class="author"><%= h(attachment.author) %>, <%= format_time(attachment.created_on) %></span>
<!-- modified by zjc author添加超链接 -->
<span class="author"><%= link_to h(attachment.author),user_path(attachment.author) %>, <%= format_time(attachment.created_on) %></span>
<% end %>
</p>
<% end %>

View File

@ -0,0 +1,24 @@
<table style="width: 200px;table-layout: fixed" >
<tr>
<% count = 0 %>
<% for attachment in attachments %>
<% if attachments.count == 1 %>
<td title="<%= attachment.filename%>" style="width: 200px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%= render :partial => 'attachment', :locals => {:attachment => attachment} %>
</td>
<% elsif attachments.count == 2 %>
<td title="<%= attachment.filename%>" style="width: 100px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%= render :partial => 'attachment', :locals => {:attachment => attachment} %>
</td>
<% else %>
<td title="<%= attachment.filename%>" style="width: 66px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<% if count == 3 %>
<% break %>
<% end %>
<%= render :partial => 'attachment', :locals => {:attachment => attachment} %>
<% count = count +1 %>
</td>
<% end %>
<% end %>
</tr>
</table>

View File

@ -0,0 +1,6 @@
<%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
<% if attachment.is_text? %>
<%= link_to image_tag('magnifier.png'),
:controller => 'attachments', :action => 'show',
:id => attachment, :filename => attachment.filename,:style => "width:50px"%>
<% end %>

View File

@ -21,22 +21,50 @@
$.globalEval(submit_homework());
return false;
}
function show()
{
$("#what_is_project_div").slideToggle();
}
</script>
</div>
<% if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? &&
(Member.where('user_id = ? and project_id = ?', User.current.id,
@bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) && cur_user_homework_for_bid(@bid).count == 0 %>
<div class='icon icon-add'>
<!-- <%= link_to l(:label_commit_homework), new_submit_homework_path, :onclick => "$('#put-bid-form').slideToggle(); this.blur(); return false;" %> -->
<%= link_to l(:label_course_new_homework),new_homework_attach_path %>
<%#= link_to l(:label_commit_homework), new_submit_homework_path, :onclick => "$('#put-bid-form').slideToggle(); this.blur(); return false;" %>
<%= link_to l(:label_course_new_homework),new_homework_attach_path %><strong style="color: #a9a9a9">&nbsp;&nbsp;(每一个作业都可以是一个精美的作品)</strong>
</div>
<% end %>
<% if @homework_list.empty? %>
<div class="font_lighter_sidebar" style="padding-left: 10px">
暂无学生提交作业!
</div>
<% end %>
<table style="width: 100%">
<tr>
<td style="width: 50%">
<% if @homework_list.empty? %>
<div class="font_lighter_sidebar" style="padding-left: 10px;">
<span>暂无学生提交作业!</span>
</div>
<% end %>
</td>
<td style="width: 50%">
<div class="font_lighter_sidebar" style="padding-left: 200px;">
<strong><a href="#" onclick="show()" style="color:#919294;">什么是项目?</a></strong>
</div>
</td>
</tr>
<tr>
<td style="width: 50%">
</td>
<td style="width: 50%">
<div id = "what_is_project_div" style="display: none">
<p>项目是一种由用户创建的基于网络的协作空间,能够为个人或小组提供分布式的协同交流和资料管理等方面的支持。</p>
<p>项目托管平台:<a href="http://forge.trustie.net/">http://forge.trustie.net/</a> </p>
<%= link_to "我要创建项目",new_project_path(course: 0, project_type: 0), :target => '_blank'%>
</div>
</td>
</tr>
</table>
<div id='bidding_project_list'>
<%= render :partial => 'homework_list', :locals => {:homework => @homework_list} %>

View File

@ -8,7 +8,7 @@
<table width="100%" valign="center">
<tr>
<td ><span style="margin-left:0px"><%= l(:label_task_plural)%>(<%= @homework_list.count%>)</span>
<%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(
<%#= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(
User.current.admin? ||
!(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) ||
(Rails.env.development?) %>
@ -19,7 +19,9 @@
<%= text_field_tag 'student_id', params[:student_id], :size => 30 %>
<%= submit_tag l(:label_search_by_student_id), :class => "small", :name => nil %>
<% end %>
</div></td>
</div>
</td>
</tr>
</table>
</div>
@ -28,67 +30,19 @@
<% @homework_list.each do |homework|%>
<table width="660px" border="0" align="center" id="homework_attach_<%= homework.id %>" >
<tr>
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
<td>
<table width="580px" border="0">
<td style="vertical-align: top;width: 70px" >
<table style="text-align: center;width: 100%;table-layout: fixed">
<tr>
<td style="width: 300px;">
&nbsp;&nbsp;<strong>作业&nbsp;&nbsp; :</strong>&nbsp;
<% if homework.name == nil || homework.name == "" %>
<% attachments = homework.attachments.map %>
<% for attachment in attachments %>
<% if attachments.count > 1 %>
<% homework_filename = attachment.filename + "等" + attachments.count.to_s + "个文件" %>
<% else %>
<% homework_filename = attachment.filename %>
<% end %>
<% end %>
<% else %>
<% homework_filename = homework.name %>
<% end %>
<strong>
<% if is_evaluation || is_teacher%>
<%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:homework => homework%>
<% else %>
<%= homework_filename %>
<% end %>
</strong>
</td>
<td style="vertical-align: top">
<% if is_student %>
<% if is_evaluation %>
<%= link_to "互评>>" , homework_attach_path(homework)%>
<% else %>
<%= link_to "查看详细" , homework_attach_path(homework)%>
<% end %>
<% else %>
<% if is_teacher %>
<%= link_to "综评>>" , homework_attach_path(homework)%>
<% end %>
<% end %>
<td title="<%= homework.user.name %>"><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
</tr>
<tr>
<td title="<%= homework.user.name %>">
<p style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><strong>
<%= link_to (is_teacher ? homework.user.realname : homework.user ), user_path(homework.user),{:style => "color:#727272"} %>
</strong></p>
</td>
</tr>
<tr>
<td colspan="1" valign="top" style="width: 300px">&nbsp;
<strong>发布人:&nbsp; <%= link_to ( is_teacher ? homework.user.realname : homework.user ), user_path(homework.user)%></strong>
</td>
<td>
<strong>作业评分:</strong>
<%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>
</td>
<td valign="top" align="right">
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
<span class="required">迟交</span>
<% end %>
</td>
</tr>
<tr>
<td valign="top">&nbsp;
<% if User.current.member_of?(@bid.courses.first) %>
<strong><%= l(:label_bidding_user_studentcode) %>&nbsp; &nbsp;<%= homework.user.student_id%></strong>
<% end %>
</td>
<td>
<% if (users_for_homework(homework).include?(User.current) || is_teacher) %>
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
@ -100,6 +54,96 @@
</td>
</tr>
</table>
<span></span>
</td>
<td colspan="2">
<table width="580px" border="0" style="table-layout: fixed">
<tr>
<td style="width: 300px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<strong>作品名称:</strong>&nbsp;
<% if homework.name == nil || homework.name == "" %>
<% homework_filename = homework.user.name + "提交的作业" %>
<% else %>
<% homework_filename = homework.name %>
<% end %>
<strong title="<%=homework_filename%>">
<%= link_to homework_filename , homework_attach_path(homework)%>
</strong>
</td>
<td style="vertical-align: top;width: 200px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<strong>合作成员:&nbsp;</strong>
<% homework_users = homework_user_of_homework(homework,is_teacher) %>
<% if homework.users.count == 0 %>
<% else %>
<span title="<%= homework_users%>"><%= homework_users %></span>
<% end %>
</td>
<td rowspan="4" style="text-align: center;vertical-align: middle;width: 30px">
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
<span class="required">迟交</span>
<% end %>
</td>
</tr>
<tr>
<td>
<strong>开发项目</strong>:&nbsp;
<% if homework.project != nil %>
<%= link_to homework.project.name,project_path(homework.project.id)%>
<% else %>
暂无
<% end %>
</td>
<td>
<strong>项目得分:&nbsp;
<span style="color: #EC6300;">
<% if homework.project != nil %>
<%= project_score homework.project %>
<% else %>
0.00
<% end %>
</span>
</strong>
</td>
</tr>
<tr>
<td>
<strong>提交文件:&nbsp;
<% if is_evaluation || is_teacher%>
<%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%>
<% else %>
<span class="required">未开启互评功能作业不允许下载</span>
<% end %>
</strong>
</td>
<td>
<strong>互评得分:&nbsp;
<span style="color: #EC6300;"><%= student_score_for_homework(homework) %></span>&nbsp;&nbsp;
<% if is_evaluation && is_student && (!users_for_homework(homework).include? User.current)%>
<%= link_to "学生互评>>",homework_attach_path(homework) %>
<% end %>
</strong>
</td>
</tr>
<tr>
<td style="vertical-align: top;width: 200px;">
<% if is_evaluation || is_teacher%>
<%= render :partial => 'app_link', :locals => {:attachments => homework.attachments} %>
<% end %>
</td>
<td>
<strong>终评得分:&nbsp;
<span style="color: #EC6300;"><%= score_for_homework homework %></span>&nbsp;&nbsp;
<% if is_teacher %>
<%= link_to "教师评分>>",homework_attach_path(homework) %>
<% end %>
</strong>
</td>
</tr>
</table>
</td>
</tr>
</table>

View File

@ -2,7 +2,7 @@
<div style="margin-left: 20px;">
<span class="portrait"><%= image_tag(url_to_avatar(@bid.author), :class => "avatar")%></span>
<span class="body">
<h3><%= link_to(@bid.author.lastname+@bid.author.firstname, user_path(@bid.author))%><%= @bid.name %></h3>
<h3><%= link_to(@bid.author.lastname+@bid.author.firstname, user_path(@bid.author))%><%= link_to(@bid.name,respond_path(@bid)) %></h3>
<% if @bid.reward_type.nil? or @bid.reward_type == 1%>
<p>
<strong><%= l(:label_bids_reward_method) %><span class="bonus"><%= l(:label_call_bonus) %>&nbsp; <%= l(:label_RMB_sign) %><%= @bid.budget %></span></strong>

View File

@ -76,7 +76,8 @@
<strong>
<%= l(:label_contest_user) %>
<% unless c_project.user.nil? %>
<%= c_project.user.lastname %><%= c_project.user.firstname %>
<!-- modified by zjc 添加超链接 -->
<%= link_to c_project.user.lastname + c_project.user.firstname,user_path(c_project.user) %>
<% end %>
</strong>

View File

@ -259,7 +259,10 @@
<span><strong><%= l(:label_attendingcontest_time) %>
</strong><%= format_time c_project.created_at %></span>
<span style="padding-left: 240px"><strong><%= l(:label_attendingcontest_spoksman) %>
</strong><%= c_project.user.name %></span>
<!-- modified by zjc 添加超链接 -->
<% unless c_project.nil? || c_project.user.nil? %>
</strong><%= link_to c_project.user.name,user_path(c_project.user) %></span>
<% end %>
</div>
<div style="padding-left: 68px">
@ -293,7 +296,10 @@
<span><strong><%= l(:label_attendingcontest_time) %>
</strong><%= format_time c_softapplication.created_at %></span>
<span style="padding-left: 240px"><strong><%= l(:label_attendingcontest_spoksman) %>
</strong><%= c_softapplication.softapplication.user.name %></span>
<!-- modified by zjc 添加超链接 -->
<% unless c_softapplication.nil? || c_softapplication.softapplication.nil? || c_softapplication.softapplication.user.nil? %>
</strong><%= link_to c_softapplication.softapplication.user.name,user_path(c_softapplication.softapplication.user) %></span>
<% end %>
</div>
<!--获奖及教师评奖-->

View File

@ -1,23 +1,9 @@
<% is_teacher = is_course_teacher User.current,homework.bid.courses.first %>
<% if comprehensive_evaluation != nil && comprehensive_evaluation.count > 0 %>
<% stars = homework.rates(:quality).where("rater_id = #{comprehensive_evaluation.first.user.id}").select("stars").first %>
<div style="height: 100px; padding-bottom: 10px">
<div style="font-size: 15px">
<strong>作业综评:</strong>
<span class="user" style="font-size: 15px">
<div data-kls="HomeworkAttach" data-id="2" data-dimension="quality" data-average="3.25" class="rateable div_inline jDisabled"
style="height: 15px; width: 100px; overflow: hidden; z-index: 1; position: relative;">
<% if stars != nil %>
<div class="jRatingColor" style="width: <%=stars.stars * 2 * 10 %>%;"></div>
<% else %>
<div class="jRatingColor" style="width: 0px;"></div>
<% end %>
<div class="jRatingAverage" style="width: 0px; top: -20px;"></div>
<div class="jStar" style="width: 115px; height: 20px; top: -40px;
background: url('/images/seems_rateable/stars.png') repeat-x scroll 0% 0% transparent;">
</div>
</div>
</span>
<%= render :partial => 'show_score', locals: {:stars => teaher_score} %>
</div>
<div style="font-size: 14px;">
<div style="margin-left: 20px;margin-bottom: 10px;margin-top: 10px;"> <%= comprehensive_evaluation.first.notes%> </div>

View File

@ -0,0 +1,14 @@
<span class="user" style="font-size: 15px">
<div data-kls="HomeworkAttach" data-id="2" data-dimension="quality" data-average="3.25" class="rateable div_inline jDisabled"
style="height: 15px; width: 100px; overflow: hidden; z-index: 1; position: relative;">
<% if stars != nil %>
<div class="jRatingColor" style="width: <%=stars.to_f * 20 %>%;"></div>
<% else %>
<div class="jRatingColor" style="width: 0px;"></div>
<% end %>
<div class="jRatingAverage" style="width: 0px; top: -20px;"></div>
<div class="jStar" style="width: 115px; height: 20px; top: -40px;
background: url('/images/seems_rateable/stars.png') repeat-x scroll 0% 0% transparent;">
</div>
</div>
</span>

View File

@ -1,6 +1,6 @@
<% if @add_jour.is_comprehensive_evaluation == 1 %>
$('#comprehensive_evaluation').html('<%= escape_javascript(render(:partial => 'comprehensive_evaluation',
:locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework} )) %>');
:locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework,:teaher_score => @teaher_score} )) %>');
<% else %>
$('#message').html('<%= escape_javascript(render(:partial => 'showjour', :locals => {:jour =>@jour, :state => false,:homework => @homework} )) %>');
$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => nil})) %>');

View File

@ -1,10 +1,10 @@
<script type="text/javascript">
function switchTab(ProTag) {
var display_index = 3 - ProTag;
document.getElementById("tab" + ProTag).className = "selected";
document.getElementById("tab" + display_index).className = "";
document.getElementById("content" + ProTag).style.display = "";
document.getElementById("content" + display_index).style.display = "none";
$("#tab" + ProTag).attr("class","selected");
$("#tab" + display_index).attr("class","");
$("#content" + ProTag).show();
$("#content" + display_index).hide();
}
</script>
@ -42,11 +42,22 @@
<div class="box" id="content1">
<%= form_for(@homework) do |f|%>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong>标 题:</strong>
<strong>标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题:</strong>&nbsp;
<%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%>
</p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong style="vertical-align: top">描 述:</strong>
<strong>提交项目:</strong>
<% if @homework.project.nil? %>
<%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true%>
<% else %>
<%= f.select :project_id, options_for_select(user_projects_option,@homework.project.id),:name => "project_id", :required => true%>
<% end %>
<%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %>
<p class="font_lighter" style="padding-left:120px;clear:left;">提交项目可以为空</p>
</p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong style="vertical-align: top">描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述:</strong>&nbsp;
<span style="margin-left:-10px;padding-right: 20px;">
<%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
</span>

View File

@ -23,11 +23,17 @@
:bid_id => @bid
}) do |f|%>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong>标 题:</strong>
<strong>标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题:</strong>
<%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>
</p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong style="vertical-align: top">描 述:</strong>
<strong>提交项目:</strong>
<%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true, :style => "width:490px;"%>
<%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %>
<p class="font_lighter" style="padding-left:120px;clear:left;">提交项目可以为空</p>
</p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong style="vertical-align: top">描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述:</strong>
<span style="margin-left:-10px;padding-right: 20px;">
<%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
</span>

View File

@ -49,7 +49,7 @@
</tr>
<tr>
<td style=" padding-left: 40px">平均评分:
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
<%= render :partial => 'show_score', :locals => {:stars => @totle_score} %>
</td>
<td style="width: 240px; word-wrap: break-word; word-break: break-all">发布时间:<%=format_time @homework.created_at %></td>
</tr>
@ -110,17 +110,12 @@
</div>
</div>
<div style="float: left; padding-left: 100px; padding-top:35px ">
<% score = @homework.average(:quality).try(:avg).try(:round, 2).to_s %>
<div style="text-align: center">最终得分</div>
<div style="padding-top: 1px; font-size: 15px; color: blue;text-align: center">
<% if score == "" %>
0分
<% else %>
<%= score %>分
<% end %>
<%= @totle_score %>分
</div>
<div style="padding-top: 3px">
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
<%= render :partial => 'show_score', :locals => {:stars => @totle_score} %>
</div>
</div>
<div style="float: left; padding-left: 100px; padding-top:35px ">
@ -137,7 +132,7 @@
<!-- 作业综评 -->
<div id="comprehensive_evaluation">
<%= render :partial => 'comprehensive_evaluation', :locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework} %>
<%= render :partial => 'comprehensive_evaluation', :locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework, :teaher_score => @teaher_score} %>
</div>
<div class="underline-contests_one"></div>

View File

@ -68,7 +68,7 @@
<td>
<table>
<tr>
<td class="info_font" style=" word-wrap: break-word; word-break: break-all"><%= h @bid.name %></td>
<td class="info_font" style=" word-wrap: break-word; word-break: break-all"><%= link_to @bid.name,bid_path %></td>
</tr>
<% if User.current.login? %>
<tr>
@ -143,7 +143,7 @@
<% if @bid.watcher_users.size>0 %>
<% for user in @bid.watcher_users%>
<%= image_tag(url_to_avatar(user), :class => "avatar", :title => user.name ) %>
<%= link_to image_tag(url_to_avatar(user), :class => "avatar", :title => user.name ),user_path(user) %>
<% end %>
<% else %>
<p class="font_lighter"><%= l(:label_project_no_follow) %></p>
@ -165,7 +165,7 @@
<td style="padding-top: 5px">
<% if @bid.projects.size>0 %>
<% for project in @bid.projects%>
<%= image_tag(url_to_avatar(project), :class => "avatar", :title => project.name) %>
<%= link_to image_tag(url_to_avatar(project), :class => "avatar", :title => project.name),project_path(project) %>
<% end%>
<% else %>
<p class="font_lighter"><%= l(:label_no_bid_project) %></p>

View File

@ -73,7 +73,8 @@
<td>
<table>
<tr>
<td class="info-course"><%= @project.name %></td>
<!-- modified by zjc 课程名称添加超链接 -->
<td class="info-course"><%= link_to @project.name,project_path(@project) %></td>
</tr>
<tr>
<td align="center">
@ -177,10 +178,11 @@
</tr>
<!-- end -->
<% unless @course.teacher.user_extensions.nil? %>
<% unless @course.teacher.user_extensions.nil? || @course.teacher.user_extensions.school.nil? %>
<tr>
<td valign="top" style="padding-left: 8px;"><%= l(:label_teacher_work_unit) %> :</td>
<td class="font_lighter_sidebar"><%= @course.teacher.user_extensions.school %></td>
<!-- modified by zjc 教师单位添加超链接 -->
<td class="font_lighter_sidebar"><%= link_to @course.teacher.user_extensions.school,options={:controller => 'welcome',:action => 'course',:school_id => @course.teacher.user_extensions.school.id}, html_options={:method => 'get'} %></td>
</tr>
<% else %>
<tr>

View File

@ -70,7 +70,8 @@
<tr>
<td style=" word-wrap: break-word; word-break: break-all;font-size: 16px;text-align: center">
<span style=" color:#ed8924">
<strong><%= h @bid.name %></strong>
<!-- modified by zjc 添加超链接 -->
<strong><%=link_to(@bid.name, respond_path(@bid)) %></strong>
</span>
</td>
</tr>
@ -114,7 +115,10 @@
<tr>
<td valign="top" style="padding-left: 8px;"><%= l(:label_teacher_work_unit) %> :</td>
<td class="font_lighter_sidebar"><%= @user.user_extensions.occupation %></td>
<!-- modified by zjc 有@user.user_extensions.occupation改为 @user.user_extensions.school 并添加超链接 -->
<% unless @user.user_extensions.nil? || @user.user_extensions.school.nil? %>
<td class="font_lighter_sidebar"><%= link_to @user.user_extensions.school,options={:controller => 'welcome',:action => 'course',:school_id => @user.user_extensions.school.id}, html_options={:method => 'get'} %></td>
<% end %>
</tr>
</table>
</div>

View File

@ -62,7 +62,7 @@
<td>
<table>
<tr>
<td class="info_font" style=" word-wrap: break-word; word-break: break-all"><%= h @contest.name %></td>
<td class="info_font" style=" word-wrap: break-word; word-break: break-all"><%= link_to @contest.name, show_contest_contest_path(@contest) %></td>
</tr>
<% if User.current.login? %>
<tr colspan='3'>

View File

@ -57,7 +57,7 @@
<td><%= image_tag(url_to_avatar(@project), :class => 'avatar2') %></td>
<td>
<div class="info-course">
<%= @project.name %>
<%= link_to @project.name, project_path(@project)%>
</div>
<div>
<!-- added by bai 增加项目得分 -->

View File

@ -16,8 +16,26 @@
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
<script type="text/javascript">
function startXMLHttp()
{
$.ajax({
url: '<%= update_score_user_path(:format => 'js') %>',
type: 'get',
data: 'id=<%= @user.id %>',
remote: true
}) ;
}
function t()
{
setInterval("startXMLHttp()",5000);
}
</script>
</head>
<body class="<%= h body_css_classes %>">
<!--加上 onload="Javascript:t()" 开始定时刷新分数 -->
<body class="<%= h body_css_classes %>" onload="Javascript:t()">
<div id="wrapper">
<div id="wrapper2">
<div id="wrapper3">
@ -56,7 +74,9 @@
<td>
<table>
<tr>
<td class="info_font" align="center" style=" word-wrap: break-word; word-break: break-all"><%= h (@user.name) %> <!-- added by bai -->
<!-- added by bai -->
<!-- modified by zjc 姓名添加超链接 -->
<td class="info_font" align="center" style=" word-wrap: break-word; word-break: break-all"><%= link_to h (@user.name) %>
<%= image_tag(gender_avatar_uri(@user), weight:"25px", height:"25px") if (@user.user_extensions && (@user.user_extensions.identity != 2) )%></td>
</tr>
<tr>
@ -93,6 +113,14 @@
<% finall_influence_score = news_score + wiki_contents_score + comments_score %>
<% finall_user_score = finall_messages_score + finall_user_project_score + finall_activity_score + finall_influence_score %>
<!-- modified by zjc 新得分显示 -->
<tr><td class="score">
<div id="score_div">
<%= render :partial => 'users/user_score', :locals => {:user => @user}%>
</div>
</td>
</tr>
<!-- end -->
<tr><td class="score">
<%= l(:label_user_grade)%>:
<%= link_to(format("%.2f" , finall_user_score).to_f, {:controller => 'users',
@ -102,7 +130,6 @@
}, :style => 'color :#E8770D;') %>
</td>
</tr>
<!-- end -->
</table></td>
@ -166,12 +193,13 @@
-->
<!-- added by bai 在个人主页里显示“工作单位”“地区”"教师的职称"-->
<!-- modified by linchun 在个人主页里显示“加入时间”,“最后登录”,“邮件地址”后面添加冒号-->
<!-- modified by zjc 高校添加超链接 -->
<% unless @user.user_extensions.nil? %>
<% unless @user.user_extensions.identity == 2 %>
<tr>
<td style="padding-left: 5px" width="70px"><%= l(:field_occupation) %></td><td class="font_lighter_sidebar" style="padding-left: 0px" width="170px">
<% unless @user.user_extensions.school.nil? %>
<%= @user.user_extensions.school.name %>
<%= link_to @user.user_extensions.school.name, options={:controller => 'welcome',:action => 'course',:school_id => @user.user_extensions.school.id}, html_options={:method => 'get'} %>
<% end %>
</td>
</tr>

View File

@ -48,15 +48,17 @@
<div class="memo-title <%= @memo.sticky ? 'sticky' : '' %> <%= @memo.locked? ? 'locked' : '' %>"><%= label_tag l(:field_subject) %>: <%=h @memo.subject %></div>
<div class="memo-content">
<%= raw @memo.content %>
<%=h sanitize(@memo.content.html_safe) %>
<p>
<% if @memo.attachments.any?%>
<% options = {:author => true, :deletable => @memo.deleted_attach_able_by?(User.current) } %>
<%= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options} %>
<% end %>
</p>
<div class="clearfix"></div>
</div>
<div class="memo-timestamp"> <%= authoring @memo.created_at, @memo.author.name %></div>
<!-- modified by zjc 修正名字无链接问题 -->
<div class="memo-timestamp"> <%= authoring @memo.created_at, @memo.author %></div>
</div>
<br />
@ -121,7 +123,8 @@
</td>
</tr>
<tr>
<td class="font_lighter" style="float:right"><%= authoring reply.created_at, reply.author.name %></td>
<!-- modified by zjc 修正名字无链接问题 -->
<td class="font_lighter" style="float:right"><%= authoring reply.created_at, reply.author %></td>
</tr>
</table>
</div>

View File

@ -29,6 +29,15 @@
<% else %>
<% if user_id == obj.author_id %>
<table style="line-height: 1px">
<tr>
<td ><%= image_tag "/images/praise_tread/praise_true.png" , weight:"22px", height:"22px",:title => l(:label_issue_not_praise_over) %></td>
<td align="center"><strong class="font_small_watch"><%= get_praise_num(obj)%></strong></td>
<td><%= image_tag "/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issue_not_treed_over) %></td>
</tr>
</table>
<% else %>
<table style="line-height: 1px">
<tr>
<td > <%= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)),
@ -38,6 +47,8 @@
:action=>"tread_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class,:horizontal => horizontal %></td>
</tr>
</table>
<% end %>
<!-- end -->
<% end %>
</div>
@ -80,7 +91,20 @@
<% end %>
<% else %>
<% if user_id == obj.author_id %>
<table style="line-height: 1px">
<tr>
<td > <%= image_tag "/images/praise_tread/praise_true.png",weight:"22px", height:"22px", :title => l(:label_issue_not_praise_over) %></td>
</tr>
<tr>
<td align="center"><strong class="font_small_watch"><%= get_praise_num(obj)%></strong></td>
</tr>
<tr>
<td><%= image_tag "/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issue_not_tread_over) %> </td>
</tr>
</table>
<% else %>
<table style="line-height: 1px">
<tr>
<td > <%= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)),
@ -94,6 +118,8 @@
:action=>"tread_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class ,:horizontal => horizontal %></td>
</tr>
</table>
<% end %>
<!-- end -->
<% end %>
</div>

View File

@ -18,7 +18,11 @@
<%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%>
<!-- <%= @admin.first.user.user_extensions.occupation %> -->
<%# unless @project.course_extra.school.nil? %>
<%= @project.course_extra.teacher.user_extensions.school.try(:name) %>
<!-- modified by zjc 单位名称添加超链接 -->
<% unless @project.course_extra.teacher.user_extensions.school.nil? %>
<%= link_to @project.course_extra.teacher.user_extensions.school.try(:name),options={:controller => 'welcome',:action => 'course',:school_id => @project.course_extra.teacher.user_extensions.school.id}, html_options={:method => 'get'}%>
<% end %>
<%# end %>
<% end %>
</p>

View File

@ -0,0 +1,34 @@
<!-- added by bai -->
<% messages_count = @user.messages.count %>
<% messages_score = messages_count * 0.05%>
<% finall_messages_score = messages_score %>
<% journals_count = @user.journals.count %>
<% journals_score = journals_count * 0.1 %>
<% user_changesets_count = @user.changesets.count %>
<% user_changesets_score = user_changesets_count * 0.3 %>
<% finall_user_project_score = journals_score + user_changesets_score %>
<% journals_for_messages_count = @user.journals_messages.count %>
<% activities_count = @user.activities.count %>
<% journals_for_messages_score = journals_for_messages_count * 0.05 %>
<% activities_score = activities_count * 0.2 %>
<% finall_activity_score = journals_for_messages_score + activities_score %>
<% news_count = @user.news.count %>
<% news_score = news_count * 0.1 %>
<% wiki_contents_count = @user.wiki_contents.count %>
<% wiki_contents_score = wiki_contents_count * 0.1 %>
<% comments_count = @user.comments.count %>
<% comments_score = comments_count * 0.1 %>
<% finall_influence_score = news_score + wiki_contents_score + comments_score %>
<% finall_user_score = finall_messages_score + finall_user_project_score + finall_activity_score + finall_influence_score %>
<div><%= l(:label_user_score) %></div>
<div> = <%= l(:label_user_score_of_collaboration) %> + <%= l(:label_user_score_of_influence) %> +
<%= l(:label_user_score_of_skill)%> + <%= l(:label_user_score_of_active) %></div>
<!-- <div>&nbsp;&nbsp;&nbsp;+ <%= l(:label_user_score_of_influence) %></div> -->
<div> = <%= format("%.2f" ,@user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence ).to_f %>
+ <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %></div>
<div> = <%= format("%.2f" ,@user.user_score_attr.total_score.nil? ? 0:@user.user_score_attr.total_score).to_f %></div>
<!-- end -->

View File

@ -0,0 +1,76 @@
<!-- added by bai -->
<% messages_count = @user.messages.count %>
<% messages_score = messages_count * 0.05%>
<% finall_messages_score = messages_score %>
<% journals_count = @user.journals.count %>
<% journals_score = journals_count * 0.1 %>
<% user_changesets_count = @user.changesets.count %>
<% user_changesets_score = user_changesets_count * 0.3 %>
<% finall_user_project_score = journals_score + user_changesets_score %>
<% journals_for_messages_count = @user.journals_messages.count %>
<% activities_count = @user.activities.count %>
<% journals_for_messages_score = journals_for_messages_count * 0.05 %>
<% activities_score = activities_count * 0.2 %>
<% finall_activity_score = journals_for_messages_score + activities_score %>
<% news_count = @user.news.count %>
<% news_score = news_count * 0.1 %>
<% wiki_contents_count = @user.wiki_contents.count %>
<% wiki_contents_score = wiki_contents_count * 0.1 %>
<% comments_count = @user.comments.count %>
<% comments_score = comments_count * 0.1 %>
<% finall_influence_score = news_score + wiki_contents_score + comments_score %>
<% finall_user_score = finall_messages_score + finall_user_project_score + finall_activity_score + finall_influence_score %>
<h3 class="title"><%= l(:label_user_score) %></h3>
<div class="inf_user_image">
<table style="border-bottom: solid 1px #80a6d2;" width="100%">
<tr>
<td align="left" valign="middle" ><%= image_tag(url_to_avatar(@user), :class => 'avatar2') %></td>
<td width="35%">
<table>
<tr class="info_font" align="center" style=" word-wrap: break-word; word-break: break-all"><td><%= h @user.name %></td></tr>
<tr class="info_font" align="left" style=" word-wrap: break-word; word-break: break-all"><td><%= @user.user_extensions.show_identity %></td></tr>
</table>
</td>
<td>
<table>
<tr class="info_font"><td><%= l(:label_user_score) %></td></tr>
<tr class="buttons_for_score" style="margin-top:30px;margin-left:144px"><td><span style="color:#ec6300"><%= format("%.2f" , @user.user_score_attr.total_score).to_f %></span></td></tr>
</table>
</td>
</tr>
</table>
<table style="border-bottom: solid 0px #80a6d2;" width="100%">
<tr>
<%= l(:label_user_score) %> :
<%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
</tr><br>
<tr>
<%= l(:label_user_score_of_collaboration) %> :
<%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %>
</tr><br>
<tr>
<%= l(:label_user_score_of_influence) %> :
<%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_f %>
</tr><br>
<tr>
<%= l(:label_user_score_of_skill) %> :
<%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %>
</tr><br>
<tr>
<%= l(:label_user_score_of_active) %>
<%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %>
</tr><br>
</table>
</div>
<div id="show_score_detail" style="padding-left: 6px">
<%= render :partial => 'users/score_new_index', :locals => {:index => 0 } %>
</div>

View File

@ -0,0 +1,6 @@
<div>协同得分:</div>
<div>&nbsp;&nbsp;&nbsp; 发帖 +2</div>
<div>&nbsp;&nbsp;&nbsp; 对缺陷留言 +1</div>
<div>&nbsp;&nbsp;&nbsp; 更改一次缺陷状态 +1</div>
<div>&nbsp;&nbsp;&nbsp; 对留言的回复 +1</div>
<div>&nbsp;&nbsp;&nbsp; 对帖子的回复 +1</div>

View File

@ -0,0 +1,6 @@
<%= l(:label_user_grade)%>:
<%= link_to(format("%.2f" , @user.user_score_attr.total_score).to_f, {:controller => 'users',
:action => 'show_new_score',
:remote => true,
:id => user.id
}, :style => 'color :#E8770D;',:id => 'user_score') %>

View File

@ -0,0 +1,3 @@
<!-- added by bai -->
$('#show_score_detail').html('<%= escape_javascript(render :partial => 'users/score_new_index', :locals => {:index =>0 }) %>');
<!-- end -->

View File

@ -0,0 +1,3 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_new_score') %>');
showModal('ajax-modal', '400px');
$('#ajax-modal').addClass('new-watcher');

View File

@ -0,0 +1,3 @@
<!-- added by bai -->
$('#show_score_detail').html('<%= escape_javascript(render :partial => 'users/topic_new_score_index', :locals => {:index =>0 }) %>');
<!-- end -->

View File

@ -0,0 +1,2 @@
$('#score_div').html('<%= escape_javascript(render(:partial => 'users/user_score',
:locals => {:user => @user} )) %>');

View File

@ -1,24 +1,27 @@
<!--add by huang-->
<h3><%= l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count)%></h3>
<h3><%= l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count) %></h3>
<div class="inf_user_image">
<% for user in @user.watcher_users %>
<ul class="list_watch"><li>
<table width="660px" border="0" align="center">
<ul class="list_watch">
<li>
<table width="660px" border="0" align="center">
<tr>
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(user), :class => "avatar"),
<td colspan="2" valign="top" width="50"><%= link_to image_tag(url_to_avatar(user), :class => "avatar"),
user_path(user),
:title => "#{user.name}" %></td>
<td><table width="580px" border="0">
<td>
<table width="580px" border="0">
<tr> <!-- modified by bai -->
<td colspan="2" valign="top"><strong><%= content_tag "div", link_to(user.name,user_path(user)), :class => "project_avatar_name" %>
<td colspan="2" valign="top">
<strong><%= content_tag "div", link_to(user.name, user_path(user)), :class => "project_avatar_name" %></strong>
</td>
</tr>
<tr>
<!-- added by bai 区分了个人列表里的项目与课程 -->
<td colspan="2" width="580px" ><p class="font_description">
<td colspan="2" width="580px"><p class="font_description">
<% unless user.memberships.empty? %>
<% cond = Project.visible_condition(User.current) + "AND projects.project_type <> 1" %>
<% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %>
<% memberships = user.memberships.all(:conditions => cond) %>
<%= l(:label_x_contribute_to, :count => memberships.count) %>
<% for member in memberships %>
@ -26,9 +29,10 @@
<% end %>
<% end %>
</p>
<p class="font_description">
<% unless user.memberships.empty? %>
<% cond = Project.visible_condition(User.current) + "AND projects.project_type = 1" %>
<% cond = Project.visible_condition(User.current) + " AND projects.project_type = 1" %>
<% memberships = user.memberships.all(:conditions => cond) %>
<%= l(:label_x_course_contribute_to, :count => memberships.count) %>
<% for member in memberships %>
@ -44,8 +48,11 @@
<td width="200" align="right" class="font_lighter"><%= l(:label_user_joinin) %><%= format_date(user.created_on) %>
</td>
</tr>
</table></td>
</table>
</td>
</tr>
</table></li></ul>
<% end %>
</table>
</li>
</ul>
<% end %>
</div>

View File

@ -98,7 +98,7 @@
<% if(course.school == nil) %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% else %>
<%= course.school.name.try(:gsub, /(.+)$/, '\1:') %>
<%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course',:school_id => course.school.id}, html_options={:method => 'get'}%>
<% end %>
</span>
<span class='font_bolder'>
@ -151,7 +151,7 @@
<div class='desc_item' >
<span class=''>
<% course = Course.find_by_extra(project.identifier) %>
<%= course.school.name.try(:gsub, /(.+)$/, '\1:') %>
<%=link_to course.school.name.try(:gsub, /(.+)$/, '\1:'),options={:action => 'course',:school_id => course.school.id}, html_options={:method => 'get'} %>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
@ -193,7 +193,8 @@
<% if(course.school == nil) %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% else %>
<%= course.school.name.try(:gsub, /(.+)$/, '\1:') %>
<!-- modified by zjc 添加超链接 -->
<%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course',:school_id => course.school.id}, html_options={:method => 'get'}%>
<% end %>
</span>
<span class='font_bolder'>

View File

@ -1537,6 +1537,8 @@ zh:
label_issue_tread: 烂问题,踩!
label_issue_praise_over: 我刚才顶过了~
label_issue_tread_over: 我刚才踩过了~
label_issue_not_praise_over: 不能顶自己~
label_issue_not_treed_over: 不能踩自己~
#end
label_goto: 前往>>
label_issue_appraise_over: 只能评价一次哦!
@ -1677,6 +1679,9 @@ zh:
label_user_score_of_project: 项目得分
label_user_score_of_activity: 活跃度得分
label_user_score_of_influence: 影响力得分
label_user_score_of_collaboration: 协同得分
label_user_score_of_skill: 技术得分
label_user_score_of_active: 项目贡献得分
label_question_top: 问题被顶次数
label_question_down: 问题被踩次数
label_answer_top: 回答被顶次数

View File

@ -232,6 +232,14 @@ RedmineApp::Application.routes.draw do
match 'influence_score_index', :to => 'users#influence_score_index', :via => :get
match 'score_index', :to => 'users#score_index', :via => :get
match 'show_new_score', :to => 'users#show_new_score', :via => :get
match 'topic_new_score_index', :controller => 'users', :action => 'topic_new_score_index', :via => [:get, :post]
match 'project_new_score_index', :to => 'users#project_new_score_index', :via => :get
match 'activity_new_score_index', :to => 'users#activity_new_score_index', :via => :get
match 'influence_new_score_index', :to => 'users#influence_new_score_index', :via => :get
match 'score_new_index', :to => 'users#score_new_index', :via => :get
match 'update_score', :to => 'users#update_score', :via => [:get,:post]
match 'show_projects_score', :to => 'projects#show_projects_score', :via => [:get, :post]
match 'issue_score_index', :to => 'projects#issue_score_index', :via => [:get, :post]
match 'news_score_index', :to => 'projects#news_score_index', :via => [:get, :post]

View File

@ -0,0 +1,19 @@
class CreateUserScoreDetails < ActiveRecord::Migration
def change
create_table :user_score_details do |t|
t.integer :current_user_id
t.integer :target_user_id
t.string :score_type
t.string :score_action
t.integer :user_id
t.integer :old_score
t.integer :new_score
t.integer :current_user_level
t.integer :target_user_level
t.integer :score_changeable_obj_id
t.string :score_changeable_obj_type
t.timestamps
end
end
end

View File

@ -0,0 +1,5 @@
class AddProjectIdToHomeworkAttach < ActiveRecord::Migration
def change
add_column :homework_attaches, :project_id, :integer, default: 0
end
end

View File

@ -0,0 +1,25 @@
class RemoveDataToHomeworkAttach < ActiveRecord::Migration
def up
bidding_projects = BidingProject.joins(:bid).where("bids.reward_type = 3")
bidding_projects.each do |biding|
homework = HomeworkAttach.new
homework.project_id = biding.project_id
homework.bid_id = biding.bid_id
homework.created_at = biding.created_at
homework.updated_at = biding.updated_at
homework.reward = biding.reward
homework.description = biding.description
homework.user_id = biding.user_id
homework.state = 0
homework.save
end
end
def down
bidding_projects = BidingProject.joins(:bid).where("bids.reward_type = 3")
bidding_projects.each do |biding|
homework = HomeworkAttach.where("bid_id = #{biding.bid_id} and user_id = #{biding.user_id}")
homework.first.destroy
end
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140609061903) do
ActiveRecord::Schema.define(:version => 20140618020535) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -206,6 +206,17 @@ ActiveRecord::Schema.define(:version => 20140609061903) do
t.string "reward"
end
create_table "contestnotifications", :force => true do |t|
t.integer "contest_id"
t.string "title"
t.string "summary"
t.string "description"
t.integer "author_id"
t.integer "notificationcomments_count"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "contests", :force => true do |t|
t.string "name"
t.string "budget", :default => ""
@ -343,6 +354,7 @@ ActiveRecord::Schema.define(:version => 20140609061903) do
t.string "name"
t.string "description"
t.integer "state"
t.integer "project_id", :default => 0
end
create_table "homework_for_courses", :force => true do |t|
@ -567,6 +579,15 @@ ActiveRecord::Schema.define(:version => 20140609061903) do
t.datetime "updated_at", :null => false
end
create_table "notificationcomments", :force => true do |t|
t.string "notificationcommented_type"
t.integer "notificationcommented_id"
t.integer "author_id"
t.text "notificationcomments"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "open_id_authentication_associations", :force => true do |t|
t.integer "issued"
t.integer "lifetime"
@ -692,7 +713,7 @@ ActiveRecord::Schema.define(:version => 20140609061903) do
end
create_table "relative_memos", :force => true do |t|
t.integer "osp_id", :null => false
t.integer "osp_id"
t.integer "parent_id"
t.string "subject", :null => false
t.text "content", :null => false
@ -923,6 +944,22 @@ ActiveRecord::Schema.define(:version => 20140609061903) do
add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id"
create_table "user_score_details", :force => true do |t|
t.integer "current_user_id"
t.integer "target_user_id"
t.string "score_type"
t.string "score_action"
t.integer "user_id"
t.integer "old_score"
t.integer "new_score"
t.integer "current_user_level"
t.integer "target_user_level"
t.integer "score_changeable_obj_id"
t.string "score_changeable_obj_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "user_scores", :force => true do |t|
t.integer "user_id"
t.integer "collaboration"

BIN
doc/测试环境搭建.doc Normal file

Binary file not shown.

View File

@ -2,9 +2,9 @@ require 'rexml/document'
module Redmine
module VERSION #:nodoc:
MAJOR = 1
MINOR = 0
TINY = 0
MAJOR = 2
MINOR = 3
TINY = 2
# Branch values:
# * official release: nil

View File

@ -21,7 +21,7 @@ namespace :user_score do
Journal.includes(:user).all.each do |j|
users[j.user.id] = users[j.user.id].to_i + 1
end
puts ":post_issue calculate Completed. collaboration users count: #{users.count}"
puts ":post_issue_message calculate Completed. collaboration users count: #{users.count}"
# 更改一次缺陷状态
Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id'").each do |j|
@ -75,7 +75,7 @@ namespace :user_score do
next
end
target_user = obj.author
level = pt.user.get_level
level = UserLevels.get_level(pt.user)#pt.user.get_level
if pt.praise_or_tread == 0
#踩帖
users_skill[pt.user.id] = users_skill[pt.user.id].to_i - 2 #踩别人帖-2分

View File

@ -0,0 +1,23 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<title>文件未找到</title>
<style>
body{
font-family: Trebuchet MS,Georgia,"Times New Roman",serif;
color:#303030;
margin:10px;
}
h1{
font-size:1.5em;
}
p{
font-size:0.8em;
}
</style>
<body>
<h1>文件已经损坏</h1>
<p>抱歉,因文件已经损坏,请重新上传此文件.</p>
<p><a href="javascript:history.back()">Back</a></p>
</body>
</html>

View File

@ -0,0 +1,97 @@
# Redmine - project management software
# Copyright (C) 2006-2013 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../test_case', __FILE__)
require 'tmpdir'
class RedminePmTest::RepositoryGitTest < RedminePmTest::TestCase
fixtures :projects, :users, :members, :roles, :member_roles
GIT_BIN = Redmine::Configuration['scm_git_command'] || "git"
def test_anonymous_read_on_public_repo_with_permission_should_succeed
assert_success "ls-remote", git_url
end
def test_anonymous_read_on_public_repo_without_permission_should_fail
Role.anonymous.remove_permission! :browse_repository
assert_failure "ls-remote", git_url
end
def test_invalid_credentials_should_fail
Project.find(1).update_attribute :is_public, false
with_credentials "dlopper", "foo" do
assert_success "ls-remote", git_url
end
with_credentials "dlopper", "wrong" do
assert_failure "ls-remote", git_url
end
end
def test_clone
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
assert_success "clone", git_url
end
end
end
def test_write_commands
Role.find(2).add_permission! :commit_access
filename = random_filename
Dir.mktmpdir do |dir|
assert_success "clone", git_url, dir
Dir.chdir(dir) do
f = File.new(File.join(dir, filename), "w")
f.write "test file content"
f.close
with_credentials "dlopper", "foo" do
assert_success "add", filename
assert_success "commit -a --message Committing_a_file"
assert_success "push", git_url, "--all"
end
end
end
Dir.mktmpdir do |dir|
assert_success "clone", git_url, dir
Dir.chdir(dir) do
assert File.exists?(File.join(dir, "#{filename}"))
end
end
end
protected
def execute(*args)
a = [GIT_BIN]
super a, *args
end
def git_url(path=nil)
host = ENV['REDMINE_TEST_DAV_SERVER'] || '127.0.0.1'
credentials = nil
if username && password
credentials = "#{username}:#{password}"
end
url = "http://#{credentials}@#{host}/git/ecookbook"
url << "/#{path}" if path
url
end
end

View File

@ -0,0 +1,294 @@
# Redmine - project management software
# Copyright (C) 2006-2013 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../test_case', __FILE__)
require 'tmpdir'
class RedminePmTest::RepositorySubversionTest < RedminePmTest::TestCase
fixtures :projects, :users, :members, :roles, :member_roles, :auth_sources
SVN_BIN = Redmine::Configuration['scm_subversion_command'] || "svn"
def test_anonymous_read_on_public_repo_with_permission_should_succeed
assert_success "ls", svn_url
end
def test_anonymous_read_on_public_repo_without_permission_should_fail
Role.anonymous.remove_permission! :browse_repository
assert_failure "ls", svn_url
end
def test_anonymous_read_on_private_repo_should_fail
Project.find(1).update_attribute :is_public, false
assert_failure "ls", svn_url
end
def test_anonymous_commit_on_public_repo_should_fail
Role.anonymous.add_permission! :commit_access
assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
end
def test_anonymous_commit_on_private_repo_should_fail
Role.anonymous.add_permission! :commit_access
Project.find(1).update_attribute :is_public, false
assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
end
def test_non_member_read_on_public_repo_with_permission_should_succeed
Role.anonymous.remove_permission! :browse_repository
with_credentials "miscuser8", "foo" do
assert_success "ls", svn_url
end
end
def test_non_member_read_on_public_repo_without_permission_should_fail
Role.anonymous.remove_permission! :browse_repository
Role.non_member.remove_permission! :browse_repository
with_credentials "miscuser8", "foo" do
assert_failure "ls", svn_url
end
end
def test_non_member_read_on_private_repo_should_fail
Project.find(1).update_attribute :is_public, false
with_credentials "miscuser8", "foo" do
assert_failure "ls", svn_url
end
end
def test_non_member_commit_on_public_repo_should_fail
Role.non_member.add_permission! :commit_access
assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
end
def test_non_member_commit_on_private_repo_should_fail
Role.non_member.add_permission! :commit_access
Project.find(1).update_attribute :is_public, false
assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
end
def test_member_read_on_public_repo_with_permission_should_succeed
Role.anonymous.remove_permission! :browse_repository
Role.non_member.remove_permission! :browse_repository
with_credentials "dlopper", "foo" do
assert_success "ls", svn_url
end
end
def test_member_read_on_public_repo_without_permission_should_fail
Role.anonymous.remove_permission! :browse_repository
Role.non_member.remove_permission! :browse_repository
Role.find(2).remove_permission! :browse_repository
with_credentials "dlopper", "foo" do
assert_failure "ls", svn_url
end
end
def test_member_read_on_private_repo_with_permission_should_succeed
Project.find(1).update_attribute :is_public, false
with_credentials "dlopper", "foo" do
assert_success "ls", svn_url
end
end
def test_member_read_on_private_repo_without_permission_should_fail
Role.find(2).remove_permission! :browse_repository
Project.find(1).update_attribute :is_public, false
with_credentials "dlopper", "foo" do
assert_failure "ls", svn_url
end
end
def test_member_commit_on_public_repo_with_permission_should_succeed
Role.find(2).add_permission! :commit_access
with_credentials "dlopper", "foo" do
assert_success "mkdir --message Creating_a_directory", svn_url(random_filename)
end
end
def test_member_commit_on_public_repo_without_permission_should_fail
Role.find(2).remove_permission! :commit_access
with_credentials "dlopper", "foo" do
assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
end
end
def test_member_commit_on_private_repo_with_permission_should_succeed
Role.find(2).add_permission! :commit_access
Project.find(1).update_attribute :is_public, false
with_credentials "dlopper", "foo" do
assert_success "mkdir --message Creating_a_directory", svn_url(random_filename)
end
end
def test_member_commit_on_private_repo_without_permission_should_fail
Role.find(2).remove_permission! :commit_access
Project.find(1).update_attribute :is_public, false
with_credentials "dlopper", "foo" do
assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
end
end
def test_invalid_credentials_should_fail
Project.find(1).update_attribute :is_public, false
with_credentials "dlopper", "foo" do
assert_success "ls", svn_url
end
with_credentials "dlopper", "wrong" do
assert_failure "ls", svn_url
end
end
def test_anonymous_read_should_fail_with_login_required
assert_success "ls", svn_url
with_settings :login_required => '1' do
assert_failure "ls", svn_url
end
end
def test_authenticated_read_should_succeed_with_login_required
with_settings :login_required => '1' do
with_credentials "miscuser8", "foo" do
assert_success "ls", svn_url
end
end
end
def test_read_on_archived_projects_should_fail
Project.find(1).update_attribute :status, Project::STATUS_ARCHIVED
assert_failure "ls", svn_url
end
def test_read_on_archived_private_projects_should_fail
Project.find(1).update_attribute :status, Project::STATUS_ARCHIVED
Project.find(1).update_attribute :is_public, false
with_credentials "dlopper", "foo" do
assert_failure "ls", svn_url
end
end
def test_read_on_closed_projects_should_succeed
Project.find(1).update_attribute :status, Project::STATUS_CLOSED
assert_success "ls", svn_url
end
def test_read_on_closed_private_projects_should_succeed
Project.find(1).update_attribute :status, Project::STATUS_CLOSED
Project.find(1).update_attribute :is_public, false
with_credentials "dlopper", "foo" do
assert_success "ls", svn_url
end
end
def test_commit_on_closed_projects_should_fail
Project.find(1).update_attribute :status, Project::STATUS_CLOSED
Role.find(2).add_permission! :commit_access
with_credentials "dlopper", "foo" do
assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
end
end
def test_commit_on_closed_private_projects_should_fail
Project.find(1).update_attribute :status, Project::STATUS_CLOSED
Project.find(1).update_attribute :is_public, false
Role.find(2).add_permission! :commit_access
with_credentials "dlopper", "foo" do
assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
end
end
if ldap_configured?
def test_user_with_ldap_auth_source_should_authenticate_with_ldap_credentials
ldap_user = User.new(:mail => 'example1@redmine.org', :firstname => 'LDAP', :lastname => 'user', :auth_source_id => 1)
ldap_user.login = 'example1'
ldap_user.save!
with_settings :login_required => '1' do
with_credentials "example1", "123456" do
assert_success "ls", svn_url
end
end
with_settings :login_required => '1' do
with_credentials "example1", "wrong" do
assert_failure "ls", svn_url
end
end
end
end
def test_checkout
Dir.mktmpdir do |dir|
assert_success "checkout", svn_url, dir
end
end
def test_read_commands
assert_success "info", svn_url
assert_success "ls", svn_url
assert_success "log", svn_url
end
def test_write_commands
Role.find(2).add_permission! :commit_access
filename = random_filename
Dir.mktmpdir do |dir|
assert_success "checkout", svn_url, dir
Dir.chdir(dir) do
# creates a file in the working copy
f = File.new(File.join(dir, filename), "w")
f.write "test file content"
f.close
assert_success "add", filename
with_credentials "dlopper", "foo" do
assert_success "commit --message Committing_a_file"
assert_success "copy --message Copying_a_file", svn_url(filename), svn_url("#{filename}_copy")
assert_success "delete --message Deleting_a_file", svn_url(filename)
assert_success "mkdir --message Creating_a_directory", svn_url("#{filename}_dir")
end
assert_success "update"
# checks that the working copy was updated
assert File.exists?(File.join(dir, "#{filename}_copy"))
assert File.directory?(File.join(dir, "#{filename}_dir"))
end
end
end
def test_read_invalid_repo_should_fail
assert_failure "ls", svn_url("invalid")
end
protected
def execute(*args)
a = [SVN_BIN, "--no-auth-cache --non-interactive"]
a << "--username #{username}" if username
a << "--password #{password}" if password
super a, *args
end
def svn_url(path=nil)
host = ENV['REDMINE_TEST_DAV_SERVER'] || '127.0.0.1'
url = "http://#{host}/svn/ecookbook"
url << "/#{path}" if path
url
end
end

View File

@ -0,0 +1,81 @@
# Redmine - project management software
# Copyright (C) 2006-2013 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../../test_helper', __FILE__)
module RedminePmTest
class TestCase < ActiveSupport::TestCase
attr_reader :command, :response, :status, :username, :password
# Cannot use transactional fixtures here: database
# will be accessed from Redmine.pm with its own connection
self.use_transactional_fixtures = false
def test_dummy
end
protected
def assert_response(expected, msg=nil)
case expected
when :success
assert_equal 0, status,
(msg || "The command failed (exit: #{status}):\n #{command}\nOutput was:\n#{formatted_response}")
when :failure
assert_not_equal 0, status,
(msg || "The command succeed (exit: #{status}):\n #{command}\nOutput was:\n#{formatted_response}")
else
assert_equal expected, status, msg
end
end
def assert_success(*args)
execute *args
assert_response :success
end
def assert_failure(*args)
execute *args
assert_response :failure
end
def with_credentials(username, password)
old_username, old_password = @username, @password
@username, @password = username, password
yield if block_given?
ensure
@username, @password = old_username, old_password
end
def execute(*args)
@command = args.join(' ')
@status = nil
IO.popen("#{command} 2>&1") do |io|
@response = io.read
end
@status = $?.exitstatus
end
def formatted_response
"#{'='*40}\n#{response}#{'='*40}"
end
def random_filename
Redmine::Utils.random_hex(16)
end
end
end

View File

@ -267,31 +267,3 @@ attachments_020:
filename: root_attachment.txt
filesize: 54
author_id: 2
attachments_021:
content_type: text/plain
downloads: 0
created_on: 2012-05-12 16:14:50 +09:00
disk_filename: 120512161450_project_test.txt
disk_directory:
container_id: 2
digest: b0fe2abdb2599743d554a61d7da7ff74
id: 21
container_type: Project
description: ""
filename: project_test.txt
filesize: 54
author_id: 2
attachments_022:
content_type: text/plain
downloads: 0
created_on: 2012-05-12 16:14:50 +09:00
disk_filename: 120512161450_course_test.txt
disk_directory:
container_id: 1
digest: b0fe2abdb2599743d554a61d7da7ff74
id: 22
container_type: Project
description: ""
filename: course_test.txt
filesize: 54
author_id: 2

13
test/fixtures/auth_sources.yml vendored Normal file
View File

@ -0,0 +1,13 @@
---
auth_sources_001:
id: 1
type: AuthSourceLdap
name: 'LDAP test server'
host: '127.0.0.1'
port: 389
base_dn: 'OU=Person,DC=redmine,DC=org'
attr_login: uid
attr_firstname: givenName
attr_lastname: sn
attr_mail: mail
onthefly_register: false

22
test/fixtures/changes.yml vendored Normal file
View File

@ -0,0 +1,22 @@
---
changes_001:
id: 1
changeset_id: 100
action: A
path: /test/some/path/in/the/repo
from_path:
from_revision:
changes_002:
id: 2
changeset_id: 100
action: A
path: /test/some/path/elsewhere/in/the/repo
from_path:
from_revision:
changes_003:
id: 3
changeset_id: 101
action: M
path: /test/some/path/in/the/repo
from_path:
from_revision:

104
test/fixtures/changesets.yml vendored Normal file
View File

@ -0,0 +1,104 @@
---
changesets_001:
commit_date: 2007-04-11
committed_on: 2007-04-11 15:14:44 +02:00
revision: 1
scmid: 691322a8eb01e11fd7
id: 100
comments: 'My very first commit do not escaping #<>&'
repository_id: 10
committer: dlopper
user_id: 3
changesets_002:
commit_date: 2007-04-12
committed_on: 2007-04-12 15:14:44 +02:00
revision: 2
id: 101
comments: 'This commit fixes #1, #2 and references #1 & #3'
repository_id: 10
committer: dlopper
user_id: 3
changesets_003:
commit_date: 2007-04-12
committed_on: 2007-04-12 15:14:44 +02:00
revision: 3
id: 102
comments: |-
A commit with wrong issue ids
IssueID #666 #3
repository_id: 10
committer: dlopper
user_id: 3
changesets_004:
commit_date: 2007-04-12
committed_on: 2007-04-12 15:14:44 +02:00
revision: 4
id: 103
comments: |-
A commit with an issue id of an other project
IssueID 4 2
repository_id: 10
committer: dlopper
user_id: 3
changesets_005:
commit_date: "2007-09-10"
comments: Modified one file in the folder.
committed_on: 2007-09-10 19:01:08
revision: "5"
id: 104
scmid:
user_id: 3
repository_id: 10
committer: dlopper
changesets_006:
commit_date: "2007-09-10"
comments: Moved helloworld.rb from / to /folder.
committed_on: 2007-09-10 19:01:47
revision: "6"
id: 105
scmid:
user_id: 3
repository_id: 10
committer: dlopper
changesets_007:
commit_date: "2007-09-10"
comments: Removed one file.
committed_on: 2007-09-10 19:02:16
revision: "7"
id: 106
scmid:
user_id: 3
repository_id: 10
committer: dlopper
changesets_008:
commit_date: "2007-09-10"
comments: |-
This commits references an issue.
Refs #2
committed_on: 2007-09-10 19:04:35
revision: "8"
id: 107
scmid:
user_id: 3
repository_id: 10
committer: dlopper
changesets_009:
commit_date: "2009-09-10"
comments: One file added.
committed_on: 2009-09-10 19:04:35
revision: "9"
id: 108
scmid:
user_id: 3
repository_id: 10
committer: dlopper
changesets_010:
commit_date: "2009-09-10"
comments: Same file modified.
committed_on: 2009-09-10 19:04:35
revision: "10"
id: 109
scmid:
user_id: 3
repository_id: 10
committer: dlopper

17
test/fixtures/comments.yml vendored Normal file
View File

@ -0,0 +1,17 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
comments_001:
commented_type: News
commented_id: 1
id: 1
author_id: 1
comments: my first comment
created_on: 2006-12-10 18:10:10 +01:00
updated_on: 2006-12-10 18:10:10 +01:00
comments_002:
commented_type: News
commented_id: 1
id: 2
author_id: 2
comments: This is an other comment
created_on: 2006-12-10 18:12:10 +01:00
updated_on: 2006-12-10 18:12:10 +01:00

View File

@ -0,0 +1,8 @@
default:
somesetting: foo
production:
development:
test:

7
test/fixtures/configuration/empty.yml vendored Normal file
View File

@ -0,0 +1,7 @@
default:
production:
development:
test:

View File

@ -0,0 +1,8 @@
default:
production:
development:
test:
somesetting: foo

View File

@ -0,0 +1,9 @@
default:
somesetting: foo
production:
development:
test:
somesetting: bar

165
test/fixtures/custom_fields.yml vendored Normal file
View File

@ -0,0 +1,165 @@
---
custom_fields_001:
name: Database
min_length: 0
regexp: ""
is_for_all: true
is_filter: true
type: IssueCustomField
max_length: 0
possible_values:
- MySQL
- PostgreSQL
- Oracle
id: 1
is_required: false
field_format: list
default_value: ""
editable: true
position: 2
custom_fields_002:
name: Searchable field
min_length: 1
regexp: ""
is_for_all: true
is_filter: true
type: IssueCustomField
max_length: 100
possible_values: ""
id: 2
is_required: false
field_format: string
searchable: true
default_value: "Default string"
editable: true
position: 1
custom_fields_003:
name: Development status
min_length: 0
regexp: ""
is_for_all: false
is_filter: true
type: ProjectCustomField
max_length: 0
possible_values:
- Stable
- Beta
- Alpha
- Planning
id: 3
is_required: false
field_format: list
default_value: ""
editable: true
position: 1
custom_fields_004:
name: Phone number
min_length: 0
regexp: ""
is_for_all: false
type: UserCustomField
max_length: 0
possible_values: ""
id: 4
is_required: false
field_format: string
default_value: ""
editable: true
position: 1
custom_fields_005:
name: Money
min_length: 0
regexp: ""
is_for_all: false
type: UserCustomField
max_length: 0
possible_values: ""
id: 5
is_required: false
field_format: float
default_value: ""
editable: true
position: 2
custom_fields_006:
name: Float field
min_length: 0
regexp: ""
is_for_all: true
type: IssueCustomField
max_length: 0
possible_values: ""
id: 6
is_required: false
field_format: float
default_value: ""
editable: true
position: 3
custom_fields_007:
name: Billable
min_length: 0
regexp: ""
is_for_all: false
is_filter: true
type: TimeEntryActivityCustomField
max_length: 0
possible_values: ""
id: 7
is_required: false
field_format: bool
default_value: ""
editable: true
position: 1
custom_fields_008:
name: Custom date
min_length: 0
regexp: ""
is_for_all: true
is_filter: false
type: IssueCustomField
max_length: 0
possible_values: ""
id: 8
is_required: false
field_format: date
default_value: ""
editable: true
position: 4
custom_fields_009:
name: Project 1 cf
min_length: 0
regexp: ""
is_for_all: false
is_filter: true
type: IssueCustomField
max_length: 0
possible_values: ""
id: 9
is_required: false
field_format: date
default_value: ""
editable: true
position: 5
custom_fields_010:
name: Overtime
min_length: 0
regexp: ""
is_for_all: false
is_filter: false
type: TimeEntryCustomField
max_length: 0
possible_values: ""
id: 10
is_required: false
field_format: bool
default_value: 0
editable: true
position: 1
custom_fields_011:
id: 11
name: Binary
type: CustomField
possible_values:
- !binary |
SGXDqWzDp2prc2Tigqw2NTTDuQ==
- Other value
field_format: list

View File

@ -0,0 +1,4 @@
---
custom_fields_projects_001:
custom_field_id: 9
project_id: 1

View File

@ -0,0 +1,19 @@
---
custom_fields_trackers_001:
custom_field_id: 1
tracker_id: 1
custom_fields_trackers_002:
custom_field_id: 2
tracker_id: 1
custom_fields_trackers_003:
custom_field_id: 2
tracker_id: 3
custom_fields_trackers_004:
custom_field_id: 6
tracker_id: 1
custom_fields_trackers_005:
custom_field_id: 6
tracker_id: 2
custom_fields_trackers_006:
custom_field_id: 6
tracker_id: 3

103
test/fixtures/custom_values.yml vendored Normal file
View File

@ -0,0 +1,103 @@
---
custom_values_006:
customized_type: Issue
custom_field_id: 2
customized_id: 3
id: 6
value: "125"
custom_values_007:
customized_type: Project
custom_field_id: 3
customized_id: 1
id: 7
value: Stable
custom_values_001:
customized_type: Principal
custom_field_id: 4
customized_id: 3
id: 1
value: ""
custom_values_002:
customized_type: Principal
custom_field_id: 4
customized_id: 4
id: 2
value: 01 23 45 67 89
custom_values_003:
customized_type: Principal
custom_field_id: 4
customized_id: 2
id: 3
value: "01 42 50 00 00"
custom_values_004:
customized_type: Issue
custom_field_id: 2
customized_id: 1
id: 4
value: "125"
custom_values_005:
customized_type: Issue
custom_field_id: 2
customized_id: 2
id: 5
value: ""
custom_values_008:
customized_type: Issue
custom_field_id: 1
customized_id: 3
id: 8
value: "MySQL"
custom_values_009:
customized_type: Issue
custom_field_id: 2
customized_id: 7
id: 9
value: "this is a stringforcustomfield search"
custom_values_010:
customized_type: Issue
custom_field_id: 6
customized_id: 1
id: 10
value: "2.1"
custom_values_011:
customized_type: Issue
custom_field_id: 6
customized_id: 2
id: 11
value: "2.05"
custom_values_012:
customized_type: Issue
custom_field_id: 6
customized_id: 3
id: 12
value: "11.65"
custom_values_013:
customized_type: Issue
custom_field_id: 6
customized_id: 7
id: 13
value: ""
custom_values_014:
customized_type: Issue
custom_field_id: 6
customized_id: 5
id: 14
value: "-7.6"
custom_values_015:
customized_type: Enumeration
custom_field_id: 7
customized_id: 10
id: 15
value: true
custom_values_016:
customized_type: Enumeration
custom_field_id: 7
customized_id: 11
id: 16
value: '1'
custom_values_017:
customized_type: Issue
custom_field_id: 8
customized_id: 1
id: 17
value: '2009-12-01'

25
test/fixtures/diffs/issue-12641-ja.diff vendored Normal file
View File

@ -0,0 +1,25 @@
# HG changeset patch
# User tmaruyama
# Date 1362559296 0
# Node ID ee54942e0289c30bea1b1973750b698b1ee7c466
# Parent 738777832f379f6f099c25251593fc57bc17f586
fix some Japanese "issue" translations (#13350)
Contributed by Go MAEDA.
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -904,9 +904,9 @@ ja:
text_journal_set_to: "%{label} を %{value} にセット"
text_journal_deleted: "%{label} を削除 (%{old})"
text_journal_added: "%{label} %{value} を追加"
- text_tip_issue_begin_day: この日に開始するタスク
- text_tip_issue_end_day: この日に終了するタスク
- text_tip_issue_begin_end_day: この日のうちに開始して終了するタスク
+ text_tip_issue_begin_day: この日に開始するチケット
+ text_tip_issue_end_day: この日に終了するチケット
+ text_tip_issue_begin_end_day: この日に開始・終了するチケット
text_caracters_maximum: "最大%{count}文字です。"
text_caracters_minimum: "最低%{count}文字の長さが必要です"
text_length_between: "長さは%{min}から%{max}文字までです。"

19
test/fixtures/diffs/issue-12641-ru.diff vendored Normal file
View File

@ -0,0 +1,19 @@
# HG changeset patch
# User tmaruyama
# Date 1355872765 0
# Node ID 8a13ebed1779c2e85fa644ecdd0de81996c969c4
# Parent 5c3c5f917ae92f278fe42c6978366996595b0796
Russian "about_x_hours" translation changed by Mikhail Velkin (#12640)
diff --git a/config/locales/ru.yml b/config/locales/ru.yml
--- a/config/locales/ru.yml
+++ b/config/locales/ru.yml
@@ -115,7 +115,7 @@ ru:
one: "около %{count} часа"
few: "около %{count} часов"
many: "около %{count} часов"
- other: "около %{count} часа"
+ other: "около %{count} часов"
x_hours:
one: "1 час"
other: "%{count} часов"

View File

@ -0,0 +1,7 @@
--- a.txt 2013-04-05 14:19:39.000000000 +0900
+++ b.txt 2013-04-05 14:19:51.000000000 +0900
@@ -1,3 +1,3 @@
aaaa
-日本
+日本語
bbbb

View File

@ -0,0 +1,7 @@
--- a.txt 2013-04-05 14:19:39.000000000 +0900
+++ b.txt 2013-04-05 14:19:51.000000000 +0900
@@ -1,3 +1,3 @@
aaaa
-日本
+にっぽん日本
bbbb

46
test/fixtures/diffs/partials.diff vendored Normal file
View File

@ -0,0 +1,46 @@
--- partials.txt Wed Jan 19 12:06:17 2011
+++ partials.1.txt Wed Jan 19 12:06:10 2011
@@ -1,31 +1,31 @@
-Lorem ipsum dolor sit amet, consectetur adipiscing elit
+Lorem ipsum dolor sit amet, consectetur adipiscing xx
Praesent et sagittis dui. Vivamus ac diam diam
-Ut sed auctor justo
+xxx auctor justo
Suspendisse venenatis sollicitudin magna quis suscipit
-Sed blandit gravida odio ac ultrices
+Sed blandit gxxxxa odio ac ultrices
Morbi rhoncus est ut est aliquam tempus
-Morbi id nisi vel felis tincidunt tempus
+Morbi id nisi vel felis xx tempus
Mauris auctor sagittis ante eu luctus
-Fusce commodo felis sed ligula congue molestie
+Fusce commodo felis sed ligula congue
Lorem ipsum dolor sit amet, consectetur adipiscing elit
-Praesent et sagittis dui. Vivamus ac diam diam
+et sagittis dui. Vivamus ac diam diam
Ut sed auctor justo
Suspendisse venenatis sollicitudin magna quis suscipit
Sed blandit gravida odio ac ultrices
-Lorem ipsum dolor sit amet, consectetur adipiscing elit
-Praesent et sagittis dui. Vivamus ac diam diam
+Lorem ipsum dolor sit amet, xxxx adipiscing elit
Ut sed auctor justo
Suspendisse venenatis sollicitudin magna quis suscipit
Sed blandit gravida odio ac ultrices
-Morbi rhoncus est ut est aliquam tempus
+Morbi rhoncus est ut est xxxx tempus
+New line
Morbi id nisi vel felis tincidunt tempus
Mauris auctor sagittis ante eu luctus
Fusce commodo felis sed ligula congue molestie
-Lorem ipsum dolor sit amet, consectetur adipiscing elit
-Praesent et sagittis dui. Vivamus ac diam diam
-Ut sed auctor justo
+Lorem ipsum dolor sit amet, xxxxtetur adipiscing elit
+Praesent et xxxxx. Vivamus ac diam diam
+Ut sed auctor
Suspendisse venenatis sollicitudin magna quis suscipit
Sed blandit gravida odio ac ultrices
Morbi rhoncus est ut est aliquam tempus

79
test/fixtures/diffs/subversion.diff vendored Normal file
View File

@ -0,0 +1,79 @@
Index: app/views/settings/_general.rhtml
===================================================================
--- app/views/settings/_general.rhtml (revision 2094)
+++ app/views/settings/_general.rhtml (working copy)
@@ -48,6 +48,9 @@
<p><label><%= l(:setting_feeds_limit) %></label>
<%= text_field_tag 'settings[feeds_limit]', Setting.feeds_limit, :size => 6 %></p>
+<p><label><%= l(:setting_diff_max_lines_displayed) %></label>
+<%= text_field_tag 'settings[diff_max_lines_displayed]', Setting.diff_max_lines_displayed, :size => 6 %></p>
+
<p><label><%= l(:setting_gravatar_enabled) %></label>
<%= check_box_tag 'settings[gravatar_enabled]', 1, Setting.gravatar_enabled? %><%= hidden_field_tag 'settings[gravatar_enabled]', 0 %></p>
</div>
Index: app/views/common/_diff.rhtml
===================================================================
--- app/views/common/_diff.rhtml (revision 2111)
+++ app/views/common/_diff.rhtml (working copy)
@@ -1,4 +1,5 @@
-<% Redmine::UnifiedDiff.new(diff, :type => diff_type).each do |table_file| -%>
+<% diff = Redmine::UnifiedDiff.new(diff, :type => diff_type, :max_lines => Setting.diff_max_lines_displayed.to_i) -%>
+<% diff.each do |table_file| -%>
<div class="autoscroll">
<% if diff_type == 'sbs' -%>
<table class="filecontent syntaxhl">
@@ -62,3 +63,5 @@
</div>
<% end -%>
+
+<%= l(:text_diff_truncated) if diff.truncated? %>
Index: lang/lt.yml
===================================================================
--- config/settings.yml (revision 2094)
+++ config/settings.yml (working copy)
@@ -61,6 +61,9 @@
feeds_limit:
format: int
default: 15
+diff_max_lines_displayed:
+ format: int
+ default: 1500
enabled_scm:
serialized: true
default:
Index: lib/redmine/unified_diff.rb
===================================================================
--- lib/redmine/unified_diff.rb (revision 2110)
+++ lib/redmine/unified_diff.rb (working copy)
@@ -19,8 +19,11 @@
# Class used to parse unified diffs
class UnifiedDiff < Array
def initialize(diff, options={})
+ options.assert_valid_keys(:type, :max_lines)
diff_type = options[:type] || 'inline'
+ lines = 0
+ @truncated = false
diff_table = DiffTable.new(diff_type)
diff.each do |line|
if line =~ /^(---|\+\+\+) (.*)$/
@@ -28,10 +31,17 @@
diff_table = DiffTable.new(diff_type)
end
diff_table.add_line line
+ lines += 1
+ if options[:max_lines] && lines > options[:max_lines]
+ @truncated = true
+ break
+ end
end
self << diff_table unless diff_table.empty?
self
end
+
+ def truncated?; @truncated; end
end
# Class that represents a file diff

14
test/fixtures/documents.yml vendored Normal file
View File

@ -0,0 +1,14 @@
documents_001:
created_on: 2007-01-27 15:08:27 +01:00
project_id: 1
title: "Test document"
id: 1
description: "Document description"
category_id: 1
documents_002:
created_on: 2007-02-12 15:08:27 +01:00
project_id: 1
title: "An other document"
id: 2
description: ""
category_id: 1

105
test/fixtures/enabled_modules.yml vendored Normal file
View File

@ -0,0 +1,105 @@
---
enabled_modules_001:
name: issue_tracking
project_id: 1
id: 1
enabled_modules_002:
name: time_tracking
project_id: 1
id: 2
enabled_modules_003:
name: news
project_id: 1
id: 3
enabled_modules_004:
name: documents
project_id: 1
id: 4
enabled_modules_005:
name: files
project_id: 1
id: 5
enabled_modules_006:
name: wiki
project_id: 1
id: 6
enabled_modules_007:
name: repository
project_id: 1
id: 7
enabled_modules_008:
name: boards
project_id: 1
id: 8
enabled_modules_009:
name: repository
project_id: 3
id: 9
enabled_modules_010:
name: wiki
project_id: 3
id: 10
enabled_modules_011:
name: issue_tracking
project_id: 2
id: 11
enabled_modules_012:
name: time_tracking
project_id: 3
id: 12
enabled_modules_013:
name: issue_tracking
project_id: 3
id: 13
enabled_modules_014:
name: issue_tracking
project_id: 5
id: 14
enabled_modules_015:
name: wiki
project_id: 2
id: 15
enabled_modules_016:
name: boards
project_id: 2
id: 16
enabled_modules_017:
name: calendar
project_id: 1
id: 17
enabled_modules_018:
name: gantt
project_id: 1
id: 18
enabled_modules_019:
name: calendar
project_id: 2
id: 19
enabled_modules_020:
name: gantt
project_id: 2
id: 20
enabled_modules_021:
name: calendar
project_id: 3
id: 21
enabled_modules_022:
name: gantt
project_id: 3
id: 22
enabled_modules_023:
name: calendar
project_id: 5
id: 23
enabled_modules_024:
name: gantt
project_id: 5
id: 24
enabled_modules_025:
name: news
project_id: 2
id: 25
enabled_modules_026:
name: repository
project_id: 2
id: 26

1
test/fixtures/encoding/iso-8859-1.txt vendored Normal file
View File

@ -0,0 +1 @@
Texte encodé en ISO-8859-1.

103
test/fixtures/enumerations.yml vendored Normal file
View File

@ -0,0 +1,103 @@
---
enumerations_001:
name: Uncategorized
id: 1
type: DocumentCategory
active: true
position: 1
enumerations_002:
name: User documentation
id: 2
type: DocumentCategory
active: true
position: 2
enumerations_003:
name: Technical documentation
id: 3
type: DocumentCategory
active: true
position: 3
enumerations_004:
name: Low
id: 4
type: IssuePriority
active: true
position: 1
position_name: lowest
enumerations_005:
name: Normal
id: 5
type: IssuePriority
is_default: true
active: true
position: 2
position_name: default
enumerations_006:
name: High
id: 6
type: IssuePriority
active: true
position: 3
position_name: high3
enumerations_007:
name: Urgent
id: 7
type: IssuePriority
active: true
position: 4
position_name: high2
enumerations_008:
name: Immediate
id: 8
type: IssuePriority
active: true
position: 5
position_name: highest
enumerations_009:
name: Design
id: 9
type: TimeEntryActivity
position: 1
active: true
enumerations_010:
name: Development
id: 10
type: TimeEntryActivity
position: 2
is_default: true
active: true
enumerations_011:
name: QA
id: 11
type: TimeEntryActivity
position: 3
active: true
enumerations_012:
name: Default Enumeration
id: 12
type: Enumeration
is_default: true
active: true
enumerations_013:
name: Another Enumeration
id: 13
type: Enumeration
active: true
enumerations_014:
name: Inactive Activity
id: 14
type: TimeEntryActivity
position: 4
active: false
enumerations_015:
name: Inactive Priority
id: 15
type: IssuePriority
position: 6
active: false
enumerations_016:
name: Inactive Document Category
id: 16
type: DocumentCategory
active: false
position: 4

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More