From b80c51475f7689c95e5c13f9d7e861baaaed84a2 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 19 May 2014 17:44:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=8F=82=E4=B8=8E=E4=BA=BA=E5=91=98=E7=B1=BBhomework=5Fusers?= =?UTF-8?q?=E5=8F=8A=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81=202.homework=5Fat?= =?UTF-8?q?tach=E5=A2=9E=E5=8A=A0=E5=AD=97=E6=AE=B5=EF=BC=9Aname=EF=BC=8Cd?= =?UTF-8?q?escription=EF=BC=8Cstate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_users_controller.rb | 3 +++ app/helpers/homework_users_helper.rb | 2 ++ app/models/homework_attach.rb | 4 ++++ app/models/homework_user.rb | 6 +++++ app/models/user.rb | 2 ++ .../contests/show_attendingcontest.html.erb | 16 ++++++------- config/routes.rb | 3 +++ .../20140519054846_create_homework_users.rb | 10 ++++++++ ...40519070751_add_name_to_homework_attach.rb | 7 ++++++ db/schema.rb | 23 ++++++++++++------- test/fixtures/homework_users.yml | 9 ++++++++ 11 files changed, 69 insertions(+), 16 deletions(-) create mode 100644 app/controllers/homework_users_controller.rb create mode 100644 app/helpers/homework_users_helper.rb create mode 100644 app/models/homework_user.rb create mode 100644 db/migrate/20140519054846_create_homework_users.rb create mode 100644 db/migrate/20140519070751_add_name_to_homework_attach.rb create mode 100644 test/fixtures/homework_users.yml diff --git a/app/controllers/homework_users_controller.rb b/app/controllers/homework_users_controller.rb new file mode 100644 index 00000000..cb55d965 --- /dev/null +++ b/app/controllers/homework_users_controller.rb @@ -0,0 +1,3 @@ +class HomeworkUsersController < ApplicationController + +end diff --git a/app/helpers/homework_users_helper.rb b/app/helpers/homework_users_helper.rb new file mode 100644 index 00000000..48a9a8e4 --- /dev/null +++ b/app/helpers/homework_users_helper.rb @@ -0,0 +1,2 @@ +module HomeworkUsersHelper +end diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb index 4bac5844..e395e65e 100644 --- a/app/models/homework_attach.rb +++ b/app/models/homework_attach.rb @@ -1,8 +1,12 @@ class HomeworkAttach < ActiveRecord::Base include Redmine::SafeAttributes + + #attr_accessible :name, :description, :state, :user_id, :bid_id + belongs_to :user belongs_to :bid has_many :journals_for_messages, :as => :jour, :dependent => :destroy + has_many :homework_users, :dependent => :destroy seems_rateable :allow_update => true, :dimensions => :quality safe_attributes "bid_id", diff --git a/app/models/homework_user.rb b/app/models/homework_user.rb new file mode 100644 index 00000000..da7e65af --- /dev/null +++ b/app/models/homework_user.rb @@ -0,0 +1,6 @@ +class HomeworkUser < ActiveRecord::Base + attr_accessible :homework_attach_id, :user_id + + belongs_to :homework_attach + has_one :user +end diff --git a/app/models/user.rb b/app/models/user.rb index d16d790d..84027579 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -68,6 +68,8 @@ class User < Principal ['none', :label_user_mail_option_none] ] + has_one :homework_user + 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)} has_many :changesets, :dependent => :nullify diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index 8a00f12a..d63c4f81 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -85,12 +85,12 @@