Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add parent task to periodic tasks #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/periodictask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def generate_issue(now = Time.now)
subj = parse_macro(subject.try(:dup), now)
desc = parse_macro(description.try(:dup), now)

issue = Issue.new(:project_id => project_id, :tracker_id => tracker_id || project.trackers.first.try(:id), :category_id => issue_category_id,
issue = Issue.new(:project_id => project_id, :tracker_id => tracker_id || project.trackers.first.try(:id), :category_id => issue_category_id , :parent_id => parent_id,
:assigned_to_id => assigned_to_id, :author_id => author_id,
:subject => subj, :description => desc)
issue.start_date ||= now.to_date if set_start_date?
Expand Down
3 changes: 3 additions & 0 deletions app/views/periodictask/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<%= l(:no_categories_in_project) %>
<% end %>
</p>
<p>
<%= label(:periodictask, :parent_id, l(:label_parent_id)) %><%= f.number_field :parent_id, step: :any %>
</p>
<p>
<%= label(:periodictask, :assigned_to_user_id, l(:label_assigned_to_user)) %>
<% if @assignables.length > 0 %>
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ en:
label_estimated_hours_after: Hours
label_description: Description
label_issue_category: Issue Category
label_parent_id: Issue Parent task
label_unit_day: day(s)
label_unit_business_day: business day(s)
label_unit_week: week(s)
Expand Down
11 changes: 11 additions & 0 deletions db/migrate/20231223141012_add_parent_id_to_periodictasks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
active_record_migration_class = ActiveRecord::Migration.respond_to?(:current_version) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration

class AddParentIdToPeriodictasks < active_record_migration_class
def self.up
add_column :periodictasks, :parent_id, :integer, :null => true, :default => nil
end

def self.down
remove_column :periodictasks, :parent_id
end
end
2 changes: 2 additions & 0 deletions test/fixtures/periodictasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ one:
project_id: 1
tracker_id: 1
issue_category_id: 1
parent_id: 1
assigned_to_id: 1
author_id: 1
subject: MyString
Expand All @@ -17,6 +18,7 @@ two:
project_id: 1
tracker_id: 1
issue_category_id: 1
parent_id: 1
assigned_to_id: 1
author_id: 1
subject: MyString
Expand Down