diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 5435a2d61..daf11b33f 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -1,3 +1,4 @@ +# -*coding:utf-8 -*- # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -14,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + class MembersController < ApplicationController model_object Member before_filter :find_model_object, :except => [:index, :create, :autocomplete] @@ -124,7 +126,13 @@ class MembersController < ApplicationController attrs = params[:membership].dup user_ids = attrs.delete(:user_ids) user_ids.each do |user_id| - members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id) + member = Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id) + role = Role.find_by_id(params[:membership][:role_ids]) + # 这里的判断只能通过角色名,可以弄成常量 + if role.name == "学生" + StudentsForCourse.create(:student_id => user_id, :course_id =>@course.id) + end + members << member #user_grades << UserGrade.new(:user_id => user_id, :course_id => @course.id) if (params[:membership][:role_ids]) role = Role.find(params[:membership][:role_ids][0]) @@ -201,6 +209,15 @@ class MembersController < ApplicationController if (params[:membership][:role_ids]) role = Role.find(params[:membership][:role_ids][0]) + # 这里的判断只能通过角色名,可以弄成常量 + if role.name == "学生" + StudentsForCourse.create(:student_id => @member.user_id, :course_id =>@course.id) + else + joined = StudentsForCourse.where('student_id = ? and course_id = ?', @member.user_id,@course.id) + joined.each do |join| + join.delete + end + end if role.allowed_to?(:is_manager) @courseInfo = CourseInfos.new(:user_id => @member.user_id, :course_id => @course.id) @courseInfo.save @@ -271,6 +288,11 @@ class MembersController < ApplicationController user.destroy end end + joined = StudentsForCourse.where('student_id = ? and course_id = ?', @member.user_id,@course.id) + joined.each do |join| + join.delete + end + end respond_to do |format| format.html { redirect_to_settings_in_courses } diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e81355260..c074be37b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -642,9 +642,9 @@ class UsersController < ApplicationController return end if @obj.save - ## 执行成功的操作。 + logger.debug "#{__FILE__}:#{__LINE__} ===> #{@obj.to_json}" else - #捕获异常 + logger.error "#{__FILE__}:#{__LINE__} ===> #{@obj.errors.try(:full_messages)}" end respond_to do |format| format.js diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bf125972b..e3b2df048 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -474,11 +474,16 @@ module ApplicationHelper def principals_check_box_tags_ex(name, principals) s = '' principals.each do |principal| - if principal.has_attribute?(:userInfo) - s << "\n" - else - s << "\n" - end + s << "\n" + end + s.html_safe + end + + #扩展的checkbox生成 + def principals_radio_box_tags_ex(name, principals) + s = '' + principals.each do |principal| + s << "\n" end s.html_safe end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index b03f6cfa1..033b6405c 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -114,7 +114,15 @@ module CoursesHelper # 学生人数计算 # add by nwb def studentCount course - course.student.count + count = course.student.count + if count <= 5 + result = count.to_s + elsif count < 10 && count > 5 + result = "5+" + else + result = (count-count % 10).to_s + "+" + end + result end def eventToLanguageCourse event_type, course diff --git a/app/helpers/stores_helper.rb b/app/helpers/stores_helper.rb index b4cd47eb1..5a161dc85 100644 --- a/app/helpers/stores_helper.rb +++ b/app/helpers/stores_helper.rb @@ -42,7 +42,6 @@ module StoresHelper container = attachment.container case container.class.to_s when 'Message' - # binding.pry # '项目 > zzz > 论坛 > 帖子xxx' # topic_str = container.project.project_type == 0 ? l(:label_board) : l(:label_new_course) diff --git a/app/models/course.rb b/app/models/course.rb index 75bac905c..45830c719 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -36,7 +36,7 @@ class Course < ActiveRecord::Base validates_presence_of :password, :term,:name validates_format_of :class_period, :with =>/^[1-9]\d*$/ - validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/ + #validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/ before_save :self_validate after_create :create_board_sync diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb index fc71bc64a..0cf722851 100644 --- a/app/views/contestnotifications/index.html.erb +++ b/app/views/contestnotifications/index.html.erb @@ -77,7 +77,7 @@ <%= stylesheet_link_tag 'scm' %> <% end %> - <% html_title(l(:label_news_plural)) -%> + <% html_title(l(:label_contest_notification)) -%>