From 69e366d841f2770c7b44fd653b707c998dd3bf58 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 4 Jun 2014 16:58:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E8=AF=BE=E7=A8=8B=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 6 ++++++ app/views/courses/_set_course_time.html.erb | 8 ++++---- ...604071624_rename_project_id_to_homework_for_courses.rb | 5 +++++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb diff --git a/app/models/course.rb b/app/models/course.rb index 9b2e0d840..8dcb53387 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -17,6 +17,12 @@ class Course < ActiveRecord::Base :include => :principal, :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})" has_many :users, :through => :members + 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 :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy + has_many :student, :through => :students_for_courses, :source => :user + validates_presence_of :password, :term validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/ diff --git a/app/views/courses/_set_course_time.html.erb b/app/views/courses/_set_course_time.html.erb index 7f2b629c1..384b07df2 100644 --- a/app/views/courses/_set_course_time.html.erb +++ b/app/views/courses/_set_course_time.html.erb @@ -1,11 +1,11 @@ <% - id = "finish_course_#{project.id}" - display = (project.course_extra.teacher.id == User.current.id || User.current.admin?) + id = "finish_course_#{course.id}" + display = (course.teacher.id == User.current.id || User.current.admin?) %> <% if display #如果课程已结束%> - <% linkPath = course_endTime_timeout?(project) ? restartcourse_project_path(project) : finishcourse_project_path(project, format: :js) %> - <% desc = course_endTime_timeout?(project) ? '重启' : '关闭' %> + <% linkPath = course_endTime_timeout?(course) ? restartcourse_course_path(course) : finishcourse_course_path(course, format: :js) %> + <% desc = course_endTime_timeout?(course) ? '重启' : '关闭' %> <%= link_to "#{desc}课程", linkPath, :remote => true, :method => :post, :id => id, :confirm => ("确定要#{desc}课程?") %> <% else %> diff --git a/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb b/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb new file mode 100644 index 000000000..e7cd811a8 --- /dev/null +++ b/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb @@ -0,0 +1,5 @@ +class RenameProjectIdToHomeworkForCourses < ActiveRecord::Migration + def change + rename_column(:homework_for_courses, :project_id, :course_id) + end +end