diff --git a/README.rdoc b/README.rdoc index 8fcf1f3..badd033 100644 --- a/README.rdoc +++ b/README.rdoc @@ -3,8 +3,7 @@ チケットの既読/未読を管理し、チケット一覧に「既読」「読んだ日時」列を追加します。 チケットを更新すると、そのチケットは未読チケットに戻ります。 -Redmine2.5.1で簡単な動作確認したのみ。 - +Redmine2.6.0, rails 4.1.8 == インストール @@ -37,6 +36,10 @@ Redmine2.5.1で簡単な動作確認したのみ。 == 更新履歴 +=== Version 0.0.5 + +Fixed support for Rails 4.1.8 + === Version 0.0.4 2.3のクエリの実装変更に仮対応。 diff --git a/app/models/already_read.rb b/app/models/already_read.rb index fb57a2c..b24a06d 100644 --- a/app/models/already_read.rb +++ b/app/models/already_read.rb @@ -6,18 +6,23 @@ class AlreadyRead < ActiveRecord::Base # "活動"に表示されるようにイベントをプロバイダを登録する acts_as_event :title => Proc.new {|o| "#{o.issue.tracker.name} ##{o.issue.id} (#{o.issue.status}): #{o.issue.subject}"}, - :type => 'issue-note', + :type => 'issue-note', #Proc.new {|o| 'issue' + (o.closed? ? ' closed' : '') }, + :datetime => :created_on, :author => :user, :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.issue.id}} - acts_as_activity_provider :find_options => {:include => [ {:issue => [:project, :tracker, :status]}, :user ]}, + acts_as_activity_provider :timestamp => 'created_on', + :find_options => {:include => [ {:issue => [:project, :tracker, :status]}, :user ]}, :author_key => :user_id, :type => 'issues' - # "活動"で参照するための閲覧スコープ - scope :visible, - lambda {|*args| { :include => {:issue => :project}, - :conditions => Issue.visible_condition(args.shift || User.current, *args) } } + scope :visible, lambda {|*args| + includes(:issue => :project). + references(:project). + where(Issue.visible_condition(args.shift || User.current, *args)) + } + + # 状態の説明 # "活動"で参照する def description diff --git a/app/views/already_read/_update_context.erb b/app/views/already_read/_update_context.erb index fedd26d..a950064 100644 --- a/app/views/already_read/_update_context.erb +++ b/app/views/already_read/_update_context.erb @@ -7,12 +7,12 @@ <% unless all_read %>
  • <%= context_menu_link l(:label_mark_read).capitalize, - {:controller => 'issues', :action => 'bulk_set_read', :issues => @issues, :ids => @issues.collect(&:id), :set_read => true, :back_url => @back}, + {:controller => 'issues', :action => 'bulk_set_read', :issues => @issues, :ids => @issues.collect(&:id), :set_read => true, :back_url => @back, :project => @project}, :method => :post,:disabled => !@can[:update] %>
  • <% end %> <% unless all_unread %>
  • <%= context_menu_link l(:label_mark_unread).capitalize, - { :controller => 'issues', :action => 'bulk_set_read', :issues => @issues, :ids => @issues.collect(&:id), :set_unread => true, :back_url => @back}, + { :controller => 'issues', :action => 'bulk_set_read', :issues => @issues, :ids => @issues.collect(&:id), :set_unread => true, :back_url => @back, :project => @project}, :method => :post, :disabled => !@can[:update] %>
  • <% end %> \ No newline at end of file diff --git a/assets/images/new_icon.gif b/assets/images/new_icon.gif new file mode 100644 index 0000000..01e7374 Binary files /dev/null and b/assets/images/new_icon.gif differ diff --git a/assets/images/new_icon.jpg b/assets/images/new_icon.jpg index 0160355..c78b75a 100644 Binary files a/assets/images/new_icon.jpg and b/assets/images/new_icon.jpg differ diff --git a/assets/images/new_icon.jpg.backup b/assets/images/new_icon.jpg.backup new file mode 100644 index 0000000..0160355 Binary files /dev/null and b/assets/images/new_icon.jpg.backup differ diff --git a/config/routes.rb b/config/routes.rb index 625d169..b0bf08c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,4 @@ # Plugin's routes # See: http://guides.rubyonrails.org/routing.html - match 'issues/bulk_set_read', :controller => 'issues', :action => 'bulk_set_read' + match 'issues/bulk_set_read', :controller => 'issues', :action => 'bulk_set_read', :via => 'Post' diff --git a/init.rb b/init.rb index 2c13ede..e479403 100644 --- a/init.rb +++ b/init.rb @@ -9,11 +9,12 @@ name 'Redmine Already Read plugin' author 'OZAWA Yasuhiro' description 'Markup read issues.' - version '0.0.4' - url 'https://github.com/ameya86/redmine_already_read' - author_url 'http://blog.livedoor.jp/ameya86/' + version '0.0.5' + url 'https://github.com/egisz/redmine_already_read' + #author_url 'http://blog.livedoor.jp/ameya86/' - Redmine::AccessControl.permission(:view_issues).actions << "issues/bulk_set_read" unless Redmine::AccessControl.permission(:view_issues).actions.include?("issues/bulk_set_read") + # Nepadeda, nes neperduoda kazkodel projekto :( + # Redmine::AccessControl.permission(:view_issues).actions << "issues/bulk_set_read" activity_provider :issues, :class_name => 'AlreadyRead' end diff --git a/lib/already_read/issue_patch.rb b/lib/already_read/issue_patch.rb index 4237a0b..cd6c6e3 100644 --- a/lib/already_read/issue_patch.rb +++ b/lib/already_read/issue_patch.rb @@ -21,7 +21,7 @@ def css_classes_with_already_read end class Issue < ActiveRecord::Base - has_many :already_reads, :include => [:user], :order => :created_on + has_many :already_reads, -> {includes :users, order('already_reads.created_on') } has_many :already_read_users, :through => :already_reads, :source => :user after_update :reset_already_read diff --git a/lib/already_read/issues_controller_patch.rb b/lib/already_read/issues_controller_patch.rb index 27e657f..2ec1988 100644 --- a/lib/already_read/issues_controller_patch.rb +++ b/lib/already_read/issues_controller_patch.rb @@ -1,14 +1,18 @@ require_dependency 'issues_controller' class IssuesController < ApplicationController + # Overide Controller's authorize filter, exclude bulk_set_read + before_filter :authorize, :except => [:index, :bulk_set_read] after_filter :issue_read, :only => [:show] - prepend_before_filter :find_issues, :only => [:bulk_set_read, :bulk_edit, :bulk_update, :destroy] + after_filter :bulk_set_read, :only => [:bulk_edit, :bulk_update, :destroy] def bulk_set_read - if params[:set_read] - User.current.already_read_issues << @issues.reject{|issue| issue.already_read?} - elsif params[:set_unread] + issues = Issue.find(params["issues"]); + Rails::logger.info "AlreadyRead Plugin: bulk_set_read: #{params}, issues: #{issues}" if Rails::logger && Rails::logger.info + if params[:set_unread] AlreadyRead.destroy_all(:issue_id => params[:ids], :user_id => User.current.id) + else + User.current.already_read_issues << issues.reject{|issue| issue.already_read?} end redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project}) end diff --git a/lib/already_read/user_patch.rb b/lib/already_read/user_patch.rb index 63bbaae..1c807ab 100644 --- a/lib/already_read/user_patch.rb +++ b/lib/already_read/user_patch.rb @@ -2,6 +2,6 @@ require_dependency 'user' class User < Principal - has_many :already_reads, :order => :created_on + has_many :already_reads, -> {order('already_reads.created_on')} has_many :already_read_issues, :through => :already_reads, :source => :issue end