Skip to content

Redmine 3.0 compatibility #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions app/controllers/canned_responses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class CannedResponsesController < ApplicationController

before_filter :find_project

before_filter [:require_admin_if_global, :authorize], :except => :insert
before_filter :require_admin_if_global, :except => :insert
before_filter :authorize_unless_global, :only => :insert

layout :select_layout
Expand All @@ -23,7 +23,7 @@ def edit

def create
@canned_response = @canned_responses.new
if @canned_response.update_attributes(params[:canned_response])
if @canned_response.update_attributes(cr_params)
flash[:notice] = l(:notice_canned_response_created)
redirect_to @canned_response
else
Expand All @@ -32,7 +32,7 @@ def create
end

def update
if @canned_response.update_attributes(params[:canned_response])
if @canned_response.update_attributes(cr_params)
flash[:notice] = l(:notice_canned_response_updated)
redirect_to @canned_response
else
Expand All @@ -48,7 +48,7 @@ def destroy
end

def preview
@text = params[:canned_response][:text]
@text = cr_params[:text]
render :partial => 'common/preview'
end

Expand All @@ -58,6 +58,10 @@ def insert

private

def cr_params
params.require(:canned_response).permit(:title, :text)
end

include CannedResponsesHelper

def select_layout
Expand Down
4 changes: 2 additions & 2 deletions app/models/canned_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ class CannedResponse < ActiveRecord::Base

validates_presence_of :title, :text

scope :global, where(:project_id => nil)
default_scope order(:title)
scope :global, lambda { where(:project_id => nil) }
default_scope { order(:title) }

def global?
project.nil?
Expand Down
5 changes: 3 additions & 2 deletions app/views/hooks/_canned_responses_issue_insert.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
<% url = url_for(:controller => 'canned_responses', :action => 'insert',
:project_id => nil, :id => ':id') %>
<% js = <<EOF
if ($('#canned_response').attr('value'))
$.ajax({ url: '#{url}'.replace(':id', $('#canned_response').attr('value')), type: 'get',
val = $(':selected', '#canned_response').attr('value');
if (val)
$.ajax({ url: '#{url}'.replace(':id', val), type: 'get',
success: function(data) {
$('#issue_#{issue.new_record? ? 'description' : 'notes'}').html(data);
}
Expand Down
5 changes: 2 additions & 3 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
require 'redmine'

Redmine::Plugin.register :redmine_canned_responses do
name 'Redmine Canned Responses plugin'
author 'Alex Shulgin <ash@commandprompt.com>'
description 'Store and use prepared (canned) responses, per-project or globally.'
version '0.2.0'
version '0.3.0'
requires_redmine '3.0.0'
url 'http://github.com/commandprompt/redmine_canned_responses'
# author_url 'http://example.com/about'

Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_canned_responses/project_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module ProjectPatch

def self.included(base)
base.class_eval do
has_many :canned_responses, lambda {order('title')}
has_many :canned_responses, lambda { order('title') }
end
end
end
Expand Down