修改新建课程成员时的唯一性判断
This commit is contained in:
parent
59a261d96d
commit
e698f3a6c6
|
@ -25,7 +25,7 @@ class Member < ActiveRecord::Base
|
||||||
belongs_to :course
|
belongs_to :course
|
||||||
|
|
||||||
validates_presence_of :principal
|
validates_presence_of :principal
|
||||||
validates_uniqueness_of :user_id, :scope => :project_id
|
validates_uniqueness_of :user_id, :scope => [:project_id,:course_id]
|
||||||
validate :validate_role
|
validate :validate_role
|
||||||
|
|
||||||
before_destroy :set_issue_category_nil
|
before_destroy :set_issue_category_nil
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class AddCourseidToToMembers < ActiveRecord::Migration
|
class AddCourseidToToMembers < ActiveRecord::Migration
|
||||||
def change
|
def change
|
||||||
add_column :members, :course_id, :int
|
add_column :members, :course_id, :int,:default => -1
|
||||||
change_column_null(:members, :project_id, true)
|
change_column_null(:members, :project_id, true)
|
||||||
remove_index :members, name: 'index_members_on_user_id_and_project_id'
|
remove_index :members, name: 'index_members_on_user_id_and_project_id'
|
||||||
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", "project_id","course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true
|
||||||
|
|
|
@ -115,14 +115,14 @@ module Redmine
|
||||||
end
|
end
|
||||||
|
|
||||||
user1 = User.find_by_admin(true)
|
user1 = User.find_by_admin(true)
|
||||||
if provider_options.has_key?(:permission)
|
if event_type.to_s == 'course_files' || event_type.to_s == 'course_journals_for_messages' || event_type.to_s == 'course_messages'
|
||||||
|
scope = scope
|
||||||
|
elsif provider_options.has_key?(:permission)
|
||||||
scope = scope.scoped(:conditions => Project.allowed_to_condition(user1, provider_options[:permission] || :view_project, options))
|
scope = scope.scoped(:conditions => Project.allowed_to_condition(user1, provider_options[:permission] || :view_project, options))
|
||||||
elsif respond_to?(:visible)
|
elsif respond_to?(:visible)
|
||||||
scope = scope.visible(user1, options)
|
scope = scope.visible(user1, options)
|
||||||
elsif provider_options.has_key?(:func) && provider_options[:func].eql?('memos')
|
elsif provider_options.has_key?(:func) && provider_options[:func].eql?('memos')
|
||||||
scope = scope
|
scope = scope
|
||||||
elsif event_type.to_s == 'course_files' || event_type.to_s == 'course_journals_for_messages' || event_type.to_s == 'course_messages'
|
|
||||||
scope = scope
|
|
||||||
else
|
else
|
||||||
ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option."
|
ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option."
|
||||||
# scope = scope
|
# scope = scope
|
||||||
|
|
Loading…
Reference in New Issue