From 6b758375f8e3560b3359792f38b1f290ac8f251e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 10 Apr 2015 15:01:33 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=90=9C=E7=B4=A2=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E6=8A=A5500=202=E3=80=81=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E6=8F=8F=E8=BF=B0=E6=8D=A2=E8=A1=8C=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 10 ++++++++-- app/helpers/courses_helper.rb | 5 +++-- app/views/messages/_form_course.html.erb | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index ff937990b..1c2419305 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1,5 +1,5 @@ class CoursesController < ApplicationController - layout 'base_courses' + # layout 'base_courses' include CoursesHelper include ActivitiesHelper helper :activities @@ -73,6 +73,7 @@ class CoursesController < ApplicationController if @course.errors.full_messages.count <= 0 respond_to do |format| format.html { + # render :layout => 'base_courses' flash[:notice] = l(:notice_successful_update) redirect_to settings_course_url(@course) } @@ -82,7 +83,7 @@ class CoursesController < ApplicationController respond_to do |format| format.html { settings - render :action => 'settings' + redirect_to settings_course_url(@course) } format.api { render_validation_errors(@course) } end @@ -407,6 +408,10 @@ class CoursesController < ApplicationController @roles = Role.givable.all[3..5] @members = @course.member_principals.includes(:roles, :principal).all.sort + respond_to do |format| + format.html { render :layout => 'base_courses' } + format.api { render_validation_errors(@course) } + end else render_403 end @@ -424,6 +429,7 @@ class CoursesController < ApplicationController else respond_to do |format| format.html { + render :layout => 'base_courses' flash[:notice] = l(:notice_successful_create) if params[:continue] redirect_to new_course_url(attrs, :course => '0') diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index f4a5ac193..55f216ab9 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -20,7 +20,7 @@ module CoursesHelper # 返回教师数量,即roles表中定义的Manager def teacherCount project - project.members.count - studentCount(project).to_i + project ? project.members.count - studentCount(project).to_i : 0 # or # searchTeacherAndAssistant(project).count end @@ -152,7 +152,7 @@ module CoursesHelper # 学生人数计算 # add by nwb def studentCount course - course.student.count.to_s#course.student.count + course ? course.student.count.to_s : 0#course.student.count end #课程成员数计算 @@ -782,6 +782,7 @@ module CoursesHelper end def visable_attachemnts_incourse course + return[] unless course result = [] course.attachments.each do |attachment| if attachment.is_public? || User.current.member_of_course?(course) || User.current.admin? diff --git a/app/views/messages/_form_course.html.erb b/app/views/messages/_form_course.html.erb index f4f8126fe..54a62144a 100644 --- a/app/views/messages/_form_course.html.erb +++ b/app/views/messages/_form_course.html.erb @@ -44,7 +44,7 @@ <%= f.kindeditor :content, :editor_id => 'message_content_editor', :owner_id => @message.nil? ? 0: @message.id, :owner_type => OwnerTypeHelper::MESSAGE, - :width => '91%', + :width => '90%', :height => 300, :class => 'talk_text fl', :input_html => { :id => 'message_content',