diff --git a/ReadMe.txt b/ReadMe.txt
index 35e56515d..722b4cd37 100644
--- a/ReadMe.txt
+++ b/ReadMe.txt
@@ -1,65 +1,72 @@
-===================================[2014-04-09]=================================
-kw: 域名, 二级域名, subdomain, forge, course, contest
-域名跳转(forge/course/contest)这几个设置在settings.yml中
-但是跳转在development模式下会导致无法开发
-
-app/models/setting.rb :165
- # fixed domain url in development. tantantan's bug
- if Rails.env.development?
- methods.map do |m|
- define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/
- end
- end
- 程序部分链接中制定了subdomain参数,使链接在二级域名中来回跳转。
- 为了开发方便,使之功能在development模式下失效。
-
-
-===================================[2014-04-09]=================================
-kw: 菜单, 导航栏, layout
-网页上方的导航条没有用Redmine::MenuManager
-MenuManager的样式无法定制,菜单显示条件if中的proc执行行为没有了解
-
-#导航栏匹配域名显示和改变
-app\helper\application_helper.rb
-render_dynamic_nav 方法中,利用变量,可以设置在layout中具体显示哪些条目
-
-app\views\layouts\_base_header.html.erb
-需要显示的条目,由具体的实例变量设置(在各个layout中)
-
-
-===================================[2014-04-09]=================================
-kw: home_path, 首页, 跳转, 二级域名, welcome
-#首页根据域名匹配进入不同的页面
-app\controller\welcome_controller.rb
-#entry_select 放射设置二级域名所显示的首页
-
-
-
-===================================[2014-06-06]=================================
-kw: user_scores
-user_scores表结构有问题,需要运行
-bundle exec rake db:migrate:down VERSION=20140410021724
-bundle exec rake db:migrate:up VERSION=20140410021724
-
-
-
-===================================[2014-07-08]=================================
-kw: CKEditor, 富文本, 编辑器
-CKEditor插件加载方法
-1.把插件文件夹拷入plugins文件夹,确保文件夹名为redmine_ckeditor
-2.运行 bundle install --without development test
-3.运行 rake redmine:plugins:migrate RAILS_ENV=production
-4.启动服务器
-5.配置CKEditor插件(Administration > Plugins > Configure)
-6.把文本格式 (Administration > Settings > General > Text formatting)改为CKEditor
-注意:一定要先配置CKEditor插件再见文本格式更改,不然,数据库不会生成对应记录,会报错。。
-
-
-
-===================================[2014-07-19]=================================
-kw: 首页, 定制, forge, course, contest, 排序
-若遇到首页定制报错问题请尝试如下操作
-如果运行迁移文件有报错与‘sort_type’相关 先运行 bundle exec rake db:migrate:down version=20140716021202 bundle exec rake db:migrate:up version=20140716021202
-在按如下步骤执行,未报与之相关的则直接按如下步骤执行
-1.运行 bundle exec rake db:migrate:down version=20140719080032
-2.运行 bundle exec rake db:migrate:up version=20140719080032
+===================================[2014-04-09]=================================
+kw: , , subdomain, forge, course, contest
+תforge/course/contest⼸settings.yml
+תdevelopmentģʽ»ᵼ
+
+app/models/setting.rb :165
+ # fixed domain url in development. tantantan's bug
+ if Rails.env.development?
+ methods.map do |m|
+ define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/
+ end
+ end
+ ƶsubdomainʹڶת
+ Ϊ˿㣬ʹ֮developmentģʽʧЧ
+
+
+===================================[2014-04-09]=================================
+kw: ˵, , layout
+ҳϷĵûRedmine::MenuManager
+MenuManagerʽƣ˵ʾifеprocִΪû˽
+
+#ƥʾı
+app\helper\application_helper.rb
+render_dynamic_nav УñlayoutоʾЩĿ
+
+app\views\layouts\_base_header.html.erb
+ҪʾĿɾʵãڸlayoutУ
+
+
+===================================[2014-04-09]=================================
+kw: home_path, ҳ, ת, , welcome
+#ҳƥ벻ͬҳ
+app\controller\welcome_controller.rb
+#entry_select öʾҳ
+
+
+
+===================================[2014-06-06]=================================
+kw: user_scores
+user_scoresṹ⣬Ҫ
+bundle exec rake db:migrate:down VERSION=20140410021724
+bundle exec rake db:migrate:up VERSION=20140410021724
+
+
+
+===================================[2014-07-08]=================================
+kw: CKEditor, ı, ༭
+CKEditorط
+1.ѲļпpluginsļУȷļΪredmine_ckeditor
+2. bundle install --without development test
+3. rake redmine:plugins:migrate RAILS_ENV=production
+4.
+5.CKEditor(Administration > Plugins > Configure)
+6.ıʽ (Administration > Settings > General > Text formatting)ΪCKEditor
+ע⣺һҪCKEditorټıʽģȻݿⲻɶӦ¼ᱨ
+
+
+
+===================================[2014-07-19]=================================
+kw: ҳ, , forge, course, contest,
+ҳƱ볢²
+Ǩļб롮sort_type
+ bundle exec rake db:migrate:down version=20140716021202 bundle exec rake db:migrate:up version=20140716021202
+ڰ²ִУδ֮صֱӰ²ִ
+1. bundle exec rake db:migrate:down version=20140719080032
+2. bundle exec rake db:migrate:up version=20140719080032
+===================================[2014-07-30]=================================
+kw: ҳ, , forge, course, contest, image_width
+
+undefined image_width
+bundle exec rake db:migrate:down version=20140725062302
+bundle exec rake db:migrate:up version=20140725062302
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 36b7e8598..aac107cfb 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -153,6 +153,8 @@ class AdminController < ApplicationController
@first_page.image_width = params[:image_width]
@first_page.image_height = params[:image_height]
@first_page.sort_type = params[:sort_type]
+ @first_page.show_course = params[:show_course]
+ @first_page.show_contest = params[:show_contest]
if @first_page.save
respond_to do |format|
flash[:notice] = l(:notice_successful_update)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 110974b77..c4b72f584 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -41,6 +41,7 @@ class ApplicationController < ActionController::Base
cookies.delete(autologin_cookie_name)
end
+ before_filter :find_first_page
before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization
before_filter :user_agent
@@ -720,4 +721,11 @@ class ApplicationController < ActionController::Base
raise RuntimeError, 'unknow type, Please input you type into this helper.'
end
end
+
+ #查找首页相关信息
+ def find_first_page
+ @first_page = FirstPage.where("page_type = 'project'").first
+ @show_course = @first_page.show_course
+ @show_contest = @first_page.show_contest
+ end
end
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 026a12e9a..44d68de26 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -26,6 +26,7 @@ class AttachmentsController < ApplicationController
accept_api_auth :show, :download, :upload
require 'iconv'
+
def show
respond_to do |format|
format.html {
@@ -41,6 +42,13 @@ class AttachmentsController < ApplicationController
render :action => 'diff'
elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte
@content = File.new(@attachment.diskfile, "rb").read
+ # 编码为非 UTF-8先进行间接转码
+ # 部分unicode编码不直接支持转为 UTF-8
+ # modify by nwb
+ if @content.encoding.name != 'UTF-8'
+ @content = @content.force_encoding('GBK')
+ @content = @content.encode('UTF-8')
+ end
render :action => 'file'
else
download
@@ -173,8 +181,11 @@ class AttachmentsController < ApplicationController
respond_to do |format|
# modify by nwb
- if !@attachment.container.nil? && (@attachment.container.is_a?(Course) || @attachment.container.course)
- if @course.nil?
+ if !@attachment.container.nil? &&
+ (@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) && @attachment.container.course ) )
+ if @attachment.container.is_a?(News)
+ format.html { redirect_to_referer_or news_path(@attachment.container) }
+ elsif @course.nil?
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
else
format.html { redirect_to_referer_or course_path(@course) }
@@ -206,6 +217,17 @@ class AttachmentsController < ApplicationController
end
end
+ #删除竞赛作品的附件
+ def delete_softapplications
+ @attachment = Attachment.find params[:id]
+ @softapplication = @attachment.container if @attachment!=nil
+ @attachment.container.attachments.delete(@attachment) if @attachment!=nil
+ respond_to do |format|
+ format.html { redirect_to_referer_or edit_softapplication_path(@softapplication) }
+ #format.js
+ end
+ end
+
def autocomplete
# modify by nwb
if params[:project_id]
@@ -233,6 +255,9 @@ class AttachmentsController < ApplicationController
attach_copied_obj.container = obj
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
+ if attach_copied_obj.attachtype == nil
+ attach_copied_obj.attachtype = 1
+ end
@obj = obj
@save_flag = attach_copied_obj.save
@save_message = attach_copied_obj.errors.full_messages
@@ -262,6 +287,9 @@ class AttachmentsController < ApplicationController
attach_copied_obj.container = obj
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
+ if attach_copied_obj.attachtype == nil
+ attach_copied_obj.attachtype = 4
+ end
@obj = obj
@save_flag = attach_copied_obj.save
@save_message = attach_copied_obj.errors.full_messages
diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb
index ef0be71ac..49ee47327 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -7,6 +7,9 @@ class BidsController < ApplicationController
menu_item :project, :only => [:show_project,:show_results, :new_submit_homework]
menu_item :homework_respond, :only => :homework_respond
menu_item :homework_statistics, :only => :homework_statistics
+
+ before_filter :can_show_course,only: []
+ before_filter :can_show_contest,only: []
#Ended by young
before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:delete,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork,
:show_course, :show_courseEx,:show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings]
@@ -983,5 +986,21 @@ class BidsController < ApplicationController
render_403 unless currentUser.member_of_course?(@bid.courses.first)
end
+ #验证是否显示课程
+ def can_show_course
+ @first_page = FirstPage.where("page_type = 'project'").first
+ if @first_page.show_course == 2
+ render_404
+ end
+ end
+
+ #验证是否显示竞赛
+ def can_show_contest
+ @first_page = FirstPage.where("page_type = 'project'").first
+ if @first_page.show_contest == 2
+ render_404
+ end
+ end
+
end
diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb
index cf8750b5d..e2f5e3731 100644
--- a/app/controllers/contests_controller.rb
+++ b/app/controllers/contests_controller.rb
@@ -7,6 +7,8 @@ class ContestsController < ApplicationController
menu_item :application, :only => :show_softapplication
menu_item :attendingcontests, :only => :show_attendingcontest
menu_item :contestnotifications, :only => :index
+
+ before_filter :can_show_contest,except: []
before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :show_attendingcontest, :index, :set_reward_project, :set_reward_softapplication, :create,:destroy,:more,:back,:add,:add_softapplication,:new,:show_results, :set_reward,
:show_contest_project, :show_contest_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings]
@@ -27,8 +29,9 @@ class ContestsController < ApplicationController
# @contests = Contest.visible
# @contests ||= []
@offset, @limit = api_offset_and_limit({:limit => 10})
- @contests = Contest.visible
- @contests = @contests.like(params[:name]) if params[:name].present?
+ #@contests = Contest.visible
+ #@contests = @contests.like(params[:name]) if params[:name].present?
+ @contests = Contest.visible.where("name like '%#{params[:name]}%'")
if params[:contests_search]
(redirect_to contests_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
end
@@ -645,5 +648,13 @@ end
render_404
end
+ #验证是否显示竞赛
+ def can_show_contest
+ @first_page = FirstPage.where("page_type = 'project'").first
+ if @first_page.show_contest == 2
+ render_404
+ end
+ end
+
end
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 9db479eb5..85dfba8cf 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -13,6 +13,7 @@ class CoursesController < ApplicationController
menu_item l(:label_sort_by_active), :only => :index
menu_item l(:label_sort_by_influence), :only => :index
+ before_filter :can_show_course, :except => []
before_filter :find_course, :except => [ :index, :search,:list, :new,:join,:unjoin, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches]
before_filter :authorize_course, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course]
before_filter :authorize_course_global, :only => [:view_homework_attaches, :new,:create]
@@ -494,7 +495,7 @@ class CoursesController < ApplicationController
if (User.current.logged? && User.current.member_of_course?(Course.find params[:id] ))
render :layout => 'base_courses'
else
- render_404
+ render_403
end
end
@@ -711,7 +712,13 @@ class CoursesController < ApplicationController
end
end
-
+ #验证是否显示课程
+ def can_show_course
+ @first_page = FirstPage.where("page_type = 'project'").first
+ if @first_page.show_course == 2
+ render_404
+ end
+ end
diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb
index 1cb3fa197..920cd9d4d 100644
--- a/app/controllers/homework_attach_controller.rb
+++ b/app/controllers/homework_attach_controller.rb
@@ -2,6 +2,7 @@ class HomeworkAttachController < ApplicationController
layout "course_base"
include CoursesHelper
###############################
+ before_filter :can_show_course,except: []
#判断当前角色权限时需先找到当前操作的project
before_filter :find_course_by_bid_id, :only => [:new]
before_filter :find_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users]
@@ -352,5 +353,13 @@ class HomeworkAttachController < ApplicationController
}
end
end
+
+ #验证是否显示课程
+ def can_show_course
+ @first_page = FirstPage.where("page_type = 'project'").first
+ if @first_page.show_course == 2
+ render_404
+ end
+ end
end
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index e974936eb..b364440c9 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -18,7 +18,7 @@
class MessagesController < ApplicationController
menu_item :boards
default_search_scope :messages
- before_filter :find_board, :only => [:new, :preview]
+ before_filter :find_board, :only => [:new, :preview,:edit]
before_filter :find_attachments, :only => [:preview]
before_filter :find_message, :except => [:new, :preview]
before_filter :authorize, :except => [:preview, :edit, :destroy, :new]
@@ -85,7 +85,7 @@ class MessagesController < ApplicationController
@reply.board = @board
@reply.safe_attributes = params[:reply]
@topic.children << @reply
- @topic.update_attribute(:updated_on, Time.now)
+ #@topic.update_attribute(:updated_on, Time.now)
if !@reply.new_record?
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
attachments = Attachment.attach_files(@reply, params[:attachments])
@@ -107,7 +107,15 @@ class MessagesController < ApplicationController
flash[:notice] = l(:notice_successful_update)
@message.reload
redirect_to board_message_path(@message.board, @message.root, :r => (@message.parent_id && @message.id))
+ elsif request.get?
+ respond_to do |format|
+ format.html {
+ layout_file = @project ? 'base_projects' : 'base_courses'
+ render :layout => layout_file
+ }
+ end
end
+
end
# Delete a messages
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index ca75f488b..b46bff2ff 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class ProjectsController < ApplicationController
layout :select_project_layout
+
menu_item :overview
menu_item :roadmap, :only => :roadmap
menu_item :settings, :only => :settings
@@ -102,6 +103,8 @@ class ProjectsController < ApplicationController
end
def index
+ #调用存储过程更新提交次数
+ ActiveRecord::Base.connection.execute("CALL sp_project_status_cursor();")
#Modified by nie
@project_type = params[:project_type].to_i
per_page_option = 10
@@ -149,6 +152,7 @@ class ProjectsController < ApplicationController
end
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
+
respond_to do |format|
format.html {
render :layout => 'base'
@@ -447,24 +451,10 @@ class ProjectsController < ApplicationController
end
def new
- @project_type = params[:project_type] ||= params[:course]
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
-
- case @project_type
- when '0' # Project
- @project = Project.new
- @project.safe_attributes = params[:project]
- when '1' # Course
- @project = Project.new
- @project.safe_attributes = params[:project]
- @course_tag = params[:course]
- @course = Course.new
- @course.safe_attributes = params[:course]
- else # default Project
- @project = Project.new
- @project.safe_attributes = params[:project]
- end
+ @project = Project.new
+ @project.safe_attributes = params[:project]
render :layout => 'base'
end
@@ -478,128 +468,43 @@ class ProjectsController < ApplicationController
end
def create
-
- @course_tag = params[:project][:project_type]
- if(@course_tag=="1")
- if User.current.user_extensions.identity#.include?(UserExtensions::TEACHER,UserExtensions::DEVELOPER)
- @course = Course.new
- @course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
- @course.safe_attributes = params[:project][:course]
- @course.tea_id = User.current.id
- # added by bai
- @course.term = params[:term]
- @course.time = params[:time]
- #@course.school_id = params[:occupation]
- @course.school_id = User.current.user_extensions.school_id
- @course.setup_time = params[:setup_time]
- @course.endup_time = params[:endup_time]
- @course.class_period = params[:class_period]
- end
- end
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@project = Project.new
- @project.user_id = User.current.id
- @project.dts_test = params[:project][:dts_test]
@project.safe_attributes = params[:project]
- if @course_tag == '1'
- @project.identifier = @course.extra
- end
- if @course_tag == '1'
- if User.current.user_extensions.identity == 0
- if@course.save
- if validate_parent_id && @project.save
- @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
- # Add current user as a project member if he is not admin
- unless User.current.admin?
- r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
- m = Member.new(:user => User.current, :roles => [r])
- project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
- user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id)
- if params[:project][:is_public] == '1'
- project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :project_type => @course_tag)
- end
- @project.members << m
- @project.project_infos << project
- end
- respond_to do |format|
- format.html {
- flash[:notice] = l(:notice_successful_create)
- if params[:continue]
- attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
- redirect_to new_project_path(attrs, :course => '0')
- #Added by young
-
- elsif params[:course_continue]
- redirect_to new_project_path(:course => '1')
- #Ended by young
- else
- redirect_to settings_project_path(@project,:project_type => 1)
- end
- }
- format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
- end
+ if validate_parent_id && @project.save
+ @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
+ # Add current user as a project member if he is not admin
+ #unless User.current.admin?
+ r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
+ m = Member.new(:user => User.current, :roles => [r])
+ project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
+ user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id)
+ Rails.logger.debug "UserGrade created: #{user_grades.to_json}"
+ if params[:project][:is_public] == '1'
+ project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type)
+ Rails.logger.debug "ProjectStatus created: #{project_status.to_json}"
+ end
+ @project.members << m
+ @project.project_infos << project_info
+ #end
+ respond_to do |format|
+ format.html {
+ flash[:notice] = l(:notice_successful_create)
+ if params[:continue]
+ attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
+ redirect_to new_project_path(attrs, :course => '0')
else
- @course.destroy
- respond_to do |format|
- format.html { render :action => 'new', :layout => 'base'}#Added by young
- format.api { render_validation_errors(@project) }
- end
+ redirect_to settings_project_path(@project)
end
- else
- if validate_parent_id && @project.save
- @project.delete
- respond_to do |format|
- format.html { render :action => 'new', :layout => 'base'}#Added by young
- format.api { render_validation_errors(@project) }
- end
- else
- respond_to do |format|
- format.html { render :action => 'new', :layout => 'base'}#Added by young
- format.api { render_validation_errors(@project) }
- end
- end
- end
+ }
+ format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
end
else
- #@project.memberships.create
- if validate_parent_id && @project.save
- @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
- # Add current user as a project member if he is not admin
- #unless User.current.admin?
- r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
- m = Member.new(:user => User.current, :roles => [r])
- project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
- user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id)
- if params[:project][:is_public] == '1' || @course_tag=="1"
- project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type)
- end
- @project.members << m
- @project.project_infos << project
- #end
- respond_to do |format|
- format.html {
- flash[:notice] = l(:notice_successful_create)
- if params[:continue]
- attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
- redirect_to new_project_path(attrs, :course => '0')
- #Added by young
-
- elsif params[:course_continue]
- redirect_to new_project_path(:course => '1')
- #Ended by young
- else
- redirect_to settings_project_path(@project)
- end
- }
- format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
- end
- else
- respond_to do |format|
- format.html { render :action => 'new', :layout => 'base'}#Added by young
- format.api { render_validation_errors(@project) }
- end
- end
+ respond_to do |format|
+ format.html { render :action => 'new', :layout => 'base'}#Added by young
+ format.api { render_validation_errors(@project) }
+ end
end
end
@@ -833,7 +738,7 @@ class ProjectsController < ApplicationController
def update
@project.safe_attributes = params[:project]
- @project.dts_test = params[:project][:dts_test]
+ #@project.dts_test = params[:project][:dts_test]
if validate_parent_id && @project.save
@course = Course.find_by_extra(@project.identifier)
unless @course.nil?
diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb
index 1808a3eaa..f2b0a0c83 100644
--- a/app/controllers/softapplications_controller.rb
+++ b/app/controllers/softapplications_controller.rb
@@ -172,8 +172,8 @@ class SoftapplicationsController < ApplicationController
# PUT /softapplications/1.json
def update
# @softapplication = Softapplication.find(params[:id])
- @softapplication.attachments.map{|attach| attach.destroy }
- @softapplication.save_attachments(params[:attachments])
+ #@softapplication.attachments.map{|attach| attach.destroy }
+ @softapplication.save_attachments(params[:attachments]) if params[:attachments]
#@softapplication.deposit_project = params[:project]
@softapplication.project = Project.find_by_id(params[:project])
@@ -304,6 +304,36 @@ class SoftapplicationsController < ApplicationController
end
end
+ def search
+ @softapplications = Softapplication.where("name like '%#{params[:name]}%'")
+
+ #new added fenyefunction
+ @limit = 5
+ @softapplication_count = @softapplications.count
+ @softapplication_pages = Paginator.new @softapplication_count, @limit, params['page']
+ @offset ||= @softapplication_pages.offset
+
+ #new added sort
+ if params[:softapplication_sort_type].present?
+ case params[:softapplication_sort_type]
+ when '0'
+ @softapplications = @softapplications[@offset, @limit]
+ @s_state = 0
+ when '1'
+ @softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
+ @s_state = 1
+ end
+ else
+ @softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
+ @s_state = 1
+ end
+ #new added end
+
+ respond_to do |format|
+ format.html
+ end
+ end
+
private
def find_softapplication
@softapplication = Softapplication.find_by_id(params[:id])
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index ba01aa990..1318e40a5 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -71,8 +71,8 @@ class TagsController < ApplicationController
@projects_results,
@issues_results,
@bids_results,
- @forums_results,
- attachments_results,
+ @forums_results,
+ @attachments_results,
@contests_results,
@courses_results,
@open_source_projects_results= refresh_results(@obj_id,@obj_flag,@selected_tags)
@@ -107,8 +107,8 @@ class TagsController < ApplicationController
@projects_results,
@issues_results,
@bids_results,
- @forums_results,
- attachments_results,
+ @forums_results,
+ @attachments_results,
@contests_results,
@courses_results,
@open_source_projects_results= refresh_results(@obj_id,@show_flag)
@@ -130,8 +130,8 @@ class TagsController < ApplicationController
@projects_results,
@issues_results,
@bids_results,
- @forums_results,
- attachments_results,
+ @forums_results,
+ @attachments_results,
@contests_results,
@courses_results,
@open_source_projects_results= refresh_results(@obj_id,@show_flag)
@@ -199,7 +199,7 @@ class TagsController < ApplicationController
@bids_results = nil
@contests_results = nil
@forums_results = nil
- attachments_results = nil
+ @attachments_results = nil
@open_source_projects_results = nil
@obj_pages = nil
@obj = nil
@@ -228,8 +228,9 @@ class TagsController < ApplicationController
# modifed by Long Jun
# this is used to find the attachments that came from the same project and tagged with the same tag.
- @result = get_attachments_by_project_tag(selected_tags, @obj)
- @obj_pages, attachments_results, @results_count = for_pagination(@result)
+ #@result = get_attachments_by_project_tag(selected_tags, @obj)
+ @result = get_attachments_by_tag(selected_tags)
+ @obj_pages, @attachments_results, @results_count = for_pagination(@result)
when '7'
@obj = Contest.find_by_id(obj_id)
@obj_pages,@contests_results,@results_count = for_pagination(get_contests_by_tag(selected_tags))
@@ -249,8 +250,8 @@ class TagsController < ApplicationController
@projects_results,
@issues_results,
@bids_results,
- @forums_results,
- attachments_results,
+ @forums_results,
+ @attachments_results,
@contests_results,
@courses_results,
@open_source_projects_results]
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index a3bb96aa9..7220f3ccb 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -29,7 +29,7 @@ class UsersController < ApplicationController
#Ended by young
-
+ before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
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,:show_new_score, :topic_new_score_index, :project_new_score_index,
@@ -41,6 +41,7 @@ class UsersController < ApplicationController
: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
+ #before_filter :rest_user_score, only: :show
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx
#william
@@ -54,6 +55,7 @@ class UsersController < ApplicationController
include AvatarHelper
include WordsHelper
include GitlabHelper
+ include UserScoreHelper
# added by liuping 关注
@@ -263,9 +265,6 @@ class UsersController < ApplicationController
sort_init 'login', 'asc'
sort_update %w(login firstname lastname mail admin created_on last_login_on)
- # Deprecation
- @project_type = params[:project_type]
-
case params[:format]
when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 15})
@@ -274,16 +273,9 @@ class UsersController < ApplicationController
end
# retrieve all users
- scope = UserStatus.visible
-
- # if role has something, change scope.
- case params[:role]
- when 'teacher'
- scope = UserStatus.teacher
- when 'student'
- scope = UserStatus.student
- else
- end
+ # 先内连一下statuses 保证排序之后数量一致
+ scope = User.visible.
+ joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id")
# unknow
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
@@ -295,25 +287,32 @@ class UsersController < ApplicationController
# users classify
case params[:user_sort_type]
when '0'
+ # 创建时间排序
@s_type = 0
- @us_ordered = scope.
- joins("LEFT JOIN users ON user_statuses.user_id = users.id").
- reorder('users.created_on DESC')
+ @users = scope.reorder('users.created_on DESC')
when '1'
+ # 活跃度排序, 就是所谓的得分情况
@s_type = 1
- @us_ordered = scope.reorder('user_statuses.grade DESC')
+ @users = scope.
+ joins("LEFT JOIN user_scores ON users.id = user_scores.user_id").
+ reorder('user_scores.active DESC')
when '2'
+ # 粉丝数排序
@s_type = 2
- @us_ordered = scope.reorder('user_statuses.watchers_count DESC')
+ @users = scope.
+ #joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id").
+ reorder('user_statuses.watchers_count DESC')
+
else
+ # 默认活跃度排序
@s_type = 1
- @us_ordered = scope.reorder('user_statuses.grade DESC')
+ @users = scope.
+ joins("LEFT JOIN user_scores ON users.id = user_scores.user_id").
+ reorder('user_scores.active DESC')
end
# limit and offset
- @users_statuses = @us_ordered.offset(@user_pages.offset).limit(@user_pages.per_page)
- # get users ActiveRecord
- @users = @users_statuses.includes(:user).map(&:user)
+ @users = @users.limit(@user_pages.per_page).offset(@user_pages.offset)
@user_base_tag = params[:id] ? 'base_users':'users_base'
respond_to do |format|
@@ -784,4 +783,25 @@ class UsersController < ApplicationController
redirect_to my_account_path
end
end
+
+ #重置用户得分
+ def rest_user_score
+ memo_num(@user)
+ messges_for_issue_num(@user)
+ issues_status_num(@user)
+ replay_for_memo_num(@user)
+ tread_num(@user)
+ praise_num(@user)
+ changeset_num(@user)
+ document_num(@user)
+
+ end
+
+ #验证是否显示课程
+ def can_show_course
+ @first_page = FirstPage.where("page_type = 'project'").first
+ if @first_page.show_course == 2
+ render_404
+ end
+ end
end
diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb
index 0cca7be6e..c7cbf217d 100644
--- a/app/controllers/welcome_controller.rb
+++ b/app/controllers/welcome_controller.rb
@@ -18,12 +18,14 @@
class WelcomeController < ApplicationController
include ApplicationHelper
include WelcomeHelper
+
caches_action :robots
# before_filter :fake, :only => [:index, :course]
before_filter :entry_select, :only => [:index]
def index
@first_page = FirstPage.where("page_type = 'project'").first
+ #@show_course = @first_page.show_course
if @first_page.nil? || @first_page.sort_type.nil?
@projects = find_miracle_project(10, 3,"grade desc")
else
@@ -146,16 +148,27 @@ class WelcomeController < ApplicationController
private
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
def entry_select
+ @first_page = FirstPage.where("page_type = 'project'").first
url = request.original_url
- if url.include?("course.trustie.net")
- course
- render :course
+ if url.include?(Setting.host_course)
+ if @first_page.show_course == 1
+ course
+ render :course
+ else
+ render_404
+ end
+
return 0
- elsif url.include?("contest.trustie.net")
- contest
- render :contest
+ elsif url.include?(Setting.host_contest)
+ if @first_page.show_contest == 1
+ contest
+ render :contest
+ else
+ render_404
+ end
+
return 0
- elsif url.include?("user.trustie.net")
+ elsif url.include?(Setting.host_user)
redirect_to(:controller => "users", :action => "index")
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index b6cd47924..9f8b8fff5 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -68,6 +68,10 @@ module ApplicationHelper
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
end
+ def link_to_if_authorized_course(name, options = {}, html_options = nil, *parameters_for_method_reference)
+ link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_course(options[:controller] || params[:controller], options[:action])
+ end
+
def link_to_if_authorized_contest(name, options = {}, html_options = nil, *parameters_for_method_reference)
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_contest(options[:controller] || params[:controller], options[:action])
end
@@ -823,8 +827,11 @@ module ApplicationHelper
def select_option_helper option
tmp = Hash.new
tmp={"" => ""}
- option.each do |project|
- tmp[project.name] = project.id
+ if option.nil?
+ else
+ option.each do |project|
+ tmp[project.name] = project.id
+ end
end
tmp
end
@@ -1168,25 +1175,27 @@ module ApplicationHelper
objects = objects.first
end
# end
- objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact
- errors = objects.map {|o| o.errors.full_messages}.flatten
- if errors.any?
- html << "
\n"
- errors.each do |error|
+ if objects != nil
+ objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact
+ errors = objects.map {|o| o.errors.full_messages}.flatten
+ if errors.any?
+ html << "\n"
+ errors.each do |error|
+ ###by xianbo
+ if(error!=l(:label_repository_path_not_null))
+ html << "#{h error} \n"
+ end
+ ###xianbo
+ end
###by xianbo
- if(error!=l(:label_repository_path_not_null))
- html << "#{h error} \n"
+ unless params[:repository].nil?
+ if params[:repository][:upassword]==""
+ html << ""+ l(:label_password_not_null) +" \n"
+ end
end
###xianbo
+ html << " \n"
end
- ###by xianbo
- unless params[:repository].nil?
- if params[:repository][:upassword]==""
- html << ""+ l(:label_password_not_null) +" \n"
- end
- end
- ###xianbo
- html << " \n"
end
html.html_safe
end
@@ -1729,18 +1738,18 @@ module ApplicationHelper
#@nav_dispaly_project_label
nav_list = Array.new
- nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label
- nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label
- nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label
+ nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label && @show_course == 1
+ nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label && @show_course == 1
+ nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label && @show_course == 1
nav_list.push(main_project_link) if @nav_dispaly_main_project_label
- nav_list.push(main_course_link) if @nav_dispaly_main_course_label
- nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label
+ nav_list.push(main_course_link) if @nav_dispaly_main_course_label && @show_course == 1
+ nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label && @show_contest == 1
- nav_list.push(courses_link) if @nav_dispaly_course_label
+ nav_list.push(courses_link) if @nav_dispaly_course_label && @show_course == 1
nav_list.push(projects_link) if @nav_dispaly_project_label
nav_list.push(users_link) if @nav_dispaly_user_label
- nav_list.push(contest_link) if @nav_dispaly_contest_label
+ nav_list.push(contest_link) if @nav_dispaly_contest_label && @show_contest == 1
nav_list.push(bids_link) if @nav_dispaly_bid_label
nav_list.push(forum_link) if @nav_dispaly_forum_label
nav_list.push(stores_link) if @nav_dispaly_store_all_label
diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb
index b43eb22f1..ee9d2a70d 100644
--- a/app/helpers/attachments_helper.rb
+++ b/app/helpers/attachments_helper.rb
@@ -87,8 +87,9 @@ module AttachmentsHelper
@project_id = obj.container_id
end
- Attachment.tagged_with(tag_name).order('created_on desc').where("(container_id = :project_id and container_type = 'Project') or
+ attachments = Attachment.tagged_with(tag_name).order('created_on desc').where("(container_id = :project_id and container_type = 'Project') or
(container_id in (select id from versions where project_id =:project_id) and container_type = 'Version')", {:project_id => @project_id})
+ return attachments
end
diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb
index 720919369..ba055ddf4 100644
--- a/app/helpers/user_score_helper.rb
+++ b/app/helpers/user_score_helper.rb
@@ -408,19 +408,47 @@ module UserScoreHelper
update_score(option_number)
end
+ #发帖数
+ def memo_num(user,project=nil)
+ if project.nil?
+ Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count
+ else
+ Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
+ end
+
+ end
+
#更新对缺陷留言数
def update_messges_for_issue(user,type)
option_number = get_option_number(user,type)
- option_number.messages_for_issues = Journal.includes(:user).where("user_id = '#{user.id}'").all.count
+ option_number.messages_for_issues = Journal.includes(:user).where("user_id = '#{user.id}' and notes != '' and notes is not null").all.count
update_score(option_number)
end
+ def messges_for_issue_num(user,project=nil)
+ if project.nil?
+ Journal.includes(:user).where("user_id = '#{user.id}' and notes != '' and notes is not null").all.count
+ else
+ Journal.includes(:user).joins(:issue).where("#{Journal.table_name}.user_id = '#{user.id}' and #{Issue.table_name}.project_id = '#{project.id}' and #{Journal.table_name}.notes != '' and #{Journal.table_name}.notes is not null").all.count
+ end
+ end
+
#更新更改缺陷状态状态次数
def update_issues_status(user,type)
option_number = get_option_number(user,type)
option_number.issues_status = Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
update_score(option_number)
end
+
+ def issues_status_num(user,project=nil)
+ if project.nil?
+ Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
+ else
+ Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
+ end
+
+ end
+
#更新对留言的回复数量
def update_replay_for_message(user,type)
option_number = get_option_number(user,type)
@@ -428,13 +456,25 @@ module UserScoreHelper
update_score(option_number)
end
+ def replay_for_message_num(user)
+ JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id}").count
+ end
+
#更新对帖子的回复数量
def update_replay_for_memo(user,type)
option_number = get_option_number(user,type)
- option_number.replay_for_memo = Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count + Memo.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count
+ option_number.replay_for_memo = Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count #+ Memo.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count
update_score(option_number)
end
+ def replay_for_memo_num(user,project=nil)
+ if project.nil?
+ Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count
+ else
+ Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
+ end
+ end
+
#更新被关注的人数
def update_follow(user,type)
option_number = get_option_number(user,type)
@@ -442,11 +482,15 @@ module UserScoreHelper
update_score(option_number)
end
+ def follow_num(user)
+ Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count
+ end
+
#更新帖子踩各项数量
def update_tread(user,type)
option_number = get_option_number(user,type)
- option_number.tread = PraiseTread.where("praise_tread_object_type = 'Memo' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count
- pts = PraiseTread.where("praise_tread_object_type = 'Memo' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all
+ option_number.tread = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count
+ pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all
result = []
result1 = []
result2 = []
@@ -472,10 +516,64 @@ module UserScoreHelper
update_score(option_number)
end
+ def tread_num(user,project=nil)
+ if project.nil?
+ result0 = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count
+ pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all
+ result = []
+ result1 = []
+ result2 = []
+ pts.each do |pt|
+ obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id)
+ if obj.nil?
+ next
+ end
+ target_user = obj.author
+ level = UserLevels.get_level(pt.user)#pt.user.get_level
+ project = pt.project
+ if level == 1 && target_user.id = user.id
+ result << pt
+ elsif level == 2 && target_user.id = user.id
+ result1 << pt
+ elsif level == 3 && target_user.id = user.id
+ result2 << pt
+ end
+ end
+ [:tread=>result0,:tead_by_one => result.count,:tread_by_two => result1.count,:tread_by_three =>result2.count]
+ else
+ result0 = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count
+ pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all
+ result = []
+ result1 = []
+ result2 = []
+ pts.each do |pt|
+ obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id)
+ if obj.nil?
+ next
+ end
+ if !(pt.praise_tread_object_type == "Issue" && obj.project.id == project.id) && !(pt.praise_tread_object_type == "Message" && obj.board.project.id == project.id)
+ next
+ end
+ target_user = obj.author
+ level = UserLevels.get_level(pt.user)#pt.user.get_level
+ project = pt.project
+ if level == 1 && target_user.id = user.id
+ result << pt
+ elsif level == 2 && target_user.id = user.id
+ result1 << pt
+ elsif level == 3 && target_user.id = user.id
+ result2 << pt
+ end
+ end
+ [:tread=>result0,:tead_by_one => result.count,:tread_by_two => result1.count,:tread_by_three =>result2.count]
+ end
+
+ end
+
#更新帖子顶数量
def update_praise(user,type)
option_number = get_option_number(user,type)
- pts = PraiseTread.where("praise_tread_object_type = 'Memo' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all
+ pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all
result = []
result1 = []
result2 = []
@@ -501,6 +599,58 @@ module UserScoreHelper
update_score(option_number)
end
+ def praise_num(user,project=nil)
+ if project.nil?
+ pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all
+ result = []
+ result1 = []
+ result2 = []
+ pts.each do |pt|
+ obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id)
+ if obj.nil?
+ next
+ end
+ if !(pt.praise_tread_object_type == "Issue" && obj.project.id == project.id) && !(pt.praise_tread_object_type == "Message" && obj.board.project.id == project.id)
+ next
+ end
+ target_user = obj.author
+ level = UserLevels.get_level(pt.user)#pt.user.get_level
+ project = pt.project
+ if level == 1 && target_user.id = user.id
+ result << pt
+ elsif level == 2 && target_user.id = user.id
+ result1 << pt
+ elsif level == 3 && target_user.id = user.id
+ result2 << pt
+ end
+ end
+ [:praise_by_one => result.count,:praise_by_two => result1.count,:praise_by_three => result2.count]
+ else
+ pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all
+ result = []
+ result1 = []
+ result2 = []
+ pts.each do |pt|
+ obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id)
+ if obj.nil?
+ next
+ end
+ target_user = obj.author
+ level = UserLevels.get_level(pt.user)#pt.user.get_level
+ project = pt.project
+ if level == 1 && target_user.id = user.id
+ result << pt
+ elsif level == 2 && target_user.id = user.id
+ result1 << pt
+ elsif level == 3 && target_user.id = user.id
+ result2 << pt
+ end
+ end
+ [:praise_by_one => result.count,:praise_by_two => result1.count,:praise_by_three => result2.count]
+ end
+
+ end
+
#更新提交代码次数
def update_changeset(user,type)
option_number = get_option_number(user,type)
@@ -508,6 +658,15 @@ module UserScoreHelper
update_score(option_number)
end
+ def changeset_num(user,project=nil)
+ if project.nil?
+ Changeset.includes(:user).where("user_id = '#{user.id}'").all.count
+ else
+ Changeset.includes(:user).joins(:repository).where("#{Changeset.table_name}.user_id = '#{user.id}' and #{Repository.table_name}.project_id = #{project.id}").all.count
+ end
+
+ end
+
#更新文档提交次数
def update_document(user,type)
option_number = get_option_number(user,type)
@@ -515,12 +674,30 @@ module UserScoreHelper
update_score(option_number)
end
+ def document_num(user,project=nil?)
+ if project.nil?
+ Document.includes(:user).where("user_id = '#{user.id}'").all.count
+ else
+ Document.includes(:user,:project).where("user_id = '#{user.id}' and project_id = '#{project.id}'").all.count
+ end
+
+ end
+
#更新附件提交数量
def update_attachment(user,type)
option_number = get_option_number(user,type)
option_number.attachment = Attachment.includes(:author).where("author_id = '#{user.id}'").all.count
update_score(option_number)
end
+ #===================here to continue============================
+ def attachment_num(user,project=nil)
+ if project.nil?
+ Attachment.includes(:author).where("author_id = '#{user.id}'").all.count
+ else
+ Attachment.includes(:author,:container).where("author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}").all.count
+ end
+
+ end
#更新缺陷完成度次数
def update_issue_done_ratio(user,type)
@@ -529,10 +706,18 @@ module UserScoreHelper
update_score(option_number)
end
+ def issue_done_ratio_num(user,project)
+ Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
+ end
+
#更新发布缺陷次数
def update_post_issue(user,type)
option_number = get_option_number(user,type)
option_number.post_issue = Issue.includes(:author).where("author_id = '#{user.id}'").all.count
update_score(option_number)
end
+
+ def post_issue_num(user,project=nil)
+ Issue.includes(:author).where("author_id = '#{user.id}'").all.count
+ end
end
diff --git a/app/models/contest.rb b/app/models/contest.rb
index e1706b166..f1503f593 100644
--- a/app/models/contest.rb
+++ b/app/models/contest.rb
@@ -6,7 +6,7 @@ class Contest < ActiveRecord::Base
has_many :contesting_projects, :dependent => :destroy
has_many :projects, :through => :contesting_projects
has_many :contesting_softapplications, :dependent => :destroy
- has_many :softapplications, :through => :contesting_softapplications
+ has_many :softapplications, :through => :contesting_softapplications, :dependent => :destroy
has_many :projects_member, :class_name => 'User', :through => :projects
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
diff --git a/app/models/contesting_softapplication.rb b/app/models/contesting_softapplication.rb
index f880818d9..f91c16f69 100644
--- a/app/models/contesting_softapplication.rb
+++ b/app/models/contesting_softapplication.rb
@@ -3,7 +3,7 @@ class ContestingSoftapplication < ActiveRecord::Base
attr_accessible :contest_id, :description, :softapplication_id, :user_id
belongs_to :contest
- belongs_to :softapplication
+ belongs_to :softapplication, :dependent => :destroy
belongs_to :user
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 83e7f8479..1978f5405 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -79,6 +79,7 @@ class Issue < ActiveRecord::Base
# fq
after_create :act_as_activity,:be_user_score_new_issue
after_update :be_user_score
+ before_destroy :down_user_score
# after_create :be_user_score
# end
@@ -1524,5 +1525,19 @@ class Issue < ActiveRecord::Base
update_post_issue(self.author,1)
end
+ def down_user_score
+ #缺陷完成度更新
+ if self.done_ratio_changed?
+ UserScore.project(:update_issue_ratio, User.current,self,{ issue_id: self.id })
+ #update_issue_done_ratio(User.current,1)
+ end
+ #缺陷状态更改
+ if self.status_id_changed?
+ #协同得分
+ UserScore.joint(:change_issue_status, User.current,nil,self, {issue_id: self.id})
+ #update_issues_status(self.author , 1)
+ end
+ end
+
end
diff --git a/app/models/issue_overdue.rb b/app/models/issue_overdue.rb
new file mode 100644
index 000000000..5caec94c9
--- /dev/null
+++ b/app/models/issue_overdue.rb
@@ -0,0 +1,33 @@
+class IssueOverdue < ActiveRecord::Base
+#缺陷到期后发送邮件提示
+#只监听已经提交的未到期的缺陷,已过期的缺陷默认已经发过邮件通知,不再提醒。
+ def self.mail_issue
+ threads = []
+ issues = Issue.where("done_ratio <> 100 and closed_on is null and due_date is not null")
+ puts issues
+ issues.each do |issue|
+ thread = Thread.new do
+ while true
+ cur_issue = Issue.find issue.id
+ if cur_issue.done_ratio == 100 || cur_issue.closed_on != nil
+ break
+ end
+ if Time.now < Time.parse(cur_issue.due_date.to_s)
+ #休眠一个小时。。。
+ puts cur_issue.id.to_s
+ sleep 5
+ else
+ #发邮件
+ #puts "11" + issue.id.to_s
+ #Mailer.issue_expire(issue).deliver
+ Mailer.issue_add(issue).deliver
+ break
+ end
+ end
+ end
+ threads << thread
+ end
+ puts threads
+ return threads
+ end
+end
\ No newline at end of file
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 8d03f2325..c08d8d630 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -48,9 +48,9 @@ class Journal < ActiveRecord::Base
# fq
after_create :act_as_activity,:be_user_score
# end
-
+ #after_destroy :down_user_score
#before_save :be_user_score
- #before_destroy :down_user_score
+ before_destroy :down_user_score
scope :visible, lambda {|*args|
user = args.shift || User.current
@@ -158,19 +158,20 @@ class Journal < ActiveRecord::Base
# 更新用户分数 -by zjc
def be_user_score
- #新建了缺陷留言且留言不为空,不为空白
+ #新建了缺陷留言且留言不为空,不为空白
if !self.notes.nil? && self.notes.gsub(' ','') != ''
#协同得分加分
- UserScore.joint(:post_issue_message, User.current,self.issue.author,self, { message_id: self.id })
- update_messges_for_issue(User.current,1)
+ UserScore.joint(:post_issue_message, self.user,self.issue.author,self, { message_id: self.id })
end
+ #update_messges_for_issue(User.current,1)
end
# 减少用户分数 -by zjc
def down_user_score
#删除有效缺陷留言
if !self.notes.nil? && self.notes.gsub(' ','') != ''
#协同得分减分
- UserScore.joint(:delete_issue_message, User.current,self.issue.author, { message_id: self.id })
+ UserScore.joint(:delete_issue_message, self.user,self.issue.author,self, { message_id: self.id })
end
+ #update_messges_for_issue(User.current,1)
end
end
diff --git a/app/models/journal_detail.rb b/app/models/journal_detail.rb
index 4100a5b1c..c2b0aaa2a 100644
--- a/app/models/journal_detail.rb
+++ b/app/models/journal_detail.rb
@@ -20,6 +20,8 @@ class JournalDetail < ActiveRecord::Base
belongs_to :journal
before_save :normalize_values
after_create :be_user_score
+ #after_destroy :down_user_score
+ before_destroy :down_user_score
private
def normalize_values
@@ -42,11 +44,24 @@ class JournalDetail < ActiveRecord::Base
def be_user_score
#更新缺陷完成度
- if self.prop_key = 'done_ratio'
- update_issue_done_ratio(User.current,1)
+ if self.prop_key == 'done_ratio'
+ #update_issue_done_ratio(User.current,1)
#更新缺陷状态
- elsif self.prop_key = 'status_id'
- update_issues_status(User.current , 1)
+ elsif self.prop_key == 'status_id'
+ #update_issues_status(User.current , 1)
+ end
+ end
+
+ #更新用户分数
+ def down_user_score
+ #update_issue_done_ratio(User.current,1)
+ #update_issues_status(User.current , 1)
+
+ if self.prop_key == 'done_ratio'
+
+ #更新缺陷状态
+ elsif self.prop_key == 'status_id'
+ UserScore.joint(:delete_issue_status, self.journal.user,nil,self, {issue_id: self.id})
end
end
diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb
index 4debe668f..c79004794 100644
--- a/app/models/journals_for_message.rb
+++ b/app/models/journals_for_message.rb
@@ -68,6 +68,7 @@ class JournalsForMessage < ActiveRecord::Base
return true
end
end
+
def self.remove_by_user? user
if( self.user == user ||
@@ -87,6 +88,15 @@ class JournalsForMessage < ActiveRecord::Base
def reference_user
User.find(reply_id)
end
+
+ def delete_by_user?user
+ # 用户可删除自己的留言
+ if self.user.id == user.id || user.admin?
+ return true
+ else
+ return false
+ end
+ end
def self.reference_message(user_id)
@user = User.find(user_id)
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index ecc7a8d91..f6c5e1a9e 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -104,7 +104,7 @@ class Mailer < ActionMailer::Base
message_id issue
@author = issue.author
@issue = issue
- @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
+ @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id)
recipients = issue.recipients
cc = issue.watcher_recipients - recipients
mail :to => recipients,
@@ -167,12 +167,6 @@ class Mailer < ActionMailer::Base
#缺陷到期邮件通知
def issue_expire issue
- #@issues = issues
- #s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}")
- #puts s + "////" + issue.assigned_to.mail
- #@issues_url = url_for(:controller => 'issues', :action => 'show',:id => issue.id)
- #mail :to => issue.assigned_to.mail,
- # :subject => s
issue_id = issue.project_index
redmine_headers 'Project' => issue.project.identifier,
'Issue-Id' => issue_id,
@@ -181,12 +175,34 @@ class Mailer < ActionMailer::Base
message_id issue
@author = issue.author
@issue = issue
- @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
+ @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id)
recipients = issue.recipients
- cc = issue.watcher_recipients - recipients
+ s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}")
mail :to => recipients,
- :cc => cc,
- :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}"
+ :subject => s
+ #########################################################################################################
+ #@issues = issues
+ #s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}")
+ #puts s + "////" + issue.assigned_to.mail
+ #@issues_url = url_for(:controller => 'issues', :action => 'show',:id => issue.id)
+ #mail :to => issue.assigned_to.mail,
+ # :subject => s
+ #########################################################################################################
+ #issue_id = issue.project_index
+ #redmine_headers 'Project' => issue.project.identifier,
+ # 'Issue-Id' => issue_id,
+ # 'Issue-Author' => issue.author.login
+ #redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
+ #message_id issue
+ #@author = issue.author
+ #@issue = issue
+ #@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
+ #recipients = issue.recipients
+ #cc = issue.watcher_recipients - recipients
+ #mail :to => recipients,
+ # :cc => cc,
+ # :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}"
+ ######################################################################################################
end
@@ -566,34 +582,7 @@ class Mailer < ActionMailer::Base
end
end
- #缺陷到期后发送邮件提示
- def mail_issue
- threads = []
- issues = Issue.where("done_ratio <> 100 && closed_on is null && due_date is not null")
- issues.each do |issue|
- thread = Thread.start do
- while true
- cur_issue = Issue.find issue.id
- if cur_issue.done_ratio == 100 || cur_issue.closed_on != nil
- break
- end
- if Time.now < Time.parse(cur_issue.due_date.to_s)
- #休眠一个小时。。。
- sleep 3600
- else
- #发邮件
- puts issue.id.to_s
- Mailer.issue_expire(issue).deliver
- #Mailer.issue_add(issue).deliver
- break
- end
- end
- end
- threads << thread
- end
- puts threads.count.to_s
- threads
- end
+
private
diff --git a/app/models/memo.rb b/app/models/memo.rb
index 6370065ba..1d191e39d 100644
--- a/app/models/memo.rb
+++ b/app/models/memo.rb
@@ -42,9 +42,9 @@ class Memo < ActiveRecord::Base
"parent_id",
"replies_count"
- after_create :add_author_as_watcher, :reset_counters!,:be_user_score
+ after_create :add_author_as_watcher, :reset_counters!#,:be_user_score -- 公共区发帖暂不计入得分
# after_update :update_memos_forum
- after_destroy :reset_counters!
+ after_destroy :reset_counters!#,:down_user_score -- 公共区发帖暂不计入得分
# after_create :send_notification
# after_save :plusParentAndForum
# after_destroy :minusParentAndForum
@@ -157,4 +157,10 @@ class Memo < ActiveRecord::Base
end
end
+ #被删除时更新用户分数
+ def down_user_score
+ update_memo_number(User.current,1)
+ update_replay_for_memo(User.current,1)
+ end
+
end
diff --git a/app/models/message.rb b/app/models/message.rb
index 2c183dc59..a57797af1 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -59,12 +59,12 @@ class Message < ActiveRecord::Base
after_create :add_author_as_watcher, :reset_counters!
after_update :update_messages_board
- after_destroy :reset_counters!
+ after_destroy :reset_counters!#,:down_user_score
# fq
after_create :act_as_activity,:be_user_score
#before_save :be_user_score
- #before_destroy :down_user_score
+ before_destroy :down_user_score
# end
scope :visible, lambda {|*args|
@@ -149,23 +149,24 @@ class Message < ActiveRecord::Base
#更新用户分数 -by zjc
def be_user_score
#新建message且无parent的为发帖
- if self.parent_id.nil?
- UserScore.joint(:post_message, User.current,nil,self, { message_id: self.id })
- update_memo_number(User.current,1)
+ if self.parent_id.nil? && !self.board.project.nil?
+ UserScore.joint(:post_message, self.author,nil,self, { message_id: self.id })
+ #update_memo_number(User.current,1)
#新建message且有parent的为回帖
- elsif !self.parent_id.nil?
- UserScore.joint(:reply_posting, User.current,self.parent.author,self, { message_id: self.id })
- update_replay_for_memo(User.current,1)
+ elsif !self.parent_id.nil? && !self.board.project.nil?
+ UserScore.joint(:reply_posting, self.author,self.parent.author,self, { message_id: self.id })
+ #update_replay_for_memo(User.current,1)
end
end
+
#减少用户分数
def down_user_score
- #删除发帖
- if self.parent_id.nil?
- UserScore.joint(:delete_message, User.current,nil, { message_id: self.id })
- #删除留言
- else
- UserScore.joint(:reply_deleting, User.current,self.parent.author, { message_id: self.id })
+ if self.parent_id.nil? && !self.board.project.nil?
+ UserScore.joint(:delete_message, self.author,nil,self, { message_id: self.id })
+ elsif !self.parent_id.nil? && !self.board.project.nil?
+ UserScore.joint(:reply_deleting, self.author,self.parent.author,self, { message_id: self.id })
end
+ #update_memo_number(User.current,1)
+ #update_replay_for_memo(User.current,1)
end
end
diff --git a/app/models/project.rb b/app/models/project.rb
index d6283e44f..1a2c0504d 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -758,6 +758,7 @@ class Project < ActiveRecord::Base
'tracker_ids',
'issue_custom_field_ids',
'project_type',
+ 'dts_test',
'attachmenttype'
diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb
index 770d70d53..a572a22ba 100644
--- a/app/models/softapplication.rb
+++ b/app/models/softapplication.rb
@@ -11,6 +11,10 @@ class Softapplication < ActiveRecord::Base
belongs_to :project
has_many :contests, :through => :contesting_softapplications
+ validates_length_of :name, :maximum => 125
+ validates_length_of :application_developers, :maximum => 125
+ validates_length_of :android_min_version_available, :maximum => 125
+
def add_jour(user, notes, reference_user_id = 0, options = {})
if options.count == 0
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
diff --git a/app/models/user_score.rb b/app/models/user_score.rb
index 6371fc12d..219c7e8e5 100644
--- a/app/models/user_score.rb
+++ b/app/models/user_score.rb
@@ -69,10 +69,11 @@ class UserScore < ActiveRecord::Base
end
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 => UserLevels.get_level(current_user),: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 :delete_message # current_user 删帖了 Delete 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 => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
+ 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
@@ -81,11 +82,12 @@ class UserScore < ActiveRecord::Base
user_grade.save
end
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 => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),: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_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})"
+ Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a issue message. 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
+ create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "delete_issue_message",:user_id => current_user.id,:old_score => user_score.collaboration + 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
+ Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue message. options => (#{options.to_s})"
when :change_issue_status # current_user 更改了缺陷的状态 Changed Issue
user_score.collaboration = user_score.collaboration.to_i + 1
user_score.save
@@ -95,6 +97,11 @@ class UserScore < ActiveRecord::Base
end
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 => UserLevels.get_level(current_user),: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 :delete_issue_status
+ 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 => "delete_issue_status",:user_id => current_user.id,:old_score => user_score.collaboration + 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
+ Rails.logger.info "[UserScore#joint] ===> User: #{current_user} delete 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
@@ -117,10 +124,10 @@ class UserScore < ActiveRecord::Base
end
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 => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),: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
@@ -329,6 +336,11 @@ class UserScore < ActiveRecord::Base
end
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 => UserLevels.get_level(current_user),: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 :delete_issue_ratio
+ 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 => "delete_issue_ratio",:user_id => current_user.id,:old_score => user_score.active + 2,:new_score => user_score.active,:current_user_level => UserLevels.get_level(current_user),: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}] delete issue ratio. options => (#{options.to_s})"
when :post_issue # current_user 发布了缺陷 issue
user_score.active = user_score.active.to_i + 4
user_score.save
diff --git a/app/views/admin/first_page_made.html.erb b/app/views/admin/first_page_made.html.erb
index b83e54db1..8cb5b3716 100644
--- a/app/views/admin/first_page_made.html.erb
+++ b/app/views/admin/first_page_made.html.erb
@@ -27,24 +27,35 @@
<%= l(:label_imgae_height)%>:
<%= text_field_tag 'image_height', params[:label_imgae_height], :value => @first_page.image_height,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
-
+
+ <%= l(:label_show_course) %>:
+
+ ><%= l(:general_text_yes) %>
+ ><%= l(:general_text_no) %>
+
+
+
+ <%= l(:label_show_contest) %>:
+
+ ><%= l(:general_text_yes) %>
+ ><%= l(:general_text_no) %>
+
+
+
+ <%= l(:label_sort_type)%>:
+
+ ><%= l(:label_sort_by_active) %>
+ ><%= l(:label_sort_by_influence) %>
+ ><%= l(:label_sort_by_time) %>
+
+
<%= l(:label_site_description)%>:
<%= text_area 'first_page', 'description', :value => @first_page.description,:cols => 80, :rows => 15, :class => 'wiki-edit' %>
<%= wikitoolbar_for 'first_page_description' %>
-
- <%= l(:label_sort_type)%>:
-
- ><%= l(:label_sort_by_active) %>
- ><%= l(:label_sort_by_influence) %>
- ><%= l(:label_sort_by_time) %>
-
-
+
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %>
diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb
index f8447590c..a1efc32fc 100644
--- a/app/views/admin/index.html.erb
+++ b/app/views/admin/index.html.erb
@@ -1,6 +1,6 @@
<%=l(:label_administration)%>
-
+
<%= render :partial => 'menu' %>
diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb
index 52b090bd8..cdd1fdd2f 100644
--- a/app/views/attachments/_links.html.erb
+++ b/app/views/attachments/_links.html.erb
@@ -1,6 +1,9 @@
<% for attachment in attachments %>
-
<%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
+
+
+ <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
+
<% if attachment.is_text? %>
<%= link_to image_tag('magnifier.png'),
:controller => 'attachments', :action => 'show',
@@ -15,11 +18,20 @@
:method => :delete,
:class => 'delete',
:title => l(:button_delete) %>
- <% else %>
+ <%# elsif attachment.container_type == 'Softapplication'%>
+ <%#= link_to image_tag('delete.png'), delete_softapplications_attachments_path(:id => attachment.id),
+ :data => {:confirm => l(:text_are_you_sure)},
+ :method => :delete,
+ :class => 'delete',
+ :remote => true,
+ :title => l(:button_delete) %>
+ <% else %>
<%= link_to image_tag('delete.png'), attachment_path(attachment),
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,
:class => 'delete',
+ :remote => true,
+ #:id => "attachments_" + attachment.id.to_s,
:title => l(:button_delete) %>
<% end %>
<% end %>
diff --git a/app/views/attachments/delete_softapplications.js.erb b/app/views/attachments/delete_softapplications.js.erb
new file mode 100644
index 000000000..95085ba93
--- /dev/null
+++ b/app/views/attachments/delete_softapplications.js.erb
@@ -0,0 +1,2 @@
+<% options = {:author => true, :deletable => true} %>
+$("#soft_attachments_links").html('<%= escape_javascript(render(:partial => 'links', :locals => {:attachments => @softapplication.attachments, :options => options} )) %>');
\ No newline at end of file
diff --git a/app/views/auto_completes/issues.html.erb b/app/views/auto_completes/issues.html.erb
index b097eaff4..1df31e41b 100644
--- a/app/views/auto_completes/issues.html.erb
+++ b/app/views/auto_completes/issues.html.erb
@@ -1,6 +1,6 @@
<%= raw @issues.map {|issue| {
'id' => issue.id,
- 'label' => "#{issue.tracker} ##{issue.id}: #{truncate issue.subject.to_s, :length => 60}",
+ 'label' => "#{issue.tracker} ##{issue.project_index}: #{truncate issue.subject.to_s, :length => 60}",
'value' => issue.id
}
}.to_json
diff --git a/app/views/contests/_new_softapplication.html.erb b/app/views/contests/_new_softapplication.html.erb
new file mode 100644
index 000000000..c83bdf6e9
--- /dev/null
+++ b/app/views/contests/_new_softapplication.html.erb
@@ -0,0 +1,98 @@
+<%#= error_messages_for 'softapplication' %>
+<%= form_for Softapplication.new, :url => softapplications_path do |f| %>
+
+ <%= hidden_field_tag 'contest_id', @contest.id %>
+
+ <%= l(:label_work_name) %>
+ * :
+ <%= f.text_field :name, :required => true, :size => 60, :style => "width:350px;" %>
+ (<%= l(:label_workname_lengthlimit) %>)
+
+
+
+
+
+
+ <%= l(:label_running_platform) %>
+ * :
+
+ <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:350px;" %>
+
+ (<%= l(:label_workdescription_lengthlimit) %>)
+
+
+
+
+
+
+ <%= l(:label_work_type) %>
+ * :
+
+
+ <%#= select_tag 'app_type_name', work_type_opttion, {:name => 'app_type_name',:style => "width:358px;"} %>
+
+ <%= f.select :app_type_name,work_type_opttion, {},{:style => "width:358px;",:onchange => "selectChange(this)"} %>
+ <%#= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %>
+
+
+ <%#= f.text_field :other_input, :required => true, :size => 60, :style => "width:100px;" %>
+
+
+
+
+
+
+
+
+ <%= l(:label_work_description) %>
+ * :
+ <%= f.text_field :description, :required => true, :size => 60, :style => "width:350px;" %>
+
+
+
+
+
+
+
+ <%= l(:label_softapplication_developers) %>
+ * :
+ <%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:350px;" %>
+ (<%= l(:label_workdescription_lengthlimit) %>)
+
+
+
+
+
+
+ <%= l(:label_work_deposit_project) %>:
+ <%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:358px;" %>
+ <%= link_to l(:label_create_new_projects),{:controller => 'projects',:action => 'new',course: 0, project_type: 0,host: Setting.project_domain}, :target => '_blank' %>
+
+
+
+
+
+
+
+ <%= l(:label_upload_softworkpacket_photo) %>
+
+ <%#= render_flash_messages %>
+
+ <%= render :partial => 'attachments/form' %>
+
+
+
+ 1、<%= l(:label_upload_softapplication_packets_mustpacketed) %>
+
+ 2、<%= l(:label_upload_softapplication_photo_condition) %>
+
+
+
+
+
+ <%= submit_tag l(:button_create) %>
+ <%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();",
+ :type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'",
+ :onmouseover => "this.style.backgroundPosition = 'left -30px'" %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/contests/index.html.erb b/app/views/contests/index.html.erb
index 8c999f941..6f8430ca0 100644
--- a/app/views/contests/index.html.erb
+++ b/app/views/contests/index.html.erb
@@ -6,17 +6,17 @@
<%= l(:label_user_location) %> :
<% if User.current.logged? %>
- <% unless User.current.user_extensions.identity == 1 %>
- <%= link_to(l(:label_newtype_contest), {:controller => 'contests', :action => 'new_contest'}, :class => 'icon icon-add', :target => "_blank") %>
- <% end %>
- <% end %>
+ <% unless User.current.user_extensions.identity == 1 %>
+ <%= link_to(l(:label_newtype_contest), {:controller => 'contests', :action => 'new_contest'}, :class => 'icon icon-add', :target => "_blank") %>
+ <% end %>
+ <% end %>
-
-
+
+
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %>
-
+
diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb
index b261780bd..799656f36 100644
--- a/app/views/contests/show_attendingcontest.html.erb
+++ b/app/views/contests/show_attendingcontest.html.erb
@@ -88,7 +88,7 @@
<%= l(:label_attending_contest) %>:
- <%= link_to l(:label_new_attendingcontest_work), "javascript:void(0);", onclick: "$('#put-project-form').toggle();" %>
+ <%= link_to l(:label_new_attendingcontest_work), "javascript:void(0);", onclick: "$('#put-project-form').slideToggle();" %>
<% else %>
@@ -99,102 +99,8 @@
<% end %>
-
<%= format_time(comment.created_on) %>
- <%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment},
+ <%= link_to_if_authorized_course image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment},
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %>
diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb
index f5781b26a..47a87f441 100644
--- a/app/views/projects/_form.html.erb
+++ b/app/views/projects/_form.html.erb
@@ -15,9 +15,11 @@
<%= f.check_box :is_public, :style => "margin-left:10px;" %>
<%= f.check_box :hidden_repo, :style => "margin-left:10px;" %>
+
<%= f.text_field :project_type, :value => 0 %>
<%= wikitoolbar_for 'project_description' %>
diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb
index c057202f8..41ad2a62c 100644
--- a/app/views/projects/_project.html.erb
+++ b/app/views/projects/_project.html.erb
@@ -12,7 +12,7 @@
- <%= textilizable(project.short_description, :project => project) %>
+ <%= textilizable(project.short_description.strip, :project => project) %>
@@ -45,7 +45,7 @@
- <% find_project_repository @project %>
+ <% #find_project_repository @project %>
<%= content_tag('span', "#{@project.repository.nil? || @project.project_status.nil? ? '0' : @project.project_status.changesets_count }", :class => "info") %>
diff --git a/app/views/projects/_tools_expand.html.erb b/app/views/projects/_tools_expand.html.erb
index 5ee70fa9d..df6cd481b 100644
--- a/app/views/projects/_tools_expand.html.erb
+++ b/app/views/projects/_tools_expand.html.erb
@@ -16,7 +16,7 @@
<%= link_to l(:project_module_gantt) ,project_gantt_path(@project) %>
其他工具
- <% if @project.dts_test == 1 %>
+ <% if @project.enabled_modules.where(" name = 'dts'").count > 0 %>
<%= link_to l(:label_module_share) ,share_show_path(@project) %>
<% end %>
<%= link_to l(:project_module_documents), project_documents_path(@project) %>
diff --git a/app/views/projects/new.html.erb b/app/views/projects/new.html.erb
index 0b76a7f44..184a67e3d 100644
--- a/app/views/projects/new.html.erb
+++ b/app/views/projects/new.html.erb
@@ -1,28 +1,15 @@
<% @nav_dispaly_project_label = 1
@nav_dispaly_forum_label = 1 %>
+
<%= labelled_form_for @project do |f| %>
-
- <% if @course_tag == '1' %>
- <%=l(:label_course_new)%>
-
-
- <%= render :partial => 'course_form', :locals => { :f => f } %>
-
- <%= submit_tag l(:button_create), :class => "enterprise"%>
-
-
-
- <% else %>
- <%=l(:label_project_new)%>
-
-
<%=raw l(:label_project_new_description)%>
- <%= render :partial => 'form', :locals => { :f => f } %>
-
- <%= submit_tag l(:button_create), :class => "enterprise"%>
-
-
-
- <% end %>
- <%= javascript_tag "$('#project_name').focus();" %>
+ <%=l(:label_project_new)%>
+
+
<%=raw l(:label_project_new_description)%>
+ <%= render :partial => 'form', :locals => { :f => f } %>
+
+ <%= submit_tag l(:button_create), :class => "enterprise"%>
+
+
+ <%#= submit_tag l(:button_create_and_continue), :name => 'continue' %>
+ <%= javascript_tag "$('#project_name').focus();" %>
<% end %>
-
diff --git a/app/views/projects/settings/_members.html.erb b/app/views/projects/settings/_members.html.erb
index f69f9edff..ab046bcb6 100644
--- a/app/views/projects/settings/_members.html.erb
+++ b/app/views/projects/settings/_members.html.erb
@@ -92,6 +92,7 @@
<%= render_principals_for_applied_members(@project) %>
+
<%= l(:label_role_plural) %>:
<% roles.each do |role| %>
diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb
index db51eca1d..e299be182 100644
--- a/app/views/projects/show.html.erb
+++ b/app/views/projects/show.html.erb
@@ -25,6 +25,11 @@
<%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Project)) ? project_files_path(e.container) : e.event_url %>
+
+
+ <%#= textilizable e.event_url,:description %>
+
+
<%= h(truncate(strip_tags(e.event_description).gsub(/ /, ' '), length: 30, omission: '...')) %>
diff --git a/app/views/repositories/_form_create.html.erb b/app/views/repositories/_form_create.html.erb
index 89ae6ffd0..669f47071 100644
--- a/app/views/repositories/_form_create.html.erb
+++ b/app/views/repositories/_form_create.html.erb
@@ -22,12 +22,12 @@ border:none
<% end %>
<%= f.check_box :is_default, :label => :field_repository_is_default %>
-
<%= f.text_field :identifier, :required=>true, :disabled => @repository.identifier_frozen?, :label => l(:label_repository_name) %>
+
<%= f.text_field :identifier, :required=>true, :disabled => @repository.identifier_frozen?, :label => l(:label_repository_name)%>
<% unless @repository.identifier_frozen? %>
<%= l(:text_length_between, :min => 1, :max => Repository::IDENTIFIER_MAX_LENGTH) %>
<%= l(:text_repository_identifier_info).html_safe %>
<% end %>
-
+
<%= f.password_field :upassword, :required =>true, :label=> :field_password %>
<%= l(:label_upassword_info)%>
diff --git a/app/views/softapplications/_form.html.erb b/app/views/softapplications/_form.html.erb
index 27954a7d0..17cb20598 100644
--- a/app/views/softapplications/_form.html.erb
+++ b/app/views/softapplications/_form.html.erb
@@ -32,7 +32,7 @@
<%= l(:label_work_name) %>
* : <%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %>
- <%= l(:label_softapplication_name_condition)%>
+ (<%= l(:label_workname_lengthlimit) %>)
@@ -40,7 +40,7 @@
<%= l(:label_running_platform) %>
* : <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %>
-
+ (<%= l(:label_workdescription_lengthlimit) %>)
@@ -73,7 +73,7 @@
<%= l(:label_work_description) %>
* : <%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %>
- <%= l(:label_softapplication_description_condition)%>
+
@@ -82,7 +82,7 @@
<%= l(:label_softapplication_developers) %>
* : <%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:400px;" %>
-
+ (<%= l(:label_workdescription_lengthlimit) %>)
@@ -100,10 +100,17 @@
+
+ <% options = {:author => true, :deletable => true} %>
+
+ <%= render :partial => 'attachments/links',
+ :locals => {:attachments => @softapplication.attachments, :options => options} %>
+
+
<%=l(:label_upload_softworkpacket_photo)%>
<%= render_flash_messages %>
- <%= render :partial => 'attachments/form' %>
+ <%= render :partial => 'attachments/form' %>
1、<%=l(:label_upload_softapplication_packets_mustpacketed)%> 2、<%=l(:label_upload_softapplication_photo_condition)%>
<%=l(:label_updated_caution)%>
diff --git a/app/views/softapplications/_list.html.erb b/app/views/softapplications/_list.html.erb
new file mode 100644
index 000000000..4f99519b5
--- /dev/null
+++ b/app/views/softapplications/_list.html.erb
@@ -0,0 +1,24 @@
+
+ <% @softapplications.each do |softapplication| %>
+
+ <%= link_to softapplication.name, softapplication, :target => "_blank" %>
+ <%= rating_for softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %>
+
+
+ <%= image_tag('/images/app1.png')%>
+ <%= softapplication.description.truncate(95, omission: '...') %>
+
+ <%contest = softapplication.contests.first%>
+
<%=l(:label_attendingcontestwork_belongs_contest)%>:<%= contest ? link_to(contest.name.truncate(14, omission: '...'), show_attendingcontest_contest_path(contest), title: contest.name.to_s ) : '尚未加入竞赛'%>
+
<%=l(:label_attendingcontestwork_belongs_type)%>:<%= softapplication.app_type_name.truncate(10, omission: '...') %>
+
<%=l(:label_attendingcontestwork_adaptive_system)%>:<%= softapplication.android_min_version_available %>
+
+
+ <%=l(:label_attendingcontestwork_developers)%>:<%= softapplication.application_developers %>
+ <%=l(:label_attendingcontestwork_release_time)%>:<%=format_time softapplication.created_at %>
+
+
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/softapplications/index.html.erb b/app/views/softapplications/index.html.erb
index 5b355f65c..bccbd9bee 100644
--- a/app/views/softapplications/index.html.erb
+++ b/app/views/softapplications/index.html.erb
@@ -3,37 +3,15 @@
<%=render :partial => 'layouts/base_softapplication_index_top_content'%>
<% if @softapplications.size > 0%>
- <%= sort_softapplication(@s_state)%>
-
-
- <% @softapplications.each do |softapplication| %>
-
- <%= link_to softapplication.name, softapplication, :target => "_blank" %>
- <%= rating_for softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %>
-
-
-
<%= image_tag('/images/app1.png')%>
-
<%= softapplication.description.truncate(95, omission: '...') %>
-
- <%contest = softapplication.contests.first%>
-
<%=l(:label_attendingcontestwork_belongs_contest)%>:<%= contest ? link_to(contest.name.truncate(14, omission: '...'), show_attendingcontest_contest_path(contest), title: contest.name.to_s ) : '尚未加入竞赛'%>
-
<%=l(:label_attendingcontestwork_belongs_type)%>:<%= softapplication.app_type_name.truncate(10, omission: '...') %>
-
<%=l(:label_attendingcontestwork_adaptive_system)%>:<%= softapplication.android_min_version_available %>
-
-
- <%=l(:label_attendingcontestwork_developers)%>:<%= softapplication.application_developers %>
- <%=l(:label_attendingcontestwork_release_time)%>:<%=format_time softapplication.created_at %>
-
-
-
- <% end %>
+
+ <%= sort_softapplication(@s_state)%>
+ <%= render :partial => "list" %>
-
<% else %>
<%= render :partial => "layouts/no_content"%>
<% end %>
-
+
<% html_title l(:label_contest_work_list)%>
\ No newline at end of file
diff --git a/app/views/softapplications/search.html.erb b/app/views/softapplications/search.html.erb
new file mode 100644
index 000000000..0f0913139
--- /dev/null
+++ b/app/views/softapplications/search.html.erb
@@ -0,0 +1,11 @@
+<%=render :partial => 'layouts/base_softapplication_index_top_content'%>
+
+<% if @softapplications.size > 0%>
+ <%#= sort_softapplication(@s_state)%>
+
+ <%= render :partial => "list" %>
+
+<% else %>
+ <%= render :partial => "layouts/no_content"%>
+<% end %>
+<% html_title l(:label_contest_work_list)%>
\ No newline at end of file
diff --git a/app/views/softapplications/search.js.erb b/app/views/softapplications/search.js.erb
new file mode 100644
index 000000000..8b4b8afb2
--- /dev/null
+++ b/app/views/softapplications/search.js.erb
@@ -0,0 +1,2 @@
+
+$('#softapplications_list').html('<%= escape_javascript(render(:partial => 'list' )) %>');
\ No newline at end of file
diff --git a/app/views/tags/_show_attachments.html.erb b/app/views/tags/_show_attachments.html.erb
index 43ed76e02..8b0bb1f8b 100644
--- a/app/views/tags/_show_attachments.html.erb
+++ b/app/views/tags/_show_attachments.html.erb
@@ -1,5 +1,5 @@
-<% if attachments_results.try(:size).to_i < 0 %>
+<% if attachments_results.nil? || attachments_results.try(:size).to_i < 0 %>
<% else %>
<% attachments_results.each do |file| %>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index 6270b5f50..c4e0ef98d 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -88,7 +88,7 @@
<% when 'Bid' %>
- <% if act.reward_type ==3 %>
+ <% if act.reward_type == 3 && @show_course == 1%>
<% if e.user == User.current %>
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to format_activity_title("#{l(:label_active_homework)}##{act.id}:#{act.name}"), respond_path(e.act_id) %>
@@ -137,7 +137,12 @@
<% end %>
- <%= act.notes.html_safe %>
+ <% if act.notes.nil? %>
+ <% desStr = '' %>
+ <% else %>
+ <% desStr=act.notes.html_safe %>
+ <% end %>
+ <%= desStr %>
@@ -252,17 +257,35 @@
<% if e.user == User.current %>
- <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %>
+
+ <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %>
+
+
+ <%= l(:label_i_new_activity) %>
+
+ <%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %>
<% else %>
- <%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %>
+
+ <%= link_to(h(e.user), user_path(e.user_id)) %>
+
+
+ <%= l(:label_new_activity) %>
+
+ <%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %>
<% end %>
- <%= textilizable(act.description) %>
+
+
+ <%= textilizable act, :description %>
+
+
+
+
@@ -276,7 +299,7 @@
<% when 'Contest' %>
- <% if e.user == User.current %>
+ <% if e.user == User.current && @show_contest == 1%>
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to format_activity_title("#{l(:label_contest)}: #{act.name}"), {:controller => 'contests', :action => 'show_contest', :id => act.id} %>
diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb
index 10da9f331..27afed749 100644
--- a/app/views/welcome/contest.html.erb
+++ b/app/views/welcome/contest.html.erb
@@ -275,10 +275,10 @@
<%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %>
- <%=l(:label_question_sponsor)%>: <%= link_to_user(topic.author) %>
+ <%=l(:label_question_sponsor)%>: <%= link_to topic.author.login.truncate(10, omission: '...'),user_path(topic.author),title: topic.author.login %>
- <%=l(:label_final_reply)%>: <%=link_to_user topic.last_reply.try(:author) %>
+ <%=l(:label_final_reply)%>: <% unless (topic.last_reply.nil? || topic.last_reply.author.nil?) %><%=link_to topic.last_reply.author.login.truncate(10, omission: '...'),user_path(topic.last_reply.author),title: topic.last_reply.author.login%><% end %>
<%=l(:label_reply)%>(<%= link_to topic.try(:replies_count), topic.event_url %>)
diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb
index dae00f50e..3aca2c350 100644
--- a/app/views/welcome/course.html.erb
+++ b/app/views/welcome/course.html.erb
@@ -102,7 +102,7 @@
<% find_all_new_hot_course(9, @school_id).map do |course| %>
- >
+ /,"") %>>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
@@ -120,9 +120,9 @@
<%#=course.try(:teacher).try(:name)%>
-
+
[<%= get_course_term course %>]
- <%= link_to(course.name, course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
+ <%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= "#{studentCount(course)}人" %>)
<% files_count = course.attachments.count.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
@@ -148,7 +148,7 @@
-
+
[<%= get_course_term course %>]
- <%= link_to(course.name, course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
+ <%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= "#{studentCount(course)}人" %>)
<% files_count = course.attachments.count.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
@@ -188,7 +188,7 @@
<% find_all_new_hot_course(9 - school_course.count, @school_id).map do |course| %>
-
>
+ /,"") %>>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
@@ -206,10 +206,10 @@
<%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %>
-
+
[<%= get_course_term course %>]
- <%= link_to(course.name, course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
- <%= "#{studentCount(course)}人" %> )
+ <%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
+ (<%= "#{studentCount(course)}人" %> )
<% files_count = course.attachments.count.to_i.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
@@ -243,10 +243,10 @@
<%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %>
- 楼主: <%= link_to_user(topic.author) %>
+ 楼主: <%= link_to topic.author.login.truncate(10, omission: '...'),user_path(topic.author),title: topic.author.login %>
- 最后回复:<%= link_to_user topic.last_reply.try(:author) %>
+ 最后回复:<% unless (topic.last_reply.nil? || topic.last_reply.author.nil?) %><%=link_to topic.last_reply.author.login.truncate(10, omission: '...'),user_path(topic.last_reply.author),title: topic.last_reply.author.login%><% end %>
回复(<%= link_to topic.try(:replies_count), topic.event_url %>)
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb
index 7dd1e751d..f8c7f880d 100644
--- a/app/views/welcome/index.html.erb
+++ b/app/views/welcome/index.html.erb
@@ -166,10 +166,10 @@
<%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %>
- 楼主: <%= link_to_user(topic.author) %>
+ 楼主: <%= link_to topic.author.login.truncate(10, omission: '...'),user_path(topic.author),title: topic.author.login %>
- 最后回复:<%=link_to_user topic.last_reply.try(:author) %>
+ 最后回复:<% unless (topic.last_reply.nil? || topic.last_reply.author.nil?) %><%=link_to topic.last_reply.author.login.truncate(10, omission: '...'),user_path(topic.last_reply.author),title: topic.last_reply.author.login%><% end %>
回复(<%= link_to topic.try(:replies_count), topic.event_url %>)
diff --git a/config/configuration.yml b/config/configuration.yml
index a329ff100..833b19083 100644
--- a/config/configuration.yml
+++ b/config/configuration.yml
@@ -87,12 +87,12 @@ default:
- address: smtp.gmail.com
+ address: smtp.qq.com
port: 587
- domain: smtp.gmail.com
+ domain: smtp.qq.com
authentication: :plain
- user_name: trustieforge@gmail.com
- password: '!@#$%^&*('
+ user_name: 939547590@qq.com
+ password: 'suwen11223344'
# Absolute path to the directory where attachments are stored.
# The default is the 'files' directory in your Redmine instance.
diff --git a/config/initializers/task.rb b/config/initializers/task.rb
index f42741864..1c687d15e 100644
--- a/config/initializers/task.rb
+++ b/config/initializers/task.rb
@@ -1,4 +1,12 @@
-#Mailer.mail_issue.each do |t|
+#@threads = IssueOverdue.mail_issue
+#ii = 1
+#@threads.each do |t|
# t.join
#end
+#Thread.new do
+# if Time.now == Time.
+#
+# end
+#end
+
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 1e975decc..e1b93f649 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -186,6 +186,7 @@ en:
notice_account_deleted: "Your account has been permanently deleted."
notice_user_successful_create: "User %{id} created."
+ error_attachment_empty: "error in add file"
error_class_period_only_num: "class period can only digital"
error_can_t_load_default_data: "Default configuration could not be loaded: %{value}"
error_scm_not_found: "The entry or revision was not found in the repository."
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 76391e543..daf356e7d 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -195,6 +195,7 @@ zh:
notice_gantt_chart_truncated: "这个表是截断的因为它超过了可以显示的最大数量(%{max})"
error_complete_occupation: "请您填写工作单位,否则本系统的部分功能将无法正常使用。"
+ error_attachment_empty: "添加文件出错!"
error_class_period_only_num: "课程学时只能为数字"
error_can_t_load_default_data: "无法载入默认设置:%{value}"
@@ -251,7 +252,7 @@ zh:
field_lastname_eg: '(例:张三丰,请填写[张])'
field_mail: 邮件地址
field_filename: 文件
- field_file_dense: 文件密级
+ field_file_dense: 是否公开
field_filesize: 大小
field_downloads: 下载次数
field_author: 作者
@@ -498,13 +499,14 @@ zh:
project_module_time_tracking: 时间跟踪
project_module_news: 新闻
project_module_documents: 文档
- project_module_files: 资料下载
+ project_module_files: 作品下载
project_module_wiki: Wiki
project_module_repository: 版本库
project_module_boards: 讨论区
project_module_calendar: 日历
project_module_gantt: 甘特图
project_module_course: 课程
+ project_module_dts: DTS测试工具
label_module_share: DTS测试工具
label_user: 用户
@@ -579,6 +581,8 @@ zh:
label_sort_type: 热门项目排序方式
label_contest_notification_title: 竞赛通知标题
label_contest_notification_content: 竞赛通知内容
+ label_show_course: 显示课程
+ label_show_contest: 显示竞赛
#by young
label_requirement: 需求
label_new_course: 课程列表
@@ -2046,6 +2050,7 @@ zh:
notice_account_updated: 帐号更新成功
notice_attendingcontest_work_successfully_created: 恭喜您,参赛作品创建成功!
notice_softapplication_was_successfully_updated: 恭喜您,参赛作品更新成功!
+ notice_attendingcontest_work_failed_created: 参赛产品创建失败
label_attendingcontestwork_belongs_contest: 所属竞赛
label_attendingcontestwork_belongs_type: 所属类别
diff --git a/config/routes.rb b/config/routes.rb
index 948eee4a5..af70b76da 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -76,6 +76,7 @@ RedmineApp::Application.routes.draw do
collection do
match 'new_message', via: :get
+ match 'search', via: [:get, :post]
end
member do
match 'create_message' , via: :post
@@ -519,6 +520,7 @@ RedmineApp::Application.routes.draw do
match "updateType" , via: [:get, :post]
match "updateFileDense" , via: [:get, :post]
match "renderTag" , via: [:get, :post]
+ match 'delete_softapplications', via: [:get, :post]
end
end
diff --git a/config/settings.yml b/config/settings.yml
index cffbaa5fa..f1c584b2b 100644
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -75,6 +75,10 @@ host_course:
default: course.trustie.net
host_contest:
default: contest.trustie.net
+host_user:
+ default: user.trustie.net
+host_repository:
+ default: repository.trustie.net
protocol:
default: http
feeds_limit:
@@ -177,6 +181,7 @@ default_projects_modules:
- calendar
- gantt
- course
+ - dts
default_projects_tracker_ids:
serialized: true
default:
diff --git a/db/migrate/20140324015819_create_open_source_projects.rb b/db/migrate/20140324015819_create_open_source_projects.rb
index 22034c3bb..e454b3473 100644
--- a/db/migrate/20140324015819_create_open_source_projects.rb
+++ b/db/migrate/20140324015819_create_open_source_projects.rb
@@ -2,7 +2,7 @@ class CreateOpenSourceProjects < ActiveRecord::Migration
def change
create_table :open_source_projects do |t|
t.column "name", :string, :default => nil, :null => true
- t.column "description", :string, :default => '', :null => true
+ t.column "description", :text, :null => true
t.column "commit_count", :integer, :default => 0
t.column "code_line", :integer, :default => 0
t.column "users_count",:integer, :default => 0
diff --git a/db/migrate/20140411011700_change_description_type_to_open_source_project.rb b/db/migrate/20140411011700_change_description_type_to_open_source_project.rb
deleted file mode 100644
index 8c8804d8a..000000000
--- a/db/migrate/20140411011700_change_description_type_to_open_source_project.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class ChangeDescriptionTypeToOpenSourceProject < ActiveRecord::Migration
- def up
- change_column :open_source_projects, :description, :text
- end
-
- def down
- raise ActiveRecord::IrreversibleMigration
- end
-end
diff --git a/db/migrate/20140505082635_drop_user_scores.rb b/db/migrate/20140505082635_drop_user_scores.rb
deleted file mode 100644
index fc65788f2..000000000
--- a/db/migrate/20140505082635_drop_user_scores.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class DropUserScores < ActiveRecord::Migration
- def change
- drop_table :user_scores
- end
-end
diff --git a/db/migrate/20140505083430_create_user_scores.rb b/db/migrate/20140505083430_create_user_scores.rb
deleted file mode 100644
index 6c63aa327..000000000
--- a/db/migrate/20140505083430_create_user_scores.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class CreateUserScores < ActiveRecord::Migration
- def change
- create_table :user_scores do |t|
- t.integer :user_id
- t.integer :collaboration
- t.integer :influence
- t.integer :skill
- t.integer :activity
- end
- end
-end
diff --git a/db/migrate/20140606028512_add_course_roles.rb b/db/migrate/20140606028512_add_course_roles.rb
index 3435dd25f..05c678c62 100644
--- a/db/migrate/20140606028512_add_course_roles.rb
+++ b/db/migrate/20140606028512_add_course_roles.rb
@@ -4,49 +4,49 @@ class AddCourseRoles < ActiveRecord::Migration
# 添加课程权限
Role.all.each do |role|
if role.name == 'Non member'
- role.permissions.append(:view_course )
- role.permissions.append(:search_course )
- role.permissions.append(:add_course )
+ role.add_permission!(:view_course )
+ role.add_permission!(:search_course )
+ role.add_permission!(:add_course )
elsif role.name == 'Anonymous'
- role.permissions.append(:view_course )
- role.permissions.append(:search_course )
+ role.add_permission!(:view_course )
+ role.add_permission!(:search_course )
elsif role.name == 'Manager'
- role.permissions.append(:view_course )
- role.permissions.append(:search_course )
- role.permissions.append(:add_course )
- role.permissions.append(:close_course )
- role.permissions.append(:select_course_modules )
- role.permissions.append(:edit_course )
+ role.add_permission!(:view_course )
+ role.add_permission!(:search_course )
+ role.add_permission!(:add_course )
+ role.add_permission!(:close_course )
+ role.add_permission!(:select_course_modules )
+ role.add_permission!(:edit_course )
elsif role.name =='Developer'
- role.permissions.append(:view_course )
- role.permissions.append(:search_course )
- role.permissions.append(:add_course )
- role.permissions.append(:close_course )
- role.permissions.append(:select_course_modules )
- role.permissions.append(:edit_course )
+ role.add_permission!(:view_course )
+ role.add_permission!(:search_course )
+ role.add_permission!(:add_course )
+ role.add_permission!(:close_course )
+ role.add_permission!(:select_course_modules )
+ role.add_permission!(:edit_course )
elsif role.name == 'Reporter'
- role.permissions.append(:view_course )
- role.permissions.append(:search_course )
+ role.add_permission!(:view_course )
+ role.add_permission!(:search_course )
elsif role.name == '助教'
- role.permissions.append(:view_course )
- role.permissions.append(:search_course )
- role.permissions.append(:add_course )
- role.permissions.append(:select_course_modules )
- role.permissions.append(:edit_course )
+ role.add_permission!(:view_course )
+ role.add_permission!(:search_course )
+ role.add_permission!(:add_course )
+ role.add_permission!(:select_course_modules )
+ role.add_permission!(:edit_course )
elsif role.name == '老师'
- role.permissions.append(:view_course )
- role.permissions.append(:search_course )
- role.permissions.append(:add_course )
- role.permissions.append(:close_course )
- role.permissions.append(:select_course_modules )
- role.permissions.append(:edit_course )
+ role.add_permission!(:view_course )
+ role.add_permission!(:search_course )
+ role.add_permission!(:add_course )
+ role.add_permission!(:close_course )
+ role.add_permission!(:select_course_modules )
+ role.add_permission!(:edit_course )
elsif role.name == '学生'
- role.permissions.append(:view_course )
- role.permissions.append(:search_course )
+ role.add_permission!(:view_course )
+ role.add_permission!(:search_course )
end
- role.permissions.append(:view_course_files )
- role.permissions.append(:view_course_journals_for_messages )
- role.permissions.append(:view_course_messages )
+ role.add_permission!(:view_course_files )
+ role.add_permission!(:view_course_journals_for_messages )
+ role.add_permission!(:view_course_messages )
role.save(:validate => false)
end
end
diff --git a/db/migrate/20140710071720_create_first_pages.rb b/db/migrate/20140710071720_create_first_pages.rb
index c33283a06..a6af63ca4 100644
--- a/db/migrate/20140710071720_create_first_pages.rb
+++ b/db/migrate/20140710071720_create_first_pages.rb
@@ -9,12 +9,13 @@ class CreateFirstPages < ActiveRecord::Migration
t.timestamps
end
+
fp = FirstPage.new
fp.web_title = "Trustie - 为大学生技术创新筑巢"
fp.title = "Trustie在线项目托管平台"
fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。"
fp.page_type = "project"
- fp.save
+ fp.save(:validate => false)
end
end
diff --git a/db/migrate/20140711012924_add_contest_and_course_first_page.rb b/db/migrate/20140711012924_add_contest_and_course_first_page.rb
index 801219bd5..8a7673b11 100644
--- a/db/migrate/20140711012924_add_contest_and_course_first_page.rb
+++ b/db/migrate/20140711012924_add_contest_and_course_first_page.rb
@@ -6,12 +6,12 @@ class AddContestAndCourseFirstPage < ActiveRecord::Migration
fp.title = "Trustie在线课程实践平台"
fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。"
fp.page_type = "course"
- fp.save
+ fp.save(:validate => false)
fp1 = FirstPage.new
fp1.web_title = ""
fp1.title = "Trustie在线竞赛实战平台"
fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。"
fp1.page_type = "contest"
- fp1.save
+ fp1.save(:validate => false)
end
end
diff --git a/db/migrate/20140714081030_set_web_title.rb b/db/migrate/20140714081030_set_web_title.rb
index 51b1f6d89..73a536d1c 100644
--- a/db/migrate/20140714081030_set_web_title.rb
+++ b/db/migrate/20140714081030_set_web_title.rb
@@ -3,7 +3,7 @@ class SetWebTitle < ActiveRecord::Migration
def change
FirstPage.all.each do |fp|
fp.web_title = "Trustie - 为大学生技术创新筑巢"
- fp.save
+ fp.save(:validate => false)
end
end
end
diff --git a/db/migrate/20140716021558_set_sort_type.rb b/db/migrate/20140716021558_set_sort_type.rb
index 04511ca2b..0042749ba 100644
--- a/db/migrate/20140716021558_set_sort_type.rb
+++ b/db/migrate/20140716021558_set_sort_type.rb
@@ -2,7 +2,7 @@ class SetSortType < ActiveRecord::Migration
def change
FirstPage.all.each do |fp|
fp.sort_type = 1
- fp.save
+ fp.save(:validate => false)
end
end
end
diff --git a/db/migrate/20140719080032_repair_first_page.rb b/db/migrate/20140719080032_repair_first_page.rb
index a1faf7f90..60e429f04 100644
--- a/db/migrate/20140719080032_repair_first_page.rb
+++ b/db/migrate/20140719080032_repair_first_page.rb
@@ -9,7 +9,7 @@ class RepairFirstPage < ActiveRecord::Migration
fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。"
fp.page_type = "project"
fp.sort_type = 1
- fp.save
+ fp.save(:validate => false)
else
fp = pro_fps.first
fp.web_title = "Trustie - 为大学生技术创新筑巢"
@@ -17,7 +17,7 @@ class RepairFirstPage < ActiveRecord::Migration
fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。"
fp.page_type = "project"
fp.sort_type = 1
- fp.save
+ fp.save(:validate => false)
end
course_fps = FirstPage.where("page_type = 'course'")
if course_fps.nil? || course_fps.first.nil?
@@ -27,7 +27,7 @@ class RepairFirstPage < ActiveRecord::Migration
fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。"
fp.page_type = "course"
fp.sort_type = 1
- fp.save
+ fp.save(:validate => false)
else
fp = course_fps.first
fp.web_title = "Trustie - 为大学生技术创新筑巢"
@@ -35,7 +35,7 @@ class RepairFirstPage < ActiveRecord::Migration
fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。"
fp.page_type = "course"
fp.sort_type = 1
- fp.save
+ fp.save(:validate => false)
end
contest_fps = FirstPage.where("page_type = 'contest'")
if contest_fps.nil? || contest_fps.first.nil?
@@ -45,7 +45,7 @@ class RepairFirstPage < ActiveRecord::Migration
fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。"
fp1.page_type = "contest"
fp1.sort_type = 1
- fp1.save
+ fp1.save(:validate => false)
else
fp1 = contest_fps.first
fp1.web_title = "Trustie - 为大学生技术创新筑巢"
@@ -53,7 +53,7 @@ class RepairFirstPage < ActiveRecord::Migration
fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。"
fp1.page_type = "contest"
fp1.sort_type = 1
- fp1.save
+ fp1.save(:validate => false)
end
end
end
diff --git a/db/migrate/20140728014933_first_page_add_column.rb b/db/migrate/20140728014933_first_page_add_column.rb
new file mode 100644
index 000000000..408cdc54c
--- /dev/null
+++ b/db/migrate/20140728014933_first_page_add_column.rb
@@ -0,0 +1,5 @@
+class FirstPageAddColumn < ActiveRecord::Migration
+ def change
+ add_column("first_pages","show_course",:integer,default: 1)
+ end
+end
diff --git a/db/migrate/20140730021521_first_page_add_contest_column.rb b/db/migrate/20140730021521_first_page_add_contest_column.rb
new file mode 100644
index 000000000..884847722
--- /dev/null
+++ b/db/migrate/20140730021521_first_page_add_contest_column.rb
@@ -0,0 +1,5 @@
+class FirstPageAddContestColumn < ActiveRecord::Migration
+ def change
+ add_column("first_pages","show_contest",:integer,default: 1)
+ end
+end
diff --git a/db/migrate/20140730024419_update_contestnotifications_description.rb b/db/migrate/20140730024419_update_contestnotifications_description.rb
new file mode 100644
index 000000000..a959e93bd
--- /dev/null
+++ b/db/migrate/20140730024419_update_contestnotifications_description.rb
@@ -0,0 +1,9 @@
+class UpdateContestnotificationsDescription < ActiveRecord::Migration
+ def up
+ change_column :contestnotifications, :description, :text
+ end
+
+ def down
+ change_column :contestnotifications, :description, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 2927e6fac..72e6ccba9 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20140725062302) do
+ActiveRecord::Schema.define(:version => 20140730024419) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -177,58 +177,6 @@ ActiveRecord::Schema.define(:version => 20140725062302) do
add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true
- create_table "code_review_assignments", :force => true do |t|
- t.integer "issue_id"
- t.integer "change_id"
- t.integer "attachment_id"
- t.string "file_path"
- t.string "rev"
- t.string "rev_to"
- t.string "action_type"
- t.integer "changeset_id"
- end
-
- create_table "code_review_project_settings", :force => true do |t|
- t.integer "project_id"
- t.integer "tracker_id"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.integer "updated_by"
- t.boolean "hide_code_review_tab", :default => false
- t.integer "auto_relation", :default => 1
- t.integer "assignment_tracker_id"
- t.text "auto_assign"
- t.integer "lock_version", :default => 0, :null => false
- t.boolean "tracker_in_review_dialog", :default => false
- end
-
- create_table "code_review_user_settings", :force => true do |t|
- t.integer "user_id", :default => 0, :null => false
- t.integer "mail_notification", :default => 0, :null => false
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- create_table "code_reviews", :force => true do |t|
- t.integer "project_id"
- t.integer "change_id"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.integer "line"
- t.integer "updated_by_id"
- t.integer "lock_version", :default => 0, :null => false
- t.integer "status_changed_from"
- t.integer "status_changed_to"
- t.integer "issue_id"
- t.string "action_type"
- t.string "file_path"
- t.string "rev"
- t.string "rev_to"
- t.integer "attachment_id"
- t.integer "file_count", :default => 0, :null => false
- t.boolean "diff_all"
- end
-
create_table "comments", :force => true do |t|
t.string "commented_type", :limit => 30, :default => "", :null => false
t.integer "commented_id", :default => 0, :null => false
@@ -272,7 +220,7 @@ ActiveRecord::Schema.define(:version => 20140725062302) do
t.integer "contest_id"
t.string "title"
t.string "summary"
- t.string "description"
+ t.text "description"
t.integer "author_id"
t.integer "notificationcomments_count"
t.datetime "created_at", :null => false
@@ -419,12 +367,14 @@ ActiveRecord::Schema.define(:version => 20140725062302) do
t.string "web_title"
t.string "title"
t.text "description"
+ t.string "page_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
- t.string "page_type"
t.integer "sort_type"
t.integer "image_width", :default => 107
t.integer "image_height", :default => 63
+ t.integer "show_course", :default => 1
+ t.integer "show_contest", :default => 1
end
create_table "forums", :force => true do |t|
@@ -845,18 +795,18 @@ ActiveRecord::Schema.define(:version => 20140725062302) do
create_table "relative_memos", :force => true do |t|
t.integer "osp_id"
t.integer "parent_id"
- t.string "subject", :null => false
- t.text "content", :limit => 16777215, :null => false
+ t.string "subject", :null => false
+ t.text "content", :null => false
t.integer "author_id"
- t.integer "replies_count", :default => 0
+ t.integer "replies_count", :default => 0
t.integer "last_reply_id"
- t.boolean "lock", :default => false
- t.boolean "sticky", :default => false
- t.boolean "is_quote", :default => false
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.integer "viewed_count_crawl", :default => 0
- t.integer "viewed_count_local", :default => 0
+ t.boolean "lock", :default => false
+ t.boolean "sticky", :default => false
+ t.boolean "is_quote", :default => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.integer "viewed_count_crawl", :default => 0
+ t.integer "viewed_count_local", :default => 0
t.string "url"
t.string "username"
t.string "userhomeurl"
@@ -880,19 +830,6 @@ ActiveRecord::Schema.define(:version => 20140725062302) do
add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"
- create_table "rich_rich_files", :force => true do |t|
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.string "rich_file_file_name"
- t.string "rich_file_content_type"
- t.integer "rich_file_file_size"
- t.datetime "rich_file_updated_at"
- t.string "owner_type"
- t.integer "owner_id"
- t.text "uri_cache"
- t.string "simplified_type", :default => "file"
- end
-
create_table "roles", :force => true do |t|
t.string "name", :limit => 30, :default => "", :null => false
t.integer "position", :default => 1
@@ -943,11 +880,10 @@ ActiveRecord::Schema.define(:version => 20140725062302) do
t.string "url"
t.string "title"
t.integer "share_type"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
t.integer "project_id"
t.integer "user_id"
- t.string "description"
end
create_table "softapplications", :force => true do |t|
@@ -1053,8 +989,8 @@ ActiveRecord::Schema.define(:version => 20140725062302) do
t.integer "zip_code"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
- t.string "technical_title"
t.integer "identity"
+ t.string "technical_title"
t.string "student_id"
t.string "teacher_realname"
t.string "student_realname"
@@ -1112,6 +1048,9 @@ ActiveRecord::Schema.define(:version => 20140725062302) do
t.integer "active"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
+ t.integer "level"
+ t.integer "file"
+ t.integer "issue"
end
create_table "user_statuses", :force => true do |t|
diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
index b9e6174ae..9f85dc49f 100644
--- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
+++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
@@ -48,8 +48,13 @@ module Redmine
end
def attachments_deletable?(user=User.current)
- (respond_to?(:visible?) ? visible?(user) : true) &&
- user.allowed_to?(self.class.attachable_options[:delete_permission], self.project)
+ if (self.has_attribute?(:course) ||self.has_attribute?(:course_id)) && self.course
+ (respond_to?(:visible?) ? visible?(user) : true) &&
+ user.allowed_to?(self.class.attachable_options[:delete_permission], self.course)
+ else
+ (respond_to?(:visible?) ? visible?(user) : true) &&
+ user.allowed_to?(self.class.attachable_options[:delete_permission], self.project)
+ end
end
def saved_attachments
diff --git a/lib/redmine.rb b/lib/redmine.rb
index 6215a04ba..4fa909325 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -244,6 +244,9 @@ Redmine::AccessControl.map do |map|
map.permission :view_gantt, {:gantts => [:show, :update]}, :read => true
end
+ map.project_module :dts do |map|
+ map.permission :do_dts, {:dts => :show}, :read => true
+ end
# map.project_module :journals do |map|
# map.permission :view_journals_for_messages, {:gantts => [:show, :update]}, :read => true
# end
diff --git a/lib/redmine/access_control.rb b/lib/redmine/access_control.rb
index e0a8e16c0..e71c0090a 100644
--- a/lib/redmine/access_control.rb
+++ b/lib/redmine/access_control.rb
@@ -67,6 +67,7 @@ module Redmine
def available_project_modules
@available_project_modules ||= @permissions.collect(&:project_module).uniq.compact
end
+
def available_contest_modules
@available_contest_modules ||= @permissions.collect(&:contest_module).uniq.compact
end
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 3b1e503c4..9d1a6bc93 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -307,7 +307,8 @@ span.forums-avatar-right{
.borad-topic-count{
padding-top: 10px;
padding-left: 5px;
- padding-right: 5px;
+ padding-right: 5px;
+ clear: left;
}
.borad-topic-count-message{
diff --git a/test/fixtures/activities.yml b/test/fixtures/activities.yml
index 585b0e66f..760473856 100644
--- a/test/fixtures/activities.yml
+++ b/test/fixtures/activities.yml
@@ -1,11 +1,12 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
- act_id:
- act_type: MyString
- user_id:
+ id: 1
+ act_id: 1
+ act_type: JournalsForMessage
+ user_id: 5
two:
- act_id:
- act_type: MyString
- user_id:
+ act_id: 2
+ act_type: JournalsForMessage
+ user_id: 5
diff --git a/test/fixtures/biding_projects.yml b/test/fixtures/biding_projects.yml
new file mode 100644
index 000000000..6a55145f4
--- /dev/null
+++ b/test/fixtures/biding_projects.yml
@@ -0,0 +1,8 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+---
+biding_project_001:
+ id: 1
+ project_id: -1
+ bid_id: 1
+
+#biding_project_002:
diff --git a/test/fixtures/bids.yml b/test/fixtures/bids.yml
new file mode 100644
index 000000000..2f486a914
--- /dev/null
+++ b/test/fixtures/bids.yml
@@ -0,0 +1,34 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+---
+homework_001:
+ id: 1
+ author_id: 20
+ budget: "0"
+ commit: 3
+ deadline: "2014-05-30"
+ description: ""
+ homework_type: 1
+ is_evaluation:
+ name: "course_001_homework_001"
+ parent_id:
+ password:
+ proportion: 60
+ reward_type: 3 # 作业
+ updated_on: 2014-05-23 08:15:28
+ created_on: 2014-05-23 08:15:28
+homework_002:
+ id: 2
+ author_id: 20
+ budget: "0"
+ commit: 3
+ deadline: "2014-05-30"
+ description: ""
+ homework_type: 1
+ is_evaluation:
+ name: "course_001_homework_002"
+ parent_id:
+ password:
+ proportion: 60
+ reward_type: 3 # 作业
+ updated_on: 2014-05-23 08:15:28
+ created_on: 2014-05-23 08:15:28
diff --git a/test/fixtures/course_infos.yml b/test/fixtures/course_infos.yml
index 79b5cfde7..dfd5db89c 100644
--- a/test/fixtures/course_infos.yml
+++ b/test/fixtures/course_infos.yml
@@ -1,9 +1,15 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
-one:
- typeId: 1
- typeName: MyString
+courses_001_infos:
+ id: 1
+ course_id: 1
+ user_id: 20
+ created_at: 2013-09-30 15:36:00
+ updated_at: 2014-04-19 01:50:41
+courses_002_infos:
+ id: 2
+ course_id: 2
+ user_id: 20
+ created_at: 2013-09-30 15:36:00
+ updated_at: 2014-04-19 01:50:41
-two:
- typeId: 1
- typeName: MyString
diff --git a/test/fixtures/course_statuses.yml b/test/fixtures/course_statuses.yml
index 8396c1d54..b2aa0f6f5 100644
--- a/test/fixtures/course_statuses.yml
+++ b/test/fixtures/course_statuses.yml
@@ -1,15 +1,18 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
-
-one:
+courses_001_statuses:
changesets_count: 1
watchers_count: 1
course_id: 1
grade: 1.5
course_ac_para: 1
+ created_at: 2013-09-30 15:36:00
+ updated_at: 2014-04-19 01:50:41
-two:
+courses_002_statuses:
changesets_count: 1
watchers_count: 1
- course_id: 1
+ course_id: 2
grade: 1.5
course_ac_para: 1
+ created_at: 2013-09-30 15:36:00
+ updated_at: 2014-04-19 01:50:41
diff --git a/test/fixtures/courses.yml b/test/fixtures/courses.yml
index 803c14c26..d6cbea59b 100644
--- a/test/fixtures/courses.yml
+++ b/test/fixtures/courses.yml
@@ -1,23 +1,23 @@
---
-courses_invalid_001:
+courses_001:
id: 1
- tea_id:
- name: ''
+ tea_id: 20
+ name: courses_001
state:
code:
- time:
+ time: 2013
extra:
- created_at: 2013-09-30 15:36:00.000000000 Z
- updated_at: 2014-04-19 01:50:41.000000000 Z
+ created_at: 2013-09-30 15:36:00
+ updated_at: 2014-04-19 01:50:41
location:
- term:
+ term: 春季学期
string:
- password:
+ password: '1234'
setup_time:
- endup_time:
- class_period:
- school_id:
- description:
+ endup_time: '2014-04-18 00:00:00'
+ class_period: '32'
+ school_id: 117
+ description: 'courses_001 description'
status: 1
attachmenttype: 2
lft:
@@ -25,16 +25,16 @@ courses_invalid_001:
is_public: 1
inherit_members: 1
-courses_008:
- id: 8
- tea_id: 5
+courses_002:
+ id: 2
+ tea_id: 20
name: 分布式计算环境
state:
code:
time: 2013
extra: course2013-09-30_23-36-00
- created_at: 2013-09-30 15:36:00.000000000 Z
- updated_at: 2014-04-19 01:50:41.000000000 Z
+ created_at: 2013-09-30 15:36:00
+ updated_at: 2014-04-19 01:50:41
location:
term: 春季学期
string:
@@ -50,129 +50,3 @@ courses_008:
rgt:
is_public: 1
inherit_members: 1
-courses_058:
- id: 58
- tea_id: 1168
- name: 软件工程实践
- state:
- code:
- time: 2014
- extra: course2014-04-17_17-12-17
- created_at: 2014-04-17 09:12:17.000000000 Z
- updated_at: 2014-04-17 09:12:17.000000000 Z
- location:
- term: 春季学期
- string:
- password: SEP2014
- setup_time:
- endup_time:
- class_period: '18'
- school_id: 0
- description: 国防科技大学计算机学院工程硕士专业选修课。
- status: 1
- attachmenttype: 2
- lft:
- rgt:
- is_public: 1
- inherit_members: 1
-courses_059:
- id: 59
- tea_id: 193
- name: 软件项目管理
- state:
- code:
- time: 2014
- extra: course2014-04-18_18-10-46
- created_at: 2014-04-18 10:10:46.000000000 Z
- updated_at: 2014-04-18 10:10:46.000000000 Z
- location:
- term: 春季学期
- string:
- password: software
- setup_time:
- endup_time:
- class_period: '30'
- school_id: 0
- description: 面向“软件工程”专业的本科生
- status: 1
- attachmenttype: 2
- lft:
- rgt:
- is_public: 1
- inherit_members: 1
-courses_060:
- id: 60
- tea_id: 1179
- name: android开发
- state:
- code:
- time: 2014
- extra: course2014-04-19_15-40-39
- created_at: 2014-04-19 07:40:39.000000000 Z
- updated_at: 2014-04-19 07:40:39.000000000 Z
- location:
- term: 春季学期
- string:
- password: trustie740208
- setup_time:
- endup_time:
- class_period: '48'
- school_id: 37
- description: ''
- status: 1
- attachmenttype: 2
- lft:
- rgt:
- is_public: 1
- inherit_members: 1
-courses_061:
- id: 61
- tea_id: 29
- name: 测试课程1
- state:
- code:
- time: 2014
- extra: course2014-06-04_14-51-56
- created_at: 2014-06-04 06:51:56.000000000 Z
- updated_at: 2014-07-15 01:40:49.000000000 Z
- location:
- term: 春季学期
- string:
- password: '1234'
- setup_time:
- endup_time: '2014-07-14 00:00:00'
- class_period: '23'
- school_id: 1579
- description: '233'
- status: 1
- attachmenttype: 2
- lft:
- rgt:
- is_public: 0
- inherit_members: 1
-course_trustie_074:
- id: 74
- tea_id: 698
- name: 电路与电子学基础(软件工程专业)
- state:
- code:
- time: 2014
- extra: course2014-05-22_16-09-25
- created_at: 2014-05-22 08:09:25.000000000 Z
- updated_at: 2014-05-22 08:09:25.000000000 Z
- location:
- term: 春季学期
- string:
- password: '12345678'
- setup_time:
- endup_time:
- class_period: '54'
- school_id: 117
- description: "电路与电子学基础,软件工程小班\\r\ 模拟电子技术部分\ "
- status: 1
- attachmenttype: 2
- lft:
- rgt:
- is_public: 1
- inherit_members: 1
-
diff --git a/test/fixtures/homework_for_courses.yml b/test/fixtures/homework_for_courses.yml
new file mode 100644
index 000000000..cf8310143
--- /dev/null
+++ b/test/fixtures/homework_for_courses.yml
@@ -0,0 +1,10 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+---
+homework_for_courses_001:
+ id: 1
+ course_id: 1
+ bid_id: 1
+homework_for_courses_002:
+ id: 2
+ course_id: 1
+ bid_id: 2
diff --git a/test/fixtures/journals_for_messages.yml b/test/fixtures/journals_for_messages.yml
new file mode 100644
index 000000000..75e4f8ed1
--- /dev/null
+++ b/test/fixtures/journals_for_messages.yml
@@ -0,0 +1,183 @@
+jfm_001:
+ id: 1
+ jour_id: 5
+ jour_type: Principal
+ user_id: 2
+ notes:
+ status: 0
+ reply_id: 0
+ created_on: 2014-07-16 15:27:2
+ updated_on: 2014-07-16 15:27:2
+ m_parent_id:
+ is_readed:
+ m_reply_count:
+ m_reply_id:
+ is_comprehensive_evaluation:
+jfm_002:
+ id: 2
+ jour_id: 5
+ jour_type: Principal
+ user_id: 2
+ notes: 我觉得这个系统挺实用,界面挺简洁美观1!
+ status:
+ reply_id: 0
+ created_on: 2014-07-16 15:27:2
+ updated_on: 2014-07-16 15:27:2
+ m_parent_id:
+ is_readed:
+ m_reply_count:
+ m_reply_id:
+ is_comprehensive_evaluation:
+jfm_003:
+ # Course one's jfm
+ id: 3
+ jour_id: 1
+ jour_type: Course
+ user_id: 2
+ notes:
+ status:
+ reply_id: 0
+ created_on: 2014-07-16 15:27:2
+ updated_on: 2014-07-16 15:27:2
+ m_parent_id:
+ is_readed:
+ m_reply_count:
+ m_reply_id:
+ is_comprehensive_evaluation:
+jfm_004:
+ # Course one's jfm
+ id: 4
+ jour_id: 1
+ jour_type: Course
+ user_id: 25
+ notes: course_001的留言by_user_025
+ status:
+ reply_id: 0
+ created_on: 2014-07-16 15:27:2
+ updated_on: 2014-07-16 15:27:2
+ m_parent_id:
+ is_readed:
+ m_reply_count:
+ m_reply_id:
+ is_comprehensive_evaluation:
+jfm_045:
+ id: 45
+ jour_id: 2
+ jour_type: Project
+ user_id: 2
+ notes: 我觉得这个系统挺实用,界面挺简洁美观!
+ status:
+ reply_id: 0
+ created_on: 2013-08-16 15:27:2
+ updated_on: 2013-08-16 15:27:2
+ m_parent_id:
+ is_readed:
+ m_reply_count:
+ m_reply_id:
+ is_comprehensive_evaluation:
+jfm_048:
+ id: 48
+ jour_id: 2
+ jour_type: Project
+ user_id: 2
+ notes: aqfbLT wcqmhgdpgfvy , [url=http://flyhqtjjtskb.com/]flyhqtjjtskb[/url],
+ [link=http://idlilqzxissn.com/]idlilqzxissn[/link], http://sfeezearevbp.com/
+ status:
+ reply_id: 0
+ created_on: 2013-08-18 20:44:18
+ updated_on: 2013-08-18 20:44:18
+ m_parent_id:
+ is_readed:
+ m_reply_count:
+ m_reply_id:
+ is_comprehensive_evaluation:
+jfm_049:
+ id: 49
+ jour_id: 2
+ jour_type: Project
+ user_id: 2
+ notes: 搜索用户时,若无对应结果,没有返回提示信息,比如不会提示:暂无此人
+ status:
+ reply_id: 0
+ created_on: 2013-08-19 08:45:27
+ updated_on: 2013-08-19 08:45:27
+ m_parent_id:
+ is_readed:
+ m_reply_count:
+ m_reply_id:
+ is_comprehensive_evaluation:
+jfm_058:
+ id: 58
+ jour_id: 2
+ jour_type: Project
+ user_id: 2
+ notes: 问题板块中 “新建问题”能不能移动到靠右~
+ status:
+ reply_id: 0
+ created_on: 2013-08-20 00:24:44
+ updated_on: 2013-08-20 00:24:44
+ m_parent_id:
+ is_readed:
+ m_reply_count:
+ m_reply_id:
+ is_comprehensive_evaluation:
+jfm_060:
+ id: 60
+ jour_id: 2
+ jour_type: Project
+ user_id: 2
+ notes:
+ status:
+ reply_id: 0
+ created_on: 2013-08-21 07:04:43
+ updated_on: 2013-08-21 07:04:43
+ m_parent_id:
+ is_readed:
+ m_reply_count:
+ m_reply_id:
+ is_comprehensive_evaluation:
+jfm_086:
+ id: 86
+ jour_id: 2
+ jour_type: Project
+ user_id: 2
+ notes: 谢谢大家的反馈!
+ status:
+ reply_id: 0
+ created_on: 2013-08-23 02:36:48
+ updated_on: 2013-08-23 02:36:48
+ m_parent_id:
+ is_readed:
+ m_reply_count:
+ m_reply_id:
+ is_comprehensive_evaluation:
+jfm_087:
+ id: 87
+ jour_id: 2
+ jour_type: Project
+ user_id: 2
+ notes: ”与我相关“处不可以直接回复
+ status:
+ reply_id: 0
+ created_on: 2013-08-23 02:44:56
+ updated_on: 2013-08-23 02:44:56
+ m_parent_id:
+ is_readed:
+ m_reply_count:
+ m_reply_id:
+ is_comprehensive_evaluation:
+jfm_088:
+ id: 88
+ jour_id: 2
+ jour_type: Project
+ user_id: 2
+ notes: 任何有关回复的地方可在任意显示处回复
+ status:
+ reply_id: 0
+ created_on: 2013-08-23 02:45:45
+ updated_on: 2013-08-23 02:45:45
+ m_parent_id:
+ is_readed:
+ m_reply_count:
+ m_reply_id:
+ is_comprehensive_evaluation:
diff --git a/test/fixtures/member_roles.yml b/test/fixtures/member_roles.yml
index 79a8a8530..999985395 100644
--- a/test/fixtures/member_roles.yml
+++ b/test/fixtures/member_roles.yml
@@ -47,8 +47,3 @@ member_roles_011:
role_id: 2
member_id: 10
inherited_from: 10
-member_roles_179:
- id: 179
- member_id: 126
- role_id: 3
- inherited_from:
diff --git a/test/fixtures/members.yml b/test/fixtures/members.yml
index 7f918f683..10d52f300 100644
--- a/test/fixtures/members.yml
+++ b/test/fixtures/members.yml
@@ -60,10 +60,3 @@ members_010:
project_id: 2
user_id: 8
mail_notification: false
-members_course_001:
- id: 126
- user_id: 5
- project_id: -1
- created_on: 2013-09-30 15:36:00.000000000 Z
- mail_notification: false
- course_id: 8
diff --git a/test/fixtures/projects.yml b/test/fixtures/projects.yml
index 0105f9356..c979498fb 100644
--- a/test/fixtures/projects.yml
+++ b/test/fixtures/projects.yml
@@ -11,18 +11,18 @@ projects_001:
parent_id:
lft: 1
rgt: 10
-projects_002:
- created_on: 2006-07-19 19:14:19 +02:00
- name: OnlineStore
- updated_on: 2006-07-19 19:14:19 +02:00
- id: 2
- description: E-commerce web site
- homepage: ""
- is_public: false
- identifier: onlinestore
- parent_id:
- lft: 11
- rgt: 12
+#projects_002:
+# created_on: 2006-07-19 19:14:19 +02:00
+# name: OnlineStore
+# updated_on: 2006-07-19 19:14:19 +02:00
+# id: 2
+# description: E-commerce web site
+# homepage: ""
+# is_public: false
+# identifier: onlinestore
+# parent_id:
+# lft: 11
+# rgt: 12
projects_003:
created_on: 2006-07-19 19:15:21 +02:00
name: eCookbook Subproject 1
@@ -71,3 +71,24 @@ projects_006:
parent_id: 5
lft: 3
rgt: 4
+trustie:
+ id: 2
+ name: SocialForge
+ description: "SocialForge是TrustieForge的升级版,支持社交化协同开发与合作。 SocialForge aims to provide a socialized and crowd sourcing enabled collaboration development platform. It is combining and will combine TrustieForge, Influx, Redmine and other open source projects."
+ homepage: http://forge.trustie.net
+ is_public: true
+ parent_id:
+ created_on: 2013-06-25 06:02:19.000000000 Z
+ updated_on: 2013-11-13 12:52:42.000000000 Z
+ identifier: trustie
+ status: 1
+ lft: 11
+ rgt: 12
+# lft: 115
+# rgt: 116
+ project_type: 0
+ hidden_repo: true
+ attachmenttype: 1
+ user_id:
+ dts_test: 0
+
diff --git a/test/fixtures/schools.yml b/test/fixtures/schools.yml
index 953c725bf..fb97019ca 100644
--- a/test/fixtures/schools.yml
+++ b/test/fixtures/schools.yml
@@ -1,9 +1,13 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
-one:
- name:
- province: MyString
+school_117:
+ id: 117
+ name: 国防科学技术大学
+ province: 湖南省
+ logo_link:
-two:
- name:
- province: MyString
+school_001:
+ id: 1
+ name: 摧毁地球人学校
+ province: 火星
+ logo_link:
diff --git a/test/fixtures/user_extensions.yml b/test/fixtures/user_extensions.yml
index 8c19ad7b1..94ee5d0e0 100644
--- a/test/fixtures/user_extensions.yml
+++ b/test/fixtures/user_extensions.yml
@@ -1,76 +1,57 @@
-person_one_extra:
- id: 44
- user_id: 29
- birthday: "2013-09-30 21:19:25"
- brief_introduction: nil
- gender: 1
- location: "江苏"
- occupation: ""
- work_experience: nil
- zip_code: nil
- created_at: "2013-09-30 21:19:25"
- updated_at: "2013-10-09 19:00:06"
- technical_title: nil
- identity: 2
- student_id: nil
- teacher_realname: nil
- student_realname: nil
- location_city: "南京"
-
-person_mao_extra:
- id: 22
- user_id: 193
- birthday: "2013-09-30 21:19:25"
- brief_introduction: "期待..."
- gender: 0
- location: "湖南长沙"
- occupation: "国防科技大学计算机学院"
- work_experience: nil
- zip_code: nil
- created_at: "2013-09-30 21:19:25"
- updated_at: "2013-10-09 19:00:06"
- technical_title: "教授"
- identity: 0
- student_id: nil
- teacher_realname: nil
- student_realname: nil
- location_city: nil
-ue_lirongzhen:
- id: 587
- user_id: 642
+user_extension_006:
+ id: 6
+ user_id: 6
birthday:
brief_introduction:
gender: 0
- location: 河南
+ location:
+ occupation:
+ work_experience:
+ zip_code:
+ created_at: 2014-07-29 02:54:09
+ updated_at: 2014-07-29 02:54:09
+ technical_title:
+ identity: 0
+ student_id:
+ teacher_realname:
+ student_realname:
+ location_city:
+ school_id:
+user_extension_020:
+ id: 20
+ user_id: 20
+ birthday:
+ brief_introduction: 哈尔
+ gender: 0
+ location: 黑龙江
occupation: kylinos-cloud
work_experience:
zip_code:
- created_at: 2014-03-18 14:52:55.000000000 Z
- updated_at: 2014-03-26 07:19:04.000000000 Z
- technical_title:
- identity: 1
- student_id: '14066023'
+ created_at: 2014-07-29 02:54:09
+ updated_at: 2014-07-29 02:54:09
+ technical_title: 助教
+ identity: 0
+ student_id:
teacher_realname:
student_realname:
- location_city: 周口
+ location_city: 哈尔滨
school_id:
-ue_yingang:
- id: 6
- user_id: 5
+user_extension_025:
+ id: 25
+ user_id: 25
birthday:
- brief_introduction: 现有功能的精细化!
+ brief_introduction: 哈尔
gender: 0
- location: 湖南
- occupation: 国防科学技术大学计算机学院
+ location: 黑龙江
+ occupation: kylinos-cloud
work_experience:
zip_code:
- created_at: 2013-09-24 09:36:12.000000000 Z
- updated_at: 2014-04-19 08:16:55.000000000 Z
- technical_title: 副教授
- identity: 0
- student_id: ''
+ created_at: 2014-07-29 02:54:09
+ updated_at: 2014-07-29 02:54:09
+ technical_title: 助教
+ identity: 1 #student
+ student_id: 10060342
teacher_realname:
- student_realname:
- location_city: 长沙
+ student_realname: 'ue_realname'
+ location_city: 哈尔滨
school_id: 117
-
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
index cf7f6da7c..48aa9c0da 100644
--- a/test/fixtures/users.yml
+++ b/test/fixtures/users.yml
@@ -72,7 +72,7 @@ users_003:
login: dlopper
type: User
users_005:
- id: 12
+ id: 5
created_on: 2006-07-19 19:33:19 +02:00
# Locked
status: 3
@@ -165,26 +165,27 @@ groups_011:
id: 11
lastname: B Team
type: Group
-users_yingang_teacher:
- id: 5
- login: jacknudt
- hashed_password: dbbd96684c9a64afe9c4935ce0b517e5e9c08064
- firstname: 刚
- lastname: 尹
- mail: jack_nudt@163.com
+users_020:
+ id: 20
+ login: teacher1
+ # password: foobar
+ hashed_password: 6b6095d977621a3071ae2670be95b88092e94b53
+ firstname: wang
+ lastname: dr
+ mail: jack_nudt@foo.bar
admin: false
status: 1
- last_login_on: 2014-04-27 13:49:18.000000000 Z
+ last_login_on: 2014-07-29 02:54:09
language: zh
auth_source_id:
- created_on: 2013-06-25 05:20:59.000000000 Z
- updated_on: 2014-07-16 03:37:51.000000000 Z
+ created_on: 2014-07-29 02:54:09
+ updated_on: 2014-07-29 02:54:09
type: User
identity_url:
mail_notification: only_my_events
- salt: 92944df2ce4dae1a4f01007263c5d8bb
-users_lirongzhen_student:
- id: 642
+ salt: 9db798ee4c462d9614479e6738790891
+users_025:
+ id: 25
login: lirongzhen
hashed_password: 070922b015398577c3ae0d87a68d5ffa93bf82e9
firstname: 荣振
diff --git a/test/functional/courses_controller_test.rb b/test/functional/courses_controller_test.rb
index 7185f6303..66e613bfb 100644
--- a/test/functional/courses_controller_test.rb
+++ b/test/functional/courses_controller_test.rb
@@ -1,7 +1,21 @@
require File.expand_path('../../test_helper', __FILE__)
class CoursesControllerTest < ActionController::TestCase
- fixtures :courses, :users, :user_extensions, :roles, :members, :member_roles, :enabled_modules, :boards, :messages
+ fixtures :courses,
+ :course_infos,
+ :course_statuses,
+ :users,
+ :user_extensions,
+ :bids,
+ :homework_for_courses,
+ :journals_for_messages,
+ :schools,
+ :roles,
+ :members,
+ :member_roles,
+ :enabled_modules,
+ :boards,
+ :messages
def setup
@request.session[:user_id] = nil
@@ -23,7 +37,7 @@ class CoursesControllerTest < ActionController::TestCase
# Get :new
# 人员添加课程的权限是不属于任何角色
def test_new_course_anyone_temporary
- @request.session[:user_id] = 5
+ @request.session[:user_id] = 20
Role.find_by_name("Non member").add_permission! :add_course #Non member
get :new
@@ -33,7 +47,7 @@ class CoursesControllerTest < ActionController::TestCase
# post :create
def test_create_course_with_access_control
- @request.session[:user_id] = 5
+ @request.session[:user_id] = 20
Role.find_by_name("Non member").add_permission! :add_course #Non member
course_name = 'course_one'
@@ -59,7 +73,7 @@ class CoursesControllerTest < ActionController::TestCase
# post :create 403
def test_create_course_without_access_control
- @request.session[:user_id] = 5
+ @request.session[:user_id] = 20
#Role.find_by_name("Non member").add_permission! :add_course #Non member
course_name = 'course_one'
@@ -77,6 +91,52 @@ class CoursesControllerTest < ActionController::TestCase
assert_response :forbidden
end
+ test ':homework get by non-member is access' do
+ get :homework, {id: 1}
+ assert_response :success
+ end
+
+ test ':feedback Get by non-member is access' do
+ get :feedback, {id: 1}
+ assert_response :success
+ # 检测留言是否在其中以及不报错
+ jfms = JournalsForMessage.where(jour_type: 'Course', jour_id: 1, m_parent_id: nil).reorder('id DESC')
+ jfms.take(5).each do |j|
+ assert_select "li#word_li_#{j.id}"
+ end
+ end
+
+ test ':homework get by non-member' do
+ get :homework, {id: 1}
+ assert_response :success
+ course = Course.find(1)
+ assert course.homeworks.any?
+ course.homeworks.each do |homework|
+ assert_select '.bid_path', homework.name
+ end
+ end
+
+ test ':new_homework by no user should not new_homework course_001' do
+ get :new_homework, {id: 1}
+ assert_response 403
+ end
+ test ':new_homework by loged & allowed user should get new_homework course_001' do
+ user_id = 25
+ member = Member.create(user_id: user_id, project_id: -1, course_id: 1, roles: [Role.last])
+ MemberRole.create(member_id: member.id, role_id: 3)
+ @request.session[:user_id] = user_id
+ get :new_homework, {id: 1}
+ assert_response :success
+ assert_template 'new_homework'
+ end
+
+ test ':member by ano' do
+ get :member, {id: 1}
+ assert_response :success
+ assert_template 'member'
+ assert assigns(:members).any?
+ end
+
# test "#index by non-admin user with view_time_entries permission should show overall spent time link" do
# @request.session[:user_id] = 3
diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb
new file mode 100644
index 000000000..412165620
--- /dev/null
+++ b/test/functional/projects_controller_test.rb
@@ -0,0 +1,95 @@
+require File.expand_path('../../test_helper', __FILE__)
+
+class ProjectsControllerTest < ActionController::TestCase
+ fixtures :projects,
+ :issues,
+ :issue_statuses,
+ :enumerations,
+ :users,
+ :issue_categories,
+ :trackers,
+ :projects_trackers,
+ :roles,
+ :member_roles,
+ :members,
+ :enabled_modules,
+ :journals,
+ :journal_details,
+ :journals_for_messages
+
+ def setup
+ @request.session[:user_id] = nil
+ @request.session[:ctime] = Time.now
+ @request.session[:atime] = Time.now
+ Setting.default_language = 'en'
+ end
+
+ test 'get :index' do
+ get :index
+ assert_response :success
+ end
+ test ':new by admin should accept get' do
+ @request.session[:user_id] = 1
+ get :new
+ assert_response :success
+ end
+ test ':new by non-admin user with add_project permission should accept get' do
+ Role.non_member.add_permission! :add_project
+ @request.session[:user_id] = 9
+ get :new
+ assert_response :success
+ assert_template 'new'
+ end
+
+ test ':create by admin user should create a new project' do
+ @request.session[:user_id] = 1
+ post :create, :project => {
+ name: "blog1",
+ description: 'weblog',
+ homepage: 'http://weblog',
+ identifier: 'blog',
+ is_public: 1,
+ custom_field_values: {'3' => 'Beta'},
+ tracker_ids: ['1', '3'],
+ :issue_custom_field_ids => ['9'],
+ :enabled_module_names => ['issue_tracking', 'news', 'repository']
+ }
+ project = Project.find_by_name(blog)
+ assert_not_nil project
+ assert_redirected_to "/projects/#{project.id}/settings"
+
+ assert_kind_of Project, project
+ assert project.active?
+ assert_equal 'weblog', project.description
+ assert_equal 'http://weblog', project.homepage
+ assert_equal true, project.is_public?
+ assert_nil project.parent
+ assert_equal 'Beta', project.custom_value_for(3).value
+ assert_equal [1, 3], project.trackers.map(&:id).sort
+ assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort
+ assert project.issue_custom_fields.include?(IssueCustomField.find(9))
+ end
+
+ test 'get :show trustie' do
+ get :show, {id: 2}
+ assert_response :success
+ end
+
+ test 'get :search, forge' do
+ query_condition = "forge"
+ get :search, {'name' => query_condition }
+ projects = assigns(:projects_all)
+ assert projects.any?, "projects should have anything."
+ projects.each do |project|
+ assert project.name.downcase.include?(query_condition), "project name is invalid: #{project.name}"
+ end
+ end
+
+ test 'get :feedback' do
+ get :feedback, {id: 2}
+ assert_response :success
+ # prject_id = 2 总有8个留言
+ assert_equal assigns(:jour).count, 8
+ end
+
+end
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
new file mode 100644
index 000000000..4d7f8d6a9
--- /dev/null
+++ b/test/functional/users_controller_test.rb
@@ -0,0 +1,37 @@
+require File.expand_path('../../test_helper', __FILE__)
+
+class UsersControllerTest < ActionController::TestCase
+ fixtures :users, :projects, :members, :member_roles, :roles,
+ :custom_fields, :custom_values, :groups_users,
+ :auth_sources,
+ :activities,
+ :journals_for_messages
+ def setup
+ User.current = nil
+ @request.session[:user_id] = 1
+ @request.session[:ctime] = Time.now
+ @request.session[:atime] = Time.now
+ end
+
+ test '#index by non-member' do
+ @request.session[:user_id] = nil
+ get :index
+ assert_response :success
+ assert_template 'index'
+ end
+
+ test '#show by non-member' do
+ @request.session[:user_id] = 8
+ get :show, {id: 5}
+ assert_response :success
+ assert_template 'show'
+ end
+
+ test '#user_newfeedback by non-member' do
+ @request.session[:user_id] = nil
+ get :user_newfeedback, {id: 5}
+ assert_response :success
+ assert_template 'user_newfeedback'
+ end
+
+end