diff --git a/README.rdoc b/README.rdoc
index 9498e3d..5876f0e 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -29,7 +29,7 @@ First, you need to define your own custom workflow(s). We already included one,
Go to the *Administration* section, then select Custom workflows. A list of defined workflows will appear. Here you can create new workflow, update, reorder and delete existing workflows. The order of workflows specifies the order in which workflow scripts will be executed.
-Then click the Create a custom workflow button. Enter a short name, full description and script itself. Below you will see two textareas. Fill one or both textareas by Ruby-language scripts that will be executed before and after saving the issue (on before_save and after_save callbacks respectively).
+Then click the Create a custom workflow button. Enter a short name and full description. Below you will see two textareas. Fill one or both textareas by Ruby-language scripts that will be executed before and after saving the issue (on before_save and after_save callbacks respectively).
Both scripts are executed in the context of the issue. So access properties and methods of the issue directly (or through keyword "self"). You can also raise exceptions by raise WorkflowError, "Your message". If you change some properties of the issue before saving it, it will be revalidated then and additional validation errors can appear.
@@ -87,9 +87,10 @@ Do not forget to check whether issue is just created. Here we create the new iss
== Compatibility
-This plug-in is compatible with Redmine 1.4.x, 2.0.x, 2.1.x
+This plug-in is compatible with Redmine 1.2.x, 1.3.x, 1.4.x, 2.0.x, 2.1.x
== Changelog
+[0.0.3] Compatibility with 1.2.x, 1.3.x
[0.0.2] Added ability to define after_save script along with before_save, improved logging, changed context of executing script to the issue.
[0.0.1] Initial commit
diff --git a/app/models/custom_workflow.rb b/app/models/custom_workflow.rb
index 6e53886..793ec8a 100644
--- a/app/models/custom_workflow.rb
+++ b/app/models/custom_workflow.rb
@@ -19,13 +19,13 @@ class CustomWorkflow < ActiveRecord::Base
issue = Issue.new
issue.send :instance_variable_set, :@issue, issue # compatibility with 0.0.1
begin
- issue.instance_eval(before_save)
+ issue.instance_eval(before_save) if respond_to?(:before_save) && before_save
rescue WorkflowError => e
rescue Exception => e
errors.add :before_save, :invalid_script, :error => e
end
begin
- issue.instance_eval(after_save)
+ issue.instance_eval(after_save) if respond_to?(:after_save) && after_save
rescue WorkflowError => e
rescue Exception => e
errors.add :after_save, :invalid_script, :error => e
diff --git a/app/views/custom_workflows/edit.html.erb b/app/views/custom_workflows/edit.html.erb
index 4de0fd3..bd23ace 100644
--- a/app/views/custom_workflows/edit.html.erb
+++ b/app/views/custom_workflows/edit.html.erb
@@ -1,8 +1,8 @@
<%= link_to l(:label_custom_workflow_plural), custom_workflows_path %> » <%= @workflow %>
-<%= error_messages_for @workflow %>
+<%= error_messages_for 'workflow' %>
-<% form = labelled_form_for @workflow do |f| %>
+<% form = form_for @workflow, :builder => (TabularFormBuilder rescue Redmine::Views::LabelledFormBuilder) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= submit_tag l(:button_save) %>
<% end %>
diff --git a/app/views/custom_workflows/index.html.erb b/app/views/custom_workflows/index.html.erb
index 4ff86d4..3038c23 100644
--- a/app/views/custom_workflows/index.html.erb
+++ b/app/views/custom_workflows/index.html.erb
@@ -21,7 +21,7 @@
">
| <%= link_to(workflow.name, edit_custom_workflow_path(workflow)) %> |
<%= textilizable(workflow.description) %> |
- <%= reorder_links("custom_workflow", {:action => 'update', :id => workflow}, :put) %> |
+ <%= reorder_links("custom_workflow", {:action => 'update', :id => workflow}) %> |
<%= link_to(l(:button_delete), workflow, :class => 'icon icon-del', :data => {:confirm => l(:text_are_you_sure)}, :confirm => l(:text_are_you_sure), :method => :delete) %>
|
diff --git a/app/views/custom_workflows/new.html.erb b/app/views/custom_workflows/new.html.erb
index 7151ec2..68cfae4 100644
--- a/app/views/custom_workflows/new.html.erb
+++ b/app/views/custom_workflows/new.html.erb
@@ -1,8 +1,8 @@
<%= link_to l(:label_custom_workflow_plural), custom_workflows_path %> » <%= l(:label_custom_workflow_new) %>
-<%= error_messages_for @workflow %>
+<%= error_messages_for 'workflow' %>
-<% form = labelled_form_for @workflow do |f| %>
+<% form = form_for @workflow, :builder => (TabularFormBuilder rescue Redmine::Views::LabelledFormBuilder) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= submit_tag l(:button_create) %>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index b55f372..40d9705 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,9 +1,11 @@
if Redmine::VERSION::MAJOR >= 2
RedmineApp::Application.routes.draw do
resources :custom_workflows
+ post '/custom_workflows/:id', :to => 'custom_workflows#update'
end
else
ActionController::Routing::Routes.draw do |map|
map.resources :custom_workflows
+ map.connect '/custom_workflows/:id', :controller => 'custom_workflows', :action => 'update', :conditions => { :method => :post }
end
end
diff --git a/db/migrate/20120831064944_create_example_workflow.rb b/db/migrate/20120831064944_create_example_workflow.rb
index d3a9ccf..7781a8b 100644
--- a/db/migrate/20120831064944_create_example_workflow.rb
+++ b/db/migrate/20120831064944_create_example_workflow.rb
@@ -12,7 +12,7 @@ Set up a correlation between the start date, due date, done ratio and status of
To use this script properly, turn off "Use current date as start date for new issues" option in the settings as this script already do it own way.
EOD
if @issue.done_ratio_changed?
- if @issue.done_ratio==100 && @issue.status_id=2
+ if @issue.done_ratio==100 && @issue.status_id==2
@issue.status_id=3
elsif [1,3,4].include?(@issue.status_id) && @issue.done_ratio<100
@issue.status_id=2
diff --git a/db/migrate/20120908085222_add_after_save_to_custom_workflows.rb b/db/migrate/20120908085222_add_after_save_to_custom_workflows.rb
index c7e9dd2..7c3009b 100644
--- a/db/migrate/20120908085222_add_after_save_to_custom_workflows.rb
+++ b/db/migrate/20120908085222_add_after_save_to_custom_workflows.rb
@@ -2,7 +2,7 @@ class AddAfterSaveToCustomWorkflows < ActiveRecord::Migration
def self.up
rename_column :custom_workflows, :script, :before_save
change_column :custom_workflows, :before_save, :text, :null => false, :default => ""
- add_column :custom_workflows, :after_save, :text, :null => false, :default => ""
+ add_column :custom_workflows, :after_save, :text, :null => false, :default => "", :after => :before_save
end
def self.down
remove_column :custom_workflows, :after_save
diff --git a/init.rb b/init.rb
index 58e13b0..8622006 100644
--- a/init.rb
+++ b/init.rb
@@ -1,3 +1,4 @@
+require 'redmine'
require 'redmine_custom_workflows/hooks'
to_prepare = Proc.new do
@@ -23,7 +24,7 @@ Redmine::Plugin.register :redmine_custom_workflows do
name 'Redmine Custom Workflow plugin'
author 'Anton Argirov'
description 'Allows to create custom workflows for issues, defined in the plain Ruby language'
- version '0.0.1'
+ version '0.0.3'
url 'http://redmine.academ.org'
menu :admin_menu, :custom_workflows, {:controller => 'custom_workflows', :action => 'index'}, :caption => :label_custom_workflow_plural