修正合并分支后的创建课程错误

This commit is contained in:
nwb 2014-06-26 09:15:56 +08:00
parent 7425178419
commit 88c3347f7c
2 changed files with 108 additions and 24 deletions

View File

@ -199,9 +199,11 @@ class Course < ActiveRecord::Base
# 删除课程所有成员
def delete_all_members
me, mr = Member.table_name, MemberRole.table_name
connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.course_id = #{id})")
Member.delete_all(['course_id = ?', id])
if self.members && self.members.count > 0
me, mr = Member.table_name, MemberRole.table_name
connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.course_id = #{id})")
Member.delete_all(['course_id = ?', id])
end
end
def get_endup_time

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140618020535) do
ActiveRecord::Schema.define(:version => 20140618155324) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -117,6 +117,7 @@ ActiveRecord::Schema.define(:version => 20140618020535) do
t.integer "messages_count", :default => 0, :null => false
t.integer "last_message_id"
t.integer "parent_id"
t.integer "course_id"
end
add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id"
@ -174,6 +175,58 @@ ActiveRecord::Schema.define(:version => 20140618020535) do
add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true
create_table "code_review_assignments", :force => true do |t|
t.integer "issue_id"
t.integer "change_id"
t.integer "attachment_id"
t.string "file_path"
t.string "rev"
t.string "rev_to"
t.string "action_type"
t.integer "changeset_id"
end
create_table "code_review_project_settings", :force => true do |t|
t.integer "project_id"
t.integer "tracker_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "updated_by"
t.boolean "hide_code_review_tab", :default => false
t.integer "auto_relation", :default => 1
t.integer "assignment_tracker_id"
t.text "auto_assign"
t.integer "lock_version", :default => 0, :null => false
t.boolean "tracker_in_review_dialog", :default => false
end
create_table "code_review_user_settings", :force => true do |t|
t.integer "user_id", :default => 0, :null => false
t.integer "mail_notification", :default => 0, :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "code_reviews", :force => true do |t|
t.integer "project_id"
t.integer "change_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "line"
t.integer "updated_by_id"
t.integer "lock_version", :default => 0, :null => false
t.integer "status_changed_from"
t.integer "status_changed_to"
t.integer "issue_id"
t.string "action_type"
t.string "file_path"
t.string "rev"
t.string "rev_to"
t.integer "attachment_id"
t.integer "file_count", :default => 0, :null => false
t.boolean "diff_all"
end
create_table "comments", :force => true do |t|
t.string "commented_type", :limit => 30, :default => "", :null => false
t.integer "commented_id", :default => 0, :null => false
@ -229,6 +282,23 @@ ActiveRecord::Schema.define(:version => 20140618020535) do
t.datetime "updated_on", :null => false
end
create_table "course_infos", :force => true do |t|
t.integer "course_id"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "course_statuses", :force => true do |t|
t.integer "changesets_count"
t.integer "watchers_count"
t.integer "course_id"
t.float "grade", :default => 0.0
t.integer "course_ac_para", :default => 0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "courses", :force => true do |t|
t.integer "tea_id"
t.string "name"
@ -236,8 +306,8 @@ ActiveRecord::Schema.define(:version => 20140618020535) do
t.string "code"
t.integer "time"
t.string "extra"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "location"
t.string "term"
t.string "string"
@ -246,6 +316,13 @@ ActiveRecord::Schema.define(:version => 20140618020535) do
t.string "endup_time"
t.string "class_period"
t.integer "school_id"
t.text "description"
t.integer "status", :default => 1
t.integer "attachmenttype", :default => 2
t.integer "lft"
t.integer "rgt"
t.integer "is_public", :limit => 1, :default => 1
t.integer "inherit_members", :limit => 1, :default => 1
end
create_table "custom_fields", :force => true do |t|
@ -309,6 +386,7 @@ ActiveRecord::Schema.define(:version => 20140618020535) do
create_table "enabled_modules", :force => true do |t|
t.integer "project_id"
t.string "name", :null => false
t.integer "course_id"
end
add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id"
@ -358,7 +436,7 @@ ActiveRecord::Schema.define(:version => 20140618020535) do
end
create_table "homework_for_courses", :force => true do |t|
t.integer "project_id"
t.integer "course_id"
t.integer "bid_id"
end
@ -513,13 +591,14 @@ ActiveRecord::Schema.define(:version => 20140618020535) do
create_table "members", :force => true do |t|
t.integer "user_id", :default => 0, :null => false
t.integer "project_id", :default => 0, :null => false
t.integer "project_id", :default => 0
t.datetime "created_on"
t.boolean "mail_notification", :default => false, :null => false
t.integer "course_id", :default => -1
end
add_index "members", ["project_id"], :name => "index_members_on_project_id"
add_index "members", ["user_id", "project_id"], :name => "index_members_on_user_id_and_project_id", :unique => true
add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true
add_index "members", ["user_id"], :name => "index_members_on_user_id"
create_table "memos", :force => true do |t|
@ -565,6 +644,7 @@ ActiveRecord::Schema.define(:version => 20140618020535) do
t.integer "author_id", :default => 0, :null => false
t.datetime "created_on"
t.integer "comments_count", :default => 0, :null => false
t.integer "course_id"
end
add_index "news", ["author_id"], :name => "index_news_on_author_id"
@ -715,18 +795,18 @@ ActiveRecord::Schema.define(:version => 20140618020535) do
create_table "relative_memos", :force => true do |t|
t.integer "osp_id"
t.integer "parent_id"
t.string "subject", :null => false
t.text "content", :null => false
t.string "subject", :null => false
t.text "content", :limit => 16777215, :null => false
t.integer "author_id"
t.integer "replies_count", :default => 0
t.integer "replies_count", :default => 0
t.integer "last_reply_id"
t.boolean "lock", :default => false
t.boolean "sticky", :default => false
t.boolean "is_quote", :default => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "viewed_count_crawl", :default => 0
t.integer "viewed_count_local", :default => 0
t.boolean "lock", :default => false
t.boolean "sticky", :default => false
t.boolean "is_quote", :default => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "viewed_count_crawl", :default => 0
t.integer "viewed_count_local", :default => 0
t.string "url"
t.string "username"
t.string "userhomeurl"
@ -961,11 +1041,13 @@ ActiveRecord::Schema.define(:version => 20140618020535) do
end
create_table "user_scores", :force => true do |t|
t.integer "user_id"
t.integer "collaboration"
t.integer "influence"
t.integer "skill"
t.integer "activity"
t.integer "user_id", :null => false
t.integer "collaboration"
t.integer "influence"
t.integer "skill"
t.integer "active"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "user_statuses", :force => true do |t|