From 6dbac4e111d26679ef1ff209c5219d253585bd27 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Fri, 20 Mar 2026 20:48:07 -0400 Subject: [PATCH] Initial Commit --- LICENSE | 21 ++++++++ README.md | 41 ++++++++++++++++ init.rb | 23 +++++++++ lib/auto_assign.rb | 16 ++++++ lib/auto_assign/patches/time_entry_patch.rb | 54 +++++++++++++++++++++ 5 files changed, 155 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 init.rb create mode 100644 lib/auto_assign.rb create mode 100644 lib/auto_assign/patches/time_entry_patch.rb diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6ca2371 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2026 Rick Barrette + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..827f04c --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# Redmine Auto Assign Plugin + +Automatically assigns an issue to the first user who logs time against it. + +--- + +## Overview + +The **Redmine Auto Assign Plugin** improves workflow efficiency by ensuring issues are assigned when work begins. + +When a user logs time on an issue: + +- If the issue is **unassigned**, it is assigned to that user +- If the issue status is **"New"**, it is changed to **"In Progress"** + +--- + +## Features + +- Auto-assigns issue on first time entry +- Updates issue status from *New → In Progress* +- Lightweight and non-intrusive +- No UI changes required +- Works with standard Redmine time tracking + +--- + +## Requirements + +- Redmine 6.x +- Compatible Ruby version (per your Redmine install) + +--- + +## Installation + +1. Copy the plugin into your Redmine plugins directory: + +```bash +cd /path/to/redmine/plugins +git clone https://github.com/rickbarrette/redmine_auto_assign.git \ No newline at end of file diff --git a/init.rb b/init.rb new file mode 100644 index 0000000..f107b51 --- /dev/null +++ b/init.rb @@ -0,0 +1,23 @@ +#The MIT License (MIT) +# +#Copyright (c) 2026 rick barrette +# +#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +require_relative 'lib/auto_assign' +require_relative 'lib/auto_assign/patches/time_entry_patch' + +Redmine::Plugin.register :redmine_auto_assign do + name 'Redmine Auto Assign plugin' + author 'Rick Barrette' + description 'Automatically assigns an issue to the first user who logs time against it.' + version '2026.3.0' + url 'https://github.com/rickbarrette/redmine_auto_assign' + author_url 'https://barrettefabrication.com' +end + +AutoAssign.setup \ No newline at end of file diff --git a/lib/auto_assign.rb b/lib/auto_assign.rb new file mode 100644 index 0000000..af01de3 --- /dev/null +++ b/lib/auto_assign.rb @@ -0,0 +1,16 @@ +#The MIT License (MIT) +# +#Copyright (c) 2026 rick barrette +# +#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +module AutoAssign + def self.setup + Rails.logger.info ">>> AutoAssign.setup CALLED" + TimeEntry.prepend AutoAssign::Patches::TimeEntryPatch + end +end diff --git a/lib/auto_assign/patches/time_entry_patch.rb b/lib/auto_assign/patches/time_entry_patch.rb new file mode 100644 index 0000000..5cd219f --- /dev/null +++ b/lib/auto_assign/patches/time_entry_patch.rb @@ -0,0 +1,54 @@ +#The MIT License (MIT) +# +#Copyright (c) 2026 rick barrette +# +#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +module AutoAssign + module Patches + module TimeEntryPatch + extend ActiveSupport::Concern + + prepended do + after_create :assign_issue + end + + def assign_issue + return unless issue + + log "assign_issue triggered for TimeEntry ##{id}" + + # Only assign if nobody is assigned yet + if issue.assigned_to.blank? + issue.assigned_to = user + log "Assigned Issue ##{issue.id} to #{user.id}" + end + + # Only move status if still "New" + if issue.status&.name == "New" + in_progress = IssueStatus.find_by(name: "In Progress") + if in_progress + issue.status = in_progress + log "Moved Issue ##{issue.id} to In Progress" + end + end + + if issue.changed? + issue.save! + else + log "No changes needed for Issue ##{issue.id}" + end + end + + private + + def log(msg) + Rails.logger.info "[AutoAssign] #{msg}" + end + end + end +end \ No newline at end of file