From c045b4682a6328c7d3f0a5b6e3cf541d5a2d9744 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 31 Oct 2014 19:30:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8C=BF=E8=AF=84=E5=88=86?= =?UTF-8?q?=E9=85=8D=E4=BD=9C=E4=B8=9A=E8=A1=A8=EF=BC=8C=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E5=92=8C=E4=BD=9C=E4=B8=9A=E3=80=81=E4=BD=9C=E5=93=81=E3=80=81?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=A1=A8=E5=85=B3=E7=B3=BB=E9=94=AE=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/bid.rb | 1 + app/models/homework_attach.rb | 1 + app/models/homework_evaluation.rb | 6 ++++++ app/models/user.rb | 1 + .../20141031111632_create_homework_evaluations.rb | 10 ++++++++++ db/schema.rb | 9 ++++++++- 6 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 app/models/homework_evaluation.rb create mode 100644 db/migrate/20141031111632_create_homework_evaluations.rb diff --git a/app/models/bid.rb b/app/models/bid.rb index bc00a8460..88014477b 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -28,6 +28,7 @@ class Bid < ActiveRecord::Base has_many :homework_for_courses, :dependent => :destroy has_many :courses, :through => :homework_for_courses, :source => :course has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy + has_many :homework_evaluations, :through => :homeworks has_many :join_in_contests, :dependent => :destroy has_many :praise_tread, as: :praise_tread_object, dependent: :destroy # has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}" diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb index 99d540bd1..e18e254cb 100644 --- a/app/models/homework_attach.rb +++ b/app/models/homework_attach.rb @@ -10,6 +10,7 @@ class HomeworkAttach < ActiveRecord::Base has_many :users, :through => :homework_users seems_rateable :allow_update => true, :dimensions => :quality belongs_to :project + has_many :homework_evaluations, :dependent => :destroy safe_attributes "bid_id", "user_id" diff --git a/app/models/homework_evaluation.rb b/app/models/homework_evaluation.rb new file mode 100644 index 000000000..ccbd26f8c --- /dev/null +++ b/app/models/homework_evaluation.rb @@ -0,0 +1,6 @@ +class HomeworkEvaluation < ActiveRecord::Base + attr_accessible :homework_attach_id, :user_id + + belongs_to :homework_attach + belongs_to :user +end diff --git a/app/models/user.rb b/app/models/user.rb index 0bb359812..bbee7f763 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -75,6 +75,7 @@ class User < Principal has_many :homework_users has_many :homework_attaches, :through => :homework_users + has_many :homework_evaluations has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)}, :after_remove => Proc.new {|user, group| group.user_removed(user)} diff --git a/db/migrate/20141031111632_create_homework_evaluations.rb b/db/migrate/20141031111632_create_homework_evaluations.rb new file mode 100644 index 000000000..39b65a033 --- /dev/null +++ b/db/migrate/20141031111632_create_homework_evaluations.rb @@ -0,0 +1,10 @@ +class CreateHomeworkEvaluations < ActiveRecord::Migration + def change + create_table :homework_evaluations do |t| + t.string :user_id + t.string :homework_attach_id + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 4d194b54e..3961db258 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 => 20141029065917) do +ActiveRecord::Schema.define(:version => 20141031111632) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -478,6 +478,13 @@ ActiveRecord::Schema.define(:version => 20141029065917) do t.integer "project_id", :default => 0 end + create_table "homework_evaluations", :force => true do |t| + t.string "user_id" + t.string "homework_attach_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "homework_for_courses", :force => true do |t| t.integer "course_id" t.integer "bid_id"