修改新建课程成员时的唯一性判断

This commit is contained in:
nwb 2014-06-16 11:34:56 +08:00
parent 59a261d96d
commit e698f3a6c6
3 changed files with 5 additions and 5 deletions

View File

@ -25,7 +25,7 @@ class Member < ActiveRecord::Base
belongs_to :course
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
before_destroy :set_issue_category_nil

View File

@ -1,6 +1,6 @@
class AddCourseidToToMembers < ActiveRecord::Migration
def change
add_column :members, :course_id, :int
add_column :members, :course_id, :int,:default => -1
change_column_null(:members, :project_id, true)
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

View File

@ -115,14 +115,14 @@ module Redmine
end
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))
elsif respond_to?(:visible)
scope = scope.visible(user1, options)
elsif provider_options.has_key?(:func) && provider_options[:func].eql?('memos')
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
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