Coder Social home page Coder Social logo

ludovicandrieux / redmine_custom_workflows Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anteo/redmine_custom_workflows

0.0 0.0 0.0 222 KB

Allows to create custom workflows for Redmine

Home Page: http://www.redmine.org/plugins/custom-workflows

License: GNU General Public License v2.0

HTML 11.99% JavaScript 13.08% Ruby 71.03% CSS 1.46% Shell 2.44%

redmine_custom_workflows's Introduction

Custom Workflows plug-in

The current version of Redmine CustomWorkflows is 1.0.2 Build Status

This plug-in provides a great functionality for those who is familiar with the Ruby language. It allows to customize workflow by defining own rules for issues processing. It's possible:

  • To change issue properties if some conditions are met;
  • To create new issues programmatically if the conditions are met (for example you can create an issue in another project if the status of source issue is changed to specific value);
  • To raise custom errors which will display to user, if he does something wrong;
  • To do anything that conforms to your needs;

Starting with version 0.1.2 you can specify observable object for workflow. Supported observable objects for now:

  • Issue (before_save, after_save)
  • Group (before_save, after_save)
  • User (before_save, after_save)
  • Group users (before_add, after_add, before_remove, after_remove)
  • <Shared code>

<Shared code> - special type for workflows that running before all other workflows and can provide libraries of additional functions or classes.

Thanks to

Plugin development was supported by DOM Digital Online Media GmbH

http://www.dom.de

Getting help

Create an issue if you want to propose a feature or report a bug:

https://github.com/anteo/redmine_custom_workflows/issues

Check Wiki for examples and programming hints:

https://github.com/anteo/redmine_custom_workflows/wiki

Installation

From a ZIP file:

  • Download the latest version of the plugin
  • Unzip to /plugins

From a GIT repository:

After download:

  • Run rake redmine:plugins:migrate
  • Restart Redmine

Configuration

First, you need to define your own custom workflow(s). We already included one, called "Duration/Done Ratio/Status correlation". You'll find it after installing the plug-in. It demonstrates some possibilities of plug-in.

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 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.

Enabling custom workflows for projects

After you defined your custom workflow(s), you need to enable it for particular project(s). There are two ways of doing this.

  • While editing existing or creating new custom workflow;
  • In project settings (if the user has appropriate permission). Open Project settings. Go to the Custom workflows tab of the project settings and enable workflow(s) you need for this project.

Now go to the Issues and test it.

Duration/Done Ratio/Status correlation example

Fill the "before save" script with:

if done_ratio_changed?
    if done_ratio==100 && status_id==2
      self.status_id=3
    elsif [1,3,4].include?(status_id) && done_ratio<100
      self.status_id=2
    end
end

if status_id_changed?
    if status_id==2
      self.start_date ||= Time.now
    end
    if status_id==3
      self.done_ratio = 100
      self.start_date ||= created_on
      self.due_date ||= Time.now
    end
end

Example of creating subtask if the issue's status has changed

Fill the "before save" script with:

@need_create = status_id_changed? && !new_record?

Fill the "after save" script with:

if @need_create
    issue = Issue.new(
      :author => User.current,
      :project => project,
      :tracker => tracker,
      :assigned_to => author,
      :parent_issue_id => id,
      :subject => "Subtask",
      :description => "Description")
    
    issue.save!
end

Do not forget to check whether issue is just created. Here we create the new issue and newly created issue will also be passed to this script on save. So without check, it will create another sub-issue. And etc. Thus it will fall into infinite recursion.

Compatibility

This plug-in is compatible with Redmine 4.1.x.

redmine_custom_workflows's People

Contributors

anteo avatar picman avatar aceccarelli avatar normanedance avatar germanolucas avatar spacewander avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.