Merge branch 'szzh' into CourseModify

Conflicts:
	app/controllers/application_controller.rb
	app/views/attachments/upload.js.erb
	app/views/courses/_homework_form.html.erb
	app/views/layouts/base_courses.html.erb
	app/views/users/_my_joinedcourse.html.erb
	db/schema.rb
	lib/redmine.rb
	lib/redmine/access_control.rb
This commit is contained in:
nwb 2014-06-17 10:12:44 +08:00
commit 099e8a0912
140 changed files with 4129 additions and 3021 deletions

View File

@ -14,7 +14,7 @@ gem "i18n", "~> 0.6.0"
gem "coderay", "~> 1.0.6"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", "3.0.0"
gem 'acts-as-taggable-on'
gem 'acts-as-taggable-on', '2.4.1'
group :development do
gem 'better_errors', path: 'lib/better_errors'

View File

@ -134,7 +134,7 @@ PLATFORMS
DEPENDENCIES
activerecord-jdbc-adapter (= 1.2.5)
activerecord-jdbcmysql-adapter
acts-as-taggable-on
acts-as-taggable-on (= 2.4.1)
better_errors!
builder (= 3.0.0)
coderay (~> 1.0.6)

View File

@ -45,3 +45,9 @@ app\controller\welcome_controller.rb
end
end
================================================================================
================================================================================
0606新坑
user_scores表结构有问题需要运行
bundle exec rake db:migrate:down VERSION=20140410021724
bundle exec rake db:migrate:up VERSION=20140410021724

View File

@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the notificationcomments controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -294,6 +294,20 @@ class ApplicationController < ActionController::Base
render_404
end
def find_contest_by_contest_id
@contest = Contest.find(params[:contest_id])
rescue ActiveRecord::RecordNotFound
render_404
end
#¸ù¾Ýcourse_idÕÒproject
def find_project_by_course_id
@bid = Bid.find params[:course_id]
@project = @bid.courses[0]
rescue ActiveRecord::RecordNotFound
render_404
end
# Find a project based on params[:project_id]
# TODO: some subclasses override this, see about merging their logic
def find_optional_project
@ -304,6 +318,14 @@ class ApplicationController < ActionController::Base
render_404
end
def find_optional_contest
@contest = Contest.find(params[:contest_id]) unless params[:contest_id].blank?
allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @contest, :global => true)
allowed ? true : deny_access
rescue ActiveRecord::RecordNotFound
render_404
end
# Finds and sets @project based on @object.project
def find_project_from_association
render_404 unless @object.present?
@ -315,6 +337,12 @@ class ApplicationController < ActionController::Base
end
def find_contest_from_association
render_404 unless @object.present?
@contest =@object.contest
end
def find_model_object
model = self.class.model_object
if model
@ -326,13 +354,23 @@ class ApplicationController < ActionController::Base
end
#added by nwb
#获取课程
#»ñÈ¡¿Î³Ì
def find_course
@course= Course.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end
# def find_model_object_contest
# model = self.class.model_object
# if model
# @object = model.find(params[:id])
# self.instance_variable_set('@' + controller_name.singularize, @object) if @object
# end
# rescue ActiveRecord::RecordNotFound
# render_404
# end
def self.model_object(model)
self.model_object = model
end

View File

@ -26,6 +26,13 @@ class BidsController < ApplicationController
helper :words
helper :welcome
def find_project_by_bid_id
@bid = Bid.find(params[:id])
@project = @bid.courses[0]
rescue ActiveRecord::RecordNotFound
render_404
end
def homework_ajax_modal
@bid = Bid.find_by_id(params[:id])
# find_bid
@ -176,7 +183,8 @@ class BidsController < ApplicationController
@homework.budget = 0
@homework.author_id = User.current.id
@homework.commit = 0
@homework.homework_type = params[:bid][:homework_type]
@homework.homework_type = 1
@homework.is_evaluation = params[:bid][:is_evaluation]
@homework.parent_id = @bid.id
@homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
# @bid.
@ -405,7 +413,9 @@ class BidsController < ApplicationController
if @bid.homework_type == 1
@homework = HomeworkAttach.new
@homework_list = @bid.homeworks
#@homework_list = @bid.homeworks
#增加作业按评分排序,
@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC")
if params[:student_id].present?
@temp = []
@homework_list.each do |pro|
@ -521,6 +531,7 @@ class BidsController < ApplicationController
message = params[:bid_message][:message] + "\n" + params[:reference_content]
else
message = params[:bid_message][:message]
@m = message
end
refer_user_id = params[:bid_message][:reference_user_id].to_i
@bid.add_jour(User.current, message, refer_user_id)
@ -687,6 +698,7 @@ class BidsController < ApplicationController
@bid = Bid.new
@bid.name = params[:bid][:name]
@bid.description = params[:bid][:description]
@bid.is_evaluation = params[:bid][:is_evaluation]
@bid.reward_type = 3
# @bid.budget = params[:bid][:budget]
@bid.deadline = params[:bid][:deadline]
@ -870,7 +882,7 @@ class BidsController < ApplicationController
def find_bid
if params[:id]
@bid = Bid.find(params[:id])
@bid = Bid.find(params[:id], :include => [{:homeworks => :user}])
@user = @bid.author
end
rescue

View File

@ -50,4 +50,6 @@ class CommentsController < ApplicationController
@comment = nil
@news
end
end

View File

@ -0,0 +1,187 @@
class ContestnotificationsController < ApplicationController
# GET /contestnotifications
# GET /contestnotifications.json
layout 'base_newcontest'
default_search_scope :contestnotifications
model_object Contestnotification
# before_filter :find_model_object, :except => [:new, :create, :index]
# before_filter :find_contest_from_association, :except => [:new, :create, :index]
before_filter :find_contest_by_contest_id, :only => [:new, :create]
before_filter :find_contest
before_filter :find_author
# before_filter :authorize, :except => [:index]
before_filter :find_optional_contest, :only => [:index]
accept_rss_auth :index
accept_api_auth :index
before_filter :access_edit_destroy, only: [:edit ,:update, :destroy]
def find_author
@user = @contest.author
render_404 if @user.nil?
end
def find_contest
@contest = Contest.find(params[:contest_id])
render_404 if @contest.nil?
end
def index
# @contestnotifications = Contestnotification.all
#
# respond_to do |format|
# format.html # index.html.erb
# format.json { render json: @contestnotifications }
# end
### begin ###
case params[:format]
when 'xml', 'json'
@offset, @limit = api_offset_and_limit
else
@limit = 10
end
scope = @contest ? @contest.contestnotifications.visible : Contestnotifications.visible
@contestnotifications_count = scope.count
@contestnotifications_pages = Paginator.new @contestnotifications_count, @limit, params['page']
@offset ||= @contestnotifications_pages.offset
@contestnotificationss = scope.all(:include => [:author, :contest],
:order => "#{Contestnotification.table_name}.created_at DESC",
:offset => @offset,
:limit => @limit)
respond_to do |format|
format.html {
@contestnotification = Contestnotification.new # for adding news inline
render :layout => 'base_newcontest'
}
format.api
format.atom { render_feed(@contestnotificationss, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") }
end
### end ###
end
# GET /contestnotifications/1
# GET /contestnotifications/1.json
def show
@contestnotification = Contestnotification.find(params[:id])
#
# respond_to do |format|
# format.html # show.html.erb
# format.json { render json: @contestnotification }
# end
@notificationcomments = @contestnotification.notificationcomments
@notificationcomments.reverse! if User.current.wants_notificationcomments_in_reverse_order?
render :layout => 'base_newcontest'
end
# GET /contestnotifications/new
# GET /contestnotifications/new.json
def new
# @contestnotification = Contestnotification.new
#
# respond_to do |format|
# format.html # new.html.erb
# format.json { render json: @contestnotification }
# end
@contestnotification = Contestnotification.new(:contest => @contest, :author => User.current)
render :layout => 'base_newcontest'
end
# GET /contestnotifications/1/edit
def edit
@contestnotification = Contestnotification.find(params[:id])
end
# POST /contestnotifications
# POST /contestnotifications.json
def create
# @contestnotification = Contestnotification.new(params[:contestnotification])
#
# respond_to do |format|
# if @contestnotification.save
# format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully created.' }
# format.json { render json: @contestnotification, status: :created, location: @contestnotification }
# else
# format.html { render action: "new" }
# format.json { render json: @contestnotification.errors, status: :unprocessable_entity }
# end
# end
@contestnotification = Contestnotification.new(:contest => @contest, :author => User.current)
@contestnotification.safe_attributes = params[:contestnotification]
@contestnotification.save_attachments(params[:attachments])
if @contestnotification.save
render_attachment_warning_if_needed(@contestnotification)
flash[:notice] = l(:notice_successful_create)
redirect_to contest_contestnotifications_path(@contest)
else
layout_file = 'base_newcontest'
render :action => 'new', :layout => layout_file
end
end
# PUT /contestnotifications/1
# PUT /contestnotifications/1.json
def update
# @contestnotification = Contestnotification.find(params[:id])
#
# respond_to do |format|
# if @contestnotification.update_attributes(params[:contestnotification])
# format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully updated.' }
# format.json { head :no_content }
# else
# format.html { render action: "edit" }
# format.json { render json: @contestnotification.errors, status: :unprocessable_entity }
# end
# end
@contestnotification = Contestnotification.find(params[:id])
@contestnotification.safe_attributes = params[:contestnotification]
@contestnotification.save_attachments(params[:attachments])
if @contestnotification.save
render_attachment_warning_if_needed(@contestnotification)
flash[:notice] = l(:notice_successful_update)
redirect_to contest_contestnotification_path(@contestnotification.contest, @contestnotification)
else
render :action => 'edit'
end
end
# DELETE /contestnotifications/1
# DELETE /contestnotifications/1.json
def destroy
# @contestnotification = Contestnotification.find(params[:id])
# @contestnotification.destroy
#
# respond_to do |format|
# format.html { redirect_to contestnotifications_url }
# format.json { head :no_content }
# end
@contestnotification = Contestnotification.find(params[:id])
@contestnotification.destroy
redirect_to contest_contestnotifications_path(@contest)
end
private
def find_optional_contest
return true unless params[:id]
@contest = Contest.find(params[:id])
# authorize
rescue ActiveRecord::RecordNotFound
render_404
end
def access_edit_destroy
if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?)
return true
else
render_403
end
end
end

View File

@ -4,9 +4,9 @@ class ContestsController < ApplicationController
menu_item :respond
menu_item :project, :only => :show_project
menu_item :application, :only => :show_softapplication
menu_item :attendingcontest, :only => :show_attendingcontest
menu_item :contestnotification, :only => :show_notification
before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :show_attendingcontest, :show_notification, :set_reward_project, :set_reward_softapplication, :create,:destroy,:more,:back,:add,:add_softapplication,:new,:show_results, :set_reward,
menu_item :attendingcontests, :only => :show_attendingcontest
menu_item :contestnotifications, :only => :index
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]
# added by fq
@ -210,11 +210,14 @@ class ContestsController < ApplicationController
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
@membership.each do |membership|
unless(membership.project.project_type==1)
membership.member_roles.each{|role|
if(role.role_id == 3)
@option << membership.project
end
}
#membership.member_roles.each{|role|
# if(role.role_id == 3)
# @option << membership.project
# end
#}
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
@option << membership.project
end
end
end
@user = @contest.author
@ -301,11 +304,15 @@ class ContestsController < ApplicationController
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
@membership.each do |membership|
unless(membership.project.project_type==1)
membership.member_roles.each{|role|
if(role.role_id == 3)
#membership.member_roles.each{|role|
#if(role.role_id == 3)
#@option << membership.project
#end
#}
#拥有编辑项目权限的可将该项目参赛
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
@option << membership.project
end
}
end
end
end
@user = @contest.author

View File

@ -62,6 +62,7 @@ class DocumentsController < ApplicationController
def create
@document = @project.documents.build
@document.safe_attributes = params[:document]
@document.user = User.current
@document.save_attachments(params[:attachments])
if @document.save
render_attachment_warning_if_needed(@document)

View File

@ -1,5 +1,30 @@
class HomeworkAttachController < ApplicationController
###############################
#判断当前角色权限时需先找到当前操作的project
before_filter :find_project_by_bid_id, :only => [:new]
before_filter :find_project_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users]
#判断当前角色是否有操作权限
#勿删 before_filter :authorize, :only => [:new,:edit,:update,:destroy]
def find_project_by_bid_id
@bid = Bid.find(params[:id])
@project = @bid.courses[0]
rescue ActiveRecord::RecordNotFound
render_404
end
def find_project_by_hoemwork_id
@homework = HomeworkAttach.find(params[:id])
@project = @homework.bid.courses[0]
end
#获取作业的成员
def get_homework_member homework
@hoemwork_users = users_for_homework(@homework)
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
@members = paginateHelper @members,10
end
def index
@homeworks = HomeworkAttach.all
respond_to do |format|
@ -8,114 +33,213 @@ class HomeworkAttachController < ApplicationController
end
end
def add_users users
if users != nil && users.count > 0
users.each do |user|
@homework.homework_users.build(:user_id => user.id)
@homework.save
#作业添加成员(参与人员)
def add_homework_users
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
#@homework = HomeworkAttach.find(params[:id])
if params[:membership]
if params[:membership][:user_ids]
attrs = params[:membership].dup
user_ids = attrs.delete(:user_ids)
user_ids.each do |user_id|
@homework.homework_users.build(:user_id => user_id)
end
end
end
@homework.save
get_homework_member @homework
respond_to do |format|
format.js
end
else
render_403 :message => :notice_not_authorized
end
end
#作业删除成员(参与人员)
def destory_homework_users
#@homework = HomeworkAttach.find(params[:id])
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first
homework_user.destroy
get_homework_member @homework
respond_to do |format|
format.js
end
else
render_403 :message => :notice_not_authorized
end
end
def create
#if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)
user_id = params[:user_id]
bid_id = params[:bid_id]
sta = 0
name = params[:new_form][:name]
description = params[:new_form][:description]
options = {
:user_id => user_id,
:state => sta,
:name => name,
:description => description,
:bid_id => bid_id
}
bid = Bid.find params[:bid_id]
if User.current.admin? || User.current.member_of?(bid.courses.first)
if bid.homeworks.where("user_id = ?",User.current).count == 0
user_id = params[:user_id]
bid_id = params[:bid_id]
sta = 0
name = params[:new_form][:name]
description = params[:new_form][:description]
options = {
:user_id => user_id,
:state => sta,
:name => name,
:description => description,
:bid_id => bid_id
}
#@bid = Bid.find bid_id
#@homework_list = @bid.homeworks
@homework = HomeworkAttach.new(options)
@homework.save_attachments(params[:attachments])
render_attachment_warning_if_needed(@homework)
#@homework_list = @bid.homeworks
@homework = HomeworkAttach.new(options)
@homework.save_attachments(params[:attachments])
render_attachment_warning_if_needed(@homework)
if @homework.save
respond_to do |format|
format.html { redirect_to project_for_bid_path @homework.bid }
format.json { head :no_content }
end
else
render_403 :message => :notice_not_authorized
end
else
render_403 :message => :notice_has_homework
end
else
render_403 :message => :notice_not_authorized
end
end
def new
@bid = Bid.find(params[:id])
if User.current.admin? || User.current.member_of?(@bid.courses.first)
#该课程的学生的集合(新建不实现功能:添加成员)
#@members = @bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id <> #{User.current.id}", {:role_id => [5, 10]})
#@members = paginateHelper @members,10
#@all_user = []
#@bid.courses.first.members.each do |member|
# @all_user << member.user
#end
@homework = HomeworkAttach.new
#@homework_user = members_for_homework(@homework) + User.current
#@members = @all_user - @homework_user
respond_to do |format|
format.html # new.html.erb
format.json { render json: @homework }
end
else
render_403 :message => :notice_not_authorized
end
end
#获取作业成员的集合
def get_homework_member_list
@homework = HomeworkAttach.find(params[:bid_id])
course = @homework.bid.courses.first
if User.current.admin? || User.current.member_of?(course)
get_homework_member @homework
else
raise "error"
end
respond_to do |format|
format.js
end
end
#获取指定作业的所有成员
def users_for_homework homework
homework.nil? ? [] : (homework.users + [homework.user])
end
#获取可选成员列表
#homework作业
#users该作业所有成员
#q:模糊匹配的用户的昵称
def members_for_homework homework,users,q
homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id not in (:users)", {:role_id => [5, 10],:users => users}).joins(:user).where("users.login like '%#{q}%'")
end
def edit
#@homework = HomeworkAttach.find(params[:id])
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
#@members = @homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]})
get_homework_member @homework
else
render_403 :message => :notice_not_authorized
end
end
def update
#@homework = HomeworkAttach.find(params[:id])
course = @homework.bid.courses.first
if User.current.admin? || User.current.member_of?(course)
name = params[:homework_name]
description = params[:homework_description]
@homework.name = name
@homework.description = description
if params[:attachments]
@homework.save_attachments(params[:attachments])
end
if @homework.save
respond_to do |format|
format.html { redirect_to project_for_bid_path @homework.bid }
format.json { head :no_content }
end
else
end
#end
end
def new
@homework = HomeworkAttach.new
@bid = Bid.find(params[:id])
respond_to do |format|
format.html # new.html.erb
format.json { render json: @homework }
end
end
def edit
@homework = HomeworkAttach.find(params[:id])
end
def update
@homework = HomeworkAttach.find(params[:id])
name = params[:homework_name]
description = params[:homework_description]
@homework.name = name
@homework.description = description
if params[:attachments]
@homework.save_attachments(params[:attachments])
end
if @homework.save
respond_to do |format|
format.html { redirect_to project_for_bid_path @homework.bid }
format.json { head :no_content }
end
else
render_403 :message => :notice_not_authorized
end
end
def destroy
@homework = HomeworkAttach.find(params[:id])
if @homework.destroy
respond_to do |format|
format.html { redirect_to project_for_bid_path @homework.bid }
format.json { head :no_content }
#@homework = HomeworkAttach.find(params[:id])
if User.current.admin? || User.current == @homework
if @homework.destroy
respond_to do |format|
format.html { redirect_to project_for_bid_path @homework.bid }
format.json { head :no_content }
end
else
end
else
render_403 :message => :notice_not_authorized
end
end
#显示作业信息
def show
@homework = HomeworkAttach.find(params[:id])
# 打分统计
stars_reates = @homework.
rates(:quality)
stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count
stars_status = stars_reates.select("stars, count(*) as scount").
group("stars")
@stars_status_map = Hash.new(0.0)
stars_status.each do |star_status|
percent = (star_status.scount * 1.0/ stars_reates_count) * 100.to_f
percent_m = format("%.2f", percent)
@stars_status_map["star#{star_status.stars.to_i}".to_sym] =
percent_m.to_s + "%"
#@homework = HomeworkAttach.find(params[:id])
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
# 打分统计
stars_reates = @homework.
rates(:quality)
stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count
stars_status = stars_reates.select("stars, count(*) as scount").
group("stars")
@stars_status_map = Hash.new(0.0)
stars_status.each do |star_status|
percent = (star_status.scount * 1.0/ stars_reates_count) * 100.to_f
percent_m = format("%.2f", percent)
@stars_status_map["star#{star_status.stars.to_i}".to_sym] =
percent_m.to_s + "%"
end
#是否已经进行过评价
@has_evaluation = stars_reates.where("rater_id = ?",User.current).count > 0
#是否开启互评功能
@is_evaluation = @homework.bid.is_evaluation == 1 || @homework.bid.is_evaluation == nil
@limit = 10
@jours = @homework.journals_for_messages.where("is_comprehensive_evaluation is null").order("created_on DESC")
@feedback_count = @jours.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
@jour = @jours[@offset, @limit]
@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC")
else
render_403 :message => :notice_not_authorized
end
@limit = 10
@jours = @homework.journals_for_messages.where("is_comprehensive_evaluation is null").order("created_on DESC")
@feedback_count = @jours.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
@jour = @jours[@offset, @limit]
@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC")
end
#删除留言

View File

@ -1,3 +1,14 @@
class HomeworkUsersController < ApplicationController
#新增数据
def create option
user = HomeworkUser.new option
user.save
user
end
#删除数据
def destory homework_user
user = HomeworkUser.find homework_user
user.destroy
user
end
end

View File

@ -19,6 +19,7 @@ class IssueCategoriesController < ApplicationController
menu_item :settings
model_object IssueCategory
before_filter :find_model_object, :except => [:index, :new, :create]
#before_filter :find_model_object_contest, :except => [:index, :new, :create]
before_filter :find_project_from_association, :except => [:index, :new, :create]
before_filter :find_project_by_project_id, :only => [:index, :new, :create]
before_filter :authorize
@ -119,4 +120,10 @@ class IssueCategoriesController < ApplicationController
super
@category = @object
end
def find_model_object_contest
super
@category = @object
end
end

View File

@ -17,6 +17,7 @@
class MembersController < ApplicationController
model_object Member
before_filter :find_model_object, :except => [:index, :create, :autocomplete]
#before_filter :find_model_object_contest, :except => [:index, :create, :autocomplete]
before_filter :find_project_from_association, :except => [:index, :create, :autocomplete]
before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete]
before_filter :authorize

View File

@ -0,0 +1,27 @@
class NotificationcommentsController < ApplicationController
# default_search_scope :contestnotifications
# model_object Contestnotifications
# before_filter :authorize
def create
#raise Unauthorized unless @contestnotifications.notificationcommentable?
@contest = Contest.find(params[:contest_id])
@contestnotification = Contestnotification.find(params[:contestnotification_id])
# @notificaioncomment = Notificationcomment.new
# @notificaioncomment.safe_attributes = params[:notificationcomment]
# @notificaioncomment.author = User.current
comment = @contestnotification.notificationcomments.new(params[:notificationcomment].merge(author_id: User.current.id))
if comment.save
flash[:notice] = l(:label_comment_added)
end
redirect_to contest_contestnotification_path(@contest, @contestnotification)
end
def destroy
@contestnotifications.notificaioncomments.find(params[:notificaioncomment_id]).destroy
redirect_to contest_contestnotification_path(@contestnotifications)
end
end

View File

@ -9,6 +9,7 @@ class PraiseTreadController < ApplicationController
if request.get?
@obj_id = params[:obj_id]
@obj_type = params[:obj_type]
@horizontal = params[:horizontal]
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
praise_tread_plus(@obj_type,@obj_id,1)
end
@ -44,6 +45,7 @@ class PraiseTreadController < ApplicationController
if request.get?
@obj_id = params[:obj_id]
@obj_type = params[:obj_type]
@horizontal = params[:horizontal]
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
praise_tread_plus(@obj_type,@obj_id,0)
end
@ -71,6 +73,10 @@ class PraiseTreadController < ApplicationController
@obj = Bid.find_by_id(id)
when 'Contest'
@obj = Contest.find_by_id(id)
when 'Memo'
@obj = Memo.find_by_id(id)
when 'Message'
@obj = Message.find_by_id(id)
end
return @obj
end

View File

@ -16,10 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class PreviewsController < ApplicationController
before_filter :find_project, :find_attachments
before_filter :find_project, :find_attachments, :find_contest, except: [:contestnotification]
def issue
@issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
@issue = @contest.issues.find_by_id(params[:id]) unless params[:id].blank?
if @issue
@description = params[:issue] && params[:issue][:description]
if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
@ -41,6 +42,12 @@ class PreviewsController < ApplicationController
render :partial => 'common/preview'
end
def contestnotification
@previewed = Contestnotification.find(params[:id])
@text = (params[:contestnotification] ? params[:contestnotification][:description] : nil)
render :partial => 'common/preview'
end
private
def find_project
@ -50,4 +57,20 @@ class PreviewsController < ApplicationController
render_404
end
def contestnotifications
if params[:id].present? && contestnotifications = Contestnotifications.visible.find_by_id(params[:id])
@previewed = contestnotifications
end
@text = (params[:contestnotifications] ? params[:contestnotifications][:description] : nil)
render :partial => 'common/preview'
end
private
def find_contest
contest_id = (params[:issue] && params[:issue][:contest_id]) || params[:contest_id]
@contest = Contest.find(contest_id)
rescue ActiveRecord::RecordNotFound
render_404
end
end

View File

@ -37,6 +37,7 @@ class ProjectsController < ApplicationController
# before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file,
# :statistics, :feedback, :course, :enterprise_course, :course_enterprise, :project_respond, :share,
# :show_projects_score, :issue_score_index, :news_score_index, :file_score_index, :code_submit_score_index, :projects_topic_score_index]
#此条勿删 课程相关权限 ,:new_homework,:homework,:feedback,,:member
before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course]
before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches]
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar]
@ -716,6 +717,9 @@ class ProjectsController < ApplicationController
@teachers= searchTeacherAndAssistant(@project)
@canShowRealName = isCourseTeacher(User.current.id)
end
#勿删 real_name action为虚拟的该方法并不存在用来辅助判断真名权限
#勿删 @canShowRealName = User.current.allowed_to?({:controller => "projects", :action => "real_name"}, @project || @projects, :global => false)
respond_to do |format|
format.html{render :layout => 'base_courses' if @base_courses_tag==1}
format.api

View File

@ -108,11 +108,16 @@ class SoftapplicationsController < ApplicationController
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
@membership.each do |membership|
unless(membership.project.project_type==1)
membership.member_roles.each{|role|
if(role.role_id == 3)
#membership.member_roles.each{|role|
# if(role.role_id == 3)
# @option << membership.project
# end
#}
#拥有编辑项目权限的可操作该项目
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
@option << membership.project
end
}
end
end
end

View File

@ -20,6 +20,7 @@ class VersionsController < ApplicationController
menu_item :roadmap
model_object Version
before_filter :find_model_object, :except => [:index, :new, :create, :close_completed]
#before_filter :find_model_object_contest, :except => [:index, :new, :create]
before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed]
before_filter :find_project_by_project_id, :only => [:index, :new, :create, :close_completed]
before_filter :authorize
@ -154,6 +155,13 @@ class VersionsController < ApplicationController
redirect_to settings_project_path(@project, :tab => 'versions')
end
def close_completed_contest
if request.put?
@contest.close_completed_versions
end
redirect_to settings_contest_path(@contest, :tab => 'versions')
end
def destroy
if @version.fixed_issues.empty?
@version.destroy

View File

@ -122,7 +122,9 @@ class WatchersController < ApplicationController
end
def find_watchables
#根据参数获取关注对象的类型user、project
klass = Object.const_get(params[:object_type].camelcase) rescue nil
#判断获取的对象类型能否响应watched_by方法
if klass && klass.respond_to?('watched_by')
@watchables = klass.find_all_by_id(Array.wrap(params[:object_id]))
raise Unauthorized if @watchables.any? {|w| w.respond_to?(:visible?) && !w.visible?}

View File

@ -18,7 +18,7 @@
class WelcomeController < ApplicationController
caches_action :robots
# before_filter :fake, :only => [:index, :course]
before_filter :entry_select_course, :entry_select_contest, :entry_select_user, :only => [:index]
before_filter :entry_select, :only => [:index]
def index
@ -92,9 +92,28 @@ class WelcomeController < ApplicationController
private
def entry_select
url = request.original_url
if url.include?("course.trustie.net")
course
render :course
return 0
elsif url.include?("contest.trustie.net")
contest
render :contest
return 0
elsif url.include?("user.trustie.net")
redirect_to(:controller => "users", :action => "index")
end
end
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
def entry_select_course
(course() and render :course and return 0) if request.original_url.match(/course\.trustie\.net/)
if request.original_url.match(/course\.trustie\.net/)
(course() and render :course and return 0)
end
end
def entry_select_contest

View File

@ -1,7 +1,21 @@
class ZipdownController < ApplicationController
#查找项目(课程)
before_filter :find_project_by_bid_id, :only => [:assort]
#检查权限
#勿删 before_filter :authorize, :only => [:assort,:download_user_homework]
SAVE_FOLDER = "#{Rails.root}/files"
OUTPUT_FOLDER = "#{Rails.root}/tmp/archiveZip"
#通过作业Id找到项目课程
def find_project_by_bid_id
obj_class = params[:obj_class]
obj_id = params[:obj_id]
obj = obj_class.constantize.find(obj_id)
case obj.class.to_s.to_sym
when :Bid
@project = obj.courses[0]
end
end
def assort
obj_class = params[:obj_class]
obj_id = params[:obj_id]
@ -22,18 +36,13 @@ class ZipdownController < ApplicationController
#下载某一学生的作业的所有文件
def download_user_homework
obj_class = params[:obj_class]
obj_id = params[:obj_id]
user_id = params[:user_id]
obj = obj_class.constantize.find(obj_id)
zipfile = nil
case obj.class.to_s.to_sym
when :Bid
zipfile = zip_user_bid obj,user_id
else
logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!"
homework = HomeworkAttach.find params[:homework]
if homework != nil && (User.current.admin? || User.current.member_of?(homework.bid.courses.first))
zipfile = zip_homework_by_user homework
send_file zipfile, :filename => homework.name, :type => detect_content_type(zipfile) if zipfile
else
render_403 :message => :notice_not_authorized
end
send_file zipfile, :filename => obj.name, :type => detect_content_type(zipfile) if zipfile
end
private
@ -47,7 +56,8 @@ class ZipdownController < ApplicationController
user_zip_paths = homeattaches.map do |homeattach|
zip_homework_by_user homeattach
end
zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER
#zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER
user_zip_paths
end
def zip_bid(bid)
@ -78,7 +88,8 @@ class ZipdownController < ApplicationController
#length = attach.storage_path.length
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
end
zipping "#{Time.now.to_i}_#{homeattach.user.name.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true
zipping "#{homeattach.user.name.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true
#user_attaches_paths
end

View File

@ -47,6 +47,10 @@ module ApplicationHelper
User.current.allowed_to?({:controller => controller, :action => action}, @project)
end
def authorize_for_contest(controller, action)
User.current.allowed_to?({:controller => controller, :action => action}, @contest)
end
# Display a link if user is authorized
#
# @param [String] name Anchor text (passed to link_to)
@ -57,6 +61,9 @@ 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_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
# Displays a link to user's account page if active
def link_to_user(user, canShowRealName = false, options={})
if user.is_a?(User)
@ -198,9 +205,8 @@ module ApplicationHelper
end
def thumbnail_tag(attachment)
imagepath = named_attachment_path(attachment, attachment.filename)
link_to image_tag(imagepath),
imagepath ,
link_to image_tag(thumbnail_path(attachment)),
named_attachment_path(attachment, attachment.filename),
:title => attachment.filename
end

View File

@ -155,16 +155,6 @@ module BidsHelper
end
people.include?(User.current)
end
#当前用户是不是指定课程的学生
def is_cur_course_student? course
people = []
course.members.each do |member|
if [5,10].include? member.roles.first.id
people << member.user
end
end
people.include?(User.current)
end
# def select_option_helper option
# tmp = Hash.new

View File

@ -0,0 +1,2 @@
module ContestnotificationsHelper
end

View File

@ -245,29 +245,49 @@ module CoursesHelper
Course.find_by_extra(try(extra))
end
#判断制定用户是不是当前课程的老师
def is_course_teacher user,course
people = []
course.members.each do |member|
role_id = member.roles.first.id
if TeacherRoles.include? role_id
people << member.user
end
end
people.include?(user)
def is_course_teacher (user,course)
course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{user.id}", {:role_id => TeacherRoles}).count != 0
#修改为根据用户是否有发布任务的权限来判断用户是否是课程的老师
#is_teacher = false
#@membership = user.memberships.all(:conditions => Project.visible_condition(User.current))
#@membership.each do |membership|
# unless(membership.project.project_type==0)
# if user.allowed_to?({:controller => "projects", :action => "new_homework"}, membership.project, :global => false)
# is_teacher = true
# end
# end
#end
#is_teacher
end
#当前用户是不是指定课程的学生
def is_cur_course_student? course
people = []
course.members.each do |member|
if StudentRoles.include? member.roles.first.id
people << member.user
end
end
people.include?(User.current)
def is_cur_course_student course
course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{User.current.id}", {:role_id => StudentRoles}).count != 0
#修改:能新建占位且不能新建任务的角色判定为学生
#is_student = false
#@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
#@membership.each do |membership|
# unless(membership.project.project_type==0)
# if !User.current.allowed_to?({:controller => "projects", :action => "new_homework"}, membership.project, :global => false) && User.current.allowed_to?({:controller => "homework_attach", :action => "new"}, membership.project, :global => false)
# is_student = true
# end
# end
#end
#is_student
end
#获取当前用户在指定作业下提交的作业的集合
def cur_user_homework_for_bid bid
cur_user_homework = HomeworkAttach.where("user_id = ? and bid_id = ?",User.current,params[:id])
cur_user_homework = HomeworkAttach.where("user_id = ? and bid_id = ?",User.current,bid.id)
cur_user_homework
end
#判断当前用户对指定作业是否已经评价过
def has_evaluation? homework
seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count
seem_count > 0
end
#获取指定作业的所有成员
def users_for_homework homework
homework.nil? ? [] : (homework.users + [homework.user])
end
end

View File

@ -1,10 +1,57 @@
module HomeworkAttachHelper
#判断是否具有删除的权限
def attach_delete(project)
if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id)
true
else
false
end
end
#作业添加、编辑界面的tab页
def homework_settings_tabs f
@f = f
tabs = [{:name => 'info', :partial => 'homework_attach/edit_homework', :label => :label_information_plural},
{:name => 'members', :partial => 'homework_attach/homework_member', :label => :label_member_plural}
]
end
#作业可选成员列表分页
def render_new_members_for_homework members
#scope = Principal.active.sorted.not_member_of(project).like(params[:q])
#scope = project.members
#principals = paginateHelper members,10
#principals = members
#principal_count = members.count
#limit = 10
#principal_pages = Redmine::Pagination::Paginator.new principal_count, limit, params['page'] #by young
#offset ||= principal_pages.offset
#principals = members[offset, limit]
users = members.map(&:user)
s = content_tag('div', member_check_box_tags_ex('membership[user_ids][]', users), :id => 'principals')
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false) {|text, parameters, options|
link_to text, get_homework_member_list_homework_attach_index_path( parameters.merge(:q => params[:q], bid_id: params[:id]||@homework)), :remote => true }
return s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
end
#扩展的checkbox生成
def member_check_box_tags_ex(name, principals)
s = ''
principals.each do |member|
s << "<label>#{ check_box_tag name, member.id, false, :id => nil } #{h member.name }</label><br/>"
end
s.html_safe
end
def paginateHelper obj, pre_size=20
@obj_count = obj.count
@obj_pages = Redmine::Pagination::Paginator.new @obj_count, pre_size, params['page']
if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation
obj.limit(@obj_pages.per_page).offset(@obj_pages.offset)
elsif obj.kind_of? Array
obj[@obj_pages.offset, @obj_pages.per_page]
else
logger.error "[ApplicationController] Error : application_controller#paginateHelper ===> unknow category: #{obj.class}"
raise RuntimeError, 'unknow type, Please input you type into this helper.'
end
end
end

View File

@ -54,7 +54,7 @@ module MembersHelper
# 当前申请加入的成员名单
def render_principals_for_applied_members(project)
scope = Principal.active.sorted.applied_members(project).like(params[:q])
principal_count = scope.count
principal_count = scope.count
principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page']
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all

View File

@ -0,0 +1,2 @@
module NotificationcommentsHelper
end

View File

@ -150,7 +150,6 @@ module ProjectsHelper
{:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural}
]
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
end
#Ended by young
@ -227,6 +226,19 @@ module ProjectsHelper
type << option2
end
#是否启动互评下拉框
def is_evaluation_option
type = []
option1 = []
option2 = []
option1 << l(:lable_start_mutual_evaluation)
option1 << 1
option2 << l(:lable_close_mutual_evaluation)
option2 << 2
type << option1
type << option2
end
# 用来判断用户是否是项目的管理员
# added by william
def is_manager?(user_id,project_id)

View File

@ -4,11 +4,15 @@ def options_from_select_project(user)
@option = []
@membership.each do |membership|
unless(membership.project.project_type==1)
membership.member_roles.each{|role|
if(role.role_id == 3)
#membership.member_roles.each{|role|
# if(role.role_id == 3)
# @option << membership.project
# end
#}
#拥有编辑项目权限的可操作该项目
if user.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
@option << membership.project
end
}
end
end
end
options_for_select(@option)

View File

@ -228,12 +228,21 @@ module UserScoreHelper
isManager = 0
members = Member.where('user_id = ?', user.id)
members.each do |m|
roles = m.member_roles
roles.each do |r|
if r.role_id == 3
#roles = m.member_roles
#roles.each do |r|
# if r.role_id == 3
# isManager = 1
# end
#end
@membership = m.memberships.all(:conditions => Project.visible_condition(User.current))
@membership.each do |membership|
#拥有编辑项目权限的可操作该项目
if m.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
isManager = 1
end
end
end
level = 0

View File

@ -22,6 +22,33 @@ module WelcomeHelper
include CoursesHelper
include ProjectsHelper
def get_timestamp(obj)
if obj.respond_to? :updated_on
:updated_on
elsif obj.respond_to? :updated_at
:updated_at
elsif obj.respond_to? :created_on
:created_on
elsif obj.respond_to? :created_at
:created_at
else
Time.now.to_i.to_s.to_sym
end
end
def cache_key_for_project(obj)
timestamp = get_timestamp(obj)
"welcome_index_project_ul_#{obj.class}_li_#{obj.id}_#{obj.__send__ timestamp}"
end
def cache_key_for_event(obj)
timestamp = get_timestamp(obj)
"welcome_index_event_ul_#{obj.class}_li_#{obj.id}_#{obj.__send__ timestamp}"
end
def cache_key_for_topic(obj)
timestamp = get_timestamp(obj)
"welcome_index_topic_ul_#{obj.class}_li_#{obj.id}_#{obj.__send__ timestamp}"
end
def welcome_join_in_course(project, user)
if(user.logged? &&
!(course_endTime_timeout? project) &&
@ -319,9 +346,10 @@ module WelcomeHelper
"show_documents" => true,
"show_messages" => true,
"show_news" => true,
"show_bids" => true
"show_bids" => true,
"show_contest" => true
}
activity.scope_select{|t| ['changesets', 'documents', 'memos', 'messages', 'journals_for_messages', 'bids', 'news'].include?(t) ? nil : 'You may think you know what the following code does, may be. but why don"t you close this file and go play with something else, Now?' }
activity.scope_select{|t| ['changesets', 'documents', 'memos', 'messages', 'journals_for_messages', 'bids', 'news', 'contestnotification'].include?(t) ? nil : 'You may think you know what the following code does, may be. but why don"t you close this file and go play with something else, Now?' }
activity.events_welcome(nil, nil, {:limit => limit, :types => 'welcome'})
end

View File

@ -65,6 +65,7 @@ class Attachment < ActiveRecord::Base
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
before_save :files_to_final_location
before_save :be_user_score # user_score
after_destroy :delete_from_disk
# Returns an unsaved copy of the attachment
@ -374,4 +375,17 @@ class Attachment < ActiveRecord::Base
end
"#{timestamp}_#{ascii}"
end
# update user score
def be_user_score
if self.container_id_changed?
type = self.container_type
types = %w|Document News Version Project Issue Message WikiPage|
if types.include?(type)
UserScore.project(:push_file, User.current, { attachment_id: self.id })
end
end
end
end

View File

@ -18,6 +18,9 @@
class Changeset < ActiveRecord::Base
belongs_to :repository
belongs_to :user
after_save :be_user_score # user_score
has_many :filechanges, :class_name => 'Change', :dependent => :delete_all
# fq
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
@ -292,4 +295,16 @@ class Changeset < ActiveRecord::Base
def self.to_utf8(str, encoding)
Redmine::CodesetUtil.to_utf8(str, encoding)
end
private
# update user score
def be_user_score
if self.new_record?
UserScore.project(:push_code, self.user, { changeset_id: self.id })
#更新用户等级
self.user.update_user_level
end
end
end

View File

@ -13,6 +13,7 @@ class Contest < ActiveRecord::Base
has_many :join_in_competitions, foreign_key: 'competition_id', :dependent => :destroy
has_many :join_in_contests, class_name: 'JoinInCompetition', foreign_key: 'competition_id', :dependent => :destroy
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
has_many :contestnotifications, :dependent => :destroy, :include => :author
@ -93,6 +94,17 @@ class Contest < ActiveRecord::Base
end
end
# Closes open and locked project versions that are completed
def close_completed_versions_contest
Version.transaction do
versions.where(:status => %w(open locked)).all.each do |version|
if version.completed?
version.update_attribute(:status, 'closed')
end
end
end
end
def set_commit(commit)
self.update_attribute(:commit, commit)
end

View File

@ -0,0 +1,63 @@
class Contestnotification < ActiveRecord::Base
#attr_accessible :author_id, :notificationcomments_count, :contest_id, :description, :summary, :title
include Redmine::SafeAttributes
#Contestnotification::Notificationcomment
belongs_to :contest
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
has_many :notificationcomments, as: :notificationcommented, :dependent => :delete_all, :order => "created_at"
# fq
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
validates_presence_of :title, :description
validates_length_of :title, :maximum => 60
validates_length_of :summary, :maximum => 255
acts_as_attachable :delete_permission => :manage_contestnotifications
acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :contest
acts_as_event :url => Proc.new {|o| {:controller => 'contestnotifications', :action => 'show', :id => o.id}}
acts_as_activity_provider :find_options => {:include => [:contest, :author]},
:author_key => :author_id
acts_as_watchable
after_create :add_author_as_watcher
after_create :act_as_activity
scope :visible, lambda {|*args|
nil
#includes(:contest).where(Contest.allowed_to_condition(args.shift || User.current, :view_contestnotifications, *args))
}
safe_attributes 'title', 'summary', 'description'
def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_contestnotifications, contest)
end
# Returns true if the news can be commented by user
def notificationcommentable?(user=User.current)
user.allowed_to?(:notificationcomment_contestnotifications, contest)
end
def recipients
#contest.users.select {|user| user.notify_about?(self)}.map(&:mail)
end
# returns latest news for contests visible by user
def self.latest(user = User.current, count = 5)
visible(user).includes([:author, :contest]).order("#{Contestnotification.table_name}.created_at DESC").limit(count).all
end
private
def add_author_as_watcher
#Watcher.create(:watchable => self, :user => author)
end
## fq
def act_as_activity
self.acts << Activity.new(:user_id => self.author_id)
end
end

View File

@ -18,7 +18,12 @@
class Document < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :project
belongs_to :user
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
before_save :be_user_score # user_score
acts_as_attachable :delete_permission => :delete_documents
acts_as_searchable :columns => ['title', "#{table_name}.description"], :include => :project
@ -54,4 +59,11 @@ class Document < ActiveRecord::Base
end
@updated_on
end
# update user score
def be_user_score
if self.new_record?
UserScore.project(:push_document, self.user, { document_id: self.id })
end
end
end

View File

@ -7,14 +7,15 @@ class HomeworkAttach < ActiveRecord::Base
belongs_to :bid
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :homework_users, :dependent => :destroy
has_many :users, :through => :homework_users
seems_rateable :allow_update => true, :dimensions => :quality
safe_attributes "bid_id",
"user_id"
acts_as_attachable
def addjours user_id,message,status = 0,is_comprehensive_evaluation = 0
jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status,:is_comprehensive_evaluation => is_comprehensive_evaluation)
def addjours user_id,message,status = 0,is_comprehensive_evaluation = 0,reply_id = 0
jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status,:is_comprehensive_evaluation => is_comprehensive_evaluation,:reply_id => reply_id)
jfm.save
jfm
end

View File

@ -1,6 +1,6 @@
class HomeworkUser < ActiveRecord::Base
attr_accessible :homework_attach_id, :user_id
belongs_to :homework_attach
belongs_to :homework_attach, :foreign_key => :homework_attach_id
belongs_to :user
end

View File

@ -77,6 +77,8 @@ class Issue < ActiveRecord::Base
# fq
after_create :act_as_activity
before_save :be_user_score
# after_create :be_user_score
# end
delegate :notes, :notes=, :private_notes, :private_notes=, :to => :current_journal, :allow_nil => true
@ -1484,4 +1486,17 @@ class Issue < ActiveRecord::Base
and #{visible_condition(User.current, :project => project)}
group by s.id, s.is_closed, j.id")
end
# update user score
def be_user_score
if self.new_record?
UserScore.project(:post_issue, User.current, { issue_id: self.id })
elsif self.done_ratio_changed?
UserScore.project(:update_issue_ratio, User.current, { issue_id: self.id })
#缺陷状态更改
elsif self.status_id_changed?
#协同得分
UserScore.joint(:change_issue_status, User.current,nil, {issue_id: self.id})
end
end
end

View File

@ -48,6 +48,9 @@ class Journal < ActiveRecord::Base
after_create :act_as_activity
# end
before_save :be_user_score
#before_destroy :down_user_score
scope :visible, lambda {|*args|
user = args.shift || User.current
@ -151,4 +154,21 @@ class Journal < ActiveRecord::Base
self.acts << Activity.new(:user_id => self.user_id)
end
# end
# 更新用户分数 -by zjc
def be_user_score
#新建了缺陷留言且留言不为空,不为空白
if self.new_record? && !self.notes.nil? && self.notes.gsub(' ','') != ''
#协同得分加分
UserScore.joint(:post_issue, User.current,self.issue.author, { message_id: self.id })
end
end
# 减少用户分数 -by zjc
def down_user_score
#删除有效缺陷留言
if !self.notes.nil? && self.notes.gsub(' ','') != ''
#协同得分减分
UserScore.joint(:delete_issue, User.current,self.issue.author, { message_id: self.id })
end
end
end

View File

@ -51,6 +51,8 @@ class JournalsForMessage < ActiveRecord::Base
after_create :act_as_activity #huang
after_create :reset_counters!
after_destroy :reset_counters!
before_save :be_user_score
#before_destroy :down_user_score
# default_scope { where('m_parent_id IS NULL') }
@ -110,4 +112,21 @@ class JournalsForMessage < ActiveRecord::Base
count = find_all_by_m_parent_id(journals_for_messages.m_parent_id).count #(SELECT COUNT(*) FROM #{JournalsForMessage.table_name} WHERE m_parent_id = #{jfm_id} )
update_all("m_reply_count = #{count.to_i}", ["id = ?", journals_for_messages.m_parent_id])
end
# 更新用户分数 -by zjc
def be_user_score
#新建了留言回复
if self.new_record? && self.reply_id != 0
#协同得分加分
UserScore.joint(:reply_message, User.current,User.find(self.reply_id), { journals_for_messages_id: self.id })
end
end
# 更新用户分数 -by zjc
def down_user_score
#删除了留言回复
if self.reply_id != 0
#协同得分减分
UserScore.joint(:reply_message_delete, User.current,User.find(self.reply_id), { journals_for_messages_id: self.id })
end
end
end

View File

@ -51,7 +51,7 @@ class Mailer < ActionMailer::Base
when :User
user_newfeedback_user_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
else
logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}"
Rails.logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}"
return -1
end
#如果是直接留言并且留言对象是Project并且Project类型是课程
@ -70,7 +70,12 @@ class Mailer < ActionMailer::Base
end
mail :to => @recipients,
:subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} "
else
elsif journals_for_message.jour.class.to_s.to_sym == :Bid
if !journals_for_message.jour.author.notify_about? journals_for_message
return -1
end
mail :to => journals_for_message.jour.author.mail, :subject => @title
else
mail :to => @mail.mail, :subject => @title
end

View File

@ -46,7 +46,7 @@ class Memo < ActiveRecord::Base
# after_create :send_notification
# after_save :plusParentAndForum
# after_destroy :minusParentAndForum
before_save :be_user_score
# scope :visible, lambda { |*args|
# includes(:forum => ).where()
# }
@ -140,5 +140,17 @@ class Memo < ActiveRecord::Base
@forum.topic_count = 0 if @forum.topic_count.to_int < 0
end
@forum.save
end
end
#更新用户分数 -by zjc
def be_user_score
#新建memo且无parent的为发帖
if self.new_record? && self.parent_id.nil?
UserScore.joint(:post_message, User.current,nil, { memo_id: self.id })
#新建memo且有parent的为回帖
elsif self.new_record? && !self.parent_id.nil?
UserScore.joint(:reply_posting, User.current,self.parent.author, { memo_id: self.id })
end
end
end

View File

@ -61,6 +61,8 @@ class Message < ActiveRecord::Base
# fq
after_create :act_as_activity
before_save :be_user_score
#before_destroy :down_user_score
# end
scope :visible, lambda {|*args|
@ -141,4 +143,25 @@ class Message < ActiveRecord::Base
self.acts << Activity.new(:user_id => self.author_id)
end
# end
#更新用户分数 -by zjc
def be_user_score
#新建message且无parent的为发帖
if self.new_record? && self.parent_id.nil?
UserScore.joint(:post_message, User.current,nil, { message_id: self.id })
#新建message且有parent的为回帖
elsif self.new_record? && !self.parent_id.nil?
UserScore.joint(:reply_posting, User.current,self.parent.author, { message_id: self.id })
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 })
end
end
end

View File

@ -0,0 +1,11 @@
class Notificationcomment < ActiveRecord::Base
attr_accessible :author_id, :notificationcommented_id, :notificationcommented_type, :notificationcomments
include Redmine::SafeAttributes
belongs_to :notificationcommented, :polymorphic => true#, :counter_cache => true
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
validates_presence_of :notificationcommented, :author, :notificationcomments
# safe_attributes 'notificationcomments'
end

View File

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

View File

@ -5,7 +5,7 @@ class ProjectInfo < ActiveRecord::Base
belongs_to :user
validates_presence_of :project_id, :user_id
validates_uniqueness_of :project_id, :scope => :user_id
after_save :update_user_level
def self.manager? (user_id, project)
for project_info in project.project_infos
if project_info.user_id == user_id
@ -14,4 +14,9 @@ class ProjectInfo < ActiveRecord::Base
end
return false
end
#更新用户等级
def update_user_level
self.user.update_user_level
end
end

View File

@ -73,7 +73,8 @@ class User < Principal
['none', :label_user_mail_option_none]
]
belongs_to :homework_user
has_many :homework_users
has_many :homework_attaches, :through => :homework_users
has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)},
:after_remove => Proc.new {|user, group| group.user_removed(user)}
@ -107,11 +108,14 @@ class User < Principal
# added by bai
has_many :join_in_contests, :dependent => :destroy
has_many :news, :foreign_key => 'author_id'
has_many :contestnotification, :foreign_key => 'author_id'
has_many :comments, :foreign_key => 'author_id'
has_many :notificationcomments, :foreign_key => 'author_id'
has_many :wiki_contents, :foreign_key => 'author_id'
has_many :journals
has_many :messages, :foreign_key => 'author_id'
has_one :user_score, :dependent => :destroy
has_many :documents # 项目中关联的文档再次与人关联
# end
######added by nie
@ -120,6 +124,10 @@ class User < Principal
#####
has_many :shares ,:dependent => :destroy
# add by zjc
has_one :level, :class_name => 'UserLevels', :dependent => :destroy
has_many :memos , :foreign_key => 'author_id'
#####
scope :logged, lambda { where("#{User.table_name}.status <> #{STATUS_ANONYMOUS}") }
scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
scope :visible, lambda {|*args|
@ -137,6 +145,7 @@ class User < Principal
has_one :user_extensions,:dependent => :destroy
## end
# default_scope -> { includes(:user_extensions, :user_score) }
scope :teacher, -> {
joins(:user_extensions).where('user_extensions.identity = ?', UserExtensions::TEACHER)
}
@ -200,6 +209,7 @@ class User < Principal
# ======================================================================
# 集中处理 User 扩展表为空的问题
# 合并 user_score 属性
validate :valid_user_extensions
after_save :save_user_extensions
@ -207,21 +217,32 @@ class User < Principal
self.user_extensions ||= UserExtensions.new
end
def user_score_attr
self.user_score ||= UserScore.new
end
alias_method :ori_respond_to?, :respond_to?
def respond_to?(m, include_private = false)
flag = UserExtensions.instance_methods.include? m.to_sym
if flag
flag
else
super
end
flag = false
flag = ori_respond_to? m.to_sym unless flag
flag = UserExtensions.new.respond_to? m.to_sym unless flag
flag = UserScore.new.respond_to? m.to_sym unless flag
flag
end
def method_missing m, *args, &block
if extensions.respond_to? m.to_sym
self.class.send :define_method, m.to_sym, *args do
self.class.send(:define_method, "_meta_#{m}".to_sym) do |*args, &block|
self.extensions.__send__ m.to_sym, *args
end
__send__ m.to_sym, *args, &block
__send__ "_meta_#{m}".to_sym, *args, &block
elsif user_score_attr.respond_to? m.to_sym
self.class.send(:define_method, "_meta_#{m}".to_sym) do |*args, &block|
self.user_score_attr.__send__ m.to_sym, *args
end
__send__ "_meta_#{m}".to_sym, *args, &block
else
super
@ -240,6 +261,7 @@ class User < Principal
def save_user_extensions
self.extensions.save
self.user_score_attr.save
end
# 集中处理 User 扩展表为空的问题 < end
# ======================================================================
@ -505,6 +527,9 @@ class User < Principal
self.pref[:comments_sorting] == 'desc'
end
def wants_notificationcomments_in_reverse_order?
self.pref[:notificationcomments_sorting] == 'desc'
end
# Return user's RSS key (a 40 chars long string), used to access feeds
def rss_key
if rss_token.nil?
@ -927,6 +952,63 @@ class User < Principal
end
end
#获取user的等级 -by zjc
def get_level
if self.level.nil?
update_user_level
end
self.level.level
end
#更新用户等级 - by zjc
def update_user_level
user_level = self.level.nil? ? UserLevels.new : self.level
user_level.user = self
#判断user的等级
pis = self.project_infos #ProjectInfo.find_all_by_user_id(self.id)
isManager = false;
pis.each do |pi|
#判断是否为项目管理员
if self.allowed_to?({:controller => "projects", :action => "edit"}, pi.project)
isManager = true;
end
end
has_effective_praise_count = false;
self.messages.each do |message|
if message.parent_id.nil?
ptcs = PraiseTreadCache.find_all_by_object_id(message.id)
ptcs.each do |ptc|
if ptc.object_type == 'Message' && ptc.praise_num.to_i > 5
has_effective_praise_count = true
end
end
end
end
if !has_effective_praise_count
self.memos do |memo|
if memo.parent_id.nil?
ptcs = PraiseTreadCache.find_all_by_object_id(memo.id)
ptcs.each do |ptc|
if ptc.object_type == 'Memo' && ptc.praise_num > 5
has_effective_praise_count = true
end
end
end
end
end
if isManager || self.changesets.count > 100
user_level.level = 3
elsif (self.changesets.count > 1 && self.changesets.count <= 100) || has_effective_praise_count
user_level.level = 2
else
user_level.level = 1
end
user_level.save
self.reload
end
protected
def validate_password_length
@ -935,7 +1017,6 @@ class User < Principal
errors.add(:password, :too_short, :count => Setting.password_min_length.to_i)
end
end
private
def act_as_activity
@ -950,6 +1031,7 @@ class User < Principal
substitute = User.anonymous
Attachment.update_all ['author_id = ?', substitute.id], ['author_id = ?', id]
Comment.update_all ['author_id = ?', substitute.id], ['author_id = ?', id]
Notificationcomment.update_all ['author_id = ?', substitute.id], ['author_id = ?', id]
Issue.update_all ['author_id = ?', substitute.id], ['author_id = ?', id]
Issue.update_all 'assigned_to_id = NULL', ['assigned_to_id = ?', id]
Journal.update_all ['user_id = ?', substitute.id], ['user_id = ?', id]
@ -977,6 +1059,8 @@ class User < Principal
Redmine::Utils.random_hex(16)
end
end
class AnonymousUser < User

View File

@ -0,0 +1,5 @@
#用户等级类 - by zjc
class UserLevels < ActiveRecord::Base
attr_accessible :user_id, :level
belongs_to :user
end

View File

@ -54,6 +54,9 @@ class UserPreference < ActiveRecord::Base
def comments_sorting; self[:comments_sorting] end
def comments_sorting=(order); self[:comments_sorting]=order end
def notificationcomments_sorting; self[:notificationcomments_sorting] end
def notificationcomments_sorting=(order); self[:notificationcomments_sorting]=order end
def warn_on_leaving_unsaved; self[:warn_on_leaving_unsaved] || '1'; end
def warn_on_leaving_unsaved=(value); self[:warn_on_leaving_unsaved]=value; end
end

View File

@ -18,6 +18,8 @@
class UserScore < ActiveRecord::Base
belongs_to :user
before_save :correct_score
def self.find_max_file
self.maximum(:file)
end
@ -33,4 +35,223 @@ class UserScore < ActiveRecord::Base
def self.find_min_issue
self.minimum(:file)
end
# 以上类方法目测没用,反正也报错
# ===============================================================================
# 前略·协同得分
# operate - 更新操作 类型 symbol
# user - 计分用户
#
# Examples
#
# UserScore.joint(:post_message, User.current, nil)
# # => true #当前用户发帖计分操作成功
#
# Returns boolean. 返回积分保存结果
def self.joint(operate, current_user, target_user, options={})
current_user, target_user = get_users(current_user, target_user)
user_score = current_user.user_score_attr
case operate
when :post_message # current_user 发帖了 Add Message
user_score.collaboration = user_score.collaboration.to_i + 2
user_score.save
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a message. options => (#{options.to_s})"
when :delete_message # current_user 发帖了 Delete Message
user_score.collaboration = user_score.collaboration.to_i - 2
user_score.save
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a message. options => (#{options.to_s})"
when :post_issue # current_user 对 target_user 的缺陷留言了 Add Journal
user_score.collaboration = user_score.collaboration.to_i + 1
user_score.save
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a issue. options => (#{options.to_s})"
when :delete_issue # current_user 删除了 对 target_user 的缺陷留言了 Delete Journal
user_score.collaboration = user_score.collaboration.to_i - 1
user_score.save
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue. options => (#{options.to_s})"
when :change_issue_status # current_user 更改了缺陷的状态 Changed Issue
user_score.collaboration = user_score.collaboration.to_i + 1
user_score.save
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} change issue status. options => (#{options.to_s})"
when :reply_message # current_user 对 target_user 留言的回复 Add Journals_for_messages
user_score.collaboration = user_score.collaboration.to_i + 1
user_score.save
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply message. options => (#{options.to_s})"
when :reply_message_delete # current_user 删除了对 target_user 留言的回复 delete Journals_for_messages
user_score.collaboration = user_score.collaboration.to_i - 1
user_score.save
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} delete reply message. options => (#{options.to_s})"
when :reply_posting # current_user 对 target_user 帖子的回复 Add Message
user_score.collaboration = user_score.collaboration.to_i + 1
user_score.save
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})"
else
Rails.logger.error "[UserScore#joint] ===> #{operate} is not define."
return false
end
rescue => e
Rails.logger.error "[UserScore#joint] ===> Exception: #{e}."
end
# 前略·影响力得分
# operate - 更新操作 类型 symbol
# user - 计分用户
#
# Examples
#
# UserScore.influence(:followed_by, user)
# # => true #当前被关注用户记分成功
#
# Returns boolean. 返回积分保存结果
def self.influence(operate, current_user, target_user, options={})
current_user, target_user = get_users(current_user, target_user)
user_score = target_user.user_score_attr
case operate
when :followed_by # current_user 关注了target_user Add watcher
user_score.influence = user_score.influence.to_i + 2
user_score.save
Rails.logger.info "[UserScore#influence] ===> User: #{current_user} be followed. options => (#{options.to_s})"
when :cancel_followed # current_uer 取消了对 target_user的关注 delete watcher
user_score.influence = user_score.influence.to_i - 2
user_score.save
Rails.logger.info "[UserScore#influence] ===> User: #{current_user} canceled followed. options => (#{options.to_s})"
else
Rails.logger.error "[UserScore#influence] ===> #{operate} is not define."
return false
end
rescue => e
Rails.logger.error "[UserScore#influence] ===> Exception: #{e}."
end
# 前略·技术得分
# operate - 更新操作 类型 symbol
# user - 计分用户
#
# Examples
#
# UserScore.skill(:followed_by, current_user, target_user)
# # => true #当前current_user对target_user用户帖子的记分成功
#
# Returns boolean. 返回积分保存结果
def self.skill(operate, current_user, target_user, options={})
current_user, target_user = get_users(current_user, target_user)
current_user_score = current_user.user_score_attr
target_user_score = target_user.user_score_attr
case operate
# when :treading # current_user 踩了 target_user 的帖子
# Rails.logger.info "[UserScore#skill] ===> User: #{current_user} treading #{target_user}'s posting. options => (#{options.to_s})"
when :treaded_by_user # current_user 踩了 target_user 的帖子
current_user_score.skill = current_user_score.skill.to_i - 2 #踩别人的帖子减2分 add praise_tread
current_user_score.save
if current_user.id == target_user.id
target_user.reload
target_user_score = target_user.user_score_attr
end
level = current_user.get_level
if level == 1
target_user_score.skill = target_user_score.skill.to_i - 2 #帖子被一级会员踩-2分 add praise_tread
target_user_score.save
elsif level == 2
target_user_score.skill = target_user_score.skill.to_i - 4 #帖子被二级会员踩-4分 add praise_tread
target_user_score.save
elsif level == 3
target_user_score.skill = target_user_score.skill.to_i - 6 #帖子被三级会员踩-6分 add praise_tread
target_user_score.save
end
Rails.logger.info "[UserScore#skill] ===> User: #{current_user} treaded_by #{target_user}. options => (#{options.to_s})"
when :praised_by_user # current_user 顶了 target_user 的帖子
level = current_user.get_level
if level == 1
target_user_score.skill = target_user_score.skill.to_i + 4 #帖子被一级会员顶+4分 add praise_tread
target_user_score.save
elsif level == 2
target_user_score.skill = target_user_score.skill.to_i + 6 #帖子被二级会员顶+6分 add praise_tread
target_user_score.save
elsif level == 3
target_user_score.skill = target_user_score.skill.to_i + 8 #帖子被三级会员顶+8分 add praise_tread
target_user_score.save
end
Rails.logger.info "[UserScore#skill] ===> User: #{current_user} praised_by #{target_user}. options => (#{options.to_s})"
else
Rails.logger.error "[UserScore#skill] ===> #{operate} is not define."
return false
end
rescue => e
Rails.logger.error "[UserScore#skill] ===> Exception: #{e}."
end
# 前略·项目得分
# operate - 更新操作 类型 symbol
# user - 计分用户
#
# Examples
#
# UserScore.project(:pull_code, current_user)
# # => true #当前current_user对项目贡献积分成功
#
# Returns boolean. 返回积分保存结果
def self.project(operate, current_user, options={})
current_user, target_user = get_users(current_user, nil)
user_score = current_user.try(:user_score_attr)
return false if current_user.nil?
case operate
when :push_code # current_user 提交了代码 changeset
user_score = user_score.active.to_i + 4
user_score.save
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed code one time. options => (#{options.to_s})"
when :push_document # current_user
user_score.active = user_score.active.to_i + 4
user_score.save
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed a document. options => (#{options.to_s})"
when :push_file # current_user
user_score.active = user_score.active.to_i + 4
user_score.save
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed a file. options => (#{options.to_s})"
when :update_issue_ratio # current_user
user_score.active = user_score.active.to_i + 2
user_score.save
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] updated issue ratio. options => (#{options.to_s})"
when :post_issue # current_user
user_score.active = user_score.active.to_i + 4
user_score.save
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] posting issue. options => (#{options.to_s})"
else
Rails.logger.error "[UserScore#project] ===> #{operate} is not define."
return false
end
rescue => e
Rails.logger.error "[UserScore#project] ===> Exception: #{e}."
end
private
def self.get_users(current_user, target_user)
cUser = (current_user.kind_of?User) ? current_user : User.find_by_id(current_user)
tUser = (target_user.kind_of?User) ? target_user : User.find_by_id(target_user)
[cUser, tUser]
end
#修正分数
#分数小于0时修正为0
#分数大于等于0时不修正 -by zjc
def correct_score
if !self.collaboration.nil? && self.collaboration < 0
self.collaboration = 0
end
if !self.influence.nil? && self.influence < 0
self.influence = 0
end
if !self.skill.nil? && self.skill < 0
self.skill = 0
end
if !self.active.nil? && self.active < 0
self.active = 0
end
end
end

View File

@ -22,6 +22,8 @@ class Watcher < ActiveRecord::Base
has_one :project_status
has_one :users_status
#end
before_save :be_user_score
before_destroy :down_user_score
validates_presence_of :user
validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
@ -70,4 +72,22 @@ class Watcher < ActiveRecord::Base
end
pruned
end
# 更新用户分数 -by zjc
def be_user_score
#添加了关注
if self.new_record? && self.watchable_type == 'Principal'
#影响力得分
UserScore.influence(:followed_by, self.user,self.watchable, { watcher_id: self.id })
end
end
#减分操作 -by zjc
def down_user_score
#取消关注
if self.watchable_type == 'Principal'
UserScore.influence(:cancel_followed, self.user,self.watchable, { watcher_id: self.id })
end
end
end

View File

@ -1,409 +1,447 @@
<!-- added by bai 增加地区-->
<script type="text/javascript" language="javascript">
function showcity(province, cityField) {
switch (province) {
case "北京" :
var cityOptions = new Array(
"东城","西城","朝阳","丰台","石景山","海淀","门头沟",
"房山","通州","顺义","昌平","大兴","平谷","怀柔","密云","延庆");
break;
case "上海" :
var cityOptions = new Array(
"崇明","黄浦","卢湾","徐汇","长宁","静安","普陀","闸北","虹口","杨浦","闵行",
"宝山","嘉定","浦东","金山","松江","青浦","南汇","奉贤");
break;
case "广东" :
var cityOptions = new Array(
"广州","深圳","珠海","东莞","中山","佛山","惠州","河源","潮州","江门","揭阳","茂名",
"梅州","清远","汕头","汕尾","韶关","顺德","阳江","云浮","湛江","肇庆");
break;
case "江苏" :
var cityOptions = new Array(
"南京","常熟","常州","海门","淮安","江都","江阴","昆山","连云港","南通",
"启东","沭阳","宿迁","苏州","太仓","泰州","同里","无锡","徐州","盐城",
"扬州","宜兴","仪征","张家港","镇江","周庄");
break;
case "重庆" :
var cityOptions = new Array(
"万州","涪陵","渝中","大渡口","江北","沙坪坝","九龙坡","南岸","北碚","万盛",
"双挢","渝北","巴南","黔江","长寿","綦江","潼南","铜梁","大足","荣昌","壁山",
"梁平","城口","丰都","垫江","武隆","忠县","开县","云阳","奉节","巫山","巫溪",
"石柱","秀山","酉阳","彭水","江津","合川","永川","南川");
break;
case "安徽" :
var cityOptions = new Array(
"合肥","安庆","蚌埠","亳州","巢湖","滁州","阜阳","贵池","淮北","淮化","淮南",
"黄山","九华山","六安","马鞍山","宿州","铜陵","屯溪","芜湖","宣城");
break;
case "福建" :
var cityOptions = new Array(
"福州","厦门","泉州","漳州","龙岩","南平","宁德","莆田","三明");
break;
case "甘肃" :
var cityOptions = new Array(
"兰州","白银","定西","敦煌","甘南","金昌","酒泉","临夏","平凉","天水",
"武都","武威","西峰","张掖");
break;
case "广西" :
var cityOptions = new Array(
"南宁","百色","北海","桂林","防城港","贵港","河池","贺州","柳州","钦州","梧州","玉林");
break;
case "贵州" :
var cityOptions = new Array(
"贵阳","安顺","毕节","都匀","凯里","六盘水","铜仁","兴义","玉屏","遵义");
break;
case "海南" :
var cityOptions = new Array(
"海口","儋县","陵水","琼海","三亚","通什","万宁");
break;
case "河北" :
var cityOptions = new Array(
"石家庄","保定","北戴河","沧州","承德","丰润","邯郸","衡水","廊坊","南戴河","秦皇岛",
"唐山","新城","邢台","张家口");
break;
case "黑龙江" :
var cityOptions = new Array(
"哈尔滨","北安","大庆","大兴安岭","鹤岗","黑河","佳木斯","鸡西","牡丹江","齐齐哈尔",
"七台河","双鸭山","绥化","伊春");
break;
case "河南" :
var cityOptions = new Array(
"郑州","安阳","鹤壁","潢川","焦作","济源","开封","漯河","洛阳","南阳","平顶山",
"濮阳","三门峡","商丘","新乡","信阳","许昌","周口","驻马店");
break;
case "香港" :
var cityOptions = new Array(
"香港","九龙","新界");
break;
case "湖北" :
var cityOptions = new Array(
"武汉","恩施","鄂州","黄冈","黄石","荆门","荆州","潜江","十堰","随州","武穴",
"仙桃","咸宁","襄阳","襄樊","孝感","宜昌");
break;
case "湖南" :
var cityOptions = new Array(
"长沙","常德","郴州","衡阳","怀化","吉首","娄底","邵阳","湘潭","益阳","岳阳",
"永州","张家界","株洲");
break;
case "江西" :
var cityOptions = new Array(
"南昌","抚州","赣州","吉安","景德镇","井冈山","九江","庐山","萍乡",
"上饶","新余","宜春","鹰潭");
break;
case "吉林" :
var cityOptions = new Array(
"长春","吉林","白城","白山","珲春","辽源","梅河","四平","松原","通化","延吉");
break;
case "辽宁" :
var cityOptions = new Array(
"沈阳","鞍山","本溪","朝阳","大连","丹东","抚顺","阜新","葫芦岛","锦州",
"辽阳","盘锦","铁岭","营口");
break;
case "澳门" :
var cityOptions = new Array("澳门");
break;
case "内蒙古" :
var cityOptions = new Array(
"呼和浩特","阿拉善盟","包头","赤峰","东胜","海拉尔","集宁","临河","通辽","乌海",
"乌兰浩特","锡林浩特");
break;
case "宁夏" :
var cityOptions = new Array(
"银川","固源","石嘴山","吴忠");
break;
case "青海" :
var cityOptions = new Array(
"西宁","德令哈","格尔木","共和","海东","海晏","玛沁","同仁","玉树");
break;
case "山东" :
var cityOptions = new Array(
"济南","滨州","兖州","德州","东营","菏泽","济宁","莱芜","聊城","临沂",
"蓬莱","青岛","曲阜","日照","泰安","潍坊","威海","烟台","枣庄","淄博");
break;
case "山西" :
var cityOptions = new Array(
"太原","长治","大同","候马","晋城","离石","临汾","宁武","朔州","忻州",
"阳泉","榆次","运城");
break;
case "陕西" :
var cityOptions = new Array(
"西安","安康","宝鸡","汉中","渭南","商州","绥德","铜川","咸阳","延安","榆林");
break;
case "四川" :
var cityOptions = new Array(
"成都","巴中","达川","德阳","都江堰","峨眉山","涪陵","广安","广元","九寨沟",
"康定","乐山","泸州","马尔康","绵阳","眉山","南充","内江","攀枝花","遂宁",
"汶川","西昌","雅安","宜宾","自贡","资阳");
break;
case "台湾" :
var cityOptions = new Array(
"台北","基隆","台南","台中","高雄","屏东","南投","云林","新竹","彰化","苗栗",
"嘉义","花莲","桃园","宜兰","台东","金门","马祖","澎湖");
break;
case "天津" :
var cityOptions = new Array(
"天津","和平","东丽","河东","西青","河西","津南","南开","北辰","河北","武清","红挢",
"塘沽","汉沽","大港","宁河","静海","宝坻","蓟县");
break;
case "新疆" :
var cityOptions = new Array(
"乌鲁木齐","阿克苏","阿勒泰","阿图什","博乐","昌吉","东山","哈密","和田","喀什",
"克拉玛依","库车","库尔勒","奎屯","石河子","塔城","吐鲁番","伊宁");
break;
case "西藏" :
var cityOptions = new Array(
"拉萨","阿里","昌都","林芝","那曲","日喀则","山南");
break;
case "云南" :
var cityOptions = new Array(
"昆明","大理","保山","楚雄","大理","东川","个旧","景洪","开远","临沧","丽江",
"六库","潞西","曲靖","思茅","文山","西双版纳","玉溪","中甸","昭通");
break;
case "浙江" :
var cityOptions = new Array(
"杭州","安吉","慈溪","定海","奉化","海盐","黄岩","湖州","嘉兴","金华","临安",
"临海","丽水","宁波","瓯海","平湖","千岛湖","衢州","江山","瑞安","绍兴","嵊州",
"台州","温岭","温州","余姚","舟山");
break;
case "海外" :
var cityOptions = new Array(
"美国","日本","英国","法国","德国","其他");
break;
default:
var cityOptions = new Array("");
break;
}
function showcity(province, cityField) {
switch (province) {
case "北京" :
var cityOptions = new Array(
"东城", "西城", "朝阳", "丰台", "石景山", "海淀", "门头沟",
"房山", "通州", "顺义", "昌平", "大兴", "平谷", "怀柔", "密云", "延庆");
break;
case "上海" :
var cityOptions = new Array(
"崇明", "黄浦", "卢湾", "徐汇", "长宁", "静安", "普陀", "闸北", "虹口", "杨浦", "闵行",
"宝山", "嘉定", "浦东", "金山", "松江", "青浦", "南汇", "奉贤");
break;
case "广东" :
var cityOptions = new Array(
"广州", "深圳", "珠海", "东莞", "中山", "佛山", "惠州", "河源", "潮州", "江门", "揭阳", "茂名",
"梅州", "清远", "汕头", "汕尾", "韶关", "顺德", "阳江", "云浮", "湛江", "肇庆");
break;
case "江苏" :
var cityOptions = new Array(
"南京", "常熟", "常州", "海门", "淮安", "江都", "江阴", "昆山", "连云港", "南通",
"启东", "沭阳", "宿迁", "苏州", "太仓", "泰州", "同里", "无锡", "徐州", "盐城",
"扬州", "宜兴", "仪征", "张家港", "镇江", "周庄");
break;
case "重庆" :
var cityOptions = new Array(
"万州", "涪陵", "渝中", "大渡口", "江北", "沙坪坝", "九龙坡", "南岸", "北碚", "万盛",
"双挢", "渝北", "巴南", "黔江", "长寿", "綦江", "潼南", "铜梁", "大足", "荣昌", "壁山",
"梁平", "城口", "丰都", "垫江", "武隆", "忠县", "开县", "云阳", "奉节", "巫山", "巫溪",
"石柱", "秀山", "酉阳", "彭水", "江津", "合川", "永川", "南川");
break;
case "安徽" :
var cityOptions = new Array(
"合肥", "安庆", "蚌埠", "亳州", "巢湖", "滁州", "阜阳", "贵池", "淮北", "淮化", "淮南",
"黄山", "九华山", "六安", "马鞍山", "宿州", "铜陵", "屯溪", "芜湖", "宣城");
break;
case "福建" :
var cityOptions = new Array(
"福州", "厦门", "泉州", "漳州", "龙岩", "南平", "宁德", "莆田", "三明");
break;
case "甘肃" :
var cityOptions = new Array(
"兰州", "白银", "定西", "敦煌", "甘南", "金昌", "酒泉", "临夏", "平凉", "天水",
"武都", "武威", "西峰", "张掖");
break;
case "广西" :
var cityOptions = new Array(
"南宁", "百色", "北海", "桂林", "防城港", "贵港", "河池", "贺州", "柳州", "钦州", "梧州", "玉林");
break;
case "贵州" :
var cityOptions = new Array(
"贵阳", "安顺", "毕节", "都匀", "凯里", "六盘水", "铜仁", "兴义", "玉屏", "遵义");
break;
case "海南" :
var cityOptions = new Array(
"海口", "儋县", "陵水", "琼海", "三亚", "通什", "万宁");
break;
case "河北" :
var cityOptions = new Array(
"石家庄", "保定", "北戴河", "沧州", "承德", "丰润", "邯郸", "衡水", "廊坊", "南戴河", "秦皇岛",
"唐山", "新城", "邢台", "张家口");
break;
case "黑龙江" :
var cityOptions = new Array(
"哈尔滨", "北安", "大庆", "大兴安岭", "鹤岗", "黑河", "佳木斯", "鸡西", "牡丹江", "齐齐哈尔",
"七台河", "双鸭山", "绥化", "伊春");
break;
case "河南" :
var cityOptions = new Array(
"郑州", "安阳", "鹤壁", "潢川", "焦作", "济源", "开封", "漯河", "洛阳", "南阳", "平顶山",
"濮阳", "三门峡", "商丘", "新乡", "信阳", "许昌", "周口", "驻马店");
break;
case "香港" :
var cityOptions = new Array(
"香港", "九龙", "新界");
break;
case "湖北" :
var cityOptions = new Array(
"武汉", "恩施", "鄂州", "黄冈", "黄石", "荆门", "荆州", "潜江", "十堰", "随州", "武穴",
"仙桃", "咸宁", "襄阳", "襄樊", "孝感", "宜昌");
break;
case "湖南" :
var cityOptions = new Array(
"长沙", "常德", "郴州", "衡阳", "怀化", "吉首", "娄底", "邵阳", "湘潭", "益阳", "岳阳",
"永州", "张家界", "株洲");
break;
case "江西" :
var cityOptions = new Array(
"南昌", "抚州", "赣州", "吉安", "景德镇", "井冈山", "九江", "庐山", "萍乡",
"上饶", "新余", "宜春", "鹰潭");
break;
case "吉林" :
var cityOptions = new Array(
"长春", "吉林", "白城", "白山", "珲春", "辽源", "梅河", "四平", "松原", "通化", "延吉");
break;
case "辽宁" :
var cityOptions = new Array(
"沈阳", "鞍山", "本溪", "朝阳", "大连", "丹东", "抚顺", "阜新", "葫芦岛", "锦州",
"辽阳", "盘锦", "铁岭", "营口");
break;
case "澳门" :
var cityOptions = new Array("澳门");
break;
case "内蒙古" :
var cityOptions = new Array(
"呼和浩特", "阿拉善盟", "包头", "赤峰", "东胜", "海拉尔", "集宁", "临河", "通辽", "乌海",
"乌兰浩特", "锡林浩特");
break;
case "宁夏" :
var cityOptions = new Array(
"银川", "固源", "石嘴山", "吴忠");
break;
case "青海" :
var cityOptions = new Array(
"西宁", "德令哈", "格尔木", "共和", "海东", "海晏", "玛沁", "同仁", "玉树");
break;
case "山东" :
var cityOptions = new Array(
"济南", "滨州", "兖州", "德州", "东营", "菏泽", "济宁", "莱芜", "聊城", "临沂",
"蓬莱", "青岛", "曲阜", "日照", "泰安", "潍坊", "威海", "烟台", "枣庄", "淄博");
break;
case "山西" :
var cityOptions = new Array(
"太原", "长治", "大同", "候马", "晋城", "离石", "临汾", "宁武", "朔州", "忻州",
"阳泉", "榆次", "运城");
break;
case "陕西" :
var cityOptions = new Array(
"西安", "安康", "宝鸡", "汉中", "渭南", "商州", "绥德", "铜川", "咸阳", "延安", "榆林");
break;
case "四川" :
var cityOptions = new Array(
"成都", "巴中", "达川", "德阳", "都江堰", "峨眉山", "涪陵", "广安", "广元", "九寨沟",
"康定", "乐山", "泸州", "马尔康", "绵阳", "眉山", "南充", "内江", "攀枝花", "遂宁",
"汶川", "西昌", "雅安", "宜宾", "自贡", "资阳");
break;
case "台湾" :
var cityOptions = new Array(
"台北", "基隆", "台南", "台中", "高雄", "屏东", "南投", "云林", "新竹", "彰化", "苗栗",
"嘉义", "花莲", "桃园", "宜兰", "台东", "金门", "马祖", "澎湖");
break;
case "天津" :
var cityOptions = new Array(
"天津", "和平", "东丽", "河东", "西青", "河西", "津南", "南开", "北辰", "河北", "武清", "红挢",
"塘沽", "汉沽", "大港", "宁河", "静海", "宝坻", "蓟县");
break;
case "新疆" :
var cityOptions = new Array(
"乌鲁木齐", "阿克苏", "阿勒泰", "阿图什", "博乐", "昌吉", "东山", "哈密", "和田", "喀什",
"克拉玛依", "库车", "库尔勒", "奎屯", "石河子", "塔城", "吐鲁番", "伊宁");
break;
case "西藏" :
var cityOptions = new Array(
"拉萨", "阿里", "昌都", "林芝", "那曲", "日喀则", "山南");
break;
case "云南" :
var cityOptions = new Array(
"昆明", "大理", "保山", "楚雄", "大理", "东川", "个旧", "景洪", "开远", "临沧", "丽江",
"六库", "潞西", "曲靖", "思茅", "文山", "西双版纳", "玉溪", "中甸", "昭通");
break;
case "浙江" :
var cityOptions = new Array(
"杭州", "安吉", "慈溪", "定海", "奉化", "海盐", "黄岩", "湖州", "嘉兴", "金华", "临安",
"临海", "丽水", "宁波", "瓯海", "平湖", "千岛湖", "衢州", "江山", "瑞安", "绍兴", "嵊州",
"台州", "温岭", "温州", "余姚", "舟山");
break;
case "海外" :
var cityOptions = new Array(
"美国", "日本", "英国", "法国", "德国", "其他");
break;
default:
var cityOptions = new Array("");
break;
}
cityField.options.length = 0;
for(var i = 0; i < cityOptions.length; i++) {
cityField.options[i]=new Option(cityOptions[i],cityOptions[i]);
/*
if (cityField.options[i].value==city)
{
//alert("here put City ok!");
document.oblogform["city"].selectedIndex = i;
}*/
}
}
cityField.options.length = 0;
for (var i = 0; i < cityOptions.length; i++) {
cityField.options[i] = new Option(cityOptions[i], cityOptions[i]);
/*
if (cityField.options[i].value==city)
{
//alert("here put City ok!");
document.oblogform["city"].selectedIndex = i;
}*/
}
}
</script>
<script type="text/javascript" language="javascript">
function showtechnical_title(identity, technical_titleField) {
switch (identity) {
function showtechnical_title(identity, technical_titleField) {
switch (identity) {
case '0' :
$('#technical_title').show()
$('#no').hide()
$('#name').show()
$('#enterprise').hide()
$('#gender').show()
var technical_titleOptions = new Array(
"<%= l(:label_technicl_title_professor) %>","<%= l(:label_technicl_title_associate_professor) %>","<%= l(:label_technicl_title_lecturer) %>","<%= l(:label_technicl_title_teaching_assistant) %>");
break;
case '0' :
$('#technical_title').show()
$('#no').hide()
$('#name').show()
$('#enterprise').hide()
$('#gender').show()
var technical_titleOptions = new Array(
"<%= l(:label_technicl_title_professor) %>", "<%= l(:label_technicl_title_associate_professor) %>", "<%= l(:label_technicl_title_lecturer) %>", "<%= l(:label_technicl_title_teaching_assistant) %>");
break;
case '1' :
$('#technical_title').hide()
$('#no').show()
$('#name').show()
$('#enterprise').hide()
$('#gender').show()
var titleOptions = new Array("");
break;
case '1' :
$('#technical_title').hide()
$('#no').show()
$('#name').show()
$('#enterprise').hide()
$('#gender').show()
var titleOptions = new Array("");
break;
case '2' :
$('#technical_title').hide()
$('#no').hide()
$('#name').hide()
$('#enterprise').show()
$('#gender').hide()
var titleOptions = new Array("");
break;
default:
$('#technical_title').hide()
$('#no').hide()
$('#name').show()
$('#enterprise').hide()
$('#gender').show()
var titleOptions = new Array("");
case '2' :
$('#technical_title').hide()
$('#no').hide()
$('#name').hide()
$('#enterprise').show()
$('#gender').hide()
var titleOptions = new Array("");
break;
default:
$('#technical_title').hide()
$('#no').hide()
$('#name').show()
$('#enterprise').hide()
$('#gender').show()
var titleOptions = new Array("");
break;
break;
}
technical_titleField.options.length = 0;
for(var i = 0; i < technical_titleOptions.length; i++) {
technical_titleField.options[i]=new Option(technical_titleOptions[i],technical_titleOptions[i]);
/*
if (cityField.options[i].value==city)
{
//alert("here put City ok!");
document.oblogform["city"].selectedIndex = i;
}*/
}
}
}
technical_titleField.options.length = 0;
for (var i = 0; i < technical_titleOptions.length; i++) {
technical_titleField.options[i] = new Option(technical_titleOptions[i], technical_titleOptions[i]);
/*
if (cityField.options[i].value==city)
{
//alert("here put City ok!");
document.oblogform["city"].selectedIndex = i;
}*/
}
}
</script>
<!-- end -->
<h3><%=l(:label_register)%> <%=link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></h3>
<h3><%= l(:label_register) %> <%= link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></h3>
<%= labelled_form_for @user, :url => register_path do |f| %>
<%= error_messages_for 'user' %>
<%= error_messages_for 'user' %>
<div class="box tabular">
<p><table><tr><td class="info" align="right" style="width: 90px"><strong><%= l(:label_identity) %><span class="required"> *</span></strong></td>
<td class="info" style="width: 10px">
<select onchange="showtechnical_title(this.value, document.getElementById(&#39;userTechnical_title&#39;));" name="identity" id="userIdentity" class="location">
<option value="">--请选择身份--</option>
<option value="0"><%= l(:label_teacher) %></option>
<option value="1"><%= l(:label_student) %></option>
<option value="2"><%= l(:label_enterprise) %></option>
<option value="3"><%= l(:label_account_developer) %></option>
<div class="box tabular">
<p>
<table>
<tr>
<td class="info" align="right" style="width: 90px">
<strong><%= l(:label_identity) %><span class="required"> *</span></strong></td>
<td class="info" style="width: 10px">
<select onchange="showtechnical_title(this.value, document.getElementById('userTechnical_title'));" name="identity" id="userIdentity" class="location">
<option value="">--请选择身份--</option>
<option value="0"><%= l(:label_teacher) %></option>
<option value="1"><%= l(:label_student) %></option>
<option value="2"><%= l(:label_enterprise) %></option>
<option value="3"><%= l(:label_account_developer) %></option>
</select></td>
<td>
<span id = 'technical_title' style = 'display:none'>
</select>
</td>
<td>
<span id='technical_title' style='display:none'>
<select name="technical_title" id="userTechnical_title"></select></span>
<span id = 'no' style = 'display:none'>
<span id='no' style='display:none'>
<!-- modified by fq -->
<% unless User.current.user_extensions.nil? %>
<% unless User.current.user_extensions.nil? %>
<%= text_field_tag :no, User.current.user_extensions.student_id, :placeholder => "请输入学号" %></span>
<!-- <input name="no" id="no" value=<%= "#{User.current.user_extensions.student_id}" %> placeholder="请输入学号"></span> -->
<% else %>
<%= text_field_tag :no, nil, :placeholder => "请输入学号" %></span>
<!-- <input name="no" id="no" placeholder="请输入学号"></span> -->
<% end %>
<!-- end -->
</td></tr></table></p>
</td>
</tr>
</table>
</p>
<% if @user.auth_source_id.nil? %>
<p><%= f.text_field :login, :size => 25, :required => true %><span id="valid_user_login"></span>
<em class="info"><%= l(:label_max_number) %></em></p>
<% if @user.auth_source_id.nil? %>
<p><%= f.text_field :login, :size => 25, :required => true %><span id="valid_user_login"></span>
<em class="info"><%= l(:label_max_number) %></em></p>
<p><%= f.password_field :password, :size => 25, :required => true %>
<em class="info"><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
<p><%= f.password_field :password, :size => 25, :required => true %>
<em class="info"><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
<p><%= f.password_field :password_confirmation, :size => 25, :required => true %></p>
<% end %>
<span id = 'name' style = 'display:none'>
<p><%= f.password_field :password_confirmation, :size => 25, :required => true %></p>
<% end %>
<span id='name' style='display:none'>
<p><%= f.text_field :firstname, :required => true %></p>
<p><%= f.text_field :lastname, :required => true %></p>
</span>
<span id = 'enterprise' style = 'display:none'>
<p><table><tr><td class="info" align="right" style="width: 90px"><strong>企业名<span class="required"> *</span></strong></td>
<td class="info" style="width: 10px">
<%= text_field_tag :enterprise_name %></td></tr></table></p>
<span id='enterprise' style='display:none'>
<p><table>
<tr>
<td class="info" align="right" style="width: 90px"><strong>企业名<span class="required"> *</span></strong></td>
<td class="info" style="width: 10px">
<%= text_field_tag :enterprise_name %></td>
</tr>
</table>
</p>
</span>
<p><%= f.text_field :mail, :required => true %><span id="valid_user_mail"></span></p>
<p>
<em class="info"><%="#{l(:label_mail_attention)} "%></em></p>
<p><%= f.select :language, lang_options_for_select , :required => true %></p>
<!-- added by bai 增加了身份、性别和地区-->
<p><%= f.text_field :mail, :required => true %><span id="valid_user_mail"></span></p>
<span id = 'gender' style = 'display:none'>
<p>
<em class="info"><%= "#{l(:label_mail_attention)} " %></em></p>
<p><%= f.select :language, lang_options_for_select, :required => true %></p>
<!-- added by bai 增加了身份、性别和地区-->
<span id='gender' style='display:none'>
<p>
<table><tr>
<td class="info" align="right" style="width: 90px"><strong><%= l(:label_gender) %><span class="required"> &nbsp;</span></strong></td>
<td class="info" style="width: 10px">
<%= select_tag 'gender', "<option value = '0'>#{l(:label_gender_male)}</option>
<table>
<tr>
<td class="info" align="right" style="width: 90px">
<strong><%= l(:label_gender) %><span class="required"> &nbsp;</span></strong></td>
<td class="info" style="width: 10px">
<%= select_tag 'gender', "<option value = '0'>#{l(:label_gender_male)}</option>
<option value = '1'>#{l(:label_gender_female)}</option>".html_safe %>
</td>
</tr></table>
</p>
</td>
</tr>
</table>
</p>
</span>
<p><table><tr><td class="info" align="right" style="width: 90px"><strong><%= l(:label_location) %><span class="required"> *</span></strong></td>
<td class="info" style="width: 80px">
<select onchange="showcity(this.value, document.getElementById(&#39;userCity&#39;));" name="province" id="userProvince">
<option value="">--请选择省份--</option>
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="广东">广东</option>
<option value="江苏">江苏</option>
<option value="浙江">浙江</option>
<option value="重庆">重庆</option>
<option value="安徽">安徽</option>
<option value="福建">福建</option>
<option value="甘肃">甘肃</option>
<option value="广西">广西</option>
<option value="贵州">贵州</option>
<option value="海南">海南</option>
<option value="河北">河北</option>
<option value="黑龙江">黑龙江</option>
<option value="河南">河南</option>
<option value="湖北">湖北</option>
<option value="湖南">湖南</option>
<option value="江西">江西</option>
<option value="吉林">吉林</option>
<option value="辽宁">辽宁</option>
<option value="内蒙古">内蒙古</option>
<option value="宁夏">宁夏</option>
<option value="青海">青海</option>
<option value="山东">山东</option>
<option value="山西">山西</option>
<option value="陕西">陕西</option>
<option value="四川">四川</option>
<option value="天津">天津</option>
<option value="新疆">新疆</option>
<option value="西藏">西藏</option>
<option value="云南">云南</option>
<option value="香港">香港特别行政区</option>
<option value="澳门">澳门特别行政区</option>
<option value="台湾">台湾</option>
<option value="海外">海外</option>
</select></td>
<td class="info" style="width: 100px">
<select name="city" id="userCity"></select></td></tr></table></p>
<!-- end -->
</div>
<p>
<table>
<tr>
<td class="info" align="right" style="width: 90px">
<strong><%= l(:label_location) %><span class="required"> *</span></strong>
</td>
<td class="info" style="width: 80px">
<select onchange="showcity(this.value, document.getElementById('userCity'));" name="province" id="userProvince">
<option value="">--请选择省份--</option>
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="广东">广东</option>
<option value="江苏">江苏</option>
<option value="浙江">浙江</option>
<option value="重庆">重庆</option>
<option value="安徽">安徽</option>
<option value="福建">福建</option>
<option value="甘肃">甘肃</option>
<option value="广西">广西</option>
<option value="贵州">贵州</option>
<option value="海南">海南</option>
<option value="河北">河北</option>
<option value="黑龙江">黑龙江</option>
<option value="河南">河南</option>
<option value="湖北">湖北</option>
<option value="湖南">湖南</option>
<option value="江西">江西</option>
<option value="吉林">吉林</option>
<option value="辽宁">辽宁</option>
<option value="内蒙古">内蒙古</option>
<option value="宁夏">宁夏</option>
<option value="青海">青海</option>
<option value="山东">山东</option>
<option value="山西">山西</option>
<option value="陕西">陕西</option>
<option value="四川">四川</option>
<option value="天津">天津</option>
<option value="新疆">新疆</option>
<option value="西藏">西藏</option>
<option value="云南">云南</option>
<option value="香港">香港特别行政区</option>
<option value="澳门">澳门特别行政区</option>
<option value="台湾">台湾</option>
<option value="海外">海外</option>
</select>
</td>
<td class="info" style="width: 100px">
<select name="city" id="userCity"></select>
</td>
</tr>
</table>
</p>
<!-- end -->
</div>
<p><table><tr><td><%= submit_tag l(:button_submit) %></td></tr></table></p>
<p>
<table>
<tr>
<td><%= submit_tag l(:button_submit) %></td>
</tr>
</table>
</p>
<% end %>
<% if Setting.openid? %>
<p><%= f.text_field :identity_url %></p>
<p><%= f.text_field :identity_url %></p>
<% end %>
<% @user.custom_field_values.select {|v| v.editable? || v.required?}.each do |value| %>
<p><%= custom_field_tag_with_label :user, value %></p>
<% @user.custom_field_values.select { |v| v.editable? || v.required? }.each do |value| %>
<p><%= custom_field_tag_with_label :user, value %></p>
<% end %>
</div>
<script type="text/javascript">
var $login = $('#user_login')
var $mail = $('#user_mail')
jQuery(document).ready(function () {
var $login = $('#user_login')
var $mail = $('#user_mail')
jQuery(document).ready(function() {
$login.blur(function(event) {
var $parent = $(this).parent();
if ( $(this).is('#user_login')) {
$.get('<%=account_valid_ajax_path%>?valid=login&value='+this.value, function(data) {
if (data.valid) {
$('#valid_user_login').html('<span class="green">'+data.message+"</span>");
}else{
$('#valid_user_login').html('<span class="red">'+data.message+"</span>");
}
});
};
});
$login.blur(function (event) {
if ($(this).is('#user_login')) {
$.get(
'<%=account_valid_ajax_path%>',
{ valid: "login",
value: this.value },
function (data) {
if (data.valid) {
$('#valid_user_login').html('<span class="green">' + data.message + "</span>");
} else {
$('#valid_user_login').html('<span class="red">' + data.message + "</span>");
}
});
}
;
});
$mail.blur(function(event) {
var $parent = $(this).parent();
if ( $(this).is('#user_mail')) {
$.get('<%=account_valid_ajax_path%>?valid=mail&value='+this.value, function(data) {
if (data.valid) {
$('#valid_user_mail').html('<span class="green">'+data.message+"</span>");
}else{
$('#valid_user_mail').html('<span class="red">'+data.message+"</span>");
}
});
};
$mail.blur(function (event) {
if ($(this).is('#user_mail')) {
$.get('<%=account_valid_ajax_path%>',
{ valid: "mail",
value: this.value },
function (data) {
if (data.valid) {
$('#valid_user_mail').html('<span class="green">' + data.message + "</span>");
} else {
$('#valid_user_mail').html('<span class="red">' + data.message + "</span>");
}
});
}
;
});
});
});
</script>

View File

@ -33,7 +33,7 @@
<% if images.any? %>
<div class="thumbnails">
<% images.each do |attachment| %>
<div><%= thumbnail_small_tag(attachment) %></div>
<div><%= thumbnail_tag(attachment) %></div>
<% end %>
</div>
<% end %>

View File

@ -15,7 +15,13 @@
<span style="float: right">
<% if(User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)) %>
<%# 提交作业按钮 %>
<%= link_to l(:label_commit_homework), '#OpenWindow', rel: 'leanModal', onclick: "showSubH(#{bid.id}, '#{bid.name}');" if User.current.member_of?(@project) %>
<!--<%= link_to l(:label_commit_homework), '#OpenWindow', rel: 'leanModal', onclick: "showSubH(#{bid.id}, '#{bid.name}');" if User.current.member_of?(@project) %>-->
<% cur_user_homework = cur_user_homework_for_bid(bid) %>
<% if cur_user_homework!= nil && cur_user_homework.count == 0 %>
<%= link_to l(:label_commit_homework),new_homework_attach_path(bid) %>
<% else %>
<span style="color: green; float: right"><%= l(:lable_has_commit_homework)%></span>
<% end %>
<% end %>
<% if (User.current.admin?||User.current.id==bid.author_id) %>
<%= link_to(

View File

@ -19,6 +19,7 @@
<p><%= f.select :homework_type, homework_type_option %>
</p>
-->
<p><%= f.select :is_evaluation, is_evaluation_option %>
<fieldset><legend><%= l(:label_attachment_plural) %></legend>
<p><%= render :partial => 'attachments/form', :locals => {:container => @homework} %></p>
</fieldset>

View File

@ -36,6 +36,7 @@
<p><%= f.select :homework_type, homework_type_option %>
</p>
-->
<p><%= f.select :is_evaluation, is_evaluation_option %>
<p><%= hidden_field_tag 'course_id', @project_id %>
</p>
<fieldset><legend><%= l(:label_attachment_plural) %></legend>

View File

@ -1,7 +1,8 @@
<!-- fq -->
<% is_student = is_cur_course_student? @bid.courses.first %>
<% is_student = is_cur_course_student(@bid.courses.first) %>
<% is_teacher = is_course_teacher User.current,@bid.courses.first %>
<!-- 当is_evaluation为1或者null(null主要是为了兼容前面数据)时代表启用互评功能2表示未启用 -->
<% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %>
<%= form_tag(:controller => 'bids', :action => "show_project", :method => :get) do %>
<div class="project-search-block">
<table width="100%" valign="center">
@ -41,23 +42,25 @@
<% else %>
<% homework_filename = attachment.filename %>
<% end %>
<!--
<% if attachments.count > 1 && attachment != attachments.first %>
<br/>
<% for item in 1..7 %>
&nbsp;
<% end %>
<% end %>
-->
<% end %>
<% else %>
<% homework_filename = homework.name %>
<% end %>
<strong><%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:obj_class => @bid.class,:obj_id => @bid, :user_id =>homework.user%></strong>
<strong>
<% if is_evaluation || is_teacher%>
<%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:homework => homework%>
<% else %>
<%= homework_filename %>
<% end %>
</strong>
</td>
<td style="vertical-align: top">
<% if is_student %>
<%= link_to "互评>>" , homework_attach_path(homework)%>
<% if is_evaluation %>
<%= link_to "互评>>" , homework_attach_path(homework)%>
<% else %>
<%= link_to "查看详细" , homework_attach_path(homework)%>
<% end %>
<% else %>
<% if is_teacher %>
<%= link_to "综评>>" , homework_attach_path(homework)%>
@ -71,13 +74,8 @@
</td>
<td>
<strong>作业评分:</strong>
<% stars_reates = homework.rates(:quality) %>
<% sum = 0 %>
<% stars_reates.each do |star_reates| %>
<% sum = sum + star_reates.stars %>
<% end %>
<% stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count %>
<%= format("%.2f", sum * 1.0 / stars_reates_count) %>
<%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>
</td>
<td valign="top" align="right">
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
@ -87,33 +85,20 @@
</tr>
<tr>
<td valign="top">&nbsp;
<% if is_cur_course_user? @bid %>
<strong><%= l(:label_bidding_user_studentcode) %>&nbsp; &nbsp;<%= homework.user.user_extensions.student_id%></strong>
<% if User.current.member_of?(@bid.courses.first) %>
<strong><%= l(:label_bidding_user_studentcode) %>&nbsp; &nbsp;<%= homework.user.student_id%></strong>
<% end %>
</td>
<td>
<% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? &&
(Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %>
<% if (users_for_homework(homework).include?(User.current) || is_teacher) %>
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
<%= link_to(l(:label_bid_respond_delete), homework,
method: :delete, :confirm => l(:text_are_you_sure)) %>
<% if homework.user == User.current || is_teacher %>
<%= link_to(l(:label_bid_respond_delete), homework,
method: :delete, :confirm => l(:text_are_you_sure)) %>
<% end %>
<% end %>
</td>
</tr>
<!--
<tr>
<td colspan="2" width="580px" >
<% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %>
<p class="font_description">
<% options = {:author => true, :deletable => attach_delete(homework)} %>
<%= render :partial => 'attachments/links',
:locals => {:attachments => homework.attachments, :options => options} %>
</p>
<% end %>
</td>
</tr>
-->
</table>
</td>
</tr>

View File

@ -1,8 +1,9 @@
<% if @bid.homework_type == Bid::HomeworkFile %>
<!-- 提交文件类型 -->
<%= render :partial => 'homework' %>
<% else %>
<!-- 提交引用项目 -->
<script type="text/javascript" language="javascript">
function clearInfo(id, content) {
var text = $('#' + id);

View File

@ -0,0 +1,11 @@
<%= error_messages_for @contestnotifications %>
<div class="add_frame_header" >
<%= l(:bale_news_notice) %>
</div>
<div class="box tabular">
<p><%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %></p>
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %></p>
</div>
<%= wikitoolbar_for 'news_description' %>

View File

@ -0,0 +1,28 @@
<!--<p><%= link_to_project(news.project) + ': ' unless @project %>
<table><tr><td><img src="/images/new/news.png" width="40" height="40"/></td><td><%= link_to h(news.title), news_path(news) %>
<%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
<% unless news.summary.blank? %></td><td><span class="fontligher"><%=h news.summary %></span><% end %></td>
<td><span class="author"><%= authoring news.created_on, news.author %></span></td></tr></table></p>-->
<table width="660px" border="0" align="center">
<tr>
<td colspan="2" valign="top" width="50" ><img src="/images/new/news.png" width="40" height="40"/></td>
<td><table width="580px" border="0">
<tr>
<td colspan="2" valign="top"><strong> <%=link_to contestnotifications.author,contest_contestnotification_path(contestnotifications)%></strong>
<a class="font_lighter"><%= l(:label_project_newshare) %></a> <%= link_to h(contestnotifications.title), contest_contestnotification_path(contestnotifications) %>
</td>
</tr>
<tr>
<td colspan="2" width="580px" ><p class="font_description"><%=h contestnotifications.description%></p></td>
</tr>
<tr>
<td align="left"><a class="font_lighter"> <%= contestnotifications.created_at %></a></td>
<td width="200" align="right" class="a"><%= link_to l(:label_project_newother),contest_contestnotification_path(contestnotifications)%>
<%= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments_count)})" if contestnotifications.notificationcomments_count > 0 %>
</td>
</tr>
</table></td>
</tr>
</table>

View File

@ -0,0 +1,12 @@
<h3><%=l(:label_news)%></h3>
<%= labelled_form_for @contestnotification, url: contest_contestnotification_path, :html => { :id => 'contestnotifications-form', :multipart => true, :method => :put } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%= preview_link preview_contestnotifications_path(id: @contestnotification), 'contestnotifications-form' %>
<% end %>
<div id="preview" class="wiki"></div>
<% content_for :header_tags do %>
<%= stylesheet_link_tag 'scm' %>
<% end %>

View File

@ -0,0 +1,14 @@
api.array :contestnotifications, api_meta(:total_count => @contestnotifications_count, :offset => @offset, :limit => @limit) do
@contestnotificationss.each do |contestnotifications|
api.contestnotifications do
api.id contestnotifications.id
api.contest(:id => contestnotifications.contest_id, :name => contestnotifications.contest.name) unless contestnotifications.contest.nil?
api.author(:id => contestnotifications.author_id, :name => contestnotifications.author.name) unless contestnotifications.author.nil?
api.title contestnotifications.title
api.summary contestnotifications.summary
api.description contestnotifications.description
api.created_at contestnotifications.created_at
end
end
end

View File

@ -0,0 +1,97 @@
<span style="font-size: 16px; border-bottom:1px solid #f0f0f0; margin-right: 15px;">
<%= l(:label_notification) %>
</span>
<% if User.current.logged? && User.current == @contest.author %>
<%= link_to(l(:bale_news_notice),
new_contest_contestnotification_path(@contest),
:class => 'icon icon-add',
:onclick => 'showAndScrollTo("add-contestnotifications", "contestnotifications_title"); return false;') %>
<% end %>
<% if @contest %>
<div id="add-contestnotifications" class="add_frame" style="display:none;">
<%= labelled_form_for @contestnotification, :url => contest_contestnotifications_path(@contest),
:html => {:id => 'contestnotifications-form', :multipart => true} do |f| %>
<%= render :partial => 'contestnotifications/form', :locals => {:f => f} %>
<%= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %>
<%#= preview_link preview_contestnotifications_path(:contest_id => @contest), 'contestnotifications-form', target='preview', {:class => 'whiteButton m3p10'} %>
|
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-contestnotifications").hide(); return false;', :class => 'whiteButton m3p10' %>
<% end if @contest %>
<div id="preview" class="wiki"></div>
</div>
<% end %>
<div>
<% if @contestnotificationss.empty? %>
<p class="nodata">
<%= l(:label_no_data) %>
</p>
<% else %>
<% @contestnotificationss.each do |contestnotifications| %>
<table class="content-text-list">
<tr>
<td colspan="2" valign="top" width="50"><%= link_to image_tag(url_to_avatar(contestnotifications.author), :class => "avatar"), user_path(contestnotifications.author) %></td>
<td>
<table width="580px" border="0">
<tr>
<td colspan="2" valign="top">
<strong><%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %></strong><span style="margin-left: 4px;" class="font_lighter">
<%= l(:label_project_notice) %></span><span><%= link_to h(contestnotifications.title), contest_contestnotification_path(@contest, contestnotifications) %></span>
<span style="float: right">
<%= link_to l(:button_edit), edit_contest_contestnotification_path(@contest, contestnotifications) if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?) %>
<%= delete_link contest_contestnotification_path(@contest, contestnotifications) if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?) %>
</span>
</td>
</tr>
<tr>
<td colspan="2" width="580px">
<span class="font_description"><%= textilizable(contestnotifications, :description) %></span></td>
</tr>
<tr>
<td align="left"><span class="font_lighter"> <%= l :label_update_time %>
&nbsp;<%= format_time(contestnotifications.created_at) %></span></td>
<td width="350" align="right" class="a"><%= link_to l(:label_check_comment), contest_contestnotification_path(@contest, contestnotifications) %><%#= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments_count)})" if contestnotifications.notificationcomments_count >= 0 %></td>
</tr>
</table>
</td>
</tr>
</table>
<% end %>
<% end %>
</div>
<!--end-->
<div style="padding-right: 10px">
<div class="pagination">
<ul>
<%= pagination_links_full @contestnotifications_pages %>
</ul>
</div>
<% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %>
<%= stylesheet_link_tag 'scm' %>
<% end %>
<% html_title(l(:label_news_plural)) -%>
</div>
<script type='text/javascript'>
$(document).ready(function ($) {
$('.content-text-list').each(function () {
$(this).find('.delete_icon').hide();
$(this).mouseenter(function (event) {
$(this).find('.delete_icon').show();
});
$(this).mouseleave(function (event) {
$(this).find('.delete_icon').hide();
});
});
});
</script>
<!--end-->

View File

@ -0,0 +1,9 @@
<%= labelled_form_for @contestnotification, :url => contest_contestnotifications_path(@contest), :html => { :id => 'contestnotifications-form', :multipart => true } do |f| %>
<%= render :partial => 'contestnotifications/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
<%= submit_tag l(:button_cancel), :class => "whiteButton m3p10 h30",:onclick => "cancel();" %>
<% end %>
<div id="preview" class="wiki"></div>

View File

@ -0,0 +1,91 @@
<div class="contextual">
<%= link_to(l(:button_edit),
edit_contest_contestnotification_path(@contest, @contestnotification),
:class => 'icon icon-edit',
:accesskey => accesskey(:edit),
:onclick => '$("#edit-contestnotifications").show(); return true;') if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?)%>
<%= delete_link contest_contestnotification_path(@contest, @contestnotification) if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?) %>
</div>
<h3><strong><%=h @contestnotification.title %></strong></h3>
<div id="edit-contestnotifications" style="display:none;">
<%= labelled_form_for @contestnotification, :url => contest_contestnotification_path(@contest),
:html => { :id => 'contestnotifications-form', :multipart => true, :method => :put } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%= link_to l(:button_cancel), "#", :onclick => '$("#edit-contestnotifications").hide(); return false;' %>
<% end %>
<div id="preview" class="wiki"></div>
</div>
<div id="notificationcomments" style="margin-bottom:16px;">
<div style="margin:15px">
<span class="font_description"> <%= textilizable(@contestnotification, :description) %> </span>
<br/>
<%#= link_to_attachments @contestnotification %>
<br/>
<!--add comment-->
<% if User.current.logged? %>
<p>
<%= toggle_link l(:label_comment_add), "add_notificationcomment_form", :focus => "notificationcomment_notificationcomments" %>
</p>
<% else %>
<%= l(:label_user_login_notificationcomment) %>
<%= link_to l(:label_user_login_new), signin_path %>
<% end %>
<%= form_tag( contest_contestnotification_notificationcomments_path(@contest, @contestnotification) , :id => "add_notificationcomment_form", :style => "display:none;") do %>
<div class="box">
<%= text_area 'notificationcomment', 'notificationcomments', :cols => 80, :rows => 15, :class => 'wiki-edit' %>
<%= wikitoolbar_for 'notificationcomment_notificationcomments' %>
</div>
<p>
<%= submit_tag l(:button_add) %>
<%= submit_tag l(:button_cancel), :onclick => "cancel();" %>
</p>
<% end %>
<% html_title @contestnotification.title -%>
<% content_for :header_tags do %>
<%= stylesheet_link_tag 'scm' %>
<% end %>
<!--dispaly comments-->
<div class="line_heng"></div>
</div>
<h3 class="notificationcomments"><%= l(:label_comment_plural) %></h3>
<% notificationcomments = @notificationcomments.reverse %>
<% notificationcomments.each do |notificationcomment| %>
<% next if notificationcomment.new_record? %>
<table width="660px" border="0" align="center">
<tr>
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(notificationcomment.author), :class => "avatar")%></td>
<td>
<table width="580px" border="0">
<tr>
<td colspan="2" valign="top"><strong><%= link_to_user(notificationcomment.author) if notificationcomment.respond_to?(:author) %> </strong><span class="font_lighter"><%= l(:label_project_newadd) %></span><%= l(:label_comment_plural) %></td>
</tr>
<tr>
<td colspan="2" width="580px" >
<p class="font_description">
<%= textilizable(notificationcomment.notificationcomments) %>
</p></td>
</tr>
<tr>
<td align="left"><span class="font_lighter"> <%= format_time(notificationcomment.created_at) %></span></td>
<td width="200" align="right" class="a"><%#= link_to_if_authorized_contest image_tag('delete.png'), {:controller => 'notificationcomments', :action => 'destroy', :id => @contestnotifications, :notificationcomment_id => notificationcomment},
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %></td>
</tr>
</table></td>
</tr>
</table>
<% end if @notificationcomments.any? %>
</div>
<!--end-->

View File

@ -15,7 +15,7 @@
</div>
<span id="praise_tread" style="float: right">
<%= render :partial => "/praise_tread/praise_tread",
:locals => {:obj => @contest,:show_flag => true,:user_id =>User.current.id}%>
:locals => {:obj => @contest,:show_flag => true,:user_id =>User.current.id,:horizontal => false}%>
</span>
</span>
</div>

View File

@ -32,10 +32,8 @@
</p> -->
<p><%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;" %><%= calendar_for('bid_deadline')%>
</p>
<!--
<p><%= f.select :homework_type, homework_type_option %>
<p><%= f.select :is_evaluation, is_evaluation_option %>
</p>
-->
<p><%= hidden_field_tag 'course_id', @course.id %>
</p>
<fieldset><legend><%= l(:label_attachment_plural) %></legend>

View File

@ -1,3 +1,5 @@
<div class="frame-wiki">
<div class="contextual">
<% if User.current.allowed_to?(:edit_documents, @project) %>
<%= link_to l(:button_edit), edit_document_path(@document), :class => 'icon icon-edit', :accesskey => accesskey(:edit) %>
@ -7,26 +9,15 @@
<% end %>
</div>
<!-- <h3><%=h @document.title %></h3>
<h2><%=h @document.title %></h2>
<p><em><%=h @document.category.name %><br />
<%= format_date @document.created_on %></em></p>
<div class="wiki">
<%= textilizable @document.description, :attachments => @document.attachments %>
</div> -->
<!--add by huang-->
<table width="660px" align="center">
<tr><td><h3><strong><%=h @document.title %></strong></h3></td></tr>
<tr><td>
<div class="font_description">
<%= textilizable @document.description, :attachments => @document.attachments %>
</div>
</td></tr>
<tr><td align="right"><p class="font_lighter"><%= format_date @document.created_on %></p></td></tr>
<tr><td class="line_under"></td></tr>
</table>
<%= textilizable @document, :description, :attachments => @document.attachments %>
</div>
<div style="border-top:solid 1px #C6E9F1;"></div>
<h3><%= l(:label_attachment_plural) %></h3>
<%= link_to_attachments @document %>
@ -42,3 +33,4 @@
<% end %>
<% html_title @document.title -%>
</div>

View File

@ -22,12 +22,6 @@
<div style="font-size: 14px;">
<div style="margin-left: 20px;margin-bottom: 10px;margin-top: 10px;"> <%= comprehensive_evaluation.first.notes%> </div>
</div>
<% if is_teacher %>
<div style="text-align: center;">评分:
<%= rating_for homework, dimension: :quality, class: 'rateable div_inline' %>
<span style="font-size: 11px">(您可以重新打分,打分结果以最后一次打分为主!)</span>
</div>
<% end %>
</div>
<% else %>
<% if is_teacher %>
@ -35,10 +29,7 @@
<div style="font-size: 15px">
<strong>作业综评:</strong>
</div>
<div style="text-align: center;">评分:
<%= rating_for homework, dimension: :quality, class: 'rateable div_inline' %>
<span style="font-size: 11px">(您可以重新打分,打分结果以最后一次打分为主!)</span>
</div>
<%= render :partial => 'evaluation', :locals => {:homework => homework} %>
<div>
<%= render :partial => 'addjour', :locals => {:homework_attach => homework, :sta => 0,:is_comprehensive_evaluation => 1} %>
</div>

View File

@ -0,0 +1,4 @@
<div style="text-align: center;">评分:
<%= rating_for homework, dimension: :quality, class: 'rateable div_inline' %>
<span style="font-size: 11px">(每个用户对每份作业只能进行一次评价!)</span>
</div>

View File

@ -0,0 +1,44 @@
<%= error_messages_for 'member' %>
<div style="float:left; width:60%;padding-left: 10px;padding-right: 10px"
xmlns="http://www.w3.org/1999/html" id = "homework_of_users">
<table class="list members" style="width: 100%">
<thead>
<tr>
<th><%= l(:label_user) %></th>
<th><%= l(:label_role_plural) %></th>
<th style="width:10%"></th>
</tr>
</thead>
<tbody>
<!-- 发布人员不能被删除,将发布人员放在第一位 -->
<tr id="member-<%= homework.user.id %>" class="<%= cycle 'odd', 'even' %> member" style="text-align: center">
<td style="width: 40%"><%= link_to_user homework.user %></td>
<td style="text-align: center;width: 50%"> 发布人员 </td>
<td></td>
</tr>
<% hoemwork_users.each do |user| %>
<tr id="member-<%= user.id %>" class="<%= cycle 'odd', 'even' %> member" style="text-align: center">
<% if homework.user != user %>
<td style="width: 40%"><%= link_to_user user %></td>
<td style="text-align: center;width: 50%"> 参与人员 </td>
<td><%= link_to l(:button_delete),destory_homework_users_homework_attach_path(:user_id=>user),:remote => true, :method => :post %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="splitcontentright" style="width: 37%">
<%= form_for(hoemwork_users, {:url => add_homework_users_homework_attach_path(homework), :remote => true, :method => :post}) do |f| %>
<fieldset>
<legend><%= l(:label_member_new) %></legend>
<p><%= label_tag "principal_search", l(:label_principal_search) %><%= text_field_tag 'principal_search', nil %></p>
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript get_homework_member_list_homework_attach_index_path(:q => params[:q], :bid_id => params[:id]||homework, :format => 'js') }')" %>
<div id="principals_for_new_member">
<%= render_new_members_for_homework(members) %>
</div>
<p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p>
</fieldset>
<% end %>
</div>

View File

@ -0,0 +1,3 @@
<div id="principals_for_new_member">
<%= render_new_members_for_homework(members) %>
</div>

View File

@ -0,0 +1,22 @@
<div class="box">
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong>标 题:</strong>
<%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>
</p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong style="vertical-align: top">描 述:</strong>
<span style="margin-left:-10px;padding-right: 20px;">
<%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
</span>
</p>
<p style="padding-left: 60px">
<fieldset style="text-align: left;">
<legend>
<%= l(:label_attachment_plural) %>
</legend>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<%= render :partial => 'attachments/form' %>
</p>
</fieldset>
</p>
</div>

View File

@ -0,0 +1 @@
$('#content2').html('<%= escape_javascript(render(:partial => 'homework_member', :locals => {:members => @members,:hoemwork_users =>@hoemwork_users,:homework => @homework} )) %>');

View File

@ -0,0 +1 @@
$('#content2').html('<%= escape_javascript(render(:partial => 'homework_member', :locals => {:members => @members,:hoemwork_users =>@hoemwork_users,:homework => @homework} )) %>');

View File

@ -1,35 +1,79 @@
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=raw l(:label_new_homework)%> </p>
<div class="box">
<script type="text/javascript">
function switchTab(ProTag) {
var display_index = 3 - ProTag;
document.getElementById("tab" + ProTag).className = "selected";
document.getElementById("tab" + display_index).className = "";
document.getElementById("content" + ProTag).style.display = "";
document.getElementById("content" + display_index).style.display = "none";
}
</script>
<div class="top-content">
<table>
<tr>
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
</tr>
<tr>
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
<span><%= link_to(@homework.bid.courses.first.name.to_s, homework_project_path(@homework.bid.courses.first)) if @homework.bid.courses.first%></span> >
<%=link_to(@homework.bid.name, respond_path(@homework.bid)) %> > <span><%= link_to "修改作业",edit_homework_attach_path(@homework)%></span></p></td>
</tr>
</table>
</div>
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=raw l(:label_edit_homework)%> </p>
<div class="tabs">
<ul>
<li>
<a id = "tab1" href="#" class = "selected" onclick="switchTab(1);this.blur();return false;">
<%= l(:label_information_plural) %>
</a>
</li>
<li>
<a id="tab2" href="#" onclick="switchTab(2); this.blur(); return false;">
<%= l(:label_member_plural) %>
</a>
</li>
</ul>
</div>
<div class="box" id="content1">
<%= form_for(@homework) do |f|%>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong>标 题:</strong>
<%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%>
</p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong style="vertical-align: top">描 述:</strong>
<span style="margin-left:-10px;padding-right: 20px;">
<%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
</span>
</p>
<p style="padding-left: 60px">
<fieldset style="text-align: left;">
<p style="padding-left: 60px">
<% options = {:author => true, :deletable => attach_delete(@homework)} %>
<%= render :partial => 'attachments/links',
:locals => {:attachments => @homework.attachments, :options => options} %>
</p>
<legend>
<%= l(:label_attachment_plural) %>
</legend>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<%= render :partial => 'attachments/form' %>
</p>
</fieldset>
</p>
<p style="padding-left: 60px;padding-top: 10px;">
<span >
<%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
</span>
</p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong>标 题:</strong>
<%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%>
</p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong style="vertical-align: top">描 述:</strong>
<span style="margin-left:-10px;padding-right: 20px;">
<%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
</span>
</p>
<p style="padding-left: 60px">
<fieldset style="text-align: left;">
<p style="padding-left: 60px">
<% options = {:author => true, :deletable => attach_delete(@homework)} %>
<%= render :partial => 'attachments/links',
:locals => {:attachments => @homework.attachments, :options => options} %>
</p>
<legend>
<%= l(:label_attachment_plural) %>
</legend>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<%= render :partial => 'attachments/form' %>
</p>
</fieldset>
</p>
<p style="padding-left: 60px;padding-top: 10px;">
<span >
<%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
</span>
</p>
<% end %>
</div>
<div id="content2" style="display: none" >
<%= render :partial => "homework_member",:locals => {:members => @members,:hoemwork_users =>@hoemwork_users,:homework => @homework} %>
</div>

View File

@ -0,0 +1,2 @@
$('#principals_for_new_member').replaceWith('<%= j(render :partial => "member_list_partial", locals:{members: @members})%>');

View File

@ -1,3 +1,19 @@
<div class="top-content">
<table>
<tr>
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
</tr>
<tr>
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
<span><%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%></span> >
<%=link_to(@bid.name, respond_path(@bid)) %> > <span><%= link_to "创建作业", new_homework_attach_path(@bid)%></span></p></td>
</tr>
</table>
</div>
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=h l(:label_new_homework)%> </p>
<div class="box">
<%= form_for('new_form', :method => :post,
@ -26,7 +42,8 @@
</p>
</fieldset>
</p>
<p style="padding-left: 60px;padding-top: 10px;">
<p style="padding-left: 60px;padding-top: 5px;">
<span >
<%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
</span>

View File

@ -1,4 +1,4 @@
<%= render :partial => 'layouts/base_homework_attach', :locals => {:homework_attach => @homework} %>
<style>
.softapplication-img .soft-application {
float: left;
@ -6,9 +6,8 @@
height: 200px;
}
</style>
<% is_student = is_cur_course_student? @homework.bid.courses.first %>
<% is_student = is_cur_course_student @homework.bid.courses.first %>
<% is_teacher = is_course_teacher User.current,@homework.bid.courses.first %>
<p id="notice"><%= notice %></p>
<!-- <%= image_tag(url_to_avatar(@user), :class => "avatar2") %> -->
<div style="height: auto; padding-bottom: 10px">
@ -24,23 +23,35 @@
<td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all">
发布人员:<%= link_to @homework.user, user_path(@homework.user)%>
</td>
<td>发布时间:<%=format_time @homework.created_at %></td>
<td style="width: 240px; word-wrap: break-word; word-break: break-all">
所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%>
</td>
</tr>
<tr>
<td style="padding-left: 40px">
<span>作业下载:</span>
<% options = {:author => true } %>
<%= render :partial => 'app_link', :locals => {:attachments => @homework.attachments, :options => options} %>
<% if @is_evaluation || is_teacher%>
<% options = {:author => true } %>
<%= render :partial => 'app_link', :locals => {:attachments => @homework.attachments, :options => options} %>
<% else %>
<%= l(:label_cant_download) %>
<% end %>
</td>
<td style="width: 240px; word-wrap: break-word; word-break: break-all">
所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%>
<td style="width: 240px; word-wrap: break-word; word-break: break-all">
参与人员:
<% @homework.users.each do |homework_user| %>
<%= link_to homework_user, user_path(homework_user)%>
<% if @homework.users.count > 1 && homework_user != @homework.users.last %>
<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% end %>
<% end %>
</td>
</tr>
<tr>
<td style="padding-left: 40px" colspan="2">平均评分:
<td style=" padding-left: 40px">平均评分:
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
</td>
<td style="width: 240px; word-wrap: break-word; word-break: break-all">发布时间:<%=format_time @homework.created_at %></td>
</tr>
</table>
</td>
@ -94,7 +105,7 @@
</div>
</div>
<%= @stars_status_map["star#{(star/20).to_s}".to_sym] %>
<br>
<br/>
<% end %>
</div>
</div>
@ -130,23 +141,37 @@
</div>
<div class="underline-contests_one"></div>
<div style="height: 50px">
<div style="font-size: 15px"><strong>作业评论:</strong></div>
<% if is_student %>
<div style="text-align: center;">评分:
<%= rating_for @homework, dimension: :quality, class: 'rateable div_inline' %>
<span style="font-size: 11px">(您可以重新打分,打分结果以最后一次打分为主!)</span>
</div>
<% end %>
</div>
<!-- 作业成员(发布人员和参与人员)不能对作业进行评分 -->
<% if !users_for_homework(@homework).include?(User.current) %>
<div style="height: 50px">
<div style="font-size: 15px"><strong>作业评论:</strong></div>
<% if is_student %>
<% if @is_evaluation %>
<% if @has_evaluation %>
<div style="text-align: center;">
<%= l(:lable_has_evaluation)%>
</div>
<% else %>
<%= render :partial => 'evaluation', :locals => {:homework => @homework} %>
<% end %>
<% else %>
<div style="text-align: center;">
<%= l(:lable_close_evaluation)%>
</div>
<% end %>
<% end %>
</div>
<% end %>
<% if !is_teacher %>
<!--提示登录后对应用进行评价-->
<div id="leave-message">
<%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => nil} %>
</div>
<!--提示登录后对应用进行评价-->
<div id="leave-message">
<%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => nil} %>
</div>
<% end %>
<!-- 留言列表区 -->
<div id="message" style="font-size: 14px;">
<%= render :partial => 'showjour', :locals => {:jour => @jour,:homework => @homework} %>

View File

@ -10,7 +10,7 @@
<% column_content = ( query.inline_columns.map {|column| "#{column_content_new(column, issue)}"}) %>
<!-- 在这里添加赞和踩-->
<span id="praise_tread" style="float: right"> <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => issue,:show_flag => true,:user_id =>User.current.id}%> </span>
<span id="praise_tread" style="float: right"> <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => issue,:show_flag => true,:user_id =>User.current.id,:horizontal => false}%> </span>
<% if issue.tracker_id == 1 %>
<%= image_tag("/images/task.png", :class => "img-tag-issues") %>

View File

@ -33,7 +33,7 @@
<!-- 顶和踩 在这里添加 -->
<span id="praise_tread" style="float: right">
<%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @issue,:show_flag => true,:user_id =>User.current.id}%>
<%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @issue,:show_flag => true,:user_id =>User.current.id,:horizontal => false}%>
</span>
<p class="author">

View File

@ -1,4 +1,5 @@
<!--add by huang-->
<% cache "footer" do %>
<div class="clearfix"></div>
<div id="footer" style="margin-left:-5px;padding-top: 20px;clear: both;font-size: 12px;">
<div style="border-top:solid 1px #C6E9F1;"></div>
@ -7,12 +8,12 @@
<!--gcm-->
<p>
<span>主办单位:</span>
<span class="footer_text_link"><%= link_to "国防科学技术大学并行与分布处理国家重点实验室","http://www.nudt.edu.cn/ArticleShow.asp?ID=47",:target=>"_blank"%></span>
<span class="footer_text_link"><%= link_to "计算机科学与技术系", "http://www.nudt.edu.cn/ArticleShow.asp?ID=41", :target => "_blank" %></span>
<span id="copyright">版权@2007~2014</span>
<span id="contact_us" class="footer_text_link"><%= link_to "联系我们","http://forge.trustie.net/projects/2/member", :target=>"_blank" %></span>
<span id="record"class="footer_text_link"><%= link_to "湘ICP备09019772","http://www.miibeian.gov.cn/", :target => "_blank" %></span>
<span><%=l(:label_organizers)%></span>
<span class="footer_text_link"><%= link_to l(:label_organizers_information),"http://www.nudt.edu.cn/ArticleShow.asp?ID=47",:target=>"_blank"%></span>
<span class="footer_text_link"><%= link_to l(:label_organizers_information_institute), "http://www.nudt.edu.cn/ArticleShow.asp?ID=41", :target => "_blank" %></span>
<span id="copyright"><%=l(:label_copyright)%>@2007~2014</span>
<span id="contact_us" class="footer_text_link"><%= link_to l(:label_contact_us),"http://forge.trustie.net/projects/2/member", :target=>"_blank" %></span>
<span id="record"class="footer_text_link"><%= link_to l(:label_record),"http://www.miibeian.gov.cn/", :target => "_blank" %></span>
</p>
<div id="logo_link">
@ -31,7 +32,9 @@
<div class="debug">
<%= debug(params) if Rails.env.development? %>
<script src="http://s4.cnzz.com/z_stat.php?id=1000482288&web_id=1000482288" language="JavaScript"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
@ -42,3 +45,5 @@
</script>
</div>
<% end %>

View File

@ -0,0 +1,15 @@
<div class="top-content">
<table>
<tr>
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
</tr>
<tr>
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
<span><%= link_to(homework_attach.bid.courses.first.name.to_s, homework_project_path(homework_attach.bid.courses.first)) if homework_attach.bid.courses.first%></span> >
<%=link_to(homework_attach.bid.name, respond_path(homework_attach.bid)) %> > <span><%= link_to homework_attach.name.nil? ? homework_attach.attachments.first.filename : homework_attach.name,homework_attach_path(homework_attach)%></span></p></td>
</tr>
</table>
</div>

View File

@ -1,7 +1,7 @@
<div class="top-content">
<table>
<tr>
<td class="info_font" style="width: 240px; color: #15bccf">创新竞赛社区</td>
<td class="info_font" style="width: 240px; color: #15bccf"><%=l(:label_contest_innovate_community)%></td>
<td style="width: 430px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
<td rowspan="2" width="305px">
<div class="project-search" style="float: right">

View File

@ -1,7 +1,7 @@
<div class="top-content">
<table>
<tr>
<td class="info_font" style="width: 240px; color: #15bccf">创新竞赛社区</td>
<td class="info_font" style="width: 240px; color: #15bccf"><%=l(:label_contest_innovate_community)%></td>
<td style="width: 430px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
<td rowspan="2" width="250px"></td>
</tr>

View File

@ -26,7 +26,7 @@
<div class="top-content">
<table>
<tr>
<td class="info_font" style="width: 240px; color: #15bccf">创新竞赛社区</td>
<td class="info_font" style="width: 240px; color: #15bccf"><%=l(:label_contest_innovate_community)%></td>
<td style="width: 430px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
<td rowspan="2" width="250px">
<div class="project-search">

View File

@ -18,8 +18,8 @@
<%= yield :header_tags -%>
</head>
<body class="<%= h body_css_classes %>">
<% project = @bid.courses.first %>
<% course = Course.find_by_extra(project.identifier) %>
<% project = @bid.courses.includes(:course_extra).first %>
<% course = project.course_extra %>
<div id="wrapper">
<div id="wrapper2">
<div id="wrapper3">
@ -47,37 +47,33 @@
<div class="main_context">
<div class="spaceleft">
<div>
<table style="width: 250px ; line-height: 1.5em;font-size: 12px">
<table>
<tr>
<td style="width: 40px">
<td style="padding-left:8px ">
<% if get_avatar?(project) %>
<%= image_tag(url_to_avatar(project),:style => "width:60px;height:60px" ) %>
<%= image_tag(url_to_avatar(project),:style => "width:80px;height:80px" ) %>
<% else %>
<%= image_tag('../images/avatars/Project/course.jpg', :style => "width:60px;height:60px") %>
<%= image_tag('../images/avatars/Project/course.jpg', :style => "width:80px;height:80px") %>
<% end %>
</td>
<td>
<table>
<tr valign="top">
<td style="width: 50px;vertical-align: top;" ><strong>课程名:</strong></td>
<td style="text-align: left">
<span style=" word-wrap: break-word; word-break: break-all"><strong> <%= link_to @bid.courses.first.name.to_s, homework_project_path(@bid.courses.first) if @bid.courses.first %></strong></span>
<tr>
<td style="vertical-align: top;font-size: 16px;text-align: center;" >
<span style=" word-wrap: break-word; word-break: break-all">
<strong>
<%= link_to @bid.courses.first.name.to_s, homework_project_path(@bid.courses.first) if @bid.courses.first %>
</strong>
</span>
</td>
</tr>
<tr>
<td style="width: 50px;vertical-align: top;"><strong>作业名:</strong></td>
<td style="text-align: left">
<span style="color:#ed8924"><strong><%= h @bid.name %></strong></span>
<td style=" word-wrap: break-word; word-break: break-all;font-size: 16px;text-align: center">
<span style=" color:#ed8924">
<strong><%= h @bid.name %></strong>
</span>
</td>
</tr>
<!-- <tr>
<td></td>
<td align="center">
<span class="bid_course" style="padding-left: 8px"> <% if @user != User.current %>
<%= watcher_link(@bid, User.current) %>
<% end %> </span>
</td>
</tr> -->
</table>
</td>
</tr>
@ -93,7 +89,7 @@
</tr>
<tr>
<td class="font_lighter_sidebar" colspan="2" style="padding-left: 8px;"><%= project.description %></td>
<td class="font_lighter_sidebar" colspan="2" style="padding-left: 8px;"><%= textilizable project.description %></td>
</tr>
<tr>
@ -128,12 +124,6 @@
<div class="inf_user_image">
<table>
<!--
<tr>
<td style="text-align: justify ; text-justify: inter-ideograph; width: 180px"><%= l(:label_teacher_homework) %> : <%= link_to(@user.lastname+@user.firstname, user_path(@user)) %></td>
</tr>
-->
<tr>
<td><%= l(:label_limit_time) %>: <%= @bid.deadline %></td>
</tr>
@ -175,7 +165,7 @@
<tr>
<td style="padding-top: 5px"> <% if @bid.homework_type == 1%>
<% if @bid.homeworks.size>0 %>
<% for homework in @bid.homeworks %>
<% for homework in @bid.homeworks.eager_load(:user) %>
<%= link_to image_tag(url_to_avatar(homework.user), :class => "avatar", :title => homework.user.name), user_path(homework.user), :class => "avatar" %> <% end %>
<% else %>
<p class="font_lighter">

View File

@ -27,7 +27,7 @@
<div class="top-content">
<table>
<tr>
<td class="info_font" style="width: 240px; color: #15bccf">创新竞赛社区</td>
<td class="info_font" style="width: 240px; color: #15bccf"><%=l(:label_contest_innovate_community)%></td>
<td style="width: 430px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
<td rowspan="2" width="250px">
<div class="project-search">
@ -43,7 +43,7 @@
<td style="padding-left: 8px"><%=link_to request.host()+"/contests", :controller=>'contests', :action=>'index' %></td>
<td ><%=link_to l(:field_homepage), home_path %> >
<%=link_to l(:label_contest_innovate), :controller=>'contests', :action=>'index' %> >
<span><%= link_to @contest.name, show_contest_contest_path %></span>
<span><%= link_to @contest.name, show_contest_contest_path(@contest) %></span>
</td>
</tr>
</table>
@ -82,7 +82,7 @@
</tr>
<tr colspan='3'>
<td valign="middle">
<span style="display:block; margin-left:20px;"><%= link_to l(:label_contest_delete), {:controller => 'contests', :action => 'destroy_contest', :id => @contest}, data: { confirm: '你确定要删除该竞赛吗?' } %></span>
<span style="display:block; margin-left:20px;"><%= link_to l(:label_contest_delete), {:controller => 'contests', :action => 'destroy_contest', :id => @contest}, data: { confirm: '你确定要删除该竞赛吗?' }, method: :delete %></span>
</td>
</tr>
<% end %>
@ -96,20 +96,16 @@
<div class="user_fans">
<table width="240" border="0">
<tr align="center" width="80px">
<!-- <td class="font_index">
<%=link_to "#{@contest.join_in_competitions.count}",:controller => "contests",:action => "show_participator" %>
</td> -->
<!--关注人数-->
<td class="font_index">
<!-- <%=link_to "#{@contest.projects.where('is_public=1').count}", :controller => 'contests', :action => 'show_project' %> -->
<%=link_to "#{@contest.watcher_users.count}", :controller => 'contests', :action => 'show_project' %>
<%=link_to "#{@contest.watcher_users.count}",show_project_contest_path(@contest) %>
</td>
<!--参赛作品数量-->
<td class="font_index">
<% if @contest.id == 2 or @contest.id == 3 or @contest.id == 6 %>
<%=link_to "#{@contest.projects.where('is_public=1').count}" %>
<% else %>
<%=link_to "#{@contest.contesting_softapplications.count}", :controller => 'contests', :action => 'show_attendingcontest' %>
<%=link_to "#{@contest.contesting_softapplications.count}",show_attendingcontest_contest_path(@contest) %>
<% end %>
</td>
@ -127,7 +123,7 @@
<div class="inf_user_image">
<table>
<tr>
<td><%= l(:lable_contest_user) %><%= link_to(@user.show_name, user_path(@user))%></td>
<td><%= l(:lable_contest_user) %>:&nbsp;<%= link_to(@user.name, user_path(@user))%></td>
</tr>
<tr>
<td><%= l(:label_bids_reward_method) %><%= @contest.budget%></td>
@ -210,25 +206,7 @@
<div class="user_underline"></div>
<!--参与者-->
<!-- <div class="user_fans">
<div class="font_title_left">
<strong><%= l(:label_participate) %></strong>
<% if show_more_participate?(@contest) %>
<span style="font-size: 12px; display: inline; float: right;" >
<%= link_to l(:label_more), :controller => "contests", :action => "show_participator"%>
</span>
<% end %>
</div>
<div class="left_wf">
<table>
<tr>
<td style="padding-top: 5px"> <%= show_participate_picture(@contest) %> </td>
</tr>
</table>
</div>
</div> -->
<div class="user_underline"></div>
</div>
@ -236,7 +214,11 @@
<div id="content">
<% if display_main_menu?(@contest) %>
<div class="tabs_new">
<%= render_menu :contest_menu %>
<ul>
<li ><%= link_to l(:label_contest_userresponse), show_contest_contest_path(@contest), :class => link_class(:respond) %></li>
<li><%= link_to l(:label_contest_joincontest), show_attendingcontest_contest_path(@contest), :class => link_class(:attendingcontests) %></li>
<li><%= link_to l(:label_contest_notification), contest_contestnotifications_path(@contest), :class => link_class(:contestnotifications) %></li>
</ul>
</div>
<% end %>

View File

@ -1,4 +1,6 @@
<div class="lz">
<!-- 在这里添加赞和踩-->
<span id="praise_tread" style="float: right"> <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @memo,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%> </span>
<div class="lz-left">
<div><%= link_to image_tag(url_to_avatar(@memo.author), :class => "avatar"), user_path(@memo.author) %></div>
<p class="clearfix"><%=link_to @memo.author.name, user_path(@memo.author) %></p>
@ -46,7 +48,6 @@
<div class="memo-title <%= @memo.sticky ? 'sticky' : '' %> <%= @memo.locked? ? 'locked' : '' %>"><%= label_tag l(:field_subject) %>: <%=h @memo.subject %></div>
<div class="memo-content">
<!-- < %= textilizable(@memo, :content) %> -->
<%= raw @memo.content %>
<p>
<% if @memo.attachments.any?%>

View File

@ -60,6 +60,8 @@
</style>
<div class="lz">
<!-- 在这里添加赞和踩-->
<span id="praise_tread" style="float: right"> <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @topic,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%> </span>
<div class="contextual">
<%= watcher_link(@topic, User.current) %>
<%= link_to(
@ -82,6 +84,7 @@
:class => 'icon icon-del'
) if @message.destroyable_by?(User.current) %>
</div>
<div class="lz-left">
<div class="">
<%= link_to image_tag(url_to_avatar(@topic.author), :class => "avatar"), user_path(@topic.author) %>

View File

@ -61,7 +61,6 @@
<tr>
<td align="left">帖子来源:<span class="font_lighter" style="color: #068d9c"><%=link_to 'OSChina', topic.url %>
</span></td>
<td colspan="3" align="center"><%= no_use_link(topic, User.current) %> </td>
</tr>

View File

@ -458,7 +458,6 @@
<tr>
<td align="left">帖子来源:<span class="font_lighter" style="color: #068d9c"><%=link_to 'OSChina', topic.url %>
</span></td>
<td colspan="3" align="center"><%= no_use_link(topic, User.current) %> </td>
</tr>
</table></td>
</tr>

View File

@ -51,5 +51,6 @@
:title => l(:button_delete)
) if @forum.destroyable_by?(User.current) %>
</div>
<div>
<%= render :partial => 'open_source_projects/show_memo', :locals => {:memos => @memos, :open_source_project => @open_source_project} %>
</div>

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