-
Notifications
You must be signed in to change notification settings - Fork 17
/
init.rb
47 lines (39 loc) · 1.85 KB
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'redmine'
require_dependency 'hooks'
require_dependency 'query_column'
# patch issue_query to allow columns for votes
issue_query = (IssueQuery rescue Query)
issue_query.add_available_column(VOI_QueryColumn.new(:sum_votes_up, :sortable => '(SELECT abs(sum(vote_val)) FROM vote_on_issues WHERE vote_val > 0 AND issue_id=issues.id )'))
issue_query.add_available_column(VOI_QueryColumn.new(:sum_votes_dn, :sortable => '(SELECT abs(sum(vote_val)) FROM vote_on_issues WHERE vote_val < 0 AND issue_id=issues.id )'))
Issue.send(:include, VoteOnIssues::Patches::QueryPatch)
Redmine::Plugin.register :vote_on_issues do
name 'Vote On Issues'
description 'This plugin allows to up- and down-vote issues.'
version '1.0.3'
url 'https://github.com/ojde/redmine-vote_on_issues-plugin'
author 'Ole Jungclaussen'
author_url 'https://jungclaussen.com'
requires_redmine :version_or_higher => '4.0.0'
project_module :vote_on_issues do
permission :cast_votes, {:issues => :cast_vote }, :require => :loggedin
permission :view_votes, {:issues => :view_votes}, :require => :loggedin
permission :view_voters, {:issues => :view_voters}, :require => :loggedin
end
# permission for menu
# permission :vote_on_issues, { :vote_on_issues => [:index] }, :public => true
# menu :project_menu,
# :vote_on_issues,
# { :controller => 'vote_on_issues', :action => 'index' },
# :caption => :menu_title,
# :after => :issues,
# :param => :project_id,
# :if => Proc.new {
# User.current.allowed_to?(:view_votes, nil, :global => true)
# }
end
class VoteOnIssuesListener < Redmine::Hook::ViewListener
render_on :view_layouts_base_html_head, :inline => <<-END
<%= stylesheet_link_tag 'view_issues_vote', :plugin => 'vote_on_issues' %>
<%= javascript_include_tag 'view_issues_vote', :plugin => 'vote_on_issues' %>
END
end