修复竞赛作品附件删除报错的bug

Signed-off-by: alan <547533434@qq.com>
course_group
alan 11 years ago
parent b35defe270
commit 43e940eb1d

@ -1,5 +1,5 @@
# source 'http://ruby.taobao.org' source 'http://ruby.taobao.org'
source 'http://ruby.sdutlinux.org/' #source 'http://ruby.sdutlinux.org/'
unless RUBY_PLATFORM =~ /w32/ unless RUBY_PLATFORM =~ /w32/
# unix-like only # unix-like only
@ -30,6 +30,7 @@ group :test do
gem 'factory_girl', '~> 4.4.0' gem 'factory_girl', '~> 4.4.0'
gem 'selenium-webdriver', '~> 2.42.0' gem 'selenium-webdriver', '~> 2.42.0'
platforms :mri, :mingw do platforms :mri, :mingw do
group :rmagick do group :rmagick do
# RMagick 2 supports ruby 1.9 # RMagick 2 supports ruby 1.9
@ -48,6 +49,7 @@ group :development, :test do
gem 'ruby-prof', '~> 0.15.1' unless RUBY_PLATFORM =~ /w32/ gem 'ruby-prof', '~> 0.15.1' unless RUBY_PLATFORM =~ /w32/
gem 'pry' gem 'pry'
gem 'pry-nav' gem 'pry-nav'
end end

@ -19,7 +19,7 @@ PATH
rails rails
GEM GEM
remote: http://ruby.sdutlinux.org/ remote: http://ruby.taobao.org/
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actionmailer (3.2.13) actionmailer (3.2.13)

@ -194,11 +194,11 @@ class AttachmentsController < ApplicationController
format.html { redirect_to_referer_or course_path(@course) } format.html { redirect_to_referer_or course_path(@course) }
end end
else else
if @project.nil? # if @project.nil?
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } # format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
else # else
format.html { redirect_to_referer_or project_path(@project) } format.html { redirect_to_referer_or project_path(@project) }
end # end
end end
format.js format.js

File diff suppressed because it is too large Load Diff

@ -1,257 +1,257 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2013 Jean-Philippe Lang # Copyright (C) 2006-2013 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module WatchersHelper module WatchersHelper
def watcher_tag(object, user, options={}) def watcher_tag(object, user, options={})
ActiveSupport::Deprecation.warn "#watcher_tag is deprecated and will be removed in Redmine 3.0. Use #watcher_link instead." ActiveSupport::Deprecation.warn "#watcher_tag is deprecated and will be removed in Redmine 3.0. Use #watcher_link instead."
watcher_link(object, user) watcher_link(object, user)
end end
###################modified by liuping, nyan ###################modified by liuping, nyan
def watcher_link(objects, user, options=[]) def watcher_link(objects, user, options=[])
return '' unless user && user.logged? return '' unless user && user.logged?
objects = Array.wrap(objects) objects = Array.wrap(objects)
watched = objects.any? {|object| object.watched_by?(user)} watched = objects.any? {|object| object.watched_by?(user)}
@watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or objects.first.instance_of?(Contest) or (objects.first.instance_of?(Bid))) @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or objects.first.instance_of?(Contest) or (objects.first.instance_of?(Bid)))
css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) :
([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s) ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s)
text = @watch_flag ? text = @watch_flag ?
(watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch))
url = watch_path( url = watch_path(
:object_type => objects.first.class.to_s.underscore, :object_type => objects.first.class.to_s.underscore,
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort) :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
) )
method = watched ? 'delete' : 'post' method = watched ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method, :class => css link_to text, url, :remote => true, :method => method, :class => css
end end
############## added by linchun ############## added by linchun
def new_watcher_link(objects, user, options=[]) def new_watcher_link(objects, user, options=[])
return '' unless user && user.logged? return '' unless user && user.logged?
objects = Array.wrap(objects) objects = Array.wrap(objects)
watched = objects.any? {|object| object.watched_by?(user)} watched = objects.any? {|object| object.watched_by?(user)}
@watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Contest))) @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Contest)))
css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) :
([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s) ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s)
text = @watch_flag ? text = @watch_flag ?
(watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch))
url = watch_path( url = watch_path(
:object_type => objects.first.class.to_s.underscore, :object_type => objects.first.class.to_s.underscore,
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort) :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
) )
method = watched ? 'delete' : 'post' method = watched ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method, :class => css link_to text, url, :remote => true, :method => method, :class => css
end end
# add by nwb # add by nwb
# 关注课程 # 关注课程
def new_course_watcher_link(objects, user, options=[]) def new_course_watcher_link(objects, user, options=[])
return '' unless user && user.logged? return '' unless user && user.logged?
objects = Array.wrap(objects) objects = Array.wrap(objects)
watched = objects.any? {|object| object.watched_by?(user)} watched = objects.any? {|object| object.watched_by?(user)}
@watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Contest))) @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Contest)))
css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) :
([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s) ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s)
text = @watch_flag ? text = @watch_flag ?
(watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch))
url = watch_path( url = watch_path(
:object_type => objects.first.class.to_s.underscore, :object_type => objects.first.class.to_s.underscore,
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort) :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
) )
method = watched ? 'delete' : 'post' method = watched ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method, :class => css link_to text, url, :remote => true, :method => method, :class => css
end end
# added by fq, modify nyan # added by fq, modify nyan
# Somebody may use option params # Somebody may use option params
def join_in_course(course, user, options=[]) def join_in_course(course, user, options=[])
return '' unless user && user.logged? return '' unless user && user.logged?
# modify by nwb # modify by nwb
# 主讲教师不允许退出课程 # 主讲教师不允许退出课程
return '' if user.id == course.tea_id return '' if user.id == course.tea_id
joined = user.member_of_course?(course) joined = user.member_of_course?(course)
text = joined ? l(:label_exit_course) : l(:label_join_course) text = joined ? l(:label_exit_course) : l(:label_join_course)
url_t = join_path(:object_id => course.id) url_t = join_path(:object_id => course.id)
url_f = try_join_path(:object_id => course.id) url_f = try_join_path(:object_id => course.id)
method = joined ? 'delete' : 'post' method = joined ? 'delete' : 'post'
if joined if joined
link_to text, url_t, :remote => true, :method => method, :id => "#{course.id}", :confirm => l(:text_are_you_sure_out), :class => []+options link_to text, url_t, :remote => true, :method => method, :id => "#{course.id}", :confirm => l(:text_are_you_sure_out), :class => []+options
else else
link_to text, url_f, :remote => true, :method => method, :id => "#{course.id}", :class => []+options link_to text, url_f, :remote => true, :method => method, :id => "#{course.id}", :class => []+options
end end
end end
# 用户是否允许加入课程判断 # 用户是否允许加入课程判断
# add by nwb # add by nwb
def join_in_course_for_list(course, user, options=[]) def join_in_course_for_list(course, user, options=[])
return '' unless user && user.logged? return '' unless user && user.logged?
# modify by nwb # modify by nwb
# 主讲教师不允许退出课程 # 主讲教师不允许退出课程
return '' if user.id == course.tea_id return '' if user.id == course.tea_id
joined = user.member_of_course?(course) joined = user.member_of_course?(course)
text = joined ? l(:label_exit_course) : l(:label_join_course) text = joined ? l(:label_exit_course) : l(:label_join_course)
url_t = join_path(:object_id => course.id) url_t = join_path(:object_id => course.id)
url_f = try_join_path(:object_id => course.id) url_f = try_join_path(:object_id => course.id)
method = joined ? 'delete' : 'post' method = joined ? 'delete' : 'post'
if joined if joined
link_to text, url_t, :remote => true, :method => method, :id => "#{course.id}", :confirm => l(:text_are_you_sure_out), :class => []+options link_to text, url_t, :remote => true, :method => method, :id => "#{course.id}", :confirm => l(:text_are_you_sure_out), :class => []+options
else else
link_to text, url_f, :remote => true, :method => method, :id => "#{course.id}", :class => []+options link_to text, url_f, :remote => true, :method => method, :id => "#{course.id}", :class => []+options
end end
end end
#added by bai #added by bai
def join_in_contest(bid, user, options=[]) def join_in_contest(bid, user, options=[])
if bid.reward_type == 2 if bid.reward_type == 2
return '' unless user && user.logged? return '' unless user && user.logged?
joined = user.join_in_contest?(bid) joined = user.join_in_contest?(bid)
text = joined ? l(:label_exit_contest) : l(:label_join_contest) text = joined ? l(:label_exit_contest) : l(:label_join_contest)
url_t = join_in_contest_path(:id => bid.id) url_t = join_in_contest_path(:id => bid.id)
url_f = try_join_in_contest_path(:id => bid.id) url_f = try_join_in_contest_path(:id => bid.id)
# url = join_in_contest_path(:id => bid.id) # url = join_in_contest_path(:id => bid.id)
method = joined ? 'delete' : 'post' method = joined ? 'delete' : 'post'
if joined if joined
link_to text, url_t, :remote => true, :method => method, :id => "#{bid.id}", :confirm => l(:text_are_you_sure_out), :class => []+options link_to text, url_t, :remote => true, :method => method, :id => "#{bid.id}", :confirm => l(:text_are_you_sure_out), :class => []+options
else else
link_to text, url_f, :remote => true, :method => method, :id => "#{bid.id}", :class => []+options link_to text, url_f, :remote => true, :method => method, :id => "#{bid.id}", :class => []+options
end end
end end
end end
##new add by linchun ##new add by linchun
def join_in_contest(contest, user, options=[]) def join_in_contest(contest, user, options=[])
return '' unless user && user.logged? return '' unless user && user.logged?
joined = user.join_in_contest?(contest) joined = user.join_in_contest?(contest)
text = joined ? l(:label_exit_contest) : l(:label_join_contest) text = joined ? l(:label_exit_contest) : l(:label_join_contest)
url_t = join_in_contest_path(:id => contest.id) url_t = join_in_contest_path(:id => contest.id)
url_f = try_join_in_contest_path(:id => contest.id) url_f = try_join_in_contest_path(:id => contest.id)
# url = join_in_contest_path(:id => contest.id) # url = join_in_contest_path(:id => contest.id)
method = joined ? 'delete' : 'post' method = joined ? 'delete' : 'post'
if joined if joined
link_to text, url_t, :remote => true, :method => method, :id => "#{contest.id}", :confirm => l(:text_are_you_sure_out), :class => []+options link_to text, url_t, :remote => true, :method => method, :id => "#{contest.id}", :confirm => l(:text_are_you_sure_out), :class => []+options
else else
link_to text, url_f, :remote => true, :method => method, :id => "#{contest.id}", :class => []+options link_to text, url_f, :remote => true, :method => method, :id => "#{contest.id}", :class => []+options
end end
end end
# liuwanwei 的需求, 新竞赛 # liuwanwei 的需求, 新竞赛
# 新路由命名为 competition # 新路由命名为 competition
def join_in_competition(competition, user) def join_in_competition(competition, user)
return '' unless user && user.logged? return '' unless user && user.logged?
joined = JoinInCompetition.where('competition_id = ? AND user_id = ?', competition.id, user.id).count>0 joined = JoinInCompetition.where('competition_id = ? AND user_id = ?', competition.id, user.id).count>0
text = joined ? l(:label_exit_contest) : l(:label_join_contest) text = joined ? l(:label_exit_contest) : l(:label_join_contest)
url_f = new_join_contests_path(:id => competition.id) url_f = new_join_contests_path(:id => competition.id)
url_t = unjoin_in_contest_contests_path(:id => competition.id) url_t = unjoin_in_contest_contests_path(:id => competition.id)
method = joined ? 'delete' : 'post' method = joined ? 'delete' : 'post'
if joined if joined
# 退出竞赛用 # 退出竞赛用
link_to text, url_t, :remote => true, :method => method, :id => "#{competition.id}", :confirm => l(:text_are_you_sure_out) link_to text, url_t, :remote => true, :method => method, :id => "#{competition.id}", :confirm => l(:text_are_you_sure_out)
else else
# 加入竞赛用 # 加入竞赛用
link_to text, url_f, :remote => true, :method => method, :id => "#{competition.id}" link_to text, url_f, :remote => true, :method => method, :id => "#{competition.id}"
end end
end end
# Returns the css class used to identify watch links for a given +object+ # Returns the css class used to identify watch links for a given +object+
def watcher_css(objects) def watcher_css(objects)
objects = Array.wrap(objects) objects = Array.wrap(objects)
id = (objects.size == 1 ? objects.first.id : 'bulk') id = (objects.size == 1 ? objects.first.id : 'bulk')
"#{objects.first.class.to_s.underscore}-#{id}-watcher" "#{objects.first.class.to_s.underscore}-#{id}-watcher"
end end
# Returns a comma separated list of users watching the given object # Returns a comma separated list of users watching the given object
def watchers_list(object) def watchers_list(object)
remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project) remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project)
content = ''.html_safe content = ''.html_safe
lis = object.watcher_users.collect do |user| lis = object.watcher_users.collect do |user|
s = ''.html_safe s = ''.html_safe
s << avatar(user, :size => "16").to_s s << avatar(user, :size => "16").to_s
s << link_to_user(user, :class => 'user') s << link_to_user(user, :class => 'user')
if remove_allowed if remove_allowed
url = {:controller => 'watchers', url = {:controller => 'watchers',
:action => 'destroy', :action => 'destroy',
:object_type => object.class.to_s.underscore, :object_type => object.class.to_s.underscore,
:object_id => object.id, :object_id => object.id,
:user_id => user} :user_id => user}
s << ' ' s << ' '
s << link_to(image_tag('delete.png'), url, s << link_to(image_tag('delete.png'), url,
:remote => true, :method => 'delete', :class => "delete") :remote => true, :method => 'delete', :class => "delete")
end end
content << content_tag('li', s, :class => "user-#{user.id}") content << content_tag('li', s, :class => "user-#{user.id}")
end end
content.present? ? content_tag('ul', content, :class => 'watchers') : content content.present? ? content_tag('ul', content, :class => 'watchers') : content
end end
def watchers_checkboxes(object, users, checked=nil) def watchers_checkboxes(object, users, checked=nil)
if users.nil? if users.nil?
else else
users.map do |user| users.map do |user|
c = checked.nil? ? object.watched_by?(user) : checked c = checked.nil? ? object.watched_by?(user) : checked
tag = check_box_tag 'issue[watcher_user_ids][]', user.id, c, :id => nil tag = check_box_tag 'issue[watcher_user_ids][]', user.id, c, :id => nil
content_tag 'label', "#{tag} #{h(user)}".html_safe, content_tag 'label', "#{tag} #{h(user)}".html_safe,
:id => "issue_watcher_user_ids_#{user.id}", :id => "issue_watcher_user_ids_#{user.id}",
:class => "floating" :class => "floating"
end.join.html_safe end.join.html_safe
end end
end end
def applied_css(project) def applied_css(project)
id = project.id id = project.id
"#{project.class.to_s.underscore}-#{id}-applied" "#{project.class.to_s.underscore}-#{id}-applied"
end end
def applied_link(project, user, options=[]) def applied_link(project, user, options=[])
return '' unless user && user.logged? return '' unless user && user.logged?
applied = project.applied_projects.find_by_user_id(user.id) applied = project.applied_projects.find_by_user_id(user.id)
text = applied ? l(:label_unapply_project) : l(:label_apply_project) text = applied ? l(:label_unapply_project) : l(:label_apply_project)
@applied_flag = project.instance_of?(Project) @applied_flag = project.instance_of?(Project)
css = @applied_flag ? ([applied_css(project), applied ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : css = @applied_flag ? ([applied_css(project), applied ? 'icon ' : 'icon '].join(' ') << options[0].to_s) :
([applied_css(project), applied ? 'icon icon-applied ' : 'icon icon-applied-off '].join(' ') << options[0].to_s) ([applied_css(project), applied ? 'icon icon-applied ' : 'icon icon-applied-off '].join(' ') << options[0].to_s)
if applied if applied
appliedid = applied.id appliedid = applied.id
end end
url = appliedproject_path( url = appliedproject_path(
:id=>appliedid, :id=>appliedid,
:user_id => user.id, :user_id => user.id,
:project_id => project.id :project_id => project.id
) )
method = applied ? 'delete' : 'post' method = applied ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method ,:class=>css link_to text, url, :remote => true, :method => method ,:class=>css
end end
def exit_project_link(project) def exit_project_link(project)
link_to(l(:label_exit_project),exit_cur_project_path(project.id), link_to(l(:label_exit_project),exit_cur_project_path(project.id),
:remote => true, :confirm => l(:lable_sure_exit_project) ) :remote => true, :confirm => l(:lable_sure_exit_project) )
end end
end end

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

@ -1,155 +1,155 @@
<!-- fq --> <!-- 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_teacher = is_course_teacher(User.current,@bid.courses.first) %>
<!-- 当is_evaluation为1或者null(null主要是为了兼容前面数据)时代表启用互评功能2表示未启用 --> <!-- 当is_evaluation为1或者null(null主要是为了兼容前面数据)时代表启用互评功能2表示未启用 -->
<% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %> <% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %>
<%= form_tag(:controller => 'bids', :action => "show_courseEx", :method => :get) do %> <%= form_tag(:controller => 'bids', :action => "show_courseEx", :method => :get) do %>
<div class="project-search-block"> <div class="project-search-block">
<table width="100%" valign="center"> <table width="100%" valign="center">
<tr> <tr>
<td ><span style="margin-left:0px"><%= l(:label_task_plural)%>(<%= @homework_list.count%>)</span> <td ><span style="margin-left:0px"><%= l(:label_task_plural)%>(<%= @homework_list.count%>)</span>
<%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(is_teacher && @bid.homeworks.count > 0) %> <%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(is_teacher && @bid.homeworks.count > 0) %>
</td> </td>
<td align="right"> <td align="right">
<div class="project-search"> <div class="project-search">
<% if is_teacher %> <% if is_teacher %>
<%= text_field_tag 'student_id', params[:student_id], :size => 30 %> <%= text_field_tag 'student_id', params[:student_id], :size => 30 %>
<%= submit_tag l(:label_search_by_student_id), :class => "small", :name => nil %> <%= submit_tag l(:label_search_by_student_id), :class => "small", :name => nil %>
<% end %> <% end %>
</div> </div>
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>
<% end %> <% end %>
<% display_id = im_watching_student_id? @bid%> <% display_id = im_watching_student_id? @bid%>
<% @homework_list.each do |homework|%> <% @homework_list.each do |homework|%>
<table width="660px" border="0" align="center" id="homework_attach_<%= homework.id %>" > <table width="660px" border="0" align="center" id="homework_attach_<%= homework.id %>" >
<tr> <tr>
<td style="vertical-align: top;width: 70px" > <td style="vertical-align: top;width: 70px" >
<table style="text-align: center;width: 100%;table-layout: fixed"> <table style="text-align: center;width: 100%;table-layout: fixed">
<% user_name = is_teacher ? (homework.user.lastname + homework.user.firstname) : homework.user.login %> <% user_name = is_teacher ? (homework.user.lastname + homework.user.firstname) : homework.user.login %>
<tr> <tr>
<td title="<%= user_name %>"><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td> <td title="<%= user_name %>"><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
</tr> </tr>
<tr> <tr>
<td title="<%= user_name %>"> <td title="<%= user_name %>">
<p style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><strong> <p style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><strong>
<%= link_to user_name, user_path(homework.user),{:style => "color:#727272"} %> <%= link_to user_name, user_path(homework.user),{:style => "color:#727272"} %>
</strong></p> </strong></p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<% if (users_for_homework(homework).include?(User.current) || is_teacher) %> <% if (users_for_homework(homework).include?(User.current) || is_teacher) %>
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %> <%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
<% if homework.user == User.current || is_teacher %> <% if homework.user == User.current || is_teacher %>
<%= link_to(l(:label_bid_respond_delete), homework, <%= link_to(l(:label_bid_respond_delete), homework,
method: :delete, :confirm => l(:text_are_you_sure)) %> method: :delete, :confirm => l(:text_are_you_sure)) %>
<% end %> <% end %>
<% end %> <% end %>
</td> </td>
</tr> </tr>
</table> </table>
<span></span> <span></span>
</td> </td>
<td colspan="2"> <td colspan="2">
<table width="580px" border="0" style="table-layout: fixed"> <table width="580px" border="0" style="table-layout: fixed">
<tr> <tr>
<td style="width: 300px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"> <td style="width: 300px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<strong>作品名称:</strong>&nbsp; <strong>作品名称:</strong>&nbsp;
<% if homework.name == nil || homework.name == "" %> <% if homework.name == nil || homework.name == "" %>
<% homework_filename = homework.user.name + "提交的作业" %> <% homework_filename = homework.user.name + "提交的作业" %>
<% else %> <% else %>
<% homework_filename = homework.name %> <% homework_filename = homework.name %>
<% end %> <% end %>
<strong title="<%=homework_filename%>"> <strong title="<%=homework_filename%>">
<%= link_to homework_filename , homework_attach_path(homework)%> <%= link_to homework_filename , homework_attach_path(homework)%>
</strong> </strong>
</td> </td>
<td style="vertical-align: top;width: 200px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"> <td style="vertical-align: top;width: 200px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<strong>合作成员:&nbsp;</strong> <strong>合作成员:&nbsp;</strong>
<% homework_users = homework_user_of_homework(homework,is_teacher) %> <% homework_users = homework_user_of_homework(homework,is_teacher) %>
<% if homework.users.count == 0 %> <% if homework.users.count == 0 %>
<% else %> <% else %>
<span title="<%= homework_users%>"><%= homework_users %></span> <span title="<%= homework_users%>"><%= homework_users %></span>
<% end %> <% end %>
</td> </td>
<td rowspan="4" style="text-align: center;vertical-align: middle;width: 30px"> <td rowspan="4" style="text-align: center;vertical-align: middle;width: 30px">
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %> <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
<span class="required">迟交</span> <span class="required">迟交</span>
<% end %> <% end %>
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="width: 300px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"> <td style="width: 300px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<strong>开发项目</strong>:&nbsp; <strong>开发项目</strong>:&nbsp;
<% if homework.project != nil %> <% if homework.project != nil %>
<span title="<%= homework.project.name %>"> <span title="<%= homework.project.name %>">
<%= link_to homework.project.name,project_path(homework.project.id)%> <%= link_to homework.project.name,project_path(homework.project.id)%>
</span> </span>
<% else %> <% else %>
暂无 暂无
<% end %> <% end %>
</td> </td>
<td> <td>
<strong>项目得分:&nbsp; <strong>项目得分:&nbsp;
<span style="color: <%= homework.project.nil? ? "#727272" : "#EC6300"%>;"> <span style="color: <%= homework.project.nil? ? "#727272" : "#EC6300"%>;">
<%= homework.project.nil? ? "N/A" : project_scores(homework.project) %> <%= homework.project.nil? ? "N/A" : project_scores(homework.project) %>
</span> </span>
</strong> </strong>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<strong>提交文件:&nbsp; <strong>提交文件:&nbsp;
<% if is_evaluation || is_teacher%> <% if is_evaluation || is_teacher%>
<%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%> <%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%>
<% else %> <% else %>
<span class="required">未开启互评功能作业不允许下载</span> <span class="required">未开启互评功能作业不允许下载</span>
<% end %> <% end %>
</strong> </strong>
</td> </td>
<td> <td>
<strong>互评得分:&nbsp; <strong>互评得分:&nbsp;
<%# student_homework_score = student_score_for_homework(homework) %> <%# student_homework_score = student_score_for_homework(homework) %>
<span style="color:<%= homework.s_score.nil? ? "#727272" : "#EC6300"%>;"> <span style="color:<%= homework.s_score.nil? ? "#727272" : "#EC6300"%>;">
<% score = homework.s_score.nil? ? "N/A" : format("%.2f",homework.s_score) %> <% score = homework.s_score.nil? ? "N/A" : format("%.2f",homework.s_score) %>
<%= score %> <%= score %>
</span>&nbsp;&nbsp; </span>&nbsp;&nbsp;
<% if is_evaluation && is_student && (!users_for_homework(homework).include? User.current)%> <% if is_evaluation && is_student && (!users_for_homework(homework).include? User.current)%>
<%= link_to "学生互评>>",homework_attach_path(homework) %> <%= link_to "学生互评>>",homework_attach_path(homework) %>
<% end %> <% end %>
</strong> </strong>
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="vertical-align: top;width: 200px;"> <td style="vertical-align: top;width: 200px;">
<% if is_evaluation || is_teacher%> <% if is_evaluation || is_teacher%>
<%= render :partial => 'app_link', :locals => {:attachments => homework.attachments} %> <%= render :partial => 'app_link', :locals => {:attachments => homework.attachments} %>
<% end %> <% end %>
</td> </td>
<td> <td>
<strong>终评得分:&nbsp; <strong>终评得分:&nbsp;
<%# totle_homework_score = score_for_homework(homework) %> <%# totle_homework_score = score_for_homework(homework) %>
<% totle_homework_score = format("%.2f",(homework.t_score.nil? ? 0.00 : homework.t_score) * (@bid.proportion * 1.0 / 100) + (homework.s_score.nil? ? 0.00 : homework.s_score) * (1 - @bid.proportion * 1.0 / 100)) %> <% totle_homework_score = format("%.2f",(homework.t_score.nil? ? 0.00 : homework.t_score) * (@bid.proportion * 1.0 / 100) + (homework.s_score.nil? ? 0.00 : homework.s_score) * (1 - @bid.proportion * 1.0 / 100)) %>
<span style="color:<%= totle_homework_score == "0.00"? "#727272" : "#EC6300"%> ;"> <span style="color:<%= totle_homework_score == "0.00"? "#727272" : "#EC6300"%> ;">
<% score = totle_homework_score == "0.00"? "N/A" : totle_homework_score %> <% score = totle_homework_score == "0.00"? "N/A" : totle_homework_score %>
<%= score %> <%= score %>
</span>&nbsp;&nbsp; </span>&nbsp;&nbsp;
<% if is_teacher %> <% if is_teacher %>
<%= link_to "教师评分>>",homework_attach_path(homework) %> <%= link_to "教师评分>>",homework_attach_path(homework) %>
<% end %> <% end %>
</strong> </strong>
</td> </td>
</tr> </tr>
</table> </table>
</td> </td>
</tr> </tr>
</table> </table>
<div class="line_under"></div> <div class="line_under"></div>
<% end %> <% end %>

@ -1,122 +1,122 @@
<script type="text/javascript"> <script type="text/javascript">
function get_options(value) { function get_options(value) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: '/school/get_options/' + encodeURIComponent(value), url: '/school/get_options/' + encodeURIComponent(value),
data: 'text', data: 'text',
success: function (data) { success: function (data) {
$("#occupation").html(data); $("#occupation").html(data);
} }
}) })
} }
function check() { function check() {
var regex = /^\d*$/; var regex = /^\d*$/;
if (!regex.test($("#class_period").val())) { if (!regex.test($("#class_period").val())) {
alert("学时只能为整数"); alert("学时只能为整数");
} }
} }
</script> </script>
<% object = [] %> <% object = [] %>
<% object << 'course' %> <% object << 'course' %>
<%= error_messages_for object %> <%= error_messages_for object %>
<% unless @course.new_record? %> <% unless @course.new_record? %>
<p><%= render :partial => "avatar/avatar_form", :locals => {source: @course} %></p> <p><%= render :partial => "avatar/avatar_form", :locals => {source: @course} %></p>
<% end %> <% end %>
<p> <p>
<label for="course_name" style="font-size: 13px;"> <label for="course_name" style="font-size: 13px;">
<%= l(:label_tags_course_name) %> <%= l(:label_tags_course_name) %>
<span class="required">*&nbsp;&nbsp;</span> <span class="required">*&nbsp;&nbsp;</span>
</label> </label>
<input id="course_name" type="text" value="<%= @course.name %>" style="width:490px;size:60;" name = "course[name]" maxlength="100"> <input id="course_name" type="text" value="<%= @course.name %>" style="width:490px;size:60;" name = "course[name]" maxlength="100">
</p> </p>
<%= f.fields_for @course do |m| %> <%= f.fields_for @course do |m| %>
<% unless @course.nil? %> <% unless @course.nil? %>
<p> <p>
<table> <table>
<tr> <tr>
<td> <td>
<span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:22px"><%= l(:label_class_period) %> <span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:22px"><%= l(:label_class_period) %>
<span class="required"> *&nbsp;&nbsp;</span></span> <span class="required"> *&nbsp;&nbsp;</span></span>
<span class="info" style="width: 10px;"><%= text_field_tag :class_period, @course.class_period, :placeholder => "在此输入课时", :maxlength => 5 %></span> <span class="info" style="width: 10px;"><%= text_field_tag :class_period, @course.class_period, :placeholder => "在此输入课时", :maxlength => 5 %></span>
<span>&nbsp;<strong><%= l(:label_class_hour) %></strong></span> <span>&nbsp;<strong><%= l(:label_class_hour) %></strong></span>
</td> </td>
</tr> </tr>
</table> </table>
</p> </p>
<% else %> <% else %>
<p> <p>
<table> <table>
<tr> <tr>
<td> <td>
<span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:22px"><%= l(:label_class_period) %> <span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:22px"><%= l(:label_class_period) %>
<span class="required"> *&nbsp;&nbsp;</span></span> <span class="required"> *&nbsp;&nbsp;</span></span>
<span class="info" style="width: 10px;"><%= text_field_tag :class_period, nil, :placeholder => "在此输入课时", :maxlength => 5 %></span><strong><%= l(:label_class_hour) %></strong> <span class="info" style="width: 10px;"><%= text_field_tag :class_period, nil, :placeholder => "在此输入课时", :maxlength => 5 %></span><strong><%= l(:label_class_hour) %></strong>
</td> </td>
</tr> </tr>
</table> </table>
</p> </p>
<% end %> <% end %>
<p> <p>
<table> <table>
<tr> <tr>
<td> <td>
<% if @course != nil %> <% if @course != nil %>
<table> <table>
<tr> <tr>
<td class="info" align="right" style="width: 86px"> <td class="info" align="right" style="width: 86px">
<strong><%= l(:label_term) %><span class="required"> *&nbsp;&nbsp;</span></strong> <strong><%= l(:label_term) %><span class="required"> *&nbsp;&nbsp;</span></strong>
</td> </td>
<td class="info" style="width: 10px"> <td class="info" style="width: 10px">
<%= select_tag :time,options_for_select(course_time_option,@course.time), {} %> <%= select_tag :time,options_for_select(course_time_option,@course.time), {} %>
</td> </td>
<td class="info" style="width: 10px"> <td class="info" style="width: 10px">
<%= select_tag :term,options_for_select(course_term_option,@course.term),{} %> <%= select_tag :term,options_for_select(course_term_option,@course.term),{} %>
</td> </td>
</tr> </tr>
</table> </table>
<% end %> <% end %>
</td> </td>
</tr> </tr>
</table> </table>
</p> </p>
<p style="margin-left:-10px;"> <p style="margin-left:-10px;">
<label for="course[course]_password" style="font-size: 13px;"><%= l(:label_new_course_password) %> <label for="course[course]_password" style="font-size: 13px;"><%= l(:label_new_course_password) %>
<span class="required">*</span> <span class="required">*</span>
</label> </label>
<input id="course_course_password" type="text" style="width:488px;margin-left: 10px;" value="<%= @course.password %>" size="60" name="course[password]"/> <input id="course_course_password" type="text" style="width:488px;margin-left: 10px;" value="<%= @course.password %>" size="60" name="course[password]"/>
</p> </p>
<em class="info" style="margin-left:95px;"><%= l(:text_command) %></em> <em class="info" style="margin-left:95px;"><%= l(:text_command) %></em>
<% end %> <% end %>
<p style="padding-right: 20px;"> <p style="padding-right: 20px;">
<label for="course_description" style="font-size: 13px;"> <label for="course_description" style="font-size: 13px;">
<%= l(:label_new_course_description) %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <%= l(:label_new_course_description) %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</label> </label>
<span class="jstEditor"> <span class="jstEditor">
<textarea id="course_description" class="wiki-edit" style="font-size:small;width:490px;margin-left:10px;" rows="8" name="course[description]" cols="40"> <textarea id="course_description" class="wiki-edit" style="font-size:small;width:490px;margin-left:10px;" rows="8" name="course[description]" cols="40">
<%= @course.description %> <%= @course.description %>
</textarea> </textarea>
</span> </span>
</p> </p>
<p style="margin-left:-10px;"> <p style="margin-left:-10px;">
<em style="color: #888888;display: block;font-size: 90%;font-style: normal;"> <em style="color: #888888;display: block;font-size: 90%;font-style: normal;">
<%= f.check_box :is_public, :style => "margin-left:10px;" %> <%= f.check_box :is_public, :style => "margin-left:10px;" %>
<%= l(:label_course_public_info) %> <%= l(:label_course_public_info) %>
</em> </em>
</p><!-- modified by bai --> </p><!-- modified by bai -->
<p style="display:none;"><%= f.text_field :course_type, :value => 1 %></p> <p style="display:none;"><%= f.text_field :course_type, :value => 1 %></p>
<%= wikitoolbar_for 'course_description' %> <%= wikitoolbar_for 'course_description' %>
<% @course.custom_field_values.each do |value| %> <% @course.custom_field_values.each do |value| %>
<p><%= custom_field_tag_with_label :course, value %></p> <p><%= custom_field_tag_with_label :course, value %></p>
<% end %> <% end %>
<%= call_hook(:view_courses_form, :course => @course, :form => f) %> <%= call_hook(:view_courses_form, :course => @course, :form => f) %>
<!--[eoform:course]--> <!--[eoform:course]-->
<% unless @course.extra_frozen? %> <% unless @course.extra_frozen? %>
<% content_for :header_tags do %> <% content_for :header_tags do %>
<%= javascript_include_tag 'course_identifier' %> <%= javascript_include_tag 'course_identifier' %>
<% end %> <% end %>
<% end %> <% end %>

@ -1,105 +1,105 @@
<%= error_messages_for 'member' %> <%= error_messages_for 'member' %>
<% <%
roles = Role.givable.all roles = Role.givable.all
roles = roles[3..5] roles = roles[3..5]
members = @course.member_principals.includes(:roles, :principal).all.sort members = @course.member_principals.includes(:roles, :principal).all.sort
%> %>
<div class="splitcontentleft"> <div class="splitcontentleft">
<% if members.any? %> <% if members.any? %>
<table class="list members"> <table class="list members">
<thead> <thead>
<tr> <tr>
<th><%= l(:label_user) %></th> <th><%= l(:label_user) %></th>
<th><%= l(:label_role_plural) %></th> <th><%= l(:label_role_plural) %></th>
<th style="width:15%"></th> <th style="width:15%"></th>
<%= call_hook(:view_projects_settings_members_table_header, :course => @course) %> <%= call_hook(:view_projects_settings_members_table_header, :course => @course) %>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% members.each do |member| %> <% members.each do |member| %>
<% next if member.new_record? %> <% next if member.new_record? %>
<tr id="member-<%= member.id %>" class="<%= cycle 'odd', 'even' %> member"> <tr id="member-<%= member.id %>" class="<%= cycle 'odd', 'even' %> member">
<td class="<%= member.principal.class.name.downcase %>"> <td class="<%= member.principal.class.name.downcase %>">
<%= link_to_user member.principal %> <%= link_to_user member.principal %>
</td> </td>
<td class="roles"> <td class="roles">
<span id="member-<%= member.id %>-roles"> <span id="member-<%= member.id %>-roles">
<%= h member.roles.sort.collect(&:to_s).join(', ') %> <%= h member.roles.sort.collect(&:to_s).join(', ') %>
</span> </span>
<%= form_for(member, {:as => :membership, :remote => true, <%= form_for(member, {:as => :membership, :remote => true,
:url => course_memberships_path(member),:method => :put, :url => course_memberships_path(member),:method => :put,
:html => {:id => "member-#{member.id}-roles-form", :html => {:id => "member-#{member.id}-roles-form",
:class => 'hol'}} :class => 'hol'}}
) do |f| %> ) do |f| %>
<p> <p>
<% roles.each do |role| %> <% roles.each do |role| %>
<label> <label>
<%= radio_button_tag 'membership[role_ids][]', role.id, member.roles.include?(role),:disabled => member.member_roles.detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? } %> <%= radio_button_tag 'membership[role_ids][]', role.id, member.roles.include?(role),:disabled => member.member_roles.detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? } %>
<%= h role %> <%= h role %>
</label> </label>
<br/> <br/>
<% end %> <% end %>
</p> </p>
<%= hidden_field_tag 'membership[role_ids][]', '' %> <%= hidden_field_tag 'membership[role_ids][]', '' %>
<p> <p>
<%= submit_tag l(:button_change), :class => "small" %> <%= submit_tag l(:button_change), :class => "small" %>
<%= link_to_function l(:button_cancel), <%= link_to_function l(:button_cancel),
"$('#member-#{member.id}-roles').show(); $('#member-#{member.id}-roles-form').hide(); return false;" "$('#member-#{member.id}-roles').show(); $('#member-#{member.id}-roles-form').hide(); return false;"
%> %>
</p> </p>
<% end %> <% end %>
</td> </td>
<!--modified by huang for: if the user'roles is Manager that he will can't modified himself--> <!--modified by huang for: if the user'roles is Manager that he will can't modified himself-->
<% if member.roles.first.to_s == "Manager" %> <% if member.roles.first.to_s == "Manager" %>
<td class="buttons"></td> <td class="buttons"></td>
<% else %> <% else %>
<td class="buttons"> <td class="buttons">
<%= link_to_function l(:button_edit), <%= link_to_function l(:button_edit),
"$('#member-#{member.id}-roles').hide(); $('#member-#{member.id}-roles-form').show(); return false;", "$('#member-#{member.id}-roles').hide(); $('#member-#{member.id}-roles-form').show(); return false;",
:class => 'icon icon-edit' %> :class => 'icon icon-edit' %>
<%= delete_link membership_path(member), <%= delete_link membership_path(member),
:remote => true, :remote => true,
:data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %> :data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %>
</td> </td>
<% end %> <% end %>
<!--end--> <!--end-->
<%= call_hook(:view_projects_settings_members_table_header, {:course => @course, :member => member}) %> <%= call_hook(:view_projects_settings_members_table_header, {:course => @course, :member => member}) %>
</tr> </tr>
<% end; reset_cycle %> <% end; reset_cycle %>
</tbody> </tbody>
</table> </table>
<% else %> <% else %>
<p class="nodata"><%= l(:label_no_data) %></p> <p class="nodata"><%= l(:label_no_data) %></p>
<% end %> <% end %>
</div> </div>
<div class="splitcontentright"> <div class="splitcontentright">
<% if roles.any? %> <% if roles.any? %>
<%= form_for(@member, {:as => :membership, :url => course_memberships_path(@course), :remote => true, :method => :post}) do |f| %> <%= form_for(@member, {:as => :membership, :url => course_memberships_path(@course), :remote => true, :method => :post}) do |f| %>
<fieldset> <fieldset>
<legend><%= l(:label_member_new) %></legend> <legend><%= l(:label_member_new) %></legend>
<p> <p>
<%= label_tag "principal_search", l(:label_principal_search) %> <%= label_tag "principal_search", l(:label_principal_search) %>
<%= text_field_tag 'principal_search', nil %> <%= text_field_tag 'principal_search', nil %>
</p> </p>
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_course_memberships_path(@course, :format => 'js') }')" %> <%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_course_memberships_path(@course, :format => 'js') }')" %>
<div id="principals_for_new_member"> <div id="principals_for_new_member">
<%= render_principals_for_new_course_members(@course) %> <%= render_principals_for_new_course_members(@course) %>
</div> </div>
<br/> <br/>
<!--show the roles which will select--> <!--show the roles which will select-->
<p style="padding-top: 5px"><%= l(:label_role_plural) %>: <p style="padding-top: 5px"><%= l(:label_role_plural) %>:
<% roles.each do |role| %> <% roles.each do |role| %>
<label> <label>
<%= radio_button_tag 'membership[role_ids][]', role.id %> <%= radio_button_tag 'membership[role_ids][]', role.id %>
<%= h role %> <%= h role %>
</label> </label>
<% end %> <% end %>
</p> </p>
<p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p> <p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p>
</fieldset> </fieldset>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>

@ -1,22 +1,22 @@
<div style="margin-left: 20px;"> <div style="margin-left: 20px;">
<% if ( !(User.current.member_of? @project) && User.current.login?) %> <!--added by linchun--> <% if ( !(User.current.member_of? @project) && User.current.login?) %> <!--added by linchun-->
<span class="icon-fav icon"></span><%= watcher_link(@project, User.current) %> <span class="icon-fav icon"></span><%= watcher_link(@project, User.current) %>
<% end %> <% end %>
</div> </div>
<!--添加项目申请--> <!--添加项目申请-->
<div style="margin-left: 20px;"> <div style="margin-left: 20px;">
<% if ( !(User.current.member_of? @project) && User.current.login?) %> <% if ( !(User.current.member_of? @project) && User.current.login?) %>
<span class="icon-fav icon"></span> <span class="icon-fav icon"></span>
<%= applied_link(@project, User.current) %> <%= applied_link(@project, User.current) %>
<% end %> <% end %>
</div> </div>
<!--添加退出项目--> <!--添加退出项目-->
<div style="margin-left: 20px;"> <div style="margin-left: 20px;">
<% if ((User.current.member_of? @project) && <% if ((User.current.member_of? @project) &&
User.current.login? && User.current.login? &&
Member.where(:user_id => User.current.id, :project_id=>@project.id).first.roles.first.to_s != "Manager") %> Member.where(:user_id => User.current.id, :project_id=>@project.id).first.roles.first.to_s != "Manager") %>
<%= exit_project_link(@project) %> <%= exit_project_link(@project) %>
<% end %> <% end %>
</div> </div>

@ -1,69 +1,69 @@
<%= error_messages_for 'role' %> <%= error_messages_for 'role' %>
<% unless @role.anonymous? %> <% unless @role.anonymous? %>
<div class="box tabular"> <div class="box tabular">
<% unless @role.builtin? %> <% unless @role.builtin? %>
<p><%= f.text_field :name, :required => true %></p> <p><%= f.text_field :name, :required => true %></p>
<p><%= f.check_box :assignable %></p> <p><%= f.check_box :assignable %></p>
<% end %> <% end %>
<p><%= f.select :issues_visibility, Role::ISSUES_VISIBILITY_OPTIONS.collect {|v| [l(v.last), v.first]} %></p> <p><%= f.select :issues_visibility, Role::ISSUES_VISIBILITY_OPTIONS.collect {|v| [l(v.last), v.first]} %></p>
<% if @role.new_record? && @roles.any? %> <% if @role.new_record? && @roles.any? %>
<p><label for="copy_workflow_from"><%= l(:label_copy_workflow_from) %></label> <p><label for="copy_workflow_from"><%= l(:label_copy_workflow_from) %></label>
<%= select_tag(:copy_workflow_from, content_tag("option") + options_from_collection_for_select(@roles, :id, :name, params[:copy_workflow_from] || @copy_from.try(:id))) %></p> <%= select_tag(:copy_workflow_from, content_tag("option") + options_from_collection_for_select(@roles, :id, :name, params[:copy_workflow_from] || @copy_from.try(:id))) %></p>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
<h3><%= l(:label_permissions) %></h3> <h3><%= l(:label_permissions) %></h3>
<div class="box tabular" id="permissions"> <div class="box tabular" id="permissions">
<% perms_by_module = @role.setable_permissions.group_by {|p| p.project_module.to_s} %> <% perms_by_module = @role.setable_permissions.group_by {|p| p.project_module.to_s} %>
<% perms_by_module.keys.sort.each do |mod| %> <% perms_by_module.keys.sort.each do |mod| %>
<% if mod.blank? %> <% if mod.blank? %>
<fieldset> <fieldset>
<legend><%= l(:label_project) %></legend> <legend><%= l(:label_project) %></legend>
<% perms_by_module[mod].each do |permission| %> <% perms_by_module[mod].each do |permission| %>
<% if permission.belong_to_project? %> <% if permission.belong_to_project? %>
<label class="floating"> <label class="floating">
<%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %> <%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %>
<%= l_or_humanize(permission.name, :prefix => 'permission_') %> <%= l_or_humanize(permission.name, :prefix => 'permission_') %>
</label> </label>
<% end %> <% end %>
<% end %> <% end %>
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend><%= l(:label_course) %></legend> <legend><%= l(:label_course) %></legend>
<% perms_by_module[mod].each do |permission| %> <% perms_by_module[mod].each do |permission| %>
<% if permission.belong_to_course? %> <% if permission.belong_to_course? %>
<label class="floating"> <label class="floating">
<%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %> <%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %>
<%= l_or_humanize(permission.name, :prefix => 'permission_') %> <%= l_or_humanize(permission.name, :prefix => 'permission_') %>
</label> </label>
<% end %> <% end %>
<% end %> <% end %>
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend><%= l(:label_contest) %></legend> <legend><%= l(:label_contest) %></legend>
<% perms_by_module[mod].each do |permission| %> <% perms_by_module[mod].each do |permission| %>
<% if permission.belong_to_contest? %> <% if permission.belong_to_contest? %>
<label class="floating"> <label class="floating">
<%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %> <%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %>
<%= l_or_humanize(permission.name, :prefix => 'permission_') %> <%= l_or_humanize(permission.name, :prefix => 'permission_') %>
</label> </label>
<% end %> <% end %>
<% end %> <% end %>
</fieldset> </fieldset>
<% else %> <% else %>
<fieldset> <fieldset>
<legend><%= l_or_humanize(mod, :prefix => 'project_module_') %></legend> <legend><%= l_or_humanize(mod, :prefix => 'project_module_') %></legend>
<% perms_by_module[mod].each do |permission| %> <% perms_by_module[mod].each do |permission| %>
<label class="floating"> <label class="floating">
<%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %> <%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %>
<%= l_or_humanize(permission.name, :prefix => 'permission_') %> <%= l_or_humanize(permission.name, :prefix => 'permission_') %>
</label> </label>
<% end %> <% end %>
</fieldset> </fieldset>
<% end %> <% end %>
<% end %> <% end %>
<br /><%= check_all_links 'permissions' %> <br /><%= check_all_links 'permissions' %>
<%= hidden_field_tag 'role[permissions][]', '' %> <%= hidden_field_tag 'role[permissions][]', '' %>
</div> </div>

@ -1,149 +1,149 @@
<h3><%= link_to l(:label_role_plural), roles_path %> &#187; <%=l(:label_permissions_report)%></h3> <h3><%= link_to l(:label_role_plural), roles_path %> &#187; <%=l(:label_permissions_report)%></h3>
<%= form_tag(permissions_roles_path, :id => 'permissions_form') do %> <%= form_tag(permissions_roles_path, :id => 'permissions_form') do %>
<%= hidden_field_tag 'permissions[0]', '', :id => nil %> <%= hidden_field_tag 'permissions[0]', '', :id => nil %>
<div class="autoscroll"> <div class="autoscroll">
<table class="list permissions"> <table class="list permissions">
<thead> <thead>
<tr> <tr>
<th><%=l(:label_permissions)%></th> <th><%=l(:label_permissions)%></th>
<% @roles.each do |role| %> <% @roles.each do |role| %>
<th> <th>
<%= content_tag(role.builtin? ? 'em' : 'span', h(role.name)) %> <%= content_tag(role.builtin? ? 'em' : 'span', h(role.name)) %>
<%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('input.role-#{role.id}')", <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('input.role-#{role.id}')",
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %>
</th> </th>
<% end %> <% end %>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% perms_by_module = @permissions.group_by {|p| p.project_module.to_s} %> <% perms_by_module = @permissions.group_by {|p| p.project_module.to_s} %>
<% perms_by_module.keys.sort.each do |mod| %> <% perms_by_module.keys.sort.each do |mod| %>
<% if mod.blank? %> <% if mod.blank? %>
<% perms_by_module[mod].select{ |p| !(p.belong_to_project?) && !(p.belong_to_course?) && !(p.belong_to_contest?) }.each do |permission| %> <% perms_by_module[mod].select{ |p| !(p.belong_to_project?) && !(p.belong_to_course?) && !(p.belong_to_contest?) }.each do |permission| %>
<tr class="<%= cycle('odd', 'even') %> permission-<%= permission.name %>"> <tr class="<%= cycle('odd', 'even') %> permission-<%= permission.name %>">
<td> <td>
<%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')",
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %>
<%= l_or_humanize(permission.name, :prefix => 'permission_') %> <%= l_or_humanize(permission.name, :prefix => 'permission_') %>
</td> </td>
<% @roles.each do |role| %> <% @roles.each do |role| %>
<td align="center"> <td align="center">
<% if role.setable_permissions.include? permission %> <% if role.setable_permissions.include? permission %>
<%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %>
<% end %> <% end %>
</td> </td>
<% end %> <% end %>
</tr> </tr>
<% end %> <% end %>
<tr class="group open"> <tr class="group open">
<td> <td>
<span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span> <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
<%= l(:label_project) %> <%= l(:label_project) %>
</td> </td>
<% @roles.each do |role| %> <% @roles.each do |role| %>
<td class="role"><%= h(role.name) %></td> <td class="role"><%= h(role.name) %></td>
<% end %> <% end %>
</tr> </tr>
<% perms_by_module[mod].select{ |p| p.belong_to_project? }.each do |permission| %> <% perms_by_module[mod].select{ |p| p.belong_to_project? }.each do |permission| %>
<tr class="<%= cycle('odd', 'even') %> permission-<%= permission.name %>"> <tr class="<%= cycle('odd', 'even') %> permission-<%= permission.name %>">
<td> <td>
<%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')",
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %>
<%= l_or_humanize(permission.name, :prefix => 'permission_') %> <%= l_or_humanize(permission.name, :prefix => 'permission_') %>
</td> </td>
<% @roles.each do |role| %> <% @roles.each do |role| %>
<td align="center"> <td align="center">
<% if role.setable_permissions.include? permission %> <% if role.setable_permissions.include? permission %>
<%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %>
<% end %> <% end %>
</td> </td>
<% end %> <% end %>
</tr> </tr>
<% end %> <% end %>
<tr class="group open"> <tr class="group open">
<td> <td>
<span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span> <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
<%= l(:label_course) %> <%= l(:label_course) %>
</td> </td>
<% @roles.each do |role| %> <% @roles.each do |role| %>
<td class="role"><%= h(role.name) %></td> <td class="role"><%= h(role.name) %></td>
<% end %> <% end %>
</tr> </tr>
<% perms_by_module[mod].select{ |p| p.belong_to_course? }.each do |permission| %> <% perms_by_module[mod].select{ |p| p.belong_to_course? }.each do |permission| %>
<tr class="<%= cycle('odd', 'even') %> permission-<%= permission.name %>"> <tr class="<%= cycle('odd', 'even') %> permission-<%= permission.name %>">
<td> <td>
<%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')",
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %>
<%= l_or_humanize(permission.name, :prefix => 'permission_') %> <%= l_or_humanize(permission.name, :prefix => 'permission_') %>
</td> </td>
<% @roles.each do |role| %> <% @roles.each do |role| %>
<td align="center"> <td align="center">
<% if role.setable_permissions.include? permission %> <% if role.setable_permissions.include? permission %>
<%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %>
<% end %> <% end %>
</td> </td>
<% end %> <% end %>
</tr> </tr>
<% end %> <% end %>
<tr class="group open"> <tr class="group open">
<td> <td>
<span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span> <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
<%= l(:label_contest) %> <%= l(:label_contest) %>
</td> </td>
<% @roles.each do |role| %> <% @roles.each do |role| %>
<td class="role"><%= h(role.name) %></td> <td class="role"><%= h(role.name) %></td>
<% end %> <% end %>
</tr> </tr>
<% perms_by_module[mod].select{ |p| p.belong_to_contest? }.each do |permission| %> <% perms_by_module[mod].select{ |p| p.belong_to_contest? }.each do |permission| %>
<tr class="<%= cycle('odd', 'even') %> permission-<%= permission.name %>"> <tr class="<%= cycle('odd', 'even') %> permission-<%= permission.name %>">
<td> <td>
<%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')",
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %>
<%= l_or_humanize(permission.name, :prefix => 'permission_') %> <%= l_or_humanize(permission.name, :prefix => 'permission_') %>
</td> </td>
<% @roles.each do |role| %> <% @roles.each do |role| %>
<td align="center"> <td align="center">
<% if role.setable_permissions.include? permission %> <% if role.setable_permissions.include? permission %>
<%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %>
<% end %> <% end %>
</td> </td>
<% end %> <% end %>
</tr> </tr>
<% end %> <% end %>
<% else %> <% else %>
<tr class="group open"> <tr class="group open">
<td> <td>
<span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span> <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
<%= l_or_humanize(mod, :prefix => 'project_module_') %> <%= l_or_humanize(mod, :prefix => 'project_module_') %>
</td> </td>
<% @roles.each do |role| %> <% @roles.each do |role| %>
<td class="role"><%= h(role.name) %></td> <td class="role"><%= h(role.name) %></td>
<% end %> <% end %>
</tr> </tr>
<% perms_by_module[mod].each do |permission| %> <% perms_by_module[mod].each do |permission| %>
<tr class="<%= cycle('odd', 'even') %> permission-<%= permission.name %>"> <tr class="<%= cycle('odd', 'even') %> permission-<%= permission.name %>">
<td> <td>
<%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')", <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('.permission-#{permission.name} input')",
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %> :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %>
<%= l_or_humanize(permission.name, :prefix => 'permission_') %> <%= l_or_humanize(permission.name, :prefix => 'permission_') %>
</td> </td>
<% @roles.each do |role| %> <% @roles.each do |role| %>
<td align="center"> <td align="center">
<% if role.setable_permissions.include? permission %> <% if role.setable_permissions.include? permission %>
<%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %> <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %>
<% end %> <% end %>
</td> </td>
<% end %> <% end %>
</tr> </tr>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
</div> </div>
<p><%= check_all_links 'permissions_form' %></p> <p><%= check_all_links 'permissions_form' %></p>
<p><%= submit_tag l(:button_save) %></p> <p><%= submit_tag l(:button_save) %></p>
<% end %> <% end %>

@ -1,481 +1,481 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2013 Jean-Philippe Lang # Copyright (C) 2006-2013 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'redmine/core_ext' require 'redmine/core_ext'
begin begin
require 'RMagick' unless Object.const_defined?(:Magick) require 'RMagick' unless Object.const_defined?(:Magick)
rescue LoadError rescue LoadError
# RMagick is not available # RMagick is not available
end end
require 'redmine/scm/base' require 'redmine/scm/base'
require 'redmine/access_control' require 'redmine/access_control'
require 'redmine/access_keys' require 'redmine/access_keys'
require 'redmine/activity' require 'redmine/activity'
require 'redmine/activity/fetcher' require 'redmine/activity/fetcher'
require 'redmine/ciphering' require 'redmine/ciphering'
require 'redmine/codeset_util' require 'redmine/codeset_util'
require 'redmine/custom_field_format' require 'redmine/custom_field_format'
require 'redmine/i18n' require 'redmine/i18n'
require 'redmine/menu_manager' require 'redmine/menu_manager'
require 'redmine/notifiable' require 'redmine/notifiable'
require 'redmine/platform' require 'redmine/platform'
require 'redmine/mime_type' require 'redmine/mime_type'
require 'redmine/notifiable' require 'redmine/notifiable'
require 'redmine/search' require 'redmine/search'
require 'redmine/syntax_highlighting' require 'redmine/syntax_highlighting'
require 'redmine/thumbnail' require 'redmine/thumbnail'
require 'redmine/unified_diff' require 'redmine/unified_diff'
require 'redmine/utils' require 'redmine/utils'
require 'redmine/version' require 'redmine/version'
require 'redmine/wiki_formatting' require 'redmine/wiki_formatting'
require 'redmine/default_data/loader' require 'redmine/default_data/loader'
require 'redmine/helpers/calendar' require 'redmine/helpers/calendar'
require 'redmine/helpers/diff' require 'redmine/helpers/diff'
require 'redmine/helpers/gantt' require 'redmine/helpers/gantt'
require 'redmine/helpers/time_report' require 'redmine/helpers/time_report'
require 'redmine/views/other_formats_builder' require 'redmine/views/other_formats_builder'
require 'redmine/views/labelled_form_builder' require 'redmine/views/labelled_form_builder'
require 'redmine/views/builders' require 'redmine/views/builders'
require 'redmine/themes' require 'redmine/themes'
require 'redmine/hook' require 'redmine/hook'
require 'redmine/plugin' require 'redmine/plugin'
if RUBY_VERSION < '1.9' if RUBY_VERSION < '1.9'
require 'fastercsv' require 'fastercsv'
else else
require 'csv' require 'csv'
FCSV = CSV FCSV = CSV
end end
Redmine::Scm::Base.add "Subversion" Redmine::Scm::Base.add "Subversion"
Redmine::Scm::Base.add "Darcs" Redmine::Scm::Base.add "Darcs"
Redmine::Scm::Base.add "Mercurial" Redmine::Scm::Base.add "Mercurial"
Redmine::Scm::Base.add "Cvs" Redmine::Scm::Base.add "Cvs"
Redmine::Scm::Base.add "Bazaar" Redmine::Scm::Base.add "Bazaar"
Redmine::Scm::Base.add "Git" Redmine::Scm::Base.add "Git"
Redmine::Scm::Base.add "Filesystem" Redmine::Scm::Base.add "Filesystem"
Redmine::CustomFieldFormat.map do |fields| Redmine::CustomFieldFormat.map do |fields|
fields.register 'string' fields.register 'string'
fields.register 'text' fields.register 'text'
fields.register 'int', :label => :label_integer fields.register 'int', :label => :label_integer
fields.register 'float' fields.register 'float'
fields.register 'list' fields.register 'list'
fields.register 'date' fields.register 'date'
fields.register 'bool', :label => :label_boolean fields.register 'bool', :label => :label_boolean
fields.register 'user', :only => %w(Issue TimeEntry Version Project), :edit_as => 'list' fields.register 'user', :only => %w(Issue TimeEntry Version Project), :edit_as => 'list'
fields.register 'version', :only => %w(Issue TimeEntry Version Project), :edit_as => 'list' fields.register 'version', :only => %w(Issue TimeEntry Version Project), :edit_as => 'list'
end end
# Permissions # Permissions
Redmine::AccessControl.map do |map| Redmine::AccessControl.map do |map|
map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true, :read => true map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true, :read => true
map.permission :search_project, {:search => :index}, :public => true, :read => true map.permission :search_project, {:search => :index}, :public => true, :read => true
map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin ,:belong_to_project => true map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin ,:belong_to_project => true
map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member ,:belong_to_project => true map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member ,:belong_to_project => true
map.permission :close_project, {:projects => [:close, :reopen]}, :require => :member, :read => true ,:belong_to_project => true map.permission :close_project, {:projects => [:close, :reopen]}, :require => :member, :read => true ,:belong_to_project => true
map.permission :select_project_modules, {:projects => :modules}, :require => :member ,:belong_to_project => true map.permission :select_project_modules, {:projects => :modules}, :require => :member ,:belong_to_project => true
map.permission :select_contest_modules, {:contests => :modules}, :require => :member ,:belong_to_contest => true map.permission :select_contest_modules, {:contests => :modules}, :require => :member ,:belong_to_contest => true
map.permission :manage_members, {:projects => :settings, :members => [:index, :show, :create, :update, :destroy, :autocomplete]}, :require => :member ,:belong_to_project => true map.permission :manage_members, {:projects => :settings, :members => [:index, :show, :create, :update, :destroy, :autocomplete]}, :require => :member ,:belong_to_project => true
map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member ,:belong_to_project => true map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member ,:belong_to_project => true
map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member ,:belong_to_project => true map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member ,:belong_to_project => true
#错的权限,先注释掉 #错的权限,先注释掉
#map.permission :view_journals_for_messages, {:gantts => [:show, :update]}, :read => true #map.permission :view_journals_for_messages, {:gantts => [:show, :update]}, :read => true
map.permission :quote_project, {},:require => :member,:belong_to_contest => true map.permission :quote_project, {},:require => :member,:belong_to_contest => true
map.permission :is_manager,{},:require => :member ,:belong_to_project => true map.permission :is_manager,{},:require => :member ,:belong_to_project => true
map.permission :as_teacher,{},:require => :member ,:belong_to_course => true map.permission :as_teacher,{},:require => :member ,:belong_to_course => true
map.permission :as_student,{},:require => :member ,:belong_to_course => true map.permission :as_student,{},:require => :member ,:belong_to_course => true
#课程权限模块 #课程权限模块
map.permission :view_course, {:courses => [:show], :activities => [:index]}, :public => true, :read => true map.permission :view_course, {:courses => [:show], :activities => [:index]}, :public => true, :read => true
map.permission :search_course, {:search => :index}, :public => true, :read => true map.permission :search_course, {:search => :index}, :public => true, :read => true
map.permission :add_course, {:courses => [:new, :create]}, :require => :loggedin ,:belong_to_course => true map.permission :add_course, {:courses => [:new, :create]}, :require => :loggedin ,:belong_to_course => true
map.permission :edit_course, {:courses => [:settings, :edit, :update]}, :require => :member ,:belong_to_course => true map.permission :edit_course, {:courses => [:settings, :edit, :update]}, :require => :member ,:belong_to_course => true
map.permission :close_course, {:courses => [:close, :reopen]}, :require => :member, :read => true ,:belong_to_course => true map.permission :close_course, {:courses => [:close, :reopen]}, :require => :member, :read => true ,:belong_to_course => true
map.permission :select_course_modules, {:courses => :modules}, :require => :member ,:belong_to_course => true map.permission :select_course_modules, {:courses => :modules}, :require => :member ,:belong_to_course => true
map.permission :view_course_journals_for_messages, {:courses => :feedback}, :require => :member,:read => true ,:belong_to_course => true map.permission :view_course_journals_for_messages, {:courses => :feedback}, :require => :member,:read => true ,:belong_to_course => true
map.permission :memos_attachments_download,{:attachments => :download} map.permission :memos_attachments_download,{:attachments => :download}
map.permission :projects_attachments_download,{:attachments => :download},:belong_to_project => true map.permission :projects_attachments_download,{:attachments => :download},:belong_to_project => true
map.permission :course_attachments_download,{:attachments => :download},:belong_to_course => true map.permission :course_attachments_download,{:attachments => :download},:belong_to_course => true
map.permission :contest_attachments_download,{:attachments => :download},:belong_to_contest => true map.permission :contest_attachments_download,{:attachments => :download},:belong_to_contest => true
#与项目一致,注释掉 #与项目一致,注释掉
#map.course_module :files do |map| #map.course_module :files do |map|
# map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin # map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin
# map.permission :view_course_files, {:files => :index, :versions => :download}, :read => true # map.permission :view_course_files, {:files => :index, :versions => :download}, :read => true
#end #end
#新闻权限与项目一致注释掉此处 #新闻权限与项目一致注释掉此处
# map.course_module :news do |map| # map.course_module :news do |map|
# map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member # map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member
# map.permission :view_course_news, {:news => [:index, :show]}, :public => true, :read => true # map.permission :view_course_news, {:news => [:index, :show]}, :public => true, :read => true
# map.permission :comment_news, {:comments => :create} # map.permission :comment_news, {:comments => :create}
# end # end
map.course_module :bids do |map| map.course_module :bids do |map|
map.permission :view_homework_attaches, {:bids => [:show, :show_project, :revision]}, :read => true,:belong_to_course => true map.permission :view_homework_attaches, {:bids => [:show, :show_project, :revision]}, :read => true,:belong_to_course => true
map.permission :paret_in_homework,{},:require => :member ,:belong_to_course => true map.permission :paret_in_homework,{},:require => :member ,:belong_to_course => true
end end
#讨论区权限与项目统一,注释掉此课程讨论区权限 #讨论区权限与项目统一,注释掉此课程讨论区权限
#map.course_module :boards do |map| #map.course_module :boards do |map|
# map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member # map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member
# map.permission :view_course_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true, :read => true # map.permission :view_course_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true, :read => true
# map.permission :add_messages, {:messages => [:new, :reply, :quote]} # map.permission :add_messages, {:messages => [:new, :reply, :quote]}
# map.permission :edit_messages, {:messages => :edit}, :require => :member # map.permission :edit_messages, {:messages => :edit}, :require => :member
# map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin # map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin
# map.permission :delete_messages, {:messages => :destroy}, :require => :member # map.permission :delete_messages, {:messages => :destroy}, :require => :member
# map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin # map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin
#end #end
#end #end
map.project_module :issue_tracking do |map| map.project_module :issue_tracking do |map|
# Issue categories # Issue categories
map.permission :manage_categories, {:projects => :settings, :issue_categories => [:index, :show, :new, :create, :edit, :update, :destroy]}, :require => :member map.permission :manage_categories, {:projects => :settings, :issue_categories => [:index, :show, :new, :create, :edit, :update, :destroy]}, :require => :member
# Issues # Issues
map.permission :view_issues, {:issues => [:index, :show], map.permission :view_issues, {:issues => [:index, :show],
:auto_complete => [:issues], :auto_complete => [:issues],
:context_menus => [:issues], :context_menus => [:issues],
:versions => [:index, :show, :status_by], :versions => [:index, :show, :status_by],
:journals => [:index, :diff], :journals => [:index, :diff],
:queries => :index, :queries => :index,
:reports => [:issue_report, :issue_report_details]}, :reports => [:issue_report, :issue_report_details]},
:read => true :read => true
map.permission :add_issues, {:issues => [:new, :create, :update_form], :attachments => :upload} map.permission :add_issues, {:issues => [:new, :create, :update_form], :attachments => :upload}
map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new], :attachments => :upload} map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new], :attachments => :upload}
map.permission :manage_issue_relations, {:issue_relations => [:index, :show, :create, :destroy]} map.permission :manage_issue_relations, {:issue_relations => [:index, :show, :create, :destroy]}
map.permission :manage_subtasks, {} map.permission :manage_subtasks, {}
map.permission :set_issues_private, {} map.permission :set_issues_private, {}
map.permission :set_own_issues_private, {}, :require => :loggedin map.permission :set_own_issues_private, {}, :require => :loggedin
map.permission :add_issue_notes, {:issues => [:edit, :update, :update_form], :journals => [:new], :attachments => :upload} map.permission :add_issue_notes, {:issues => [:edit, :update, :update_form], :journals => [:new], :attachments => :upload}
map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
map.permission :view_private_notes, {}, :read => true, :require => :member map.permission :view_private_notes, {}, :read => true, :require => :member
map.permission :set_notes_private, {}, :require => :member map.permission :set_notes_private, {}, :require => :member
map.permission :move_issues, {:issues => [:bulk_edit, :bulk_update]}, :require => :loggedin map.permission :move_issues, {:issues => [:bulk_edit, :bulk_update]}, :require => :loggedin
map.permission :delete_issues, {:issues => :destroy}, :require => :member map.permission :delete_issues, {:issues => :destroy}, :require => :member
# Queries # Queries
map.permission :manage_public_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :member map.permission :manage_public_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :member
map.permission :save_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :loggedin map.permission :save_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :loggedin
# Watchers # Watchers
map.permission :view_issue_watchers, {}, :read => true map.permission :view_issue_watchers, {}, :read => true
map.permission :add_issue_watchers, {:watchers => [:new, :create, :append, :autocomplete_for_user]} map.permission :add_issue_watchers, {:watchers => [:new, :create, :append, :autocomplete_for_user]}
map.permission :delete_issue_watchers, {:watchers => :destroy} map.permission :delete_issue_watchers, {:watchers => :destroy}
end end
map.project_module :time_tracking do |map| map.project_module :time_tracking do |map|
map.permission :log_time, {:timelog => [:new, :create]}, :require => :loggedin map.permission :log_time, {:timelog => [:new, :create]}, :require => :loggedin
map.permission :view_time_entries, {:timelog => [:index, :report, :show]}, :read => true map.permission :view_time_entries, {:timelog => [:index, :report, :show]}, :read => true
map.permission :edit_time_entries, {:timelog => [:edit, :update, :destroy, :bulk_edit, :bulk_update]}, :require => :member map.permission :edit_time_entries, {:timelog => [:edit, :update, :destroy, :bulk_edit, :bulk_update]}, :require => :member
map.permission :edit_own_time_entries, {:timelog => [:edit, :update, :destroy,:bulk_edit, :bulk_update]}, :require => :loggedin map.permission :edit_own_time_entries, {:timelog => [:edit, :update, :destroy,:bulk_edit, :bulk_update]}, :require => :loggedin
map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member
end end
map.project_module :news do |map| map.project_module :news do |map|
map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member
map.permission :view_news, {:news => [:index, :show]}, :public => true, :read => true map.permission :view_news, {:news => [:index, :show]}, :public => true, :read => true
map.permission :comment_news, {:comments => :create} map.permission :comment_news, {:comments => :create}
end end
map.contest_module :contestnotifications do |map| map.contest_module :contestnotifications do |map|
map.permission :manage_contestnotifications, {:contestnotifications => [:new, :create, :edit, :update, :destroy], :notificationcomments => [:destroy]}, :require => :member,:belong_to_contest => true map.permission :manage_contestnotifications, {:contestnotifications => [:new, :create, :edit, :update, :destroy], :notificationcomments => [:destroy]}, :require => :member,:belong_to_contest => true
map.permission :view_contestnotifications, {:contestnotifications => [:index, :show]}, :public => true, :read => true map.permission :view_contestnotifications, {:contestnotifications => [:index, :show]}, :public => true, :read => true
map.permission :notificationcomment_contestnotifications, {:notificationcomments => :create},:belong_to_contest => true map.permission :notificationcomment_contestnotifications, {:notificationcomments => :create},:belong_to_contest => true
end end
map.project_module :documents do |map| map.project_module :documents do |map|
map.permission :add_documents, {:documents => [:new, :create, :add_attachment]}, :require => :loggedin map.permission :add_documents, {:documents => [:new, :create, :add_attachment]}, :require => :loggedin
map.permission :edit_documents, {:documents => [:edit, :update, :add_attachment]}, :require => :loggedin map.permission :edit_documents, {:documents => [:edit, :update, :add_attachment]}, :require => :loggedin
map.permission :delete_documents, {:documents => [:destroy]}, :require => :loggedin map.permission :delete_documents, {:documents => [:destroy]}, :require => :loggedin
map.permission :view_documents, {:documents => [:index, :show, :download]}, :read => true map.permission :view_documents, {:documents => [:index, :show, :download]}, :read => true
end end
map.project_module :files do |map| map.project_module :files do |map|
map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin
map.permission :view_files, {:files => :index, :versions => :download}, :read => true map.permission :view_files, {:files => :index, :versions => :download}, :read => true
end end
map.project_module :wiki do |map| map.project_module :wiki do |map|
map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
map.permission :delete_wiki_pages, {:wiki => [:destroy, :destroy_version]}, :require => :member map.permission :delete_wiki_pages, {:wiki => [:destroy, :destroy_version]}, :require => :member
map.permission :view_wiki_pages, {:wiki => [:index, :show, :special, :date_index]}, :read => true map.permission :view_wiki_pages, {:wiki => [:index, :show, :special, :date_index]}, :read => true
map.permission :export_wiki_pages, {:wiki => [:export]}, :read => true map.permission :export_wiki_pages, {:wiki => [:export]}, :read => true
map.permission :view_wiki_edits, {:wiki => [:history, :diff, :annotate]}, :read => true map.permission :view_wiki_edits, {:wiki => [:history, :diff, :annotate]}, :read => true
map.permission :edit_wiki_pages, :wiki => [:edit, :update, :preview, :add_attachment] map.permission :edit_wiki_pages, :wiki => [:edit, :update, :preview, :add_attachment]
map.permission :delete_wiki_pages_attachments, {} map.permission :delete_wiki_pages_attachments, {}
map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member
end end
map.project_module :repository do |map| map.project_module :repository do |map|
map.permission :manage_repository, {:repositories => [:new, :create, :edit, :update, :committers, :destroy]}, :require => :member map.permission :manage_repository, {:repositories => [:new, :create, :edit, :update, :committers, :destroy]}, :require => :member
map.permission :browse_repository, {:repositories => [:show, :browse, :entry, :raw, :annotate, :changes, :diff, :stats, :graph]}, :read => true map.permission :browse_repository, {:repositories => [:show, :browse, :entry, :raw, :annotate, :changes, :diff, :stats, :graph]}, :read => true
map.permission :view_changesets, {:repositories => [:show, :revisions, :revision]}, :read => true map.permission :view_changesets, {:repositories => [:show, :revisions, :revision]}, :read => true
map.permission :commit_access, {} map.permission :commit_access, {}
map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]} map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]}
end end
map.project_module :boards do |map| map.project_module :boards do |map|
map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member
map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true, :read => true map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true, :read => true
map.permission :add_messages, {:messages => [:new, :reply, :quote]} map.permission :add_messages, {:messages => [:new, :reply, :quote]}
map.permission :edit_messages, {:messages => :edit}, :require => :member map.permission :edit_messages, {:messages => :edit}, :require => :member
map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin
map.permission :delete_messages, {:messages => :destroy}, :require => :member map.permission :delete_messages, {:messages => :destroy}, :require => :member
map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin
end end
map.project_module :calendar do |map| map.project_module :calendar do |map|
map.permission :view_calendar, {:calendars => [:show, :update]}, :read => true map.permission :view_calendar, {:calendars => [:show, :update]}, :read => true
end end
map.project_module :gantt do |map| map.project_module :gantt do |map|
map.permission :view_gantt, {:gantts => [:show, :update]}, :read => true map.permission :view_gantt, {:gantts => [:show, :update]}, :read => true
end end
map.project_module :dts do |map| map.project_module :dts do |map|
map.permission :do_dts, {:dts => :show}, :read => true map.permission :do_dts, {:dts => :show}, :read => true
end end
# map.project_module :journals do |map| # map.project_module :journals do |map|
# map.permission :view_journals_for_messages, {:gantts => [:show, :update]}, :read => true # map.permission :view_journals_for_messages, {:gantts => [:show, :update]}, :read => true
# end # end
end end
#by young #by young
Redmine::MenuManager.map :top_menu do |menu| Redmine::MenuManager.map :top_menu do |menu|
menu.push :home, {:host => Setting.user_domain} menu.push :home, {:host => Setting.user_domain}
menu.push :course_practice, {:controller => 'projects', :action => 'course', :project_type => 1} menu.push :course_practice, {:controller => 'projects', :action => 'course', :project_type => 1}
menu.push :project_deposit, { :controller => 'projects', :action => 'index', :project_type => 0}, :caption => :label_project_deposit menu.push :project_deposit, { :controller => 'projects', :action => 'index', :project_type => 0}, :caption => :label_project_deposit
menu.push :software_user, {:controller => 'users', :action => 'index'} menu.push :software_user, {:controller => 'users', :action => 'index'}
menu.push :contest_innovate, {:controller => 'bids', :action => 'contest', :project_type => 1} menu.push :contest_innovate, {:controller => 'bids', :action => 'contest', :project_type => 1}
menu.push :requirement_enterprise, {:controller => 'bids', :action => 'index'} menu.push :requirement_enterprise, {:controller => 'bids', :action => 'index'}
menu.push :project_module_forums, :forums_path menu.push :project_module_forums, :forums_path
menu.push :stores_index, :stores_path menu.push :stores_index, :stores_path
# menu.push :investor, :home_path # menu.push :investor, :home_path
# menu.push :theme, :home_path # menu.push :theme, :home_path
# menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } # menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? }
# menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true # menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true
# menu.push :help, Redmine::Info.help_url, :last => true # menu.push :help, Redmine::Info.help_url, :last => true
end end
#end #end
# by huang # by huang
# Redmine::MenuManager.map :top_home_menu do |menu| # Redmine::MenuManager.map :top_home_menu do |menu|
# menu.push :home, :home_path # menu.push :home, :home_path
# menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural # menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural
# menu.push :developer, {:controller => 'users', :action => 'index'} # menu.push :developer, {:controller => 'users', :action => 'index'}
# menu.push :investor, :home_path # menu.push :investor, :home_path
# menu.push :theme, :home_path # menu.push :theme, :home_path
# menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } # menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? }
# menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true # menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true
# menu.push :help, Redmine::Info.help_url, :last => true # menu.push :help, Redmine::Info.help_url, :last => true
# end # end
# Redmine::MenuManager.map :top_enterprise_menu do |menu| # Redmine::MenuManager.map :top_enterprise_menu do |menu|
# menu.push :home, :home_path # menu.push :home, :home_path
# menu.push :requirement, {:controller => 'bids', :action => 'index', :project_type => 0 } # menu.push :requirement, {:controller => 'bids', :action => 'index', :project_type => 0 }
# menu.push :projects, { :controller => 'projects', :action => 'index', :project_type => 0 }, :caption => :label_project_plural # menu.push :projects, { :controller => 'projects', :action => 'index', :project_type => 0 }, :caption => :label_project_plural
# #
# menu.push :developer, {:controller => 'users', :action => 'index', :project_type => 0 } # menu.push :developer, {:controller => 'users', :action => 'index', :project_type => 0 }
# menu.push :college_into, {:controller=>'projects', :action=>'course_enterprise', :project_type => 1 } # menu.push :college_into, {:controller=>'projects', :action=>'course_enterprise', :project_type => 1 }
# # menu.push :investor, :home_path # # menu.push :investor, :home_path
# # menu.push :theme, :home_path # # menu.push :theme, :home_path
# # menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } # # menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? }
# # menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true # # menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true
# # menu.push :help, Redmine::Info.help_url, :last => true # # menu.push :help, Redmine::Info.help_url, :last => true
# end # end
# Redmine::MenuManager.map :top_college_menu do |menu| # Redmine::MenuManager.map :top_college_menu do |menu|
# menu.push :home, :home_path # menu.push :home, :home_path
# menu.push :new_course, {:controller => 'projects', :action => 'course', :project_type => 1} # menu.push :new_course, {:controller => 'projects', :action => 'course', :project_type => 1}
# menu.push :new_homework, {:controller => 'bids', :action => 'index', :project_type => 1 } # menu.push :new_homework, {:controller => 'bids', :action => 'index', :project_type => 1 }
# menu.push :new_contest, {:controller => 'bids', :action => 'contest', :project_type => 1} # menu.push :new_contest, {:controller => 'bids', :action => 'contest', :project_type => 1}
# menu.push :projects, { :controller => 'projects', :action => 'index', :project_type => 0 }, :caption => :label_project_plural # menu.push :projects, { :controller => 'projects', :action => 'index', :project_type => 0 }, :caption => :label_project_plural
# menu.push :developer, {:controller => 'users', :action => 'index', :project_type => 1 } # menu.push :developer, {:controller => 'users', :action => 'index', :project_type => 1 }
# menu.push :enterprise_into, {:controller=>'projects', :action=>'enterprise_course', :project_type => 0 } # menu.push :enterprise_into, {:controller=>'projects', :action=>'enterprise_course', :project_type => 0 }
# menu.push :investor, :home_path # menu.push :investor, :home_path
# menu.push :theme, :home_path # menu.push :theme, :home_path
# menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } # menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? }
# menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true # menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true
# menu.push :help, Redmine::Info.help_url, :last => true # menu.push :help, Redmine::Info.help_url, :last => true
# end # end
# end # end
Redmine::MenuManager.map :account_menu do |menu| Redmine::MenuManager.map :account_menu do |menu|
menu.push :login, {:controller => 'account', :action => 'login'}, :if => Proc.new { !User.current.logged? } menu.push :login, {:controller => 'account', :action => 'login'}, :if => Proc.new { !User.current.logged? }
menu.push :register, {:controller => 'account', :action => 'register'}, :if => Proc.new { !User.current.logged? && Setting.self_registration? } menu.push :register, {:controller => 'account', :action => 'register'}, :if => Proc.new { !User.current.logged? && Setting.self_registration? }
# menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? } # menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? }
menu.push :logout, {:controller => 'account', :action => 'logout'}, :html => {:method => 'post'}, :if => Proc.new { User.current.logged? } menu.push :logout, {:controller => 'account', :action => 'logout'}, :html => {:method => 'post'}, :if => Proc.new { User.current.logged? }
end end
########fq ########fq
Redmine::MenuManager.map :bid_menu do |menu| Redmine::MenuManager.map :bid_menu do |menu|
menu.push :respond, { :controller => 'bids', :action => 'show' }, :caption => :label_user_response menu.push :respond, { :controller => 'bids', :action => 'show' }, :caption => :label_user_response
menu.push :project, { :controller => 'bids', :action => 'show_project', :host => Setting.project_domain }, :caption => :label_bidding_project menu.push :project, { :controller => 'bids', :action => 'show_project', :host => Setting.project_domain }, :caption => :label_bidding_project
# menu.push :result, { :controller => 'bids', :action => 'show_results' }, # menu.push :result, { :controller => 'bids', :action => 'show_results' },
# :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p } # :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p }
end end
###new add by linchun ###new add by linchun
Redmine::MenuManager.map :contest_menu do |menu| Redmine::MenuManager.map :contest_menu do |menu|
menu.push :respond, :show_contest_contest_path, :caption => :label_user_response menu.push :respond, :show_contest_contest_path, :caption => :label_user_response
#menu.push :project, :show_project_contest_path, :caption => :label_contest_project #menu.push :project, :show_project_contest_path, :caption => :label_contest_project
#menu.push :application, :show_softapplication_contest_path, :caption => :label_contest_application #menu.push :application, :show_softapplication_contest_path, :caption => :label_contest_application
menu.push :attendingcontest, {:controller => 'contests', :action => 'show_attendingcontest'}, :caption => :label_attending_contest menu.push :attendingcontest, {:controller => 'contests', :action => 'show_attendingcontest'}, :caption => :label_attending_contest
menu.push :contestnotifications, { :controller => 'contestnotifications', :action => 'index' }, :param => :contest_id, :caption => :label_contest_notification menu.push :contestnotifications, { :controller => 'contestnotifications', :action => 'index' }, :param => :contest_id, :caption => :label_contest_notification
#menu.push :contestnotification, {:controller => 'contests', :action => 'show_notification'}, :caption => :label_contest_notification #menu.push :contestnotification, {:controller => 'contests', :action => 'show_notification'}, :caption => :label_contest_notification
# menu.push :attendingcontest, :show_attendingcontest_contest_path, :caption => :label_attendin,g_contest # menu.push :attendingcontest, :show_attendingcontest_contest_path, :caption => :label_attendin,g_contest
# menu.push :result, { :controller => 'bids', :action => 'show_results' }, # menu.push :result, { :controller => 'bids', :action => 'show_results' },
# :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p } # :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p }
end end
#### ####
Redmine::MenuManager.map :application_menu do |menu| Redmine::MenuManager.map :application_menu do |menu|
# Empty # Empty
end end
###### ######
Redmine::MenuManager.map :homework_menu do |menu| Redmine::MenuManager.map :homework_menu do |menu|
menu.push :respond, { :controller => 'bids', :action => 'show' }, :caption => :label_homework_response menu.push :respond, { :controller => 'bids', :action => 'show' }, :caption => :label_homework_response
menu.push :project, { :controller => 'bids', :action => 'show_project' }, :caption => :label_bidding_homework menu.push :project, { :controller => 'bids', :action => 'show_project' }, :caption => :label_bidding_homework
end end
########end ########end
Redmine::MenuManager.map :admin_menu do |menu| Redmine::MenuManager.map :admin_menu do |menu|
menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural
menu.push :first_page_made, {:controller => 'admin',:action => 'first_page_made'},:caption => :label_first_page_made menu.push :first_page_made, {:controller => 'admin',:action => 'first_page_made'},:caption => :label_first_page_made
menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural
menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions
menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural
menu.push :issue_statuses, {:controller => 'issue_statuses'}, :caption => :label_issue_status_plural, menu.push :issue_statuses, {:controller => 'issue_statuses'}, :caption => :label_issue_status_plural,
:html => {:class => 'issue_statuses'} :html => {:class => 'issue_statuses'}
menu.push :workflows, {:controller => 'workflows', :action => 'edit'}, :caption => :label_workflow menu.push :workflows, {:controller => 'workflows', :action => 'edit'}, :caption => :label_workflow
menu.push :custom_fields, {:controller => 'custom_fields'}, :caption => :label_custom_field_plural, menu.push :custom_fields, {:controller => 'custom_fields'}, :caption => :label_custom_field_plural,
:html => {:class => 'custom_fields'} :html => {:class => 'custom_fields'}
menu.push :enumerations, {:controller => 'enumerations'} menu.push :enumerations, {:controller => 'enumerations'}
menu.push :settings, {:controller => 'settings'} menu.push :settings, {:controller => 'settings'}
menu.push :ldap_authentication, {:controller => 'auth_sources', :action => 'index'}, menu.push :ldap_authentication, {:controller => 'auth_sources', :action => 'index'},
:html => {:class => 'server_authentication'} :html => {:class => 'server_authentication'}
menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true
menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true
end end
#Modified by young #Modified by young
Redmine::MenuManager.map :project_menu do |menu| Redmine::MenuManager.map :project_menu do |menu|
menu.push :overview, { :controller => 'projects', :action => 'show' } menu.push :overview, { :controller => 'projects', :action => 'show' }
# menu.push :activity, { :controller => 'activities', :action => 'index' } # menu.push :activity, { :controller => 'activities', :action => 'index' }
#menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id #menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id
# :if => Proc.new { |p| p.shared_versions.any? } # :if => Proc.new { |p| p.shared_versions.any? }
menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
# menu.push :new_issue, { :controller => 'issues', :action => 'new', :copy_from => nil }, :param => :project_id, :caption => :label_issue_new, # menu.push :new_issue, { :controller => 'issues', :action => 'new', :copy_from => nil }, :param => :project_id, :caption => :label_issue_new,
# :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) } # :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }
# menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt # menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt
# menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar # menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar
menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
# menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural # menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural
# menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id, # menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id,
# :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } # :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
:if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
#menu.push :files, { :controller => 'files', :action => 'index' }, :param => :project_id, :caption => :label_file_new #menu.push :files, { :controller => 'files', :action => 'index' }, :param => :project_id, :caption => :label_file_new
menu.push :repository, { :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil }, menu.push :repository, { :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil },
:if => Proc.new { |p| p.repository && !p.repository.new_record? && !( !User.current.member_of?(p) && p.hidden_repo ) } :if => Proc.new { |p| p.repository && !p.repository.new_record? && !( !User.current.member_of?(p) && p.hidden_repo ) }
menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true
end end
#end #end
#added by young #added by young
Redmine::MenuManager.map :course_menu do |menu| Redmine::MenuManager.map :course_menu do |menu|
menu.push :overview, { :controller => 'projects', :action => 'show'} menu.push :overview, { :controller => 'projects', :action => 'show'}
menu.push :homework, { :controller => 'projects', :action => 'homework' } menu.push :homework, { :controller => 'projects', :action => 'homework' }
# menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural # menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
# menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_new, :param => :project_id # menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_new, :param => :project_id
menu.push :repository, { :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil, :course => 1 } menu.push :repository, { :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil, :course => 1 }
# menu.push :settings, { :controller => 'projects', :action => 'settings', :course => 1 }, :last => true # menu.push :settings, { :controller => 'projects', :action => 'settings', :course => 1 }, :last => true
end end
Redmine::MenuManager.map :user_menu do |menu| Redmine::MenuManager.map :user_menu do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain } menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain }
menu.push :user_course, {:controller => 'users', :action => 'user_courses'} menu.push :user_course, {:controller => 'users', :action => 'user_courses'}
#menu.push :user_homework, {:controller => 'users', :action => 'user_homeworks'} by huang #menu.push :user_homework, {:controller => 'users', :action => 'user_homeworks'} by huang
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain} menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain}
# menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'} by huang # menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'} by huang
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain} menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain}
end end
Redmine::MenuManager.map :user_enterprise_menu do |menu| Redmine::MenuManager.map :user_enterprise_menu do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain } menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain }
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain} menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.user_domain} menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.user_domain}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain} menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain}
end end
Redmine::MenuManager.map :user_menu_self do |menu| Redmine::MenuManager.map :user_menu_self do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.project_domain } menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.project_domain }
menu.push :user_information, {:controller => 'users', :action => 'info', :host => Setting.user_domain} menu.push :user_information, {:controller => 'users', :action => 'info', :host => Setting.user_domain}
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain} menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.user_domain} menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.user_domain}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain} menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain}
end end
#end #end
Redmine::Activity.map do |activity| Redmine::Activity.map do |activity|
activity.register :issues, :class_name => %w(Issue Journal) activity.register :issues, :class_name => %w(Issue Journal)
activity.register :changesets activity.register :changesets
activity.register :news activity.register :news
activity.register :contestnotification activity.register :contestnotification
activity.register :documents, :class_name => %w(Document Attachment) activity.register :documents, :class_name => %w(Document Attachment)
activity.register :files, :class_name => 'Attachment' activity.register :files, :class_name => 'Attachment'
activity.register :course_files, :class_name => 'Attachment' activity.register :course_files, :class_name => 'Attachment'
activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false
activity.register :messages, :default => false activity.register :messages, :default => false
activity.register :time_entries, :default => false activity.register :time_entries, :default => false
# added by fq # added by fq
activity.register :bids, :class_name => 'Bid' activity.register :bids, :class_name => 'Bid'
activity.register :memos, :class_name => 'Memo' activity.register :memos, :class_name => 'Memo'
activity.register :journals_for_messages activity.register :journals_for_messages
# end # end
#added by nwb #added by nwb
activity.register :course_journals_for_messages , :class_name => 'JournalsForMessage' activity.register :course_journals_for_messages , :class_name => 'JournalsForMessage'
activity.register :course_news, :class_name => 'News' activity.register :course_news, :class_name => 'News'
activity.register :course_messages, :default => false, :class_name => 'Message' activity.register :course_messages, :default => false, :class_name => 'Message'
end end
Redmine::Search.map do |search| Redmine::Search.map do |search|
search.register :issues search.register :issues
search.register :news search.register :news
search.register :contestnotification search.register :contestnotification
search.register :documents search.register :documents
search.register :changesets search.register :changesets
search.register :wiki_pages search.register :wiki_pages
search.register :messages search.register :messages
search.register :projects search.register :projects
end end
Redmine::WikiFormatting.map do |format| Redmine::WikiFormatting.map do |format|
format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper
end end
ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler

@ -1,172 +1,172 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2013 Jean-Philippe Lang # Copyright (C) 2006-2013 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module Redmine module Redmine
module AccessControl module AccessControl
class << self class << self
def map def map
mapper = Mapper.new mapper = Mapper.new
yield mapper yield mapper
@permissions ||= [] @permissions ||= []
@permissions += mapper.mapped_permissions @permissions += mapper.mapped_permissions
end end
def permissions def permissions
@permissions @permissions
end end
# Returns the permission of given name or nil if it wasn't found # Returns the permission of given name or nil if it wasn't found
# Argument should be a symbol # Argument should be a symbol
def permission(name) def permission(name)
permissions.detect {|p| p.name == name} permissions.detect {|p| p.name == name}
end end
# Returns the actions that are allowed by the permission of given name # Returns the actions that are allowed by the permission of given name
def allowed_actions(permission_name) def allowed_actions(permission_name)
perm = permission(permission_name) perm = permission(permission_name)
perm ? perm.actions : [] perm ? perm.actions : []
end end
def public_permissions def public_permissions
@public_permissions ||= @permissions.select {|p| p.public?} @public_permissions ||= @permissions.select {|p| p.public?}
end end
def members_only_permissions def members_only_permissions
@members_only_permissions ||= @permissions.select {|p| p.require_member?} @members_only_permissions ||= @permissions.select {|p| p.require_member?}
end end
def loggedin_only_permissions def loggedin_only_permissions
@loggedin_only_permissions ||= @permissions.select {|p| p.require_loggedin?} @loggedin_only_permissions ||= @permissions.select {|p| p.require_loggedin?}
end end
def read_action?(action) def read_action?(action)
if action.is_a?(Symbol) if action.is_a?(Symbol)
perm = permission(action) perm = permission(action)
!perm.nil? && perm.read? !perm.nil? && perm.read?
else else
s = "#{action[:controller]}/#{action[:action]}" s = "#{action[:controller]}/#{action[:action]}"
permissions.detect {|p| p.actions.include?(s) && !p.read?}.nil? permissions.detect {|p| p.actions.include?(s) && !p.read?}.nil?
end end
end end
def available_project_modules def available_project_modules
@available_project_modules ||= @permissions.collect(&:project_module).uniq.compact @available_project_modules ||= @permissions.collect(&:project_module).uniq.compact
end end
def available_contest_modules def available_contest_modules
@available_contest_modules ||= @permissions.collect(&:contest_module).uniq.compact @available_contest_modules ||= @permissions.collect(&:contest_module).uniq.compact
end end
def modules_permissions(modules) def modules_permissions(modules)
@permissions.select {|p| p.project_module.nil? || modules.include?(p.project_module.to_s)} @permissions.select {|p| p.project_module.nil? || modules.include?(p.project_module.to_s)}
@permissions.select {|p| p.contest_module.nil? || modules.include?(p.contest_module.to_s)} @permissions.select {|p| p.contest_module.nil? || modules.include?(p.contest_module.to_s)}
end end
end end
class Mapper class Mapper
def initialize def initialize
@project_module = nil @project_module = nil
@course_module = nil @course_module = nil
@contest_module = nil @contest_module = nil
end end
def permission(name, hash, options={}) def permission(name, hash, options={})
@permissions ||= [] @permissions ||= []
options.merge!(:project_module => @project_module) options.merge!(:project_module => @project_module)
options.merge!(:contest_module => @contest_module) options.merge!(:contest_module => @contest_module)
@permissions << Permission.new(name, hash, options) @permissions << Permission.new(name, hash, options)
end end
def project_module(name, options={}) def project_module(name, options={})
@project_module = name @project_module = name
yield self yield self
@project_module = nil @project_module = nil
end end
def course_module(name, options={}) def course_module(name, options={})
@course_module = name @course_module = name
yield self yield self
@course_module = nil @course_module = nil
end end
def contest_module(name, options={}) def contest_module(name, options={})
@contest_module = name @contest_module = name
yield self yield self
@contest_module = nil @contest_module = nil
end end
def mapped_permissions def mapped_permissions
@permissions @permissions
end end
end end
class Permission class Permission
attr_reader :name, :actions, :project_module ,:course_module, :contest_module attr_reader :name, :actions, :project_module ,:course_module, :contest_module
def initialize(name, hash, options) def initialize(name, hash, options)
@name = name @name = name
@actions = [] @actions = []
@public = options[:public] || false @public = options[:public] || false
@require = options[:require] @require = options[:require]
@read = options[:read] || false @read = options[:read] || false
@course_module = options[:course_module] @course_module = options[:course_module]
@project_module = options[:project_module] @project_module = options[:project_module]
@contest_module = options[:contest_module] @contest_module = options[:contest_module]
@belong_to_project = options[:belong_to_project] || false @belong_to_project = options[:belong_to_project] || false
@belong_to_course = options[:belong_to_course] || false @belong_to_course = options[:belong_to_course] || false
@belong_to_contest =options[:belong_to_contest] || false @belong_to_contest =options[:belong_to_contest] || false
hash.each do |controller, actions| hash.each do |controller, actions|
if actions.is_a? Array if actions.is_a? Array
@actions << actions.collect {|action| "#{controller}/#{action}"} @actions << actions.collect {|action| "#{controller}/#{action}"}
else else
@actions << "#{controller}/#{actions}" @actions << "#{controller}/#{actions}"
end end
end end
@actions.flatten! @actions.flatten!
end end
def public? def public?
@public @public
end end
def require_member? def require_member?
@require && @require == :member @require && @require == :member
end end
def require_loggedin? def require_loggedin?
@require && (@require == :member || @require == :loggedin) @require && (@require == :member || @require == :loggedin)
end end
def read? def read?
@read @read
end end
def belong_to_project? def belong_to_project?
@belong_to_project @belong_to_project
end end
def belong_to_course? def belong_to_course?
@belong_to_course @belong_to_course
end end
def belong_to_contest? def belong_to_contest?
@belong_to_contest @belong_to_contest
end end
end end
end end
end end

Loading…
Cancel
Save