Task status model + default task status generation

This commit is contained in:
2025-10-22 02:01:10 +03:00
parent 293bc06d1e
commit ae1df5f608
7 changed files with 82 additions and 21 deletions
+3 -2
View File
@@ -1,12 +1,13 @@
# frozen_string_literal: true
class Project < ApplicationRecord
enum :status, %i[preparing ready archived].index_by(&:itself), default: :preparing
enum :status, %w[preparing ready archived].index_by(&:itself), default: :preparing
validates :name, :code, presence: true
validates :code, exclusion: { in: %w[new] }, uniqueness: true, format: { with: /\A[a-z]{2,}\z/ }
has_many :tasks, dependent: :restrict_with_exception
has_many :task_statuses, dependent: :destroy
has_rich_text :description
@@ -35,7 +36,7 @@ class Project < ApplicationRecord
private
def schedule_post_init_job
ProjectPostInitJob.perform_later id
Projects::PostInitJob.perform_later id
end
def drop_tasks_number_sequence
+10
View File
@@ -0,0 +1,10 @@
# frozen_string_literal: true
class TaskStatus < ApplicationRecord
belongs_to :project
enum :category, { backlog: 100, analysis: 1000, development: 20_000, fulfillment: 60_000 }
validates :name, presence: true, uniqueness: { scope: :project }
validates :category, presence: true
end