Hook plugin - Can't understand the library
Added by Jerome S over 10 years ago
Hi,
I'm trying to develop a hook in order to do a specific operation when someone closes an issue in a project.What I'm exaclty trying to do is :
Following this structure :
- Project_1
- Subproject1_2014
+ Issue1
+ Issue2 (special field : recursive)
- Subproject2_2014
...
IF someone closes the issue with the special field "recursive" set to 1, I need to create a subproject called "Subproject1_2015" containing the same issue than the one currently closed but with the status "new".
Actually I'm quite close to the answer but I can't figure out how to DUPLICATE the "Subproject1_2014" with the same members, description, but a different name and a different identifier => create the "Subproject1_2015".
Right now I've got this piece of code :
# Simulates copy_from attributes = cur_project.attributes.dup.except('id', 'name', 'identifier', 'status', 'parent_id', 'lft', 'rgt') new_project = Project.new(attributes) new_project.enabled_module_names = cur_project.enabled_module_names new_project.trackers = cur_project.trackers new_project.custom_values = cur_project.custom_values.collect {|v| v.clone} new_project.issue_custom_fields = cur_project.issue_custom_fields # Custom new_project.name = new_project_name new_project.identifier = new_project_name.downcase new_project.description = cur_project.description # Parent part and members copy new_project[:parent_id] = cur_project[:parent_id] # Save new_project.save
cur_project is in my example "Subproject1_2014" and new_project is the new subproject I want to create under "Project_1"
Right now it creates the new subproject but WITHOUT the members copy. If I add myself into the members the subproject doesn't appear UNDER the "Project_1" in the "main view project scroller" but alone at the very bottom of the list so I guess something should be bad.
Thanks if you have read until this point, I hope you'll be able to help me :)
If you have any question just ask !
To finish I'd like to say I'm still trying to find a "real" documentation for these hooks... I'm currently looking at the unit tests in the trunk project to know what are the method names...
EDIT :
Forgot these info
About your application's environment Ruby version 1.9.3 (x86_64-linux) RubyGems version 1.8.23 Rack version 1.4 Rails version 2.3.14 Active Record version 2.3.14 Active Resource version 2.3.14 Action Mailer version 2.3.14 Active Support version 2.3.14 Edge Rails revision unknown Application root /usr/share/redmine Environment production Database adapter mysql Database schema version 20120301153455 About your Redmine plugins Example plugin 0.0.1 <- my plugin