Plugin to alter Redmine trunk behavior

Added by gabriel scolan over 11 years ago

Hi all, and happy new year !

Does someone know if it is possible to write a plugin that would add some functionalities (defining new methods or overloading methods) of already existing class ?
What I do now is to modify the redmine code directly, creating a branch and merging it with the redmine trunk regularly. Have such a possibility to create a plugin, the merge operation would not be necessary so the maintenance would be eased greatly.

My example is that I defined a custom field named "version" for issues, field that should be automatically incremented when specific fields (like description or other custom field) are modified.
An other example is to create a log of what are the issues that have been viewed (but not modified - this is already tracked in the journals) : this will help in automatically generate raw Meeting Minutes, making sure everything that was looked at is logged in the minutes. A solution would be then to overload the method "Show" of issue_controller

Thanks in advance

Replies (5)

RE: Plugin to alter Redmine trunk behavior - Added by Eric Davis over 11 years ago

Yes, you can do that from a plugin using module and including them into the base classes of Redmine. alias_method can be used to rename existing methods and alias_method_chain can be used to wrap existing methods in a custom method.

Here is some code I'm using in my plugins. If you have any questions, feel free to post them here:

Eric

RE: Plugin to alter Redmine trunk behavior - Added by gabriel scolan over 11 years ago

thanks Eric,
I'll have a look at that !

Gabriel

RE: Plugin to alter Redmine trunk behavior - Added by gabriel scolan over 11 years ago

Eric,

I've got the question_plugin you've developped from the github, but I've got the following misbehavior:

  • while editing a note, not assigning the question to anyone (field left blank), I've got a error message :
    undefined method `pending_question?' for #<Issue:0x4425758>
    (see file 5.html for more detail)
  • while edition a note, assigning the question to a user or 'anyone', I've got the error message :
    Showing issues/_sidebar.rhtml where line #7 raised:
    Association named 'project' was not found; perhaps you misspelled it?
    

    (see file 4.html for more details)
  • while creating an issue, on submit, I've to the message:
    undefined method `question' for #<Journal:0x46193c0>
    

    (see file 9.html for more details)

I'm on the r2253 of trunk

4.htm Magnifier - error while editing a note, without assigning (25.6 KB)

5.htm Magnifier - error while assigning question (12.8 KB)

9.htm Magnifier - error at creation (12.8 KB)

RE: Plugin to alter Redmine trunk behavior - Added by Eric Davis over 11 years ago

Gabriel,

Could you report this to the Questions plugin tracker so I can take a look into it? I'm running it on three systems and haven't had this error. Maybe there is a bug that I missed.

https://projects.littlestreamsoftware.com/projects/redmine-questions/issues

Eric

RE: Plugin to alter Redmine trunk behavior - Added by gabriel scolan over 11 years ago

Hi Eric,

I've tried anew to reproduce this issue, reinstalling everything from the beginning, and the issue disapeared :-)
Sorry for disturbance.

thanks for support in any case

gabriel

(1-5/5)