Merge remote-tracking branch 'remotes/origin/szzh' into develop

This commit is contained in:
nwb 2014-07-18 13:50:30 +08:00
commit b655f0c7b0
15 changed files with 99 additions and 82 deletions

View File

@ -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 }

View File

@ -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

View File

@ -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 << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal.userInfo }</label>\n"
else
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal}</label>\n"
end
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal.userInfo }</label>\n"
end
s.html_safe
end
#扩展的checkbox生成
def principals_radio_box_tags_ex(name, principals)
s = ''
principals.each do |principal|
s << "<label>#{ radio_button_tag name, principal.id, false, :id => nil } #{h principal.userInfo }</label>\n"
end
s.html_safe
end

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -77,7 +77,7 @@
<%= stylesheet_link_tag 'scm' %>
<% end %>
<% html_title(l(:label_news_plural)) -%>
<% html_title(l(:label_contest_notification)) -%>
</div>
<script type='text/javascript'>

View File

@ -14,7 +14,7 @@
<% unless contest.author.nil? %>
<%= link_to(contest.author, user_path(contest.author), :class => 'bid_user') %>:
<% end %>
&nbsp;<%= link_to(contest.name, show_contest_contest_path(contest), :class => 'bid_path', :target => "_blank") %></strong></td>
&nbsp;<%= link_to(contest.name, contest_contestnotifications_path(contest), :class => 'bid_path', :target => "_blank") %></strong></td>
</tr>
<tr>
<td width="500">

View File

@ -32,7 +32,7 @@
<p>
<% roles.each do |role| %>
<label><%= check_box_tag 'membership[role_ids][]', role.id, member.roles.include?(role),
<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? } %> <%= h role %></label><br/>
<% end %></p>
<%= hidden_field_tag 'membership[role_ids][]', '' %>
@ -82,7 +82,7 @@
<p style="padding-top: 5px"><%= l(:label_role_plural) %>:
<% roles.each do |role| %>
<label><%= check_box_tag 'membership[role_ids][]', role.id %> <%= h role %></label>
<label><%= radio_button_tag 'membership[role_ids][]', role.id %> <%= h role %></label>
<% end %></p>
<p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p>

View File

@ -214,11 +214,11 @@
<div id="content">
<% if display_main_menu?(@contest) %>
<div class="tabs_new">
<ul>
<li ><%= link_to l(:label_contest_userresponse), show_contest_contest_path(@contest), :class => link_class(:respond) %></li>
<li><%= link_to l(:label_contest_joincontest), show_attendingcontest_contest_path(@contest), :class => link_class(:attendingcontests) %></li>
<li><%= link_to l(:label_contest_notification), contest_contestnotifications_path(@contest), :class => link_class(:contestnotifications) %></li>
</ul>
<ul>
<li><%= link_to l(:label_contest_notification), contest_contestnotifications_path(@contest), :class => link_class(:contestnotifications) %></li>
<li><%= link_to l(:label_contest_joincontest), show_attendingcontest_contest_path(@contest), :class => link_class(:attendingcontests) %></li>
<li><%= link_to l(:label_contest_userresponse), show_contest_contest_path(@contest), :class => link_class(:respond) %></li>
</ul>
</div>
<% end %>

View File

@ -97,7 +97,6 @@
<div class="pagination">
<ul>
<%= pagination_links_full @events_pages %>
<% #binding.pry %>
</ul>
</div>

View File

@ -157,7 +157,7 @@
<div style="float: left; margin-left: 12px; margin-top: 10px; margin-bottom: -4px; width: 380px;">
<!-- <%= link_to(contest.name, contest.event_url, :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %> -->
<%= link_to(contest.name, show_contest_contest_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %>
<%= link_to(contest.name, contest_contestnotifications_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %>
<% if contest.id == 2 or contest.id == 3 or contest.id == 6 %>
<span class="font_lighter">(<span style="font-size: 13px"><%= link_to("#{contest.projects.where('is_public=1').count}"+l(:label_work_quantity), show_attendingcontest_contest_path(contest), :target => "_blank") %></span>)</span>
<% else %>

View File

@ -1776,7 +1776,7 @@ zh:
label_fork_homework_new: 选为作业
#wang
label_contest_userresponse: 用户留言
label_contest_joincontest: 竞赛
label_contest_joincontest: 竞赛
label_contest_notification: 竞赛通知
#end

View File

@ -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

View File

@ -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