Skip to content

Commit

Permalink
Fixes support for Rails 4.1.8, ruby 1.9.3, works with redmine version…
Browse files Browse the repository at this point in the history
… 2.6.0.devel
  • Loading branch information
Egidijus Zideckas committed Dec 5, 2014
1 parent c7d8b0f commit 63ffc0b
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 21 deletions.
7 changes: 5 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
チケットの既読/未読を管理し、チケット一覧に「既読」「読んだ日時」列を追加します。
チケットを更新すると、そのチケットは未読チケットに戻ります。

Redmine2.5.1で簡単な動作確認したのみ。

Redmine2.6.0, rails 4.1.8

== インストール

Expand Down Expand Up @@ -37,6 +36,10 @@ Redmine2.5.1で簡単な動作確認したのみ。

== 更新履歴

=== Version 0.0.5

Fixed support for Rails 4.1.8

=== Version 0.0.4

2.3のクエリの実装変更に仮対応。
Expand Down
17 changes: 11 additions & 6 deletions app/models/already_read.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/views/already_read/_update_context.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

<% unless all_read %>
<li><%= 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] %></li>
<% end %>

<% unless all_unread %>
<li><%= 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] %></li>
<% end %>
Binary file added assets/images/new_icon.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/new_icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/new_icon.jpg.backup
Binary file not shown.
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -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'
9 changes: 5 additions & 4 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/already_read/issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 8 additions & 4 deletions lib/already_read/issues_controller_patch.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/already_read/user_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 63ffc0b

Please sign in to comment.