Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
46c7a4bb9f
|
@ -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 }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -104,10 +104,25 @@ module CoursesHelper
|
|||
garble count
|
||||
end
|
||||
|
||||
alias studentCountOrigin studentCount
|
||||
# 注意:此方法有问题,速度慢且结果不准
|
||||
# alias studentCountOrigin studentCount
|
||||
#def studentCount course
|
||||
# count = studentCountOrigin course
|
||||
#garble count
|
||||
# end
|
||||
|
||||
# 学生人数计算
|
||||
# add by nwb
|
||||
def studentCount course
|
||||
count = studentCountOrigin course
|
||||
garble 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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class Course < ActiveRecord::Base
|
|||
has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :homework_for_courses, :dependent => :destroy
|
||||
has_many :student, :through => :students_for_courses, :source => :user
|
||||
has_many :student, :class_name => 'StudentsForCourse', :source => :user
|
||||
has_many :course_infos, :class_name => 'CourseInfos',:dependent => :destroy
|
||||
has_many :enabled_modules, :dependent => :delete_all
|
||||
has_many :boards, :dependent => :destroy, :order => "position ASC"
|
||||
|
@ -36,10 +36,10 @@ 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_save :create_board_sync
|
||||
after_create :create_board_sync
|
||||
before_destroy :delete_all_members
|
||||
|
||||
safe_attributes 'extra',
|
||||
|
|
|
@ -564,8 +564,10 @@ class Issue < ActiveRecord::Base
|
|||
end
|
||||
# 缺陷的短描述信息
|
||||
def short_description(length = 255)
|
||||
description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
# 不再使用短描述
|
||||
#description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
description
|
||||
end
|
||||
|
||||
private :workflow_rule_by_attribute
|
||||
|
|
|
@ -76,8 +76,10 @@ class News < ActiveRecord::Base
|
|||
|
||||
# 新闻的短描述信息
|
||||
def short_description(length = 255)
|
||||
description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
#description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
# 不再使用短描述
|
||||
description
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -85,7 +85,9 @@ class OpenSourceProject < ActiveRecord::Base
|
|||
|
||||
def short_description(length = 255)
|
||||
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
#description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
# 不再使用短描述
|
||||
description
|
||||
end
|
||||
|
||||
def applied_by?(user)
|
||||
|
|
|
@ -127,7 +127,7 @@ class Project < ActiveRecord::Base
|
|||
after_save :update_position_under_parent, :if => Proc.new {|project| project.name_changed?}
|
||||
after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?}
|
||||
# 创建project之后默认创建一个board,之后的board去掉了board的概念
|
||||
after_save :create_board_sync
|
||||
after_create :create_board_sync
|
||||
before_destroy :delete_all_members
|
||||
def remove_references_before_destroy
|
||||
return if self.id.nil?
|
||||
|
@ -630,7 +630,9 @@ class Project < ActiveRecord::Base
|
|||
# Returns a short description of the projects (first lines)
|
||||
def short_description(length = 255)
|
||||
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
# 不再使用短描述
|
||||
# description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
description
|
||||
end
|
||||
|
||||
def css_classes
|
||||
|
|
|
@ -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'>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<% unless contest.author.nil? %>
|
||||
<%= link_to(contest.author, user_path(contest.author), :class => 'bid_user') %>:
|
||||
<% end %>
|
||||
<%= link_to(contest.name, show_contest_contest_path(contest), :class => 'bid_path', :target => "_blank") %></strong></td>
|
||||
<%= link_to(contest.name, contest_contestnotifications_path(contest), :class => 'bid_path', :target => "_blank") %></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="500">
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 %>
|
||||
|
||||
|
|
|
@ -97,7 +97,6 @@
|
|||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full @events_pages %>
|
||||
<% #binding.pry %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -150,14 +150,14 @@
|
|||
<div class="d-p-projectlist">
|
||||
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
|
||||
|
||||
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
|
||||
<li style="overflow:auto;word-break:break-all;height:100%;" class='<%= cycle("odd", "even") %>'>
|
||||
<div class="avatar-4" style="float: left; margin-top: 7px">
|
||||
<%= image_tag('/images/contest1.png')%>
|
||||
</div>
|
||||
|
||||
<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 %>
|
||||
|
@ -165,8 +165,8 @@
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class='text_nowrap' style="float: left;margin:5px; margin-left: 12px; margin-bottom: 2px; width: 380px;">
|
||||
<span class='font_lighter' title =<%=contest.description.to_s%>><%=contest.description.truncate(50, omission: '...')%></span>
|
||||
<div style="float: left;margin:5px; margin-left: 12px; margin-bottom: 2px; width: 380px;">
|
||||
<span class='font_lighter' title =<%=contest.description.to_s%>><%=contest.description.to_s%></span>
|
||||
</div><br />
|
||||
|
||||
<div style="padding-left: 57px; clear: left;">
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<% #projects = find_miracle_project(10, 3) %>
|
||||
<% @projects.map do |project| %>
|
||||
<!--<%# cache cache_key_for_project(project) do %> -->
|
||||
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
|
||||
<li style="overflow:auto;word-break:break-all;height:100%;" class='<%= cycle("odd", "even") %>'>
|
||||
<div style="float: left;">
|
||||
<%= image_tag(get_project_avatar(project), :class => "avatar-4") %>
|
||||
</div>
|
||||
|
@ -72,10 +72,10 @@
|
|||
<%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%>
|
||||
(<%= link_to "#{projectCount(project)}人", project_member_path(project) ,:course =>'0' %>)
|
||||
</div>
|
||||
<div class='text_nowrap' style="float: left;margin:5px; margin-left: 10px; width: 380px;">
|
||||
<span class='font_lighter' title =<%=project.short_description.to_s%>><%=project.short_description.truncate(50, omission: '...')%></span>
|
||||
<div style=" float: left;margin:5px; margin-left: 10px; width: 380px;">
|
||||
<span class='font_lighter' title =<%=project.description.to_s%>><%=project.description%></span>
|
||||
</div>
|
||||
<div style="position:absolute; bottom:0;right:0;margin:5px 10px 5px 5px ;">
|
||||
<div >
|
||||
<%# issue_count = project.issues.count %>
|
||||
<%# issue_journal_count = project.issue_changes.count %>
|
||||
<%# issue_score = issue_count * 0.2 %>
|
||||
|
@ -103,7 +103,7 @@
|
|||
|
||||
<%# finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score %>
|
||||
<%= content_tag "span", l(:label_project_score)+ ":" + project_score(project),
|
||||
:style => "cursor: pointer; display: inline-block; float: right; color: #ec6300; ",
|
||||
:style => "cursor: pointer; display: inline-block; float: right; color: #ec6300;",
|
||||
:title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度",
|
||||
:class => "tooltip",
|
||||
:id => "tooltip-#{project.id}" %>
|
||||
|
|
|
@ -1776,7 +1776,7 @@ zh:
|
|||
label_fork_homework_new: 选为作业
|
||||
#wang
|
||||
label_contest_userresponse: 用户留言
|
||||
label_contest_joincontest: 参入竞赛
|
||||
label_contest_joincontest: 参加竞赛
|
||||
label_contest_notification: 竞赛通知
|
||||
#end
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue