diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 20bda61e..b46ab52b 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -281,12 +281,11 @@ class CoursesController < ApplicationController if @school_id == "0" or @school_id.nil? @courses_all = Course.active.visible. joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id"). - where("#{Course.table_name}.course_type = ? ", Course::CourseType_course) else @courses_all = Course.active.visible. joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id"). joins(:course_extra). - where("#{Course.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Course::CourseType_course, @school_id) + where("#{Course.table_name}.school_id = ?", @school_id) end @course_count = @courses_all.count @@ -407,8 +406,7 @@ class CoursesController < ApplicationController else @courses_all = Course.active.visible. joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id"). - joins(:course_extra). - where("#{Course.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Course::CourseType_course, @school_id) + where("#{Course.table_name}.school_id = ?", @school_id) end @course_count = @courses_all.count diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 2a408788..2915ff8f 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -87,8 +87,11 @@ class MessagesController < ApplicationController call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) attachments = Attachment.attach_files(@reply, params[:attachments]) render_attachment_warning_if_needed(@reply) + else + #render file: 'messages#show', layout: 'base_courses' end redirect_to board_message_path(@board, @topic, :r => @reply) + end # Edit a message diff --git a/app/models/course_status.rb b/app/models/course_status.rb index d5a01ac4..b36661eb 100644 --- a/app/models/course_status.rb +++ b/app/models/course_status.rb @@ -1,3 +1,7 @@ class CourseStatus < ActiveRecord::Base attr_accessible :changesets_count, :course_ac_para, :course_id, :grade, :watchers_count + + belongs_to :course + validates_presence_of :course_id + validates_uniqueness_of :course_id end diff --git a/app/models/repository.rb b/app/models/repository.rb index ce7ac9d0..57a81827 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -42,7 +42,7 @@ class Repository < ActiveRecord::Base validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph) # donwcase letters, digits, dashes, underscores but not digits only - validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :allow_blank => true + validates_format_of :identifier, :with => /^[a-zA-Z0-9_\-]+$/, :allow_blank => true # Checks if the SCM is enabled when creating a repository validate :repo_create_validation, :on => :create diff --git a/db/migrate/20140603042015_stored_course_procedure.rb b/db/migrate/20140603042015_stored_course_procedure.rb index 2f5faf5c..426567ca 100644 --- a/db/migrate/20140603042015_stored_course_procedure.rb +++ b/db/migrate/20140603042015_stored_course_procedure.rb @@ -31,7 +31,7 @@ class StoredCourseProcedure < ActiveRecord::Migration courseStatus.watchers_count = projectstatus.watchers_count courseStatus.grade = projectstatus.grade courseStatus.course_ac_para = projectstatus.course_ac_para - courseStatus.save(:validate => false) + courseStatus.save() end end end diff --git a/db/migrate/20140704034832_clear_course_status.rb b/db/migrate/20140704034832_clear_course_status.rb new file mode 100644 index 00000000..527bfd41 --- /dev/null +++ b/db/migrate/20140704034832_clear_course_status.rb @@ -0,0 +1,16 @@ +class ClearCourseStatus < ActiveRecord::Migration + def up + # 删除重复的课程状态 + # 之前做迁移的时候未加验证可能引起此问题 + courseidlist = "(-1" + CourseStatus.all.each do |status| + sql = "delete from course_statuses where course_id=" + status.course_id.to_s + " and id<>" + status.id.to_s + + " and course_id not in " +courseidlist + ")" + courseidlist += "," + status.course_id.to_s; + execute(sql) + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 37188305..32a903aa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140703085204) do +ActiveRecord::Schema.define(:version => 20140704034832) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -794,20 +794,20 @@ ActiveRecord::Schema.define(:version => 20140703085204) do end create_table "relative_memos", :force => true do |t| - t.integer "osp_id", :null => false + 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"