From e698f3a6c67b6186eb478b8d9343c0d4fa103520 Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 16 Jun 2014 11:34:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E5=BB=BA=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E6=88=90=E5=91=98=E6=97=B6=E7=9A=84=E5=94=AF=E4=B8=80?= =?UTF-8?q?=E6=80=A7=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/member.rb | 2 +- db/migrate/20140604011630_add_courseid_to_to_members.rb | 2 +- .../lib/acts_as_activity_provider.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/member.rb b/app/models/member.rb index 4810ed684..46aefbd09 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -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 diff --git a/db/migrate/20140604011630_add_courseid_to_to_members.rb b/db/migrate/20140604011630_add_courseid_to_to_members.rb index b52a26924..9dd66c7f2 100644 --- a/db/migrate/20140604011630_add_courseid_to_to_members.rb +++ b/db/migrate/20140604011630_add_courseid_to_to_members.rb @@ -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 diff --git a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb index 33bbee546..3875d5c04 100644 --- a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb +++ b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb @@ -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