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"