From a4d06fbb12f0b95ee7c898d601b7565aa76ade15 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 18 Jul 2014 10:29:49 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=88=90=E5=91=98?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BA=E5=8F=AA=E8=83=BD=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=8D=95=E4=B8=80=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 15 ++++++++++----- app/views/courses/settings/_members.html.erb | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) 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/views/courses/settings/_members.html.erb b/app/views/courses/settings/_members.html.erb index 0879b7956..b4e5004bf 100644 --- a/app/views/courses/settings/_members.html.erb +++ b/app/views/courses/settings/_members.html.erb @@ -32,7 +32,7 @@

<% roles.each do |role| %> -

<%= hidden_field_tag 'membership[role_ids][]', '' %> @@ -82,7 +82,7 @@

<%= l(:label_role_plural) %>: <% roles.each do |role| %> - + <% end %>

<%= submit_tag l(:button_add), :id => 'member-add-submit' %>

From df848ca75604aad77b2f9bb97c160d211030ccca Mon Sep 17 00:00:00 2001 From: yanxd Date: Fri, 18 Jul 2014 11:08:36 +0800 Subject: [PATCH 2/6] print tag exception, course name valid test. --- app/controllers/users_controller.rb | 4 +- app/helpers/stores_helper.rb | 1 - app/views/projects/show.html.erb | 1 - test/fixtures/courses.yml | 26 ++++++++++ test/unit/course_test.rb | 76 +++++++---------------------- 5 files changed, 45 insertions(+), 63 deletions(-) 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/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/views/projects/show.html.erb b/app/views/projects/show.html.erb index 5367f9f7c..db51eca1d 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -97,7 +97,6 @@ diff --git a/test/fixtures/courses.yml b/test/fixtures/courses.yml index c3b7c22a3..0eedd1960 100644 --- a/test/fixtures/courses.yml +++ b/test/fixtures/courses.yml @@ -124,3 +124,29 @@ courses_061: rgt: is_public: 0 inherit_members: 1 +course_trustie_074: + id: 74 + tea_id: 698 + name: 电路与电子学基础(软件工程专业) + state: + code: + time: 2014 + extra: course2014-05-22_16-09-25 + created_at: 2014-05-22 08:09:25.000000000 Z + updated_at: 2014-05-22 08:09:25.000000000 Z + location: + term: 春季学期 + string: + password: '12345678' + setup_time: + endup_time: + class_period: '54' + school_id: 117 + description: "电路与电子学基础,软件工程小班\\r\ 模拟电子技术部分\ " + status: 1 + attachmenttype: 2 + lft: + rgt: + is_public: 1 + inherit_members: 1 + diff --git a/test/unit/course_test.rb b/test/unit/course_test.rb index cc5bb934b..a29501066 100644 --- a/test/unit/course_test.rb +++ b/test/unit/course_test.rb @@ -1,68 +1,26 @@ # encoding: utf-8 -# Redmine - project management software -# Copyright (C) 2006-2013 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - require File.expand_path('../../test_helper', __FILE__) class CourseTest < ActiveSupport::TestCase + fixtures :courses, :roles, :member_roles, :members, :boards, :messages, :news def setup - @course_1 = Course.new - @course_1.id = 1 - @course_1.tea_id = 1 - @course_1.name = 'course1' - @course_1.state = 1234 - @course_1.time = 2012 - @course_1.term = '秋季学期' - @course_1.password = 1234 - @course_1.class_period = 40 - - @course_2 = Course.new - @course_2.id = 2 - @course_2.tea_id = 1 - @course_2.name = 'course2' - @course_2.state = 1234 - @course_2.time = 2013 - @course_2.term = '秋季学期' - @course_2.password = 1234 - @course_2.class_period = 40 - - @course_3 = Course.new - @course_3.id = 3 - @course_3.tea_id = 1 - @course_3.name = 'course3' - @course_3.state = 1234 - @course_3.time = 2014 - @course_3.term = '秋季学期' - @course_3.password = 1234 - @course_3.class_period = 40 - - @course_now = Course.new - @course_now.id = 4 - @course_now.tea_id = 1 - @course_now.name = 'course4' - @course_now.state = 1234 - @course_now.time = 2013 - @course_now.term = '秋季学期' - @course_now.password = 1234 - @course_now.class_period = 40 end - - test 'test course whether out of date.' do - true + + test 'name valid with CJK coding' do + course = Course.find_by_id(74) + name_quirk = '电路与电子学基础(软件工程专业)' + course.name = "test_course" + assert course.valid? + course.name = name_quirk + assert course.valid? + end + + test 'description too long must be valid.' do + course = Course.find_by_id(8) + course.description = course.description * 100 + course.valid? + assert_equal course.errors.full_messages.count, 0 + assert course.valid? end def teardown From 046142f437405f3d3b724afca4e6685f342f9f0d Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 18 Jul 2014 11:25:04 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BC=98=E5=8C=96students=5Ffor=5Fcourses?= =?UTF-8?q?=E8=A1=A8=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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 } From 5272a90227d52f60ca2b187e90eebc67cedeff32 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 18 Jul 2014 11:35:05 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=BA=E6=95=B0?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 From c443de587385e3f9ed12689f79637ada7aa494cc Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 18 Jul 2014 11:49:47 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 29618d6a72a70cf88e2ca2fdbe53bac29d5c4bb5 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 18 Jul 2014 13:48:45 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/contestnotifications/index.html.erb | 2 +- app/views/contests/_contest_list.html.erb | 2 +- app/views/layouts/base_newcontest.html.erb | 10 +++++----- app/views/welcome/contest.html.erb | 2 +- config/locales/zh.yml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) 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)) -%>